202 lines
4.6 KiB
JavaScript
Executable File
202 lines
4.6 KiB
JavaScript
Executable File
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;
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* base config
|
|
*/
|
|
const config = new Project.Config({
|
|
meta: {
|
|
title: 'Tank\'z',
|
|
filename: 'tankz',
|
|
icon: 'src/client/resources/icon.png',
|
|
pack: 'ru.m.tankz',
|
|
author: 'shmyga <shmyga.z@gmail.com>',
|
|
company: 'MegaLoMania',
|
|
version: packageInfo.version + (Config.Develop ? '-SNAPSHOT' : ''),
|
|
},
|
|
key: Config.Key,
|
|
libs: packageInfo.haxeDependencies,
|
|
sources: [
|
|
'src/common/haxe',
|
|
'src-gen/haxe',
|
|
],
|
|
assets: [
|
|
'src/common/resources/config',
|
|
],
|
|
flags: [
|
|
'proto_debug',
|
|
],
|
|
macros: [
|
|
`CompilationOption.set('build','${dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss')}')`,
|
|
]
|
|
});
|
|
|
|
const host = argv.host || 'localhost';
|
|
const port = argv.port || 5000;
|
|
|
|
/**
|
|
* client
|
|
*/
|
|
const client = new Project(
|
|
Project.BuildSystem.OPENFL,
|
|
[
|
|
Project.Platform.FLASH,
|
|
Project.Platform.HTML5,
|
|
Project.Platform.LINUX,
|
|
Project.Platform.WINDOWS,
|
|
Project.Platform.ANDROID,
|
|
],
|
|
config.branch({
|
|
name: 'client',
|
|
sources: [
|
|
'src/client/haxe',
|
|
],
|
|
main: 'ru.m.tankz.Client',
|
|
preloader: 'ru.m.tankz.Preloader',
|
|
assets: [
|
|
'src/common/resources/level',
|
|
'src/client/resources',
|
|
],
|
|
meta: {
|
|
width: 1024,
|
|
height: 576,
|
|
},
|
|
flags: [
|
|
//'proto_debug',
|
|
//'dom',
|
|
//'dev_layout',
|
|
//'bitmap_text',
|
|
],
|
|
macros: [
|
|
`CompilationOption.set('host','${host}')`,
|
|
`CompilationOption.set('port',${port})`,
|
|
]
|
|
}),
|
|
).bind(module, gulp);
|
|
|
|
/**
|
|
* editor
|
|
*/
|
|
const editor = new Project(
|
|
Project.BuildSystem.OPENFL,
|
|
[
|
|
Project.Platform.FLASH,
|
|
Project.Platform.HTML5,
|
|
Project.Platform.LINUX,
|
|
],
|
|
config.branch({
|
|
name: 'editor',
|
|
sources: [
|
|
'src/client/haxe',
|
|
'src/editor/haxe',
|
|
],
|
|
main: 'ru.m.tankz.editor.Editor',
|
|
preloader: 'ru.m.tankz.Preloader',
|
|
assets: [
|
|
'src/client/resources',
|
|
'src/editor/resources',
|
|
],
|
|
meta: {
|
|
filename: 'editor',
|
|
pack: 'ru.m.tankz.editor',
|
|
width: 1024,
|
|
height: 768,
|
|
},
|
|
flags: [
|
|
//'dev_layout',
|
|
]
|
|
})
|
|
).bind(module, gulp);
|
|
|
|
/**
|
|
* server
|
|
*/
|
|
const server = new Project(
|
|
Project.BuildSystem.HAXE,
|
|
Project.Platform.CPP,
|
|
config.branch({
|
|
name: 'server',
|
|
sources: ['src/server/haxe'],
|
|
main: 'ru.m.tankz.server.Server',
|
|
assets: [
|
|
'src/common/resources/level',
|
|
]
|
|
}),
|
|
).bind(module, gulp);
|
|
|
|
/**
|
|
* publish
|
|
*/
|
|
module.exports.publish = publish(packageInfo.name, packageInfo.version, Config.PublishDir, Config.PublishUrl);
|
|
|
|
/**
|
|
* default
|
|
*/
|
|
const defaultSeries = [
|
|
exports.clean,
|
|
exports.generate,
|
|
module.exports['client:flash:build'],
|
|
module.exports['client:flash:html'],
|
|
module.exports['client:html5:build'],
|
|
|
|
module.exports['editor:flash:build'],
|
|
module.exports['editor:flash:html'],
|
|
module.exports['editor:html5:build'],
|
|
|
|
module.exports['server:cpp:build'],
|
|
];
|
|
|
|
if (System.isLinux) {
|
|
defaultSeries.push(
|
|
module.exports['client:linux:build'],
|
|
module.exports['client:linux:archive'],
|
|
module.exports['client:linux:deb'],
|
|
|
|
module.exports['client:android:build'],
|
|
);
|
|
}
|
|
|
|
if (System.isWindows) {
|
|
defaultSeries.push(
|
|
module.exports['client:windows:build'],
|
|
module.exports['client:windows:archive'],
|
|
module.exports['client:windows:installer'],
|
|
);
|
|
}
|
|
|
|
defaultSeries.push(
|
|
exports.publish,
|
|
);
|
|
|
|
module.exports.default = gulp.series(defaultSeries);
|