diff --git a/build/prepare.js b/build/prepare.js deleted file mode 100755 index 2f42907..0000000 --- a/build/prepare.js +++ /dev/null @@ -1,36 +0,0 @@ -const {Haxe, AdobeAir, FlashPlayer} = require('gulp-haxetool'); -const packageInfo = require('../package.json'); - - -const prepareOne = (value) => { - switch (value) { - case Haxe.ID: - const haxe = new Haxe(); - return haxe.prepare().then(() => haxe.install(packageInfo.haxeDependencies)); - case AdobeAir.ID: - return new AdobeAir().prepare(); - case FlashPlayer.ID: - return new FlashPlayer().prepare(); - default: - throw Error(`Unknown target: ${value}`) - } -}; - -const prepare = (...targets) => function prepare() { - const tasks = targets.map((target) => prepareOne(target)); - return Promise.all(tasks); -}; - -const update = () => { - return new Haxe().upgrade(); -}; - -const generate = () => function generate() { - return new Haxe().haxelib([ - 'run', 'protohx', 'generate', 'protohx.json' - ]); -}; - -module.exports = prepare; -module.exports.update = update; -module.exports.generate = generate; diff --git a/build/project.js b/build/project.js index 40f18ce..e1e12bc 100644 --- a/build/project.js +++ b/build/project.js @@ -9,7 +9,6 @@ const webserver = require('gulp-webserver'); const run = require('gulp-run'); const tail = require('./tail'); const deb = require('gulp-debian'); -const dateformat = require('dateformat'); /** * @@ -33,6 +32,19 @@ class Config { this.values = values; this.macro = macro; } + + update({name, version, lib=[], cp=[], main=null, values={}, macro=[]}) { + return new Config({ + name: name || this.name, + version: version || this.version, + //lib: this.lib.concat(lib), //ToDo: check if object + lib: this.lib, + cp: this.cp.concat(cp), + main: main || this.main, + values: {...this.values, ...values}, + macro: this.macro.concat(macro), + }) + } } /** @@ -52,8 +64,7 @@ class Builder { } macro(debug) { - const build = dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss'); - let macro = [`CompilationOption.set('build','${build}')`]; + let macro = []; if (debug) { macro = macro.concat(debug.macro()); } @@ -86,6 +97,9 @@ class OpenFLBuilder extends Builder { command: 'build', platform: this.platform, version: this.config.version, + lib: this.config.lib, + cp: this.config.cp, + main: this.config.main, debug: debug, values: this.config.values, macro: this.macro(debug), @@ -112,10 +126,10 @@ class HaxeBuilder extends Builder { lib: this.config.lib, cp: this.config.cp, main: this.config.main, - outputFile: this.config.name + '.n', // ToDo: for neko only debug: debug, + values: this.config.values, macro: this.macro(debug), - values: this.config.values + outputFile: this.config.name + '.n', // ToDo: for neko only })) .pipe(gulp.dest(`${this.target}/${this.platform}`)); } diff --git a/gulpfile.js b/gulpfile.js index 271c065..2087d0b 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,8 +4,10 @@ const clean = require('gulp-clean'); const Config = require('./config.json'); const Project = require('./build/project'); const version = require('./build/version'); +const packageInfo = require('./package.json'); +const {Sdk, Haxe} = require('gulp-haxetool'); +const dateformat = require('dateformat'); -const {Sdk} = require('gulp-haxetool'); if (Config.SdkDir) { Sdk.dir = Config.SdkDir; @@ -15,23 +17,48 @@ exports.clean = () => { return gulp.src('target/*', {read: false}).pipe(clean()); }; +exports.generate = () => { + return new Haxe().haxelib([ + 'run', 'protohx', 'generate', 'protohx.json' + ]); +}; + +exports.install = () => { + return new Haxe().install(packageInfo.haxeDependencies); +}; + /** * ToDo: - * libs versions from package.json - * lib in openfl build - * cp in openfl build - * main in openfl build - * install libs in builder prepare - * - * run generate proto from prepare.js + * install before build? + * generate before build? + * [haxe] generate project.xml | project.hxp (http://www.openfl.org/lime/docs/project-files/hxp-format/) + * [haxe] another /tmp/build directories for another builds + * debug without sockets? + * linux deb package + * windows target + * window exe package (innosetup) + * flash html wrapper */ +const config = new Project.Config({ + version: version, + lib: packageInfo.haxeDependencies, + cp: [ + 'src/common/haxe', + 'src-gen/haxe', + ], + macro: [ + `CompilationOption.set('build','${dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss')}')` + ] +}); + /** * client */ -const client = new Project(new Project.Config({ +const client = new Project(config.update({ name: 'client', - version: version + cp: ['src/client/haxe'], + main: 'ru.m.tankz.Client', }), [ Project.Platform.FLASH, Project.Platform.HTML5, @@ -41,10 +68,10 @@ const client = new Project(new Project.Config({ /** * editor */ -const editor = new Project(new Project.Config({ +const editor = new Project(config.update({ name: 'editor', - version: version, - values: {build_editor: true} + cp: ['src/client/haxe', 'src/editor/haxe'], + main: 'ru.m.tankz.editor.Editor', }), [ Project.Platform.FLASH, ]).bind(module); @@ -52,20 +79,9 @@ const editor = new Project(new Project.Config({ /** * server */ -const server = new Project(new Project.Config({ +const server = new Project(config.update({ name: 'server', - version: version, - lib: [ - 'protohx:0.4.6', - 'haxework:git', - 'haxe-crypto:0.0.7', - 'yield:1.1.2', - ], - cp: [ - 'src/common/haxe', - 'src/server/haxe', - 'src-gen/haxe', - ], + cp: ['src/server/haxe'], main: 'ru.m.tankz.server.Server', }), [ Project.Platform.NEKO, diff --git a/project.xml b/project.xml index 560d7bf..6ce37fd 100755 --- a/project.xml +++ b/project.xml @@ -1,26 +1,12 @@ - - - - - - - - - - - - + + + - -
- - -
\ No newline at end of file diff --git a/tankz.service b/tankz.service deleted file mode 100644 index 3a0c626..0000000 --- a/tankz.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Tankz server - -[Service] -WorkingDirectory=/home/adman/repo/tankz/current/target -ExecStart=/usr/bin/neko tankz.n -Restart=always - -[Install] -WantedBy=multi-user.target -Alias=tankz.service \ No newline at end of file