[haxe,flashplayer] fixes

This commit is contained in:
2018-04-03 17:02:14 +03:00
parent f5cfd50537
commit 8c5179fdb5
3 changed files with 25 additions and 42 deletions

View File

@@ -3,12 +3,12 @@ const fs = require('fs');
const fse = require('fs-extra');
const os = require('os');
const through = require('through2');
const gulp = require('gulp');
const Sdk = require('./sdk');
const exec = require('./exec');
const PluginError = require('plugin-error');
const colors = require('ansi-colors');
const log = require('fancy-log');
const tar = require('tar');
class FlashPlayer extends Sdk {
@@ -18,9 +18,7 @@ class FlashPlayer extends Sdk {
}
playerPath(debug) {
const v = this.version.split('.');
const dir = `${v[0]}_${v[1]}_r${v[2]}_${v[3]}`;
return `${this.path}/${dir}${debug ? '_debug': ''}`;
return this.path;
}
prepare() {
@@ -34,13 +32,11 @@ class FlashPlayer extends Sdk {
const extract = (debug) => {
const v = this.version.split('.');
const playerPath = this.playerPath(debug);
// ToDo: fix
const archive = `${playerPath}/flashplayer${v[0]}_${v[1]}r${v[2]}_${v[3]}_linux_sa${debug ? '_debug' : ''}.${arch}.tar.gz`;
return gulp.src(archive)
.pipe(gunzip()).pipe(untar())
.pipe(gulp.dest(playerPath));
return fs.createReadStream(archive).pipe(tar.x({C: this.path}));
};
// ToDo:
return new Promise((success, fail) => {
extract().on('end', () => {
extract(true).on('end', success).on('error', fail)

View File

@@ -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-ddHH: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) => {