[build] update gulp debug logger
This commit is contained in:
@@ -10,6 +10,7 @@ const gulp = require('gulp');
|
||||
const through = require('through2');
|
||||
const col = gutil.colors;
|
||||
const Sdk = require('./sdk');
|
||||
const dateformat = require('dateformat');
|
||||
|
||||
|
||||
class Haxe extends Sdk {
|
||||
@@ -130,6 +131,12 @@ class Haxe extends Sdk {
|
||||
* }
|
||||
*/
|
||||
openfl(params) {
|
||||
params = Object.assign({
|
||||
build: dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss'),
|
||||
macro: [],
|
||||
debug: false,
|
||||
}, params);
|
||||
|
||||
const files = [];
|
||||
let stream = null;
|
||||
|
||||
@@ -156,12 +163,26 @@ class Haxe extends Sdk {
|
||||
args.push(`--app-path=${dir}`);
|
||||
args.push(`--app-file=${name}`);
|
||||
if (params.version) args.push(`--meta-version=${params.version}`);
|
||||
if (params.build) args.push(`--haxedef=BUILD="${params.build}"`);
|
||||
//if (params.build) args.push(`--haxedef=BUILD="${params.build}"`);
|
||||
args.push(`--haxeflag="--macro=CompilationOption.set('build','${params.build}')"`);
|
||||
let debug = null;
|
||||
if (params.debug) {
|
||||
debug = {
|
||||
host: 'localhost',
|
||||
port: 6000 + Math.floor(Math.random() * 1000),
|
||||
};
|
||||
args.push(`--haxeflag="--macro=CompilationOption.set('debug.address','${debug.host}')"`);
|
||||
args.push(`--haxeflag="--macro=CompilationOption.set('debug.port','${debug.port}')"`);
|
||||
args.push('-debug');
|
||||
}
|
||||
//console.log('haxelib', args.join(' '));
|
||||
this.haxelib(args).then(() => {
|
||||
stream.push(new gutil.File({
|
||||
const out = new gutil.File({
|
||||
path: params.outputFile,
|
||||
contents: fs.createReadStream(`${dir}/flash/bin/${name}.swf`)
|
||||
}));
|
||||
});
|
||||
out.debug = debug;
|
||||
stream.push(out);
|
||||
callback();
|
||||
}).catch((error) => {
|
||||
stream.emit('error', new gutil.PluginError({plugin: this.name, message: error}));
|
||||
@@ -185,9 +206,16 @@ class Haxe extends Sdk {
|
||||
* src: [],
|
||||
* main: 'Main.hx',
|
||||
* outputFile: 'out.n',
|
||||
* debug: true,
|
||||
* }
|
||||
*/
|
||||
build(params) {
|
||||
params = Object.assign({
|
||||
build: dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss'),
|
||||
macro: [],
|
||||
debug: false,
|
||||
}, params);
|
||||
|
||||
const files = [];
|
||||
let stream = null;
|
||||
|
||||
@@ -222,13 +250,25 @@ class Haxe extends Sdk {
|
||||
const dir = path.dirname(tmpFile.path);
|
||||
const name = path.basename(tmpFile.path);
|
||||
args.push(`-${params.platform}`, tmpFile.path);
|
||||
if (params.build) args.push(`--haxedef=BUILD="${params.build}"`);
|
||||
args.push(`--macro "CompilationOption.set('build','${params.build}')"`);
|
||||
let debug = null;
|
||||
if (params.debug) {
|
||||
debug = {
|
||||
host: 'localhost',
|
||||
port: 6000 + Math.floor(Math.random() * 1000),
|
||||
};
|
||||
args.push(`--macro "CompilationOption.set('debug.address','${debug.host}')"`);
|
||||
args.push(`--macro "CompilationOption.set('debug.port','${debug.port}')"`);
|
||||
args.push('-debug');
|
||||
}
|
||||
//console.log('haxe', args.join(' '));
|
||||
this.haxe(args).then(() => {
|
||||
stream.push(new gutil.File({
|
||||
const out = new gutil.File({
|
||||
path: params.outputFile,
|
||||
contents: fs.createReadStream(tmpFile.path)
|
||||
}));
|
||||
});
|
||||
out.debug = debug;
|
||||
stream.push(out);
|
||||
callback();
|
||||
}).catch((error) => {
|
||||
stream.emit('error', new gutil.PluginError({plugin: this.name, message: error}));
|
||||
|
||||
Reference in New Issue
Block a user