[gulp] udpate project
This commit is contained in:
@@ -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;
|
|
||||||
@@ -9,7 +9,6 @@ const webserver = require('gulp-webserver');
|
|||||||
const run = require('gulp-run');
|
const run = require('gulp-run');
|
||||||
const tail = require('./tail');
|
const tail = require('./tail');
|
||||||
const deb = require('gulp-debian');
|
const deb = require('gulp-debian');
|
||||||
const dateformat = require('dateformat');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -33,6 +32,19 @@ class Config {
|
|||||||
this.values = values;
|
this.values = values;
|
||||||
this.macro = macro;
|
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) {
|
macro(debug) {
|
||||||
const build = dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss');
|
let macro = [];
|
||||||
let macro = [`CompilationOption.set('build','${build}')`];
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
macro = macro.concat(debug.macro());
|
macro = macro.concat(debug.macro());
|
||||||
}
|
}
|
||||||
@@ -86,6 +97,9 @@ class OpenFLBuilder extends Builder {
|
|||||||
command: 'build',
|
command: 'build',
|
||||||
platform: this.platform,
|
platform: this.platform,
|
||||||
version: this.config.version,
|
version: this.config.version,
|
||||||
|
lib: this.config.lib,
|
||||||
|
cp: this.config.cp,
|
||||||
|
main: this.config.main,
|
||||||
debug: debug,
|
debug: debug,
|
||||||
values: this.config.values,
|
values: this.config.values,
|
||||||
macro: this.macro(debug),
|
macro: this.macro(debug),
|
||||||
@@ -112,10 +126,10 @@ class HaxeBuilder extends Builder {
|
|||||||
lib: this.config.lib,
|
lib: this.config.lib,
|
||||||
cp: this.config.cp,
|
cp: this.config.cp,
|
||||||
main: this.config.main,
|
main: this.config.main,
|
||||||
outputFile: this.config.name + '.n', // ToDo: for neko only
|
|
||||||
debug: debug,
|
debug: debug,
|
||||||
|
values: this.config.values,
|
||||||
macro: this.macro(debug),
|
macro: this.macro(debug),
|
||||||
values: this.config.values
|
outputFile: this.config.name + '.n', // ToDo: for neko only
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest(`${this.target}/${this.platform}`));
|
.pipe(gulp.dest(`${this.target}/${this.platform}`));
|
||||||
}
|
}
|
||||||
|
|||||||
68
gulpfile.js
68
gulpfile.js
@@ -4,8 +4,10 @@ const clean = require('gulp-clean');
|
|||||||
const Config = require('./config.json');
|
const Config = require('./config.json');
|
||||||
const Project = require('./build/project');
|
const Project = require('./build/project');
|
||||||
const version = require('./build/version');
|
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) {
|
if (Config.SdkDir) {
|
||||||
Sdk.dir = Config.SdkDir;
|
Sdk.dir = Config.SdkDir;
|
||||||
@@ -15,23 +17,48 @@ exports.clean = () => {
|
|||||||
return gulp.src('target/*', {read: false}).pipe(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:
|
* ToDo:
|
||||||
* libs versions from package.json
|
* install before build?
|
||||||
* lib in openfl build
|
* generate before build?
|
||||||
* cp in openfl build
|
* [haxe] generate project.xml | project.hxp (http://www.openfl.org/lime/docs/project-files/hxp-format/)
|
||||||
* main in openfl build
|
* [haxe] another /tmp/build directories for another builds
|
||||||
* install libs in builder prepare
|
* debug without sockets?
|
||||||
*
|
* linux deb package
|
||||||
* run generate proto from prepare.js
|
* 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
|
* client
|
||||||
*/
|
*/
|
||||||
const client = new Project(new Project.Config({
|
const client = new Project(config.update({
|
||||||
name: 'client',
|
name: 'client',
|
||||||
version: version
|
cp: ['src/client/haxe'],
|
||||||
|
main: 'ru.m.tankz.Client',
|
||||||
}), [
|
}), [
|
||||||
Project.Platform.FLASH,
|
Project.Platform.FLASH,
|
||||||
Project.Platform.HTML5,
|
Project.Platform.HTML5,
|
||||||
@@ -41,10 +68,10 @@ const client = new Project(new Project.Config({
|
|||||||
/**
|
/**
|
||||||
* editor
|
* editor
|
||||||
*/
|
*/
|
||||||
const editor = new Project(new Project.Config({
|
const editor = new Project(config.update({
|
||||||
name: 'editor',
|
name: 'editor',
|
||||||
version: version,
|
cp: ['src/client/haxe', 'src/editor/haxe'],
|
||||||
values: {build_editor: true}
|
main: 'ru.m.tankz.editor.Editor',
|
||||||
}), [
|
}), [
|
||||||
Project.Platform.FLASH,
|
Project.Platform.FLASH,
|
||||||
]).bind(module);
|
]).bind(module);
|
||||||
@@ -52,20 +79,9 @@ const editor = new Project(new Project.Config({
|
|||||||
/**
|
/**
|
||||||
* server
|
* server
|
||||||
*/
|
*/
|
||||||
const server = new Project(new Project.Config({
|
const server = new Project(config.update({
|
||||||
name: 'server',
|
name: 'server',
|
||||||
version: version,
|
cp: ['src/server/haxe'],
|
||||||
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',
|
|
||||||
],
|
|
||||||
main: 'ru.m.tankz.server.Server',
|
main: 'ru.m.tankz.server.Server',
|
||||||
}), [
|
}), [
|
||||||
Project.Platform.NEKO,
|
Project.Platform.NEKO,
|
||||||
|
|||||||
20
project.xml
20
project.xml
@@ -1,26 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<meta title="Tank'z" package="ru.m.tankz" company="MegaLoMania"/>
|
<meta title="Tank'z" package="ru.m.tankz" company="MegaLoMania"/>
|
||||||
<app main="ru.m.tankz.Client"/>
|
<source path="src/common/haxe"/><!-- for html5 -->
|
||||||
<source path="src/common/haxe"/>
|
<assets path="src/client/resources" rename="resources" include="*"/><!-- ? -->
|
||||||
<source path="src/client/haxe"/>
|
<haxelib name="openfl"/><!-- for flash -->
|
||||||
<source path="src-gen/haxe"/>
|
|
||||||
<assets path="src/client/resources" rename="resources" include="*"/>
|
|
||||||
<haxelib name="lime" version="6.0.1"/>
|
|
||||||
<haxelib name="openfl" version="7.0.0"/>
|
|
||||||
<haxelib name="promhx" version="1.1.0"/>
|
|
||||||
<haxelib name="protohx" version="0.4.6"/>
|
|
||||||
<haxelib name="haxework" version="git"/>
|
|
||||||
<haxelib name="yaml" version="1.3.0"/>
|
|
||||||
<haxelib name="yield" version="1.1.2"/>
|
|
||||||
<window fps="30"/>
|
<window fps="30"/>
|
||||||
<window width="1024" height="768" unless="html5"/>
|
<window width="1024" height="768" unless="html5"/>
|
||||||
<haxeflag name="-D" value="swf-gpu"/>
|
<haxeflag name="-D" value="swf-gpu"/>
|
||||||
<haxeflag name="-D" value="native-trace"/>
|
<haxeflag name="-D" value="native-trace"/>
|
||||||
<haxeflag name="-dce" value="no"/>
|
<haxeflag name="-dce" value="no"/>
|
||||||
|
|
||||||
<section if="build_editor">
|
|
||||||
<app main="ru.m.tankz.editor.Editor"/>
|
|
||||||
<source path="src/editor/haxe"/>
|
|
||||||
</section>
|
|
||||||
</project>
|
</project>
|
||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user