[haxe,flashplayer] fixes
This commit is contained in:
@@ -5,7 +5,6 @@ const tmp = require('tmp-file');
|
||||
const exec = require('./exec');
|
||||
const through = require('through2');
|
||||
const Sdk = require('./sdk');
|
||||
const dateformat = require('dateformat');
|
||||
const Vinyl = require('vinyl');
|
||||
const PluginError = require('plugin-error');
|
||||
const colors = require('ansi-colors');
|
||||
@@ -24,7 +23,7 @@ class Haxe extends Sdk {
|
||||
fs.chmodSync(binPath, 0o755);
|
||||
return binPath;
|
||||
}
|
||||
return ``
|
||||
throw `Unsupported OS: ${os.type()}`;
|
||||
}
|
||||
|
||||
get binPath() {
|
||||
@@ -140,14 +139,15 @@ class Haxe extends Sdk {
|
||||
* command: 'build',
|
||||
* platform: 'flash',
|
||||
* version: '1.0.0',
|
||||
* build: '1999.12.12 00:00',
|
||||
* values: {},
|
||||
* macro: [],
|
||||
* outputFile: 'out.swf',
|
||||
* }
|
||||
*/
|
||||
openfl(params) {
|
||||
params = Object.assign({
|
||||
build: dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss'),
|
||||
version: null,
|
||||
values: {},
|
||||
macro: [],
|
||||
debug: false,
|
||||
}, params);
|
||||
@@ -164,7 +164,10 @@ class Haxe extends Sdk {
|
||||
const endStream = (callback) => {
|
||||
log(this.tag, colors.cyan(`openfl ${params.command} ${params.platform}`));
|
||||
const args = ['-cwd', files[0].path, 'run', 'openfl', params.command, params.platform];
|
||||
if (params.values) for (let key of Object.keys(params.values)) {
|
||||
for (const macro of params.macro) {
|
||||
args.push(`--haxeflag="--macro ${macro}"`);
|
||||
}
|
||||
for (let key of Object.keys(params.values)) {
|
||||
const value = params.values[key];
|
||||
if (value === true) {
|
||||
args.push(`-D${key}`);
|
||||
@@ -178,24 +181,13 @@ class Haxe extends Sdk {
|
||||
args.push(`--app-file=${params.outputFile}`);
|
||||
}
|
||||
if (params.version) args.push(`--meta-version=${params.version}`);
|
||||
//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(' '));
|
||||
const target = `${buildDir}/${params.platform}/bin`;
|
||||
rmdir(target);
|
||||
this.haxelib(args).then(() => {
|
||||
vfs.src(`${target}/**/*`).pipe(through.obj((file, enc, cb) => {
|
||||
file.debug = debug;
|
||||
stream.push(file);
|
||||
cb();
|
||||
}, (cb) => {
|
||||
@@ -219,18 +211,19 @@ class Haxe extends Sdk {
|
||||
* {
|
||||
* platform: 'neko',
|
||||
* version: '1.0.0',
|
||||
* build: '1999.12.12 00:00',
|
||||
* values: {},
|
||||
* macro: [],
|
||||
* lib: [],
|
||||
* src: [],
|
||||
* main: 'Main.hx',
|
||||
* outputFile: 'out.n',
|
||||
* debug: true,
|
||||
* debug: false,
|
||||
* }
|
||||
*/
|
||||
build(params) {
|
||||
params = Object.assign({
|
||||
build: dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss'),
|
||||
version: null,
|
||||
values: {},
|
||||
macro: [],
|
||||
debug: false,
|
||||
}, params);
|
||||
@@ -257,7 +250,7 @@ class Haxe extends Sdk {
|
||||
for (const macro of params.macro) {
|
||||
args.push('--macro', `"${macro}"`);
|
||||
}
|
||||
if (params.values) for (let key of Object.keys(params.values)) {
|
||||
for (let key of Object.keys(params.values)) {
|
||||
const value = params.values[key];
|
||||
if (value === true) {
|
||||
args.push(`-D ${key}`);
|
||||
@@ -266,18 +259,8 @@ class Haxe extends Sdk {
|
||||
}
|
||||
}
|
||||
const tmpFile = tmp.generateFile();
|
||||
const dir = path.dirname(tmpFile.path);
|
||||
const name = path.basename(tmpFile.path);
|
||||
args.push(`-${params.platform}`, tmpFile.path);
|
||||
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(' '));
|
||||
@@ -287,7 +270,6 @@ class Haxe extends Sdk {
|
||||
//contents: fs.createReadStream(tmpFile.path),
|
||||
contents: fs.readFileSync(tmpFile.path),
|
||||
});
|
||||
out.debug = debug;
|
||||
stream.push(out);
|
||||
callback();
|
||||
}).catch((error) => {
|
||||
|
||||
Reference in New Issue
Block a user