From d079cbaac533e3ffa158eae71adbe7905061336e Mon Sep 17 00:00:00 2001 From: shmyga Date: Sun, 1 Nov 2026 18:28:46 +0300 Subject: [PATCH] fix(haxe): replace old broken haxelib when haxe preparing --- src/impl/haxe.ts | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/impl/haxe.ts b/src/impl/haxe.ts index 6f8eb4a..a28c59b 100755 --- a/src/impl/haxe.ts +++ b/src/impl/haxe.ts @@ -78,26 +78,36 @@ export class Haxe extends Sdk { env.addPath(this.path, "LD_LIBRARY_PATH"); } - prepare() { - return Promise.all([this.neko.prepare(), super.prepare()]).then(() => { - fs.copyFileSync( - path.resolve(import.meta.dirname, "template/haxe/activate"), - path.resolve(this.path, "activate"), - ); - }); + async replaceHaxelib(version: string): Promise { + const haxe = new Haxe(version); + await haxe.prepare(); + fs.copyFileSync(haxe.haxelibBin, this.haxelibBin); } - get link(): string { + async prepare(): Promise { + await Promise.all([this.neko.prepare(), super.prepare()]); + fs.copyFileSync(path.resolve(import.meta.dirname, "template/haxe/activate"), path.resolve(this.path, "activate")); + // TODO: old haxelib fail with EOF + if (this.intVersion < 430) { + await this.replaceHaxelib(Haxe.VERSION_4_3_7); + } + } + + static buildLink(version: string): string { if (System.isWindows) { - return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-win.zip`; + return `https://github.com/HaxeFoundation/haxe/releases/download/${version}/haxe-${version}-win.zip`; } else if (System.isLinux) { let arch = System.archInt; - return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-linux${arch}.tar.gz`; + return `https://github.com/HaxeFoundation/haxe/releases/download/${version}/haxe-${version}-linux${arch}.tar.gz`; } else { throw `Unsupported os: ${System.os}`; } } + get link(): string { + return Haxe.buildLink(this.version); + } + haxe(args: any) { this.activate(); return exec(".", [this.haxeBin].concat(args).join(" ")); @@ -179,7 +189,7 @@ export class Haxe extends Sdk { args.push("-debug"); } const target = path.resolve(buildDir, platform, "bin"); - if (platform !== "cpp") { + if (platform !== Platform.CPP) { fse.emptyDirSync(target); } for (const asset of config.assets) { @@ -193,7 +203,7 @@ export class Haxe extends Sdk { )[platform] || "**/*"; return this.haxe(args).then(() => { let r = vfs.src(`${target}/${result}`, { encoding: false }); - if (platform === "cpp") { + if (platform === Platform.CPP) { r = r.pipe(rename(config.meta.filename!)); } return r;