140 lines
3.5 KiB
JavaScript
140 lines
3.5 KiB
JavaScript
const gulp = require('gulp');
|
|
const gulpClean = require('gulp-clean');
|
|
const Config = require('./config.json');
|
|
const packageInfo = require('./package.json');
|
|
const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
|
|
const dateformat = require('dateformat');
|
|
const argv = require('yargs').argv;
|
|
const publish = require('./tasks/gulp-publish');
|
|
|
|
if (packageInfo.haxe) {
|
|
Haxe.VERSION = packageInfo.haxe;
|
|
}
|
|
|
|
if (Config.SdkDir) {
|
|
Sdk.dir = Config.SdkDir;
|
|
}
|
|
|
|
if (Config.BuildDir) {
|
|
Haxe.buildDir = Config.BuildDir;
|
|
}
|
|
|
|
exports.clean = function clean() {
|
|
return gulp.src('target/*', {read: false}).pipe(gulpClean());
|
|
};
|
|
|
|
exports.generate = function generate() {
|
|
return new Haxe().haxelib(['run', 'protohx', 'generate', 'protohx.json']).then(({stdout}) => {
|
|
if (stdout.indexOf('FAIL') > -1) {
|
|
throw stdout;
|
|
}
|
|
});
|
|
};
|
|
|
|
const config = new Project.Config({
|
|
meta: {
|
|
title: 'Puzzle\'z',
|
|
filename: 'puzzlez',
|
|
icon: 'src/app/resources/icon.png',
|
|
pack: 'ru.m.puzzlez',
|
|
author: 'shmyga <shmyga.z@gmail.com>',
|
|
company: 'MegaLoMania',
|
|
version: packageInfo.version + (Config.Develop ? '-SNAPSHOT' : ''),
|
|
},
|
|
key: Config.Key,
|
|
libs: packageInfo.haxeDependencies,
|
|
macros: [
|
|
`CompilationOption.set('build','${dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss')}')`,
|
|
`CompilationOption.set('UNSPLASH_KEY','${Config.UnsplashKey}')`,
|
|
`CompilationOption.set('PIXABAY_KEY','${Config.PixabayKey}')`,
|
|
],
|
|
flags: [
|
|
'proto_debug',
|
|
]
|
|
});
|
|
|
|
const app = new Project(
|
|
Project.BuildSystem.OPENFL,
|
|
[
|
|
Project.Platform.FLASH,
|
|
Project.Platform.HTML5,
|
|
Project.Platform.LINUX,
|
|
Project.Platform.WINDOWS,
|
|
Project.Platform.ANDROID,
|
|
],
|
|
config.branch({
|
|
name: 'app',
|
|
sources: [
|
|
'src-gen/haxe',
|
|
'src/common/haxe',
|
|
'src/app/haxe',
|
|
],
|
|
android: [{
|
|
path: 'dependencies/android',
|
|
extensions: ['ru.m.android.FileUtil'],
|
|
}],
|
|
assets: [
|
|
'src/app/resources',
|
|
],
|
|
main: 'ru.m.puzzlez.PuzzlezApp',
|
|
meta: {
|
|
width: 1280,
|
|
height: 768,
|
|
},
|
|
flags: [
|
|
'app',
|
|
]
|
|
}),
|
|
).bind(module, gulp);
|
|
|
|
const server = new Project(
|
|
Project.BuildSystem.HAXE,
|
|
[
|
|
Project.Platform.NEKO,
|
|
Project.Platform.CPP,
|
|
],
|
|
config.branch({
|
|
name: 'server',
|
|
sources: [
|
|
'src-gen/haxe',
|
|
'src/common/haxe',
|
|
'src/server/haxe',
|
|
],
|
|
main: 'ru.m.puzzlez.PuzzlezServer',
|
|
})
|
|
).bind(module, gulp);
|
|
|
|
module.exports.publish = publish(packageInfo.name, packageInfo.version, Config.PublishDir, Config.PublishUrl);
|
|
|
|
const defaultSeries = [
|
|
exports.clean,
|
|
exports.generate,
|
|
module.exports['app:flash:build'],
|
|
module.exports['app:flash:html'],
|
|
module.exports['app:html5:build'],
|
|
];
|
|
|
|
if (System.isLinux) {
|
|
defaultSeries.push(
|
|
module.exports['app:linux:build'],
|
|
module.exports['app:linux:archive'],
|
|
module.exports['app:linux:deb'],
|
|
|
|
module.exports['app:android:build'],
|
|
);
|
|
}
|
|
|
|
if (System.isWindows) {
|
|
defaultSeries.push(
|
|
module.exports['app:windows:build'],
|
|
module.exports['app:windows:archive'],
|
|
module.exports['app:windows:installer'],
|
|
);
|
|
}
|
|
|
|
defaultSeries.push(
|
|
exports.publish,
|
|
);
|
|
|
|
module.exports.default = gulp.series(defaultSeries);
|