@@ -1,16 +1,14 @@
|
||||
import { branch, compile } from "../core/config";
|
||||
import type { Config, PresetJson } from "../core/type";
|
||||
import { Project } from "../project";
|
||||
|
||||
export default (preset: PresetJson): Project[] => {
|
||||
export default (preset: PresetJson): Config[] => {
|
||||
const config: Config = compile(preset["default"] || {});
|
||||
const projects: Project[] = [];
|
||||
const result: Config[] = [];
|
||||
for (const [k, v] of Object.entries(preset)) {
|
||||
if (k == "default") {
|
||||
continue;
|
||||
}
|
||||
const projectConfig = branch(config, { ...v, name: k });
|
||||
projects.push(new Project(projectConfig));
|
||||
result.push(branch(config, { ...v, name: k }));
|
||||
}
|
||||
return projects;
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import compiler from "./compiler";
|
||||
import loader from "./loader";
|
||||
import register from "./register";
|
||||
import validator from "./validator";
|
||||
|
||||
export const Preset = {
|
||||
compiler,
|
||||
loader,
|
||||
register,
|
||||
validator,
|
||||
};
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ import os from "os";
|
||||
import path from "path";
|
||||
import template from "../common/template";
|
||||
import { Sdk } from "../core/sdk";
|
||||
import type { ConfigJson, ConfigSource, PackageJson, PresetJson } from "../core/type";
|
||||
import { Platform, type ConfigJson, type ConfigSource, type PackageJson, type PresetJson } from "../core/type";
|
||||
import { Haxe } from "../impl/haxe";
|
||||
import { Project } from "../project";
|
||||
import { RuffleRunner, Runner } from "../project";
|
||||
|
||||
export const DEFAULT_CONFIG_JSON: ConfigJson = {
|
||||
SdkDir: "$HOME/sdk",
|
||||
@@ -15,8 +15,9 @@ export const DEFAULT_CONFIG_JSON: ConfigJson = {
|
||||
export const resolvePath = (path: string) => path.replace("$HOME", os.homedir());
|
||||
|
||||
export const applyConfig = (config: ConfigJson) => {
|
||||
// TODO: ruffle kludge
|
||||
if (config.UseRuffle) {
|
||||
Project.useRuffle();
|
||||
Runner.register(Platform.FLASH, RuffleRunner);
|
||||
}
|
||||
if (config.SdkDir) {
|
||||
Sdk.dir = resolvePath(config.SdkDir);
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
import gulp from "gulp";
|
||||
import gulpClean from "gulp-clean";
|
||||
import type { Task } from "undertaker";
|
||||
import { System } from "../common/system";
|
||||
import { Platform } from "../core/type";
|
||||
import { Haxe } from "../impl/haxe";
|
||||
import { Builder, type Project } from "../project";
|
||||
|
||||
export default (projects: Project[]): Task => {
|
||||
gulp.task("clean", () => {
|
||||
return gulp.src("target/*", { read: false }).pipe(gulpClean());
|
||||
});
|
||||
|
||||
const project = projects[0];
|
||||
|
||||
gulp.task("setup", () => {
|
||||
return Promise.all(
|
||||
project.config.platforms.map((platform) =>
|
||||
Builder.new(project.config, platform, project.config.buildSystem).prepare(),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
const protohx = project.hasLib("protohx");
|
||||
if (protohx) {
|
||||
gulp.task("protohx:generate", () =>
|
||||
new Haxe().haxelib(["run", "protohx", "generate", "protohx.json"]).then((result: any) => {
|
||||
if (result.stdout.indexOf("FAIL") > -1) {
|
||||
throw result.stdout;
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
for (const project of projects) {
|
||||
project.register(gulp);
|
||||
}
|
||||
|
||||
const defaultSeries: Task[] = [gulp.task("clean")!, gulp.task("setup")!];
|
||||
|
||||
if (protohx) {
|
||||
defaultSeries.push(gulp.task("protohx:generate")!);
|
||||
}
|
||||
|
||||
for (const project of projects) {
|
||||
for (const platform of project.config.platforms) {
|
||||
switch (platform) {
|
||||
case Platform.FLASH:
|
||||
defaultSeries.push(gulp.task(`${project.config.name}:${platform}:build`)!);
|
||||
defaultSeries.push(gulp.task(`${project.config.name}:${platform}:html`)!);
|
||||
break;
|
||||
case Platform.HTML5:
|
||||
defaultSeries.push(gulp.task(`${project.config.name}:${platform}:build`)!);
|
||||
break;
|
||||
case Platform.LINUX:
|
||||
if (System.isLinux) {
|
||||
defaultSeries.push(gulp.task(`${project.config.name}:${platform}:build`)!);
|
||||
defaultSeries.push(gulp.task(`${project.config.name}:${platform}:archive`)!);
|
||||
defaultSeries.push(gulp.task(`${project.config.name}:${platform}:deb`)!);
|
||||
}
|
||||
break;
|
||||
case Platform.CPP:
|
||||
if (System.isLinux) {
|
||||
defaultSeries.push(gulp.task(`${project.config.name}:${platform}:build`)!);
|
||||
}
|
||||
break;
|
||||
case Platform.NEKO:
|
||||
if (System.isLinux) {
|
||||
defaultSeries.push(gulp.task(`${project.config.name}:${platform}:build`)!);
|
||||
}
|
||||
break;
|
||||
case Platform.ANDROID:
|
||||
if (System.isLinux) {
|
||||
defaultSeries.push(gulp.task(`${project.config.name}:${platform}:build`)!);
|
||||
}
|
||||
break;
|
||||
case Platform.WINDOWS:
|
||||
if (System.isWindows) {
|
||||
defaultSeries.push(gulp.task(`${project.config.name}:${platform}:build`)!);
|
||||
defaultSeries.push(gulp.task(`${project.config.name}:${platform}:archive`)!);
|
||||
defaultSeries.push(gulp.task(`${project.config.name}:${platform}:installer`)!);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const defaultTask = gulp.series(defaultSeries);
|
||||
gulp.task("default", defaultTask);
|
||||
return defaultTask;
|
||||
};
|
||||
Reference in New Issue
Block a user