This commit is contained in:
+14
-14
@@ -1,15 +1,15 @@
|
|||||||
export const BuildSystem = {
|
export enum BuildSystem {
|
||||||
HAXE: "haxe",
|
HAXE = "haxe",
|
||||||
OPENFL: "openfl",
|
OPENFL = "openfl",
|
||||||
ADOBE_AIR: "adobe_air",
|
ADOBE_AIR = "adobe_air",
|
||||||
};
|
}
|
||||||
|
|
||||||
export const Platform = {
|
export enum Platform {
|
||||||
FLASH: "flash",
|
FLASH = "flash",
|
||||||
HTML5: "html5",
|
HTML5 = "html5",
|
||||||
LINUX: "linux",
|
LINUX = "linux",
|
||||||
WINDOWS: "windows",
|
WINDOWS = "windows",
|
||||||
ANDROID: "android",
|
ANDROID = "android",
|
||||||
NEKO: "neko",
|
NEKO = "neko",
|
||||||
CPP: "cpp",
|
CPP = "cpp",
|
||||||
};
|
}
|
||||||
|
|||||||
+26
-17
@@ -10,6 +10,7 @@ import { System } from "../common/system";
|
|||||||
import template from "../common/template";
|
import template from "../common/template";
|
||||||
import type { Config, LibDef } from "../core/config";
|
import type { Config, LibDef } from "../core/config";
|
||||||
import { Sdk } from "../core/sdk";
|
import { Sdk } from "../core/sdk";
|
||||||
|
import { Platform } from "../core/type";
|
||||||
import { Neko } from "./neko";
|
import { Neko } from "./neko";
|
||||||
|
|
||||||
export class Haxe extends Sdk {
|
export class Haxe extends Sdk {
|
||||||
@@ -109,7 +110,7 @@ export class Haxe extends Sdk {
|
|||||||
return path.join(Haxe.buildDir, config.name);
|
return path.join(Haxe.buildDir, config.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
openfl(command: string, platform: string, config: Config, debug = false) {
|
openfl(command: string, platform: Platform, config: Config, debug = false) {
|
||||||
this.log.i("_openfl_ _build_ *%s*", platform);
|
this.log.i("_openfl_ _build_ *%s*", platform);
|
||||||
this.activate();
|
this.activate();
|
||||||
const buildDir = this.resolveBuildDir(config);
|
const buildDir = this.resolveBuildDir(config);
|
||||||
@@ -125,35 +126,41 @@ export class Haxe extends Sdk {
|
|||||||
const target = path.resolve(buildDir, platform, "bin");
|
const target = path.resolve(buildDir, platform, "bin");
|
||||||
fse.emptyDirSync(target);
|
fse.emptyDirSync(target);
|
||||||
const result =
|
const result =
|
||||||
{
|
(
|
||||||
android: `app/build/outputs/**/${config.meta.filename}-debug.apk`,
|
{
|
||||||
flash: "*.swf",
|
[Platform.ANDROID]: `app/build/outputs/**/${config.meta.filename}-debug.apk`,
|
||||||
}[platform] || "**/*";
|
[Platform.FLASH]: "*.swf",
|
||||||
|
} as Record<Platform, string>
|
||||||
|
)[platform] || "**/*";
|
||||||
return this.haxelib(args).then(() => {
|
return this.haxelib(args).then(() => {
|
||||||
let r = vfs.src(`${target}/${result}`, { encoding: false });
|
let r = vfs.src(`${target}/${result}`, { encoding: false });
|
||||||
if (platform === "android") {
|
if (platform === Platform.ANDROID) {
|
||||||
r = r.pipe(rename(`${config.meta.filename}_${config.meta.version}.apk`));
|
r = r.pipe(rename(`${config.meta.filename}_${config.meta.version}.apk`));
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
build(platform: string, config: Config, debug = false) {
|
build(platform: Platform, config: Config, debug = false) {
|
||||||
this.log.i("_build_ *%s*", platform);
|
this.log.i("_build_ *%s*", platform);
|
||||||
this.activate();
|
this.activate();
|
||||||
const buildDir = this.resolveBuildDir(config);
|
const buildDir = this.resolveBuildDir(config);
|
||||||
fse.ensureDirSync(buildDir);
|
fse.ensureDirSync(buildDir);
|
||||||
|
|
||||||
const ext =
|
const ext =
|
||||||
{
|
(
|
||||||
flash: ".swf",
|
{
|
||||||
neko: ".n",
|
[Platform.FLASH]: ".swf",
|
||||||
}[platform] || "";
|
[Platform.NEKO]: ".n",
|
||||||
|
} as Record<Platform, string>
|
||||||
|
)[platform] || "";
|
||||||
|
|
||||||
const out =
|
const out =
|
||||||
{
|
(
|
||||||
flash: "swf",
|
{
|
||||||
}[platform] || platform;
|
[Platform.FLASH]: "swf",
|
||||||
|
} as Record<Platform, string>
|
||||||
|
)[platform] || platform;
|
||||||
|
|
||||||
const project = template.render("project.hxml", {
|
const project = template.render("project.hxml", {
|
||||||
...config,
|
...config,
|
||||||
@@ -177,9 +184,11 @@ export class Haxe extends Sdk {
|
|||||||
fse.copySync(asset, path.join(target, asset.split("/").pop()!));
|
fse.copySync(asset, path.join(target, asset.split("/").pop()!));
|
||||||
}
|
}
|
||||||
const result =
|
const result =
|
||||||
{
|
(
|
||||||
cpp: `${config.meta.filename}/${config.main.split(".").pop()}${debug ? "-debug" : ""}`,
|
{
|
||||||
}[platform] || "**/*";
|
[Platform.CPP]: `${config.meta.filename}/${config.main.split(".").pop()}${debug ? "-debug" : ""}`,
|
||||||
|
} as Record<Platform, string>
|
||||||
|
)[platform] || "**/*";
|
||||||
return this.haxe(args).then(() => {
|
return this.haxe(args).then(() => {
|
||||||
let r = vfs.src(`${target}/${result}`, { encoding: false });
|
let r = vfs.src(`${target}/${result}`, { encoding: false });
|
||||||
if (platform === "cpp") {
|
if (platform === "cpp") {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { Config } from "../../core/config";
|
import type { Config } from "../../core/config";
|
||||||
|
import type { BuildSystem, Platform } from "../../core/type";
|
||||||
import { Target } from "./target";
|
import { Target } from "./target";
|
||||||
|
|
||||||
export class Builder extends Target {
|
export class Builder extends Target {
|
||||||
@@ -7,7 +8,7 @@ export class Builder extends Target {
|
|||||||
public buildSystem: string;
|
public buildSystem: string;
|
||||||
public debug: boolean;
|
public debug: boolean;
|
||||||
|
|
||||||
constructor(config: Config, platform: string, buildSystem: string, debug: boolean = false) {
|
constructor(config: Config, platform: Platform, buildSystem: BuildSystem, debug: boolean = false) {
|
||||||
super(config, platform);
|
super(config, platform);
|
||||||
this.buildSystem = buildSystem;
|
this.buildSystem = buildSystem;
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
@@ -17,7 +18,7 @@ export class Builder extends Target {
|
|||||||
Builder.factory[buildSystem] = builder;
|
Builder.factory[buildSystem] = builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
static new(config: Config, platform: string, buildSystem: string, debug: boolean = false): Builder {
|
static new(config: Config, platform: Platform, buildSystem: BuildSystem, debug: boolean = false): Builder {
|
||||||
return new Builder.factory[buildSystem](config, platform, buildSystem, debug);
|
return new Builder.factory[buildSystem](config, platform, buildSystem, debug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
import type { Config } from "../../core/config";
|
import type { Config } from "../../core/config";
|
||||||
|
import type { Platform } from "../../core/type";
|
||||||
import { Target } from "./target";
|
import { Target } from "./target";
|
||||||
|
|
||||||
export type PackerFactory = new (config: Config) => Packer;
|
export type PackerFactory = new (config: Config) => Packer;
|
||||||
|
|
||||||
export class Packer extends Target {
|
export class Packer extends Target {
|
||||||
static factory: Record<string, Record<string, PackerFactory>> = {};
|
static factory: Partial<Record<Platform, Record<string, PackerFactory>>> = {};
|
||||||
|
|
||||||
call() {
|
call() {
|
||||||
throw "Not Implemented";
|
throw "Not Implemented";
|
||||||
}
|
}
|
||||||
|
|
||||||
static register(platform: string, name: string, packer: PackerFactory) {
|
static register(platform: Platform, name: string, packer: PackerFactory) {
|
||||||
if (!Packer.factory[platform]) Packer.factory[platform] = {};
|
if (!Packer.factory[platform]) Packer.factory[platform] = {};
|
||||||
Packer.factory[platform][name] = packer;
|
Packer.factory[platform][name] = packer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static new(config: Config, platform: string, name: string): Packer {
|
static new(config: Config, platform: Platform, name: string): Packer {
|
||||||
return new Packer.factory[platform][name](config);
|
return new Packer.factory[platform];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import rename from "gulp-rename";
|
|||||||
import output from "../../common/output";
|
import output from "../../common/output";
|
||||||
import { tail } from "../../common/tail";
|
import { tail } from "../../common/tail";
|
||||||
import { Config } from "../../core/config";
|
import { Config } from "../../core/config";
|
||||||
|
import type { Platform } from "../../core/type";
|
||||||
import { Target } from "./target";
|
import { Target } from "./target";
|
||||||
|
|
||||||
export type RunnerFactory = new (config: Config, debug: boolean) => Runner;
|
export type RunnerFactory = new (config: Config, debug: boolean) => Runner;
|
||||||
@@ -12,7 +13,7 @@ export class Runner extends Target {
|
|||||||
|
|
||||||
public debug: boolean;
|
public debug: boolean;
|
||||||
|
|
||||||
constructor(config: Config, platform: string, debug: boolean) {
|
constructor(config: Config, platform: Platform, debug: boolean) {
|
||||||
super(config, platform);
|
super(config, platform);
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import type { Config } from "../../core/config";
|
import type { Config } from "../../core/config";
|
||||||
|
import type { Platform } from "../../core/type";
|
||||||
|
|
||||||
export class Target {
|
export class Target {
|
||||||
public config: Config;
|
public config: Config;
|
||||||
public platform: string;
|
public platform: Platform;
|
||||||
public target: string;
|
public target: string;
|
||||||
|
|
||||||
constructor(config: Config, platform: string) {
|
constructor(config: Config, platform: Platform) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.platform = platform;
|
this.platform = platform;
|
||||||
this.target = "target";
|
this.target = "target";
|
||||||
@@ -20,7 +21,7 @@ export class Target {
|
|||||||
throw "Not Implemented";
|
throw "Not Implemented";
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveTargetPath(platform = this.platform): string {
|
resolveTargetPath(platform: Platform | string = this.platform): string {
|
||||||
return path.resolve(this.target, this.config.name, platform);
|
return path.resolve(this.target, this.config.name, platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export class HaxeBuilder extends Builder {
|
|||||||
public haxe: Haxe;
|
public haxe: Haxe;
|
||||||
public android: Android;
|
public android: Android;
|
||||||
|
|
||||||
constructor(config: Config, platform: string, buildSystem: string, debug: boolean = false) {
|
constructor(config: Config, platform: Platform, buildSystem: BuildSystem, debug: boolean = false) {
|
||||||
super(config, platform, buildSystem, debug);
|
super(config, platform, buildSystem, debug);
|
||||||
this.haxe = new Haxe();
|
this.haxe = new Haxe();
|
||||||
this.android = new Android();
|
this.android = new Android();
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ export class Project {
|
|||||||
static Platform = Platform;
|
static Platform = Platform;
|
||||||
static Builder = Builder;
|
static Builder = Builder;
|
||||||
|
|
||||||
public buildSystem: string;
|
public buildSystem: BuildSystem;
|
||||||
public platforms: string[];
|
public platforms: Platform[];
|
||||||
public config: Config;
|
public config: Config;
|
||||||
|
|
||||||
constructor(buildSystem: string, platforms: string[] | string, config: Config) {
|
constructor(buildSystem: BuildSystem, platforms: Platform[] | Platform, config: Config) {
|
||||||
this.buildSystem = buildSystem;
|
this.buildSystem = buildSystem;
|
||||||
this.platforms = Array.isArray(platforms) ? platforms : [platforms];
|
this.platforms = Array.isArray(platforms) ? platforms : [platforms];
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@@ -34,23 +34,23 @@ export class Project {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
build(platform: string, debug: boolean = false): Task[] {
|
build(platform: Platform, debug: boolean = false): Task[] {
|
||||||
const builder = Builder.new(this.config, platform, this.buildSystem, debug);
|
const builder = Builder.new(this.config, platform, this.buildSystem, debug);
|
||||||
const tasks: Task[] = [builder.prepare.bind(builder)];
|
const tasks: Task[] = [builder.prepare.bind(builder)];
|
||||||
tasks.push(builder.call.bind(builder));
|
tasks.push(builder.call.bind(builder));
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
run(platform: string, debug: boolean = false): Task[] {
|
run(platform: Platform, debug: boolean = false): Task[] {
|
||||||
const runner = Runner.new(this.config, platform, debug);
|
const runner = Runner.new(this.config, platform, debug);
|
||||||
return [runner.prepare.bind(runner), runner.call.bind(runner)];
|
return [runner.prepare.bind(runner), runner.call.bind(runner)];
|
||||||
}
|
}
|
||||||
|
|
||||||
test(platform: string, debug: boolean = true): Task[] {
|
test(platform: Platform, debug: boolean = true): Task[] {
|
||||||
return this.build(platform, debug).concat(this.run(platform, debug));
|
return this.build(platform, debug).concat(this.run(platform, debug));
|
||||||
}
|
}
|
||||||
|
|
||||||
pack(platform: string, name: string) {
|
pack(platform: Platform, name: string) {
|
||||||
const packer = Packer.new(this.config, platform, name);
|
const packer = Packer.new(this.config, platform, name);
|
||||||
return [packer.prepare.bind(packer), packer.call.bind(packer)];
|
return [packer.prepare.bind(packer), packer.call.bind(packer)];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { System } from "../common/system";
|
|||||||
import template from "../common/template";
|
import template from "../common/template";
|
||||||
import { Config, type ConfigParams, type SignKey } from "../core/config";
|
import { Config, type ConfigParams, type SignKey } from "../core/config";
|
||||||
import { Sdk } from "../core/sdk";
|
import { Sdk } from "../core/sdk";
|
||||||
import { Platform } from "../core/type";
|
import { BuildSystem, Platform } from "../core/type";
|
||||||
import { Haxe } from "../impl/haxe";
|
import { Haxe } from "../impl/haxe";
|
||||||
|
|
||||||
export interface PresetConfig {
|
export interface PresetConfig {
|
||||||
@@ -24,8 +24,8 @@ export const DEFAULT_CONFIG: PresetConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export interface ProjectPreset {
|
export interface ProjectPreset {
|
||||||
buildSystem?: string;
|
buildSystem?: BuildSystem;
|
||||||
platforms?: string[];
|
platforms?: Platform[];
|
||||||
config: ConfigParams;
|
config: ConfigParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user