Compare commits

...
1 Commits
Author SHA1 Message Date
shmyga 705651eddc refactor(task): rework setup task
test / test (push) Successful in 1m6s
2026-11-12 20:35:06 +03:00
6 changed files with 43 additions and 43 deletions
+5 -3
View File
@@ -18,7 +18,7 @@ export class Sdk {
} }
static path(name: string, version: string) { static path(name: string, version: string) {
return path.join(this.dir, name, version); return path.resolve(path.join(this.dir, name, version));
} }
public name: string; public name: string;
@@ -26,6 +26,8 @@ export class Sdk {
public log: Logger; public log: Logger;
public path: string; public path: string;
protected strip: number = 1;
constructor(name: string, version: string) { constructor(name: string, version: string) {
this.name = name; this.name = name;
this.log = new Logger(name); this.log = new Logger(name);
@@ -55,14 +57,14 @@ export class Sdk {
}; };
} }
prepare(strip = 1): Promise<any> { prepare(): Promise<any> {
this.log.i("version: *%s*", this.version); this.log.i("version: *%s*", this.version);
if (this.prepared) { if (this.prepared) {
return Promise.resolve(); return Promise.resolve();
} else { } else {
const url = resolveLink(this.link, { name: this.name, version: this.version }); const url = resolveLink(this.link, { name: this.name, version: this.version });
this.log.i("download: *%s*", url); this.log.i("download: *%s*", url);
return download(url, this.path, { strip }); return download(url, this.path, { strip: this.strip });
} }
} }
} }
+3 -1
View File
@@ -40,6 +40,8 @@ export class Android extends Sdk {
url = "https://dl.google.com/android/repository/commandlinetools-<%= os_name %>-<%= version %>_latest.zip"; url = "https://dl.google.com/android/repository/commandlinetools-<%= os_name %>-<%= version %>_latest.zip";
protected strip = 0;
constructor(version?: string, ndkVersion?: string) { constructor(version?: string, ndkVersion?: string) {
super(Android.ID, version || Android.VERSION); super(Android.ID, version || Android.VERSION);
this.ndk = new AndroidNdk(ndkVersion); this.ndk = new AndroidNdk(ndkVersion);
@@ -67,7 +69,7 @@ export class Android extends Sdk {
prepare(): Promise<any> { prepare(): Promise<any> {
const result = []; const result = [];
result.push(super.prepare(0)); result.push(super.prepare());
result.push(this.ndk.prepare()); result.push(this.ndk.prepare());
return Promise.all(result); return Promise.all(result);
} }
+2 -4
View File
@@ -26,6 +26,8 @@ export class FlashPlayer extends Sdk {
private debug: boolean; private debug: boolean;
protected strip = 0;
url = url =
"https://fpdownload.macromedia.com/pub/flashplayer/updaters/" + "https://fpdownload.macromedia.com/pub/flashplayer/updaters/" +
"<%= version %>/" + "<%= version %>/" +
@@ -36,10 +38,6 @@ export class FlashPlayer extends Sdk {
this.debug = debug; this.debug = debug;
} }
prepare() {
return super.prepare(0);
}
get prepared() { get prepared() {
try { try {
return fs.existsSync(this.flashPlayerBin); return fs.existsSync(this.flashPlayerBin);
+2 -2
View File
@@ -19,8 +19,8 @@ export class InnoSetup extends Sdk {
return "http://www.jrsoftware.org/download.php/is.exe"; return "http://www.jrsoftware.org/download.php/is.exe";
} }
prepare(strip = 1) { prepare() {
let result = super.prepare(strip); let result = super.prepare();
if (!this.prepared) { if (!this.prepared) {
result = result.then(() => { result = result.then(() => {
return exec(this.path, `is.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=${this.path}`); return exec(this.path, `is.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=${this.path}`);
+25 -28
View File
@@ -1,3 +1,4 @@
import type Stream from "stream";
import vfs from "vinyl-fs"; import vfs from "vinyl-fs";
import exec from "../../../common/exec"; import exec from "../../../common/exec";
import { streamToPromise } from "../../../common/util"; import { streamToPromise } from "../../../common/util";
@@ -16,47 +17,43 @@ export class HaxeBuilder extends Builder {
this.android = new Android(); this.android = new Android();
} }
setup() { async setup(): Promise<any> {
let result: Promise<any> = this.haxe.prepare().then(() => this.haxe.install(this.config.libs)); await this.haxe.prepare();
await this.haxe.install(this.config.libs);
if (this.buildSystem === BuildSystem.OPENFL) { if (this.buildSystem === BuildSystem.OPENFL) {
if (this.platform === Platform.ANDROID) { if (this.platform === Platform.ANDROID) {
result = result await this.android.prepare();
.then(() => this.android.prepare()) this.android.activate();
.then(() => this.android.activate()) await this.android.sdkmanager([
.then(() => // TODO: android sdk dependencies config?
this.android.sdkmanager([ "platform-tools",
// TODO: android sdk dependencies config? "build-tools;27.0.3",
"platform-tools", "platforms;android-28",
"build-tools;27.0.3", "cmake;3.6.4111459",
"platforms;android-28", ]);
"cmake;3.6.4111459",
]),
);
const AndroidSDK = this.android.android_home; const AndroidSDK = this.android.android_home;
const AndroidNDK = this.android.ndk_home; const AndroidNDK = this.android.ndk_home;
const answer = `echo "${[AndroidSDK, AndroidNDK].join("\n")}"`; const answer = `echo "${[AndroidSDK, AndroidNDK].join("\n")}"`;
result = result.then(() => { await exec(".", [answer, "|", this.haxe.haxelibBin, "run", "openfl", "setup", this.platform].join(" "));
return exec(".", [answer, "|", this.haxe.haxelibBin, "run", "openfl", "setup", this.platform].join(" "));
});
} }
} }
return result;
} }
call() { async call(): Promise<any> {
const target = this.targetPath; const target = this.targetPath;
let stream: Stream;
switch (this.buildSystem) { switch (this.buildSystem) {
case BuildSystem.OPENFL: case BuildSystem.OPENFL:
return this.haxe.openfl("build", this.platform, this.config, this.debug).then((result) => { stream = await this.haxe.openfl("build", this.platform, this.config, this.debug);
if (this.platform === Platform.ANDROID && this.config.key) { if (this.platform === Platform.ANDROID && this.config.key) {
result = result.pipe(this.android.sign(this.config.key.store, this.config.key.pass)); stream = stream.pipe(this.android.sign(this.config.key.store, this.config.key.pass));
} }
return streamToPromise(result.pipe(vfs.dest(target))); return streamToPromise(stream.pipe(vfs.dest(target)));
});
case BuildSystem.HAXE: case BuildSystem.HAXE:
return this.haxe stream = await this.haxe.build(this.platform, this.config, this.debug);
.build(this.platform, this.config, this.debug) return streamToPromise(stream.pipe(vfs.dest(target)));
.then((result) => streamToPromise(result.pipe(vfs.dest(target)))); default:
return super.call();
} }
} }
} }
+6 -5
View File
@@ -1,14 +1,15 @@
import { Builder } from "../../project"; import { Haxe } from "../../impl/haxe";
import { TaskCompilerImpl, type TaskDef } from "../core"; import { TaskCompilerImpl, type TaskDef } from "../core";
export class SetupTaskCompiler extends TaskCompilerImpl { export class SetupTaskCompiler extends TaskCompilerImpl {
*compile(): Iterable<TaskDef> { *compile(): Iterable<TaskDef> {
yield [ yield [
"setup", "setup",
() => async () => {
Promise.all( const haxe = new Haxe(this.config.haxe);
this.config.platforms.map((platform) => Builder.new(this.config, platform, this.config.buildSystem).setup()), await haxe.prepare();
), await haxe.install(this.config.libs);
},
]; ];
} }
} }