Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get compiler version for run scripts lazily #646

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/haxelib/api/GlobalScope.hx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GlobalScope extends Scope {
main: info.main
};

ScriptRunner.run(libraryRunData, resolveCompiler(), callData);
ScriptRunner.run(libraryRunData, callData, () -> haxeVersion);
}

public function getVersion(library:ProjectName):Version {
Expand Down
10 changes: 5 additions & 5 deletions src/haxelib/api/ScriptRunner.hx
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ class ScriptRunner {
/**
Run `library`, with `callData`.

`compilerData` is used if it is an interpreted script.
`getCompilerVersion` is used if it is an interpreted script.
**/
public static function run(library:LibraryRunData, compilerData:LibraryData, callData:CallData):Void {
public static function run(library:LibraryRunData, callData:CallData, getCompilerVersion:()->SemVer):Void {
final type = getType(library);

final cmd = getCmd(type);
final args = generateArgs(type, callData, SemVer.ofString(compilerData.version));
final args = generateArgs(type, callData, getCompilerVersion);

final oldState = getState();

Expand Down Expand Up @@ -122,15 +122,15 @@ class ScriptRunner {
}
}

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

final callArgs = generateScriptArgs(main, name, version, dependencies, useGlobalRepo);
Expand Down
Loading