92 lines
3.0 KiB
TypeScript
92 lines
3.0 KiB
TypeScript
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;
|
|
};
|