Skip to content

Commit

Permalink
[hx download] allow downloading releases through build.haxe.org
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Apr 24, 2024
1 parent a3b577e commit 088ad65
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 52 deletions.
4 changes: 3 additions & 1 deletion src/HaxeDownload.hx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ class HaxeDownload {
}

static function install(url:String, filename:String, ?alias:String):Void {
url = url + filename;
filename = Path.withoutDirectory(filename);
final path = Path.join([Utils.releasesDir, filename]);

DownloadHelper.download(url + filename, path, () -> {
DownloadHelper.download(url, path, () -> {
Sys.println('Downloaded $filename');
installFile(path, filename, alias);
});
Expand Down
98 changes: 49 additions & 49 deletions src/HaxeModules.hx
Original file line number Diff line number Diff line change
Expand Up @@ -57,62 +57,62 @@ class HaxeModules {
}
}

final old = Sys.getCwd();
Sys.setCwd(cwd);
final old = Sys.getCwd();
Sys.setCwd(cwd);

function findModules(path:String) {
if (Path.extension(path) == "hx") return Sys.println(path);
if (!FileSystem.isDirectory(path)) return;
function findModules(path:String) {
if (Path.extension(path) == "hx") return Sys.println(path);
if (!FileSystem.isDirectory(path)) return;

path = Path.addTrailingSlash(path);
for (f in FileSystem.readDirectory(path)) findModules(path + f);
}
path = Path.addTrailingSlash(path);
for (f in FileSystem.readDirectory(path)) findModules(path + f);
}

function extractTargetStd(cp:String):Array<String> {
var path = FileSystem.fullPath(Path.isAbsolute(cp) ? cp : Path.join([cwd, cp]));
if (!path.startsWith(stdRoot)) return [cp, null];
function extractTargetStd(cp:String):Array<String> {
var path = FileSystem.fullPath(Path.isAbsolute(cp) ? cp : Path.join([cwd, cp]));
if (!path.startsWith(stdRoot)) return [cp, null];

cp = path; // Use resolved path for std
var path = cp.substr(stdRoot.length);
path = StringTools.replace(path, '\\', '/');
while (path.charCodeAt(0) == '/'.code) path = path.substr(1);
return [cp, path.split('/').shift()];
}
cp = path; // Use resolved path for std
var path = cp.substr(stdRoot.length);
path = StringTools.replace(path, '\\', '/');
while (path.charCodeAt(0) == '/'.code) path = path.substr(1);
return [cp, path.split('/').shift()];
}

var ignoredTargets = [];
if (target != null) {
if (target != "java" && target != "jvm") ignoredTargets = ignoredTargets.concat(["java", "jvm"]);
if (target != "cpp" && target != "cppia") ignoredTargets.push("cpp");
if (target != "js") ignoredTargets.push("js");
if (target != "hl") ignoredTargets.push("hl");
if (target != "cs") ignoredTargets.push("cs");
if (target != "lua") ignoredTargets.push("lua");
if (target != "neko") ignoredTargets.push("neko");
if (target != "php") ignoredTargets.push("php");
if (target != "python") ignoredTargets.push("python");
if (target != "swf") ignoredTargets.push("flash");
}
var ignoredTargets = [];
if (target != null) {
if (target != "java" && target != "jvm") ignoredTargets = ignoredTargets.concat(["java", "jvm"]);
if (target != "cpp" && target != "cppia") ignoredTargets.push("cpp");
if (target != "js") ignoredTargets.push("js");
if (target != "hl") ignoredTargets.push("hl");
if (target != "cs") ignoredTargets.push("cs");
if (target != "lua") ignoredTargets.push("lua");
if (target != "neko") ignoredTargets.push("neko");
if (target != "php") ignoredTargets.push("php");
if (target != "python") ignoredTargets.push("python");
if (target != "swf") ignoredTargets.push("flash");
}

for (cp in classpath) {
switch extractTargetStd(cp) {
// Non-std
case [cp, null]: findModules(cp);

// Top level std
case [cp, ""]:
cp = Path.addTrailingSlash(cp);
var sub = FileSystem.readDirectory(cp);
for (f in sub) {
if (ignoredTargets.contains(f)) continue;
findModules(cp + f);
}

case [_, t] if (ignoredTargets.contains(t)):
case [cp, _]: findModules(cp);
};
}
for (cp in classpath) {
switch extractTargetStd(cp) {
// Non-std
case [cp, null]: findModules(cp);

// Top level std
case [cp, ""]:
cp = Path.addTrailingSlash(cp);
var sub = FileSystem.readDirectory(cp);
for (f in sub) {
if (ignoredTargets.contains(f)) continue;
findModules(cp + f);
}

case [_, t] if (ignoredTargets.contains(t)):
case [cp, _]: findModules(cp);
};
}

Sys.setCwd(old);
Sys.setCwd(old);
} catch (e) {
Utils.displayError(Std.string(e));
proc.close();
Expand Down
8 changes: 6 additions & 2 deletions src/HaxeNightlies.hx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import haxelib.SemVer;
import sys.io.Process;
import sys.FileSystem;

Expand All @@ -9,18 +10,21 @@ class HaxeNightlies {

public static function resolve(ref:String):String {
if (ref_check.match(ref)) return getNightly(ref);
if (SemVer.isValid(ref)) return getNightly(ref, true);
return ref;
}

static function getNightly(ref:String):Null<String> {
static function getNightly(ref:String, ?isTag:Bool = false):Null<String> {
final date = getCommitDate(ref);
if (date == null) {
if (!updated) {
updateNightliesData();
return getNightly(ref);
return getNightly(ref, isTag);
} else {
throw 'Cannot find Haxe revision $ref';
}
} else if (isTag) {
return '${date}_refs/tags/${ref}_${getShortSha(ref)}';
} else {
if (!checkBranch(ref)) throw 'Only revisions from branch development are supported atm';
return '${date}_development_${getShortSha(ref)}';
Expand Down

0 comments on commit 088ad65

Please sign in to comment.