feat(project): add preset
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import vfs from "vinyl-fs";
|
||||
import exec from "../../../common/exec";
|
||||
import { streamToPromise } from "../../../common/util";
|
||||
import { Config } from "../../../core/config";
|
||||
import { BuildSystem, Platform } from "../../../core/type";
|
||||
import { Android } from "../../../impl/android";
|
||||
import { Haxe } from "../../../impl/haxe";
|
||||
import { Builder } from "../../core/builder";
|
||||
|
||||
export class HaxeBuilder extends Builder {
|
||||
public haxe: Haxe;
|
||||
public android: Android;
|
||||
|
||||
constructor(config: Config, platform: string, buildSystem: string, debug: boolean = false) {
|
||||
super(config, platform, buildSystem, debug);
|
||||
this.haxe = new Haxe();
|
||||
this.android = new Android();
|
||||
}
|
||||
|
||||
prepare() {
|
||||
let result = this.haxe.prepare().then(() => 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([
|
||||
// ToDo: android sdk dependencies config?
|
||||
//'tools',
|
||||
"platform-tools",
|
||||
"build-tools;27.0.3",
|
||||
"platforms;android-28", //ToDo: lime version 7.6.0 -> 28; 7.0.0 -> 26
|
||||
//'ndk-bundle',
|
||||
//'lldb;3.1',
|
||||
"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(" "));
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
call() {
|
||||
const target = this.targetPath;
|
||||
switch (this.buildSystem) {
|
||||
case BuildSystem.OPENFL:
|
||||
return this.haxe.openfl("build", this.platform, this.config, this.debug).then((result) => {
|
||||
if (this.platform === Platform.ANDROID && this.config.key) {
|
||||
result = result.pipe(this.android.sign(this.config.key.store, this.config.key.pass));
|
||||
}
|
||||
return streamToPromise(result.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))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Builder.register(BuildSystem.HAXE, HaxeBuilder);
|
||||
Builder.register(BuildSystem.OPENFL, HaxeBuilder);
|
||||
Reference in New Issue
Block a user