[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 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}`));
|
||||
}
|
||||
|
||||
68
gulpfile.js
68
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,
|
||||
|
||||
20
project.xml
20
project.xml
@@ -1,26 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<meta title="Tank'z" package="ru.m.tankz" company="MegaLoMania"/>
|
||||
<app main="ru.m.tankz.Client"/>
|
||||
<source path="src/common/haxe"/>
|
||||
<source path="src/client/haxe"/>
|
||||
<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"/>
|
||||
<source path="src/common/haxe"/><!-- for html5 -->
|
||||
<assets path="src/client/resources" rename="resources" include="*"/><!-- ? -->
|
||||
<haxelib name="openfl"/><!-- for flash -->
|
||||
<window fps="30"/>
|
||||
<window width="1024" height="768" unless="html5"/>
|
||||
<haxeflag name="-D" value="swf-gpu"/>
|
||||
<haxeflag name="-D" value="native-trace"/>
|
||||
<haxeflag name="-dce" value="no"/>
|
||||
|
||||
<section if="build_editor">
|
||||
<app main="ru.m.tankz.editor.Editor"/>
|
||||
<source path="src/editor/haxe"/>
|
||||
</section>
|
||||
</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