This commit is contained in:
+5
-3
@@ -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
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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}`);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export class Target {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
call() {
|
call(): Promise<any> {
|
||||||
throw "Not Implemented";
|
throw "Not Implemented";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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(() =>
|
|
||||||
this.android.sdkmanager([
|
|
||||||
// TODO: android sdk dependencies config?
|
// TODO: android sdk dependencies config?
|
||||||
"platform-tools",
|
"platform-tools",
|
||||||
"build-tools;27.0.3",
|
"build-tools;27.0.3",
|
||||||
"platforms;android-28",
|
"platforms;android-28",
|
||||||
"cmake;3.6.4111459",
|
"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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user