This commit is contained in:
+5
-3
@@ -18,7 +18,7 @@ export class Sdk {
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -26,6 +26,8 @@ export class Sdk {
|
||||
public log: Logger;
|
||||
public path: string;
|
||||
|
||||
protected strip: number = 1;
|
||||
|
||||
constructor(name: string, version: string) {
|
||||
this.name = 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);
|
||||
if (this.prepared) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
const url = resolveLink(this.link, { name: this.name, version: this.version });
|
||||
this.log.i("download: *%s*", url);
|
||||
return download(url, this.path, { strip });
|
||||
return download(url, this.path, { strip: this.strip });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -40,6 +40,8 @@ export class Android extends Sdk {
|
||||
|
||||
url = "https://dl.google.com/android/repository/commandlinetools-<%= os_name %>-<%= version %>_latest.zip";
|
||||
|
||||
protected strip = 0;
|
||||
|
||||
constructor(version?: string, ndkVersion?: string) {
|
||||
super(Android.ID, version || Android.VERSION);
|
||||
this.ndk = new AndroidNdk(ndkVersion);
|
||||
@@ -67,7 +69,7 @@ export class Android extends Sdk {
|
||||
|
||||
prepare(): Promise<any> {
|
||||
const result = [];
|
||||
result.push(super.prepare(0));
|
||||
result.push(super.prepare());
|
||||
result.push(this.ndk.prepare());
|
||||
return Promise.all(result);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ export class FlashPlayer extends Sdk {
|
||||
|
||||
private debug: boolean;
|
||||
|
||||
protected strip = 0;
|
||||
|
||||
url =
|
||||
"https://fpdownload.macromedia.com/pub/flashplayer/updaters/" +
|
||||
"<%= version %>/" +
|
||||
@@ -36,10 +38,6 @@ export class FlashPlayer extends Sdk {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return super.prepare(0);
|
||||
}
|
||||
|
||||
get prepared() {
|
||||
try {
|
||||
return fs.existsSync(this.flashPlayerBin);
|
||||
|
||||
@@ -19,8 +19,8 @@ export class InnoSetup extends Sdk {
|
||||
return "http://www.jrsoftware.org/download.php/is.exe";
|
||||
}
|
||||
|
||||
prepare(strip = 1) {
|
||||
let result = super.prepare(strip);
|
||||
prepare() {
|
||||
let result = super.prepare();
|
||||
if (!this.prepared) {
|
||||
result = result.then(() => {
|
||||
return exec(this.path, `is.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=${this.path}`);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type Stream from "stream";
|
||||
import vfs from "vinyl-fs";
|
||||
import exec from "../../../common/exec";
|
||||
import { streamToPromise } from "../../../common/util";
|
||||
@@ -16,47 +17,43 @@ export class HaxeBuilder extends Builder {
|
||||
this.android = new Android();
|
||||
}
|
||||
|
||||
setup() {
|
||||
let result: Promise<any> = this.haxe.prepare().then(() => this.haxe.install(this.config.libs));
|
||||
async setup(): Promise<any> {
|
||||
await this.haxe.prepare();
|
||||
await this.haxe.install(this.config.libs);
|
||||
if (this.buildSystem === BuildSystem.OPENFL) {
|
||||
if (this.platform === Platform.ANDROID) {
|
||||
result = result
|
||||
.then(() => this.android.prepare())
|
||||
.then(() => this.android.activate())
|
||||
.then(() =>
|
||||
this.android.sdkmanager([
|
||||
await this.android.prepare();
|
||||
this.android.activate();
|
||||
await this.android.sdkmanager([
|
||||
// TODO: android sdk dependencies config?
|
||||
"platform-tools",
|
||||
"build-tools;27.0.3",
|
||||
"platforms;android-28",
|
||||
"cmake;3.6.4111459",
|
||||
]),
|
||||
);
|
||||
]);
|
||||
const AndroidSDK = this.android.android_home;
|
||||
const AndroidNDK = this.android.ndk_home;
|
||||
const answer = `echo "${[AndroidSDK, AndroidNDK].join("\n")}"`;
|
||||
result = result.then(() => {
|
||||
return exec(".", [answer, "|", this.haxe.haxelibBin, "run", "openfl", "setup", this.platform].join(" "));
|
||||
});
|
||||
await exec(".", [answer, "|", this.haxe.haxelibBin, "run", "openfl", "setup", this.platform].join(" "));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
call() {
|
||||
async call(): Promise<any> {
|
||||
const target = this.targetPath;
|
||||
let stream: Stream;
|
||||
switch (this.buildSystem) {
|
||||
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) {
|
||||
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:
|
||||
return this.haxe
|
||||
.build(this.platform, this.config, this.debug)
|
||||
.then((result) => streamToPromise(result.pipe(vfs.dest(target))));
|
||||
stream = await this.haxe.build(this.platform, this.config, this.debug);
|
||||
return streamToPromise(stream.pipe(vfs.dest(target)));
|
||||
default:
|
||||
return super.call();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { Builder } from "../../project";
|
||||
import { Haxe } from "../../impl/haxe";
|
||||
import { TaskCompilerImpl, type TaskDef } from "../core";
|
||||
|
||||
export class SetupTaskCompiler extends TaskCompilerImpl {
|
||||
*compile(): Iterable<TaskDef> {
|
||||
yield [
|
||||
"setup",
|
||||
() =>
|
||||
Promise.all(
|
||||
this.config.platforms.map((platform) => Builder.new(this.config, platform, this.config.buildSystem).setup()),
|
||||
),
|
||||
async () => {
|
||||
const haxe = new Haxe(this.config.haxe);
|
||||
await haxe.prepare();
|
||||
await haxe.install(this.config.libs);
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user