const gulp = require('gulp'); const gulpClean = require('gulp-clean'); const Config = require('./config.json'); const packageInfo = require('./package.json'); const {Sdk, Haxe, Project, FlashPlayer} = require('gulp-haxetool'); const dateformat = require('dateformat'); // ToDo: update default in gulp-haxetool FlashPlayer.VERSION = '32'; //Haxe.VERSION = '4.0.0-rc.2'; if (Config.SdkDir) { Sdk.dir = Config.SdkDir; } 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; } }); }; /** * ToDo: * windows target * window exe package (innosetup) */ const config = new Project.Config({ meta: { title: 'Tank\'z', filename: 'tankz', icon: 'src/client/resources/icon.png', pack: 'ru.m.tankz', author: 'shmyga ', company: 'MegaLoMania', version: packageInfo.version, }, libs: packageInfo.haxeDependencies, sources: [ 'src/common/haxe', 'src-gen/haxe', ], assets: [ 'src/common/resources' ], macros: [ //'yield.parser.Parser.auto()', // ToDo: bug with extraParams.hxml in yield library `CompilationOption.set('build','${dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss')}')`, ] }); /** * client */ const client = new Project( Project.BuildSystem.OPENFL, [ Project.Platform.FLASH, Project.Platform.HTML5, Project.Platform.LINUX, Project.Platform.ANDROID, ], config.branch({ name: 'client', sources: ['src/client/haxe'], main: 'ru.m.tankz.Client', preloader: 'ru.m.tankz.Preloader', assets: [ 'src/client/resources', ], meta: { width: 1024, height: 768, }, flags: [ //'dom', //'dev_layout', //'bitmap_text', ], }), module.exports.generate ).bind(module, gulp); /** * editor */ const editor = new Project( Project.BuildSystem.OPENFL, [ Project.Platform.FLASH, Project.Platform.HTML5, ], 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', width: 1024, height: 850, }, flags: [ //'dev_layout', ] }) ).bind(module, gulp); /** * server */ const server = new Project( Project.BuildSystem.HAXE, Project.Platform.NEKO, config.branch({ name: 'server', sources: ['src/server/haxe'], main: 'ru.m.tankz.server.Server', }) ).bind(module, gulp); /** * default */ module.exports.default = gulp.series( exports.clean, module.exports['client:flash:build'], module.exports['client:flash:html'], module.exports['client:html5:build'], module.exports['client:linux:build'], module.exports['client:linux:deb'], //module.exports['client:android:build'], module.exports['editor:flash:build'], module.exports['editor:flash:html'], module.exports['editor:html5:build'], module.exports['server:neko:build'], );