Skip to content

Commit 088ad65

Browse files
committed
[hx download] allow downloading releases through build.haxe.org
1 parent a3b577e commit 088ad65

File tree

3 files changed

+58
-52
lines changed

3 files changed

+58
-52
lines changed

src/HaxeDownload.hx

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ class HaxeDownload {
6767
}
6868

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

72-
DownloadHelper.download(url + filename, path, () -> {
74+
DownloadHelper.download(url, path, () -> {
7375
Sys.println('Downloaded $filename');
7476
installFile(path, filename, alias);
7577
});

src/HaxeModules.hx

+49-49
Original file line numberDiff line numberDiff line change
@@ -57,62 +57,62 @@ class HaxeModules {
5757
}
5858
}
5959

60-
final old = Sys.getCwd();
61-
Sys.setCwd(cwd);
60+
final old = Sys.getCwd();
61+
Sys.setCwd(cwd);
6262

63-
function findModules(path:String) {
64-
if (Path.extension(path) == "hx") return Sys.println(path);
65-
if (!FileSystem.isDirectory(path)) return;
63+
function findModules(path:String) {
64+
if (Path.extension(path) == "hx") return Sys.println(path);
65+
if (!FileSystem.isDirectory(path)) return;
6666

67-
path = Path.addTrailingSlash(path);
68-
for (f in FileSystem.readDirectory(path)) findModules(path + f);
69-
}
67+
path = Path.addTrailingSlash(path);
68+
for (f in FileSystem.readDirectory(path)) findModules(path + f);
69+
}
7070

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

75-
cp = path; // Use resolved path for std
76-
var path = cp.substr(stdRoot.length);
77-
path = StringTools.replace(path, '\\', '/');
78-
while (path.charCodeAt(0) == '/'.code) path = path.substr(1);
79-
return [cp, path.split('/').shift()];
80-
}
75+
cp = path; // Use resolved path for std
76+
var path = cp.substr(stdRoot.length);
77+
path = StringTools.replace(path, '\\', '/');
78+
while (path.charCodeAt(0) == '/'.code) path = path.substr(1);
79+
return [cp, path.split('/').shift()];
80+
}
8181

82-
var ignoredTargets = [];
83-
if (target != null) {
84-
if (target != "java" && target != "jvm") ignoredTargets = ignoredTargets.concat(["java", "jvm"]);
85-
if (target != "cpp" && target != "cppia") ignoredTargets.push("cpp");
86-
if (target != "js") ignoredTargets.push("js");
87-
if (target != "hl") ignoredTargets.push("hl");
88-
if (target != "cs") ignoredTargets.push("cs");
89-
if (target != "lua") ignoredTargets.push("lua");
90-
if (target != "neko") ignoredTargets.push("neko");
91-
if (target != "php") ignoredTargets.push("php");
92-
if (target != "python") ignoredTargets.push("python");
93-
if (target != "swf") ignoredTargets.push("flash");
94-
}
82+
var ignoredTargets = [];
83+
if (target != null) {
84+
if (target != "java" && target != "jvm") ignoredTargets = ignoredTargets.concat(["java", "jvm"]);
85+
if (target != "cpp" && target != "cppia") ignoredTargets.push("cpp");
86+
if (target != "js") ignoredTargets.push("js");
87+
if (target != "hl") ignoredTargets.push("hl");
88+
if (target != "cs") ignoredTargets.push("cs");
89+
if (target != "lua") ignoredTargets.push("lua");
90+
if (target != "neko") ignoredTargets.push("neko");
91+
if (target != "php") ignoredTargets.push("php");
92+
if (target != "python") ignoredTargets.push("python");
93+
if (target != "swf") ignoredTargets.push("flash");
94+
}
9595

96-
for (cp in classpath) {
97-
switch extractTargetStd(cp) {
98-
// Non-std
99-
case [cp, null]: findModules(cp);
100-
101-
// Top level std
102-
case [cp, ""]:
103-
cp = Path.addTrailingSlash(cp);
104-
var sub = FileSystem.readDirectory(cp);
105-
for (f in sub) {
106-
if (ignoredTargets.contains(f)) continue;
107-
findModules(cp + f);
108-
}
109-
110-
case [_, t] if (ignoredTargets.contains(t)):
111-
case [cp, _]: findModules(cp);
112-
};
113-
}
96+
for (cp in classpath) {
97+
switch extractTargetStd(cp) {
98+
// Non-std
99+
case [cp, null]: findModules(cp);
100+
101+
// Top level std
102+
case [cp, ""]:
103+
cp = Path.addTrailingSlash(cp);
104+
var sub = FileSystem.readDirectory(cp);
105+
for (f in sub) {
106+
if (ignoredTargets.contains(f)) continue;
107+
findModules(cp + f);
108+
}
109+
110+
case [_, t] if (ignoredTargets.contains(t)):
111+
case [cp, _]: findModules(cp);
112+
};
113+
}
114114

115-
Sys.setCwd(old);
115+
Sys.setCwd(old);
116116
} catch (e) {
117117
Utils.displayError(Std.string(e));
118118
proc.close();

src/HaxeNightlies.hx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import haxelib.SemVer;
12
import sys.io.Process;
23
import sys.FileSystem;
34

@@ -9,18 +10,21 @@ class HaxeNightlies {
910

1011
public static function resolve(ref:String):String {
1112
if (ref_check.match(ref)) return getNightly(ref);
13+
if (SemVer.isValid(ref)) return getNightly(ref, true);
1214
return ref;
1315
}
1416

15-
static function getNightly(ref:String):Null<String> {
17+
static function getNightly(ref:String, ?isTag:Bool = false):Null<String> {
1618
final date = getCommitDate(ref);
1719
if (date == null) {
1820
if (!updated) {
1921
updateNightliesData();
20-
return getNightly(ref);
22+
return getNightly(ref, isTag);
2123
} else {
2224
throw 'Cannot find Haxe revision $ref';
2325
}
26+
} else if (isTag) {
27+
return '${date}_refs/tags/${ref}_${getShortSha(ref)}';
2428
} else {
2529
if (!checkBranch(ref)) throw 'Only revisions from branch development are supported atm';
2630
return '${date}_development_${getShortSha(ref)}';

0 commit comments

Comments
 (0)