Skip to content

Commit 846dcf8

Browse files
tobil4skninjamuffin99
authored andcommitted
Get compiler version for run scripts lazily (HaxeFoundation#646)
It only has to be checked when running interp scripts, so we can avoid checking it in other cases.
1 parent 443689a commit 846dcf8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/haxelib/api/GlobalScope.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class GlobalScope extends Scope {
4747
main: info.main
4848
};
4949

50-
ScriptRunner.run(libraryRunData, resolveCompiler(), callData);
50+
ScriptRunner.run(libraryRunData, callData, () -> haxeVersion);
5151
}
5252

5353
public function getVersion(library:ProjectName):Version {

src/haxelib/api/ScriptRunner.hx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ class ScriptRunner {
7979
/**
8080
Run `library`, with `callData`.
8181
82-
`compilerData` is used if it is an interpreted script.
82+
`getCompilerVersion` is used if it is an interpreted script.
8383
**/
84-
public static function run(library:LibraryRunData, compilerData:LibraryData, callData:CallData):Void {
84+
public static function run(library:LibraryRunData, callData:CallData, getCompilerVersion:()->SemVer):Void {
8585
final type = getType(library);
8686

8787
final cmd = getCmd(type);
88-
final args = generateArgs(type, callData, SemVer.ofString(compilerData.version));
88+
final args = generateArgs(type, callData, getCompilerVersion);
8989

9090
final oldState = getState();
9191

@@ -122,15 +122,15 @@ class ScriptRunner {
122122
}
123123
}
124124

125-
static function generateArgs(runType:RunType, callData:CallData, compilerVersion:SemVer):Array<String> {
125+
static function generateArgs(runType:RunType, callData:CallData, getCompilerVersion:() -> SemVer):Array<String> {
126126
switch runType {
127127
case Neko(path):
128128
final callArgs = callData.args.copy();
129129
callArgs.unshift(path);
130130
callArgs.push(callData.dir);
131131
return callArgs;
132132
case Script(main, name, version, dependencies):
133-
final isHaxe4 = SemVer.compare(compilerVersion, SemVer.ofString('4.0.0')) >= 0;
133+
final isHaxe4 = SemVer.compare(getCompilerVersion(), SemVer.ofString('4.0.0')) >= 0;
134134
final useGlobalRepo = isHaxe4 && callData.useGlobalRepo;
135135

136136
final callArgs = generateScriptArgs(main, name, version, dependencies, useGlobalRepo);

0 commit comments

Comments
 (0)