[haxe,flashplayer] fixes
This commit is contained in:
@@ -3,12 +3,12 @@ const fs = require('fs');
|
|||||||
const fse = require('fs-extra');
|
const fse = require('fs-extra');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const through = require('through2');
|
const through = require('through2');
|
||||||
const gulp = require('gulp');
|
|
||||||
const Sdk = require('./sdk');
|
const Sdk = require('./sdk');
|
||||||
const exec = require('./exec');
|
const exec = require('./exec');
|
||||||
const PluginError = require('plugin-error');
|
const PluginError = require('plugin-error');
|
||||||
const colors = require('ansi-colors');
|
const colors = require('ansi-colors');
|
||||||
const log = require('fancy-log');
|
const log = require('fancy-log');
|
||||||
|
const tar = require('tar');
|
||||||
|
|
||||||
|
|
||||||
class FlashPlayer extends Sdk {
|
class FlashPlayer extends Sdk {
|
||||||
@@ -18,9 +18,7 @@ class FlashPlayer extends Sdk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
playerPath(debug) {
|
playerPath(debug) {
|
||||||
const v = this.version.split('.');
|
return this.path;
|
||||||
const dir = `${v[0]}_${v[1]}_r${v[2]}_${v[3]}`;
|
|
||||||
return `${this.path}/${dir}${debug ? '_debug': ''}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
@@ -34,13 +32,11 @@ class FlashPlayer extends Sdk {
|
|||||||
const extract = (debug) => {
|
const extract = (debug) => {
|
||||||
const v = this.version.split('.');
|
const v = this.version.split('.');
|
||||||
const playerPath = this.playerPath(debug);
|
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`;
|
const archive = `${playerPath}/flashplayer${v[0]}_${v[1]}r${v[2]}_${v[3]}_linux_sa${debug ? '_debug' : ''}.${arch}.tar.gz`;
|
||||||
return gulp.src(archive)
|
return fs.createReadStream(archive).pipe(tar.x({C: this.path}));
|
||||||
.pipe(gunzip()).pipe(untar())
|
|
||||||
.pipe(gulp.dest(playerPath));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ToDo:
|
||||||
return new Promise((success, fail) => {
|
return new Promise((success, fail) => {
|
||||||
extract().on('end', () => {
|
extract().on('end', () => {
|
||||||
extract(true).on('end', success).on('error', fail)
|
extract(true).on('end', success).on('error', fail)
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ const tmp = require('tmp-file');
|
|||||||
const exec = require('./exec');
|
const exec = require('./exec');
|
||||||
const through = require('through2');
|
const through = require('through2');
|
||||||
const Sdk = require('./sdk');
|
const Sdk = require('./sdk');
|
||||||
const dateformat = require('dateformat');
|
|
||||||
const Vinyl = require('vinyl');
|
const Vinyl = require('vinyl');
|
||||||
const PluginError = require('plugin-error');
|
const PluginError = require('plugin-error');
|
||||||
const colors = require('ansi-colors');
|
const colors = require('ansi-colors');
|
||||||
@@ -24,7 +23,7 @@ class Haxe extends Sdk {
|
|||||||
fs.chmodSync(binPath, 0o755);
|
fs.chmodSync(binPath, 0o755);
|
||||||
return binPath;
|
return binPath;
|
||||||
}
|
}
|
||||||
return ``
|
throw `Unsupported OS: ${os.type()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
get binPath() {
|
get binPath() {
|
||||||
@@ -140,14 +139,15 @@ class Haxe extends Sdk {
|
|||||||
* command: 'build',
|
* command: 'build',
|
||||||
* platform: 'flash',
|
* platform: 'flash',
|
||||||
* version: '1.0.0',
|
* version: '1.0.0',
|
||||||
* build: '1999.12.12 00:00',
|
|
||||||
* values: {},
|
* values: {},
|
||||||
|
* macro: [],
|
||||||
* outputFile: 'out.swf',
|
* outputFile: 'out.swf',
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
openfl(params) {
|
openfl(params) {
|
||||||
params = Object.assign({
|
params = Object.assign({
|
||||||
build: dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss'),
|
version: null,
|
||||||
|
values: {},
|
||||||
macro: [],
|
macro: [],
|
||||||
debug: false,
|
debug: false,
|
||||||
}, params);
|
}, params);
|
||||||
@@ -164,7 +164,10 @@ class Haxe extends Sdk {
|
|||||||
const endStream = (callback) => {
|
const endStream = (callback) => {
|
||||||
log(this.tag, colors.cyan(`openfl ${params.command} ${params.platform}`));
|
log(this.tag, colors.cyan(`openfl ${params.command} ${params.platform}`));
|
||||||
const args = ['-cwd', files[0].path, 'run', '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];
|
const value = params.values[key];
|
||||||
if (value === true) {
|
if (value === true) {
|
||||||
args.push(`-D${key}`);
|
args.push(`-D${key}`);
|
||||||
@@ -178,24 +181,13 @@ class Haxe extends Sdk {
|
|||||||
args.push(`--app-file=${params.outputFile}`);
|
args.push(`--app-file=${params.outputFile}`);
|
||||||
}
|
}
|
||||||
if (params.version) args.push(`--meta-version=${params.version}`);
|
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) {
|
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');
|
args.push('-debug');
|
||||||
}
|
}
|
||||||
//console.log('haxelib', args.join(' '));
|
|
||||||
const target = `${buildDir}/${params.platform}/bin`;
|
const target = `${buildDir}/${params.platform}/bin`;
|
||||||
rmdir(target);
|
rmdir(target);
|
||||||
this.haxelib(args).then(() => {
|
this.haxelib(args).then(() => {
|
||||||
vfs.src(`${target}/**/*`).pipe(through.obj((file, enc, cb) => {
|
vfs.src(`${target}/**/*`).pipe(through.obj((file, enc, cb) => {
|
||||||
file.debug = debug;
|
|
||||||
stream.push(file);
|
stream.push(file);
|
||||||
cb();
|
cb();
|
||||||
}, (cb) => {
|
}, (cb) => {
|
||||||
@@ -219,18 +211,19 @@ class Haxe extends Sdk {
|
|||||||
* {
|
* {
|
||||||
* platform: 'neko',
|
* platform: 'neko',
|
||||||
* version: '1.0.0',
|
* version: '1.0.0',
|
||||||
* build: '1999.12.12 00:00',
|
|
||||||
* values: {},
|
* values: {},
|
||||||
|
* macro: [],
|
||||||
* lib: [],
|
* lib: [],
|
||||||
* src: [],
|
* src: [],
|
||||||
* main: 'Main.hx',
|
* main: 'Main.hx',
|
||||||
* outputFile: 'out.n',
|
* outputFile: 'out.n',
|
||||||
* debug: true,
|
* debug: false,
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
build(params) {
|
build(params) {
|
||||||
params = Object.assign({
|
params = Object.assign({
|
||||||
build: dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss'),
|
version: null,
|
||||||
|
values: {},
|
||||||
macro: [],
|
macro: [],
|
||||||
debug: false,
|
debug: false,
|
||||||
}, params);
|
}, params);
|
||||||
@@ -257,7 +250,7 @@ class Haxe extends Sdk {
|
|||||||
for (const macro of params.macro) {
|
for (const macro of params.macro) {
|
||||||
args.push('--macro', `"${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];
|
const value = params.values[key];
|
||||||
if (value === true) {
|
if (value === true) {
|
||||||
args.push(`-D ${key}`);
|
args.push(`-D ${key}`);
|
||||||
@@ -266,18 +259,8 @@ class Haxe extends Sdk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const tmpFile = tmp.generateFile();
|
const tmpFile = tmp.generateFile();
|
||||||
const dir = path.dirname(tmpFile.path);
|
|
||||||
const name = path.basename(tmpFile.path);
|
|
||||||
args.push(`-${params.platform}`, tmpFile.path);
|
args.push(`-${params.platform}`, tmpFile.path);
|
||||||
args.push(`--macro "CompilationOption.set('build','${params.build}')"`);
|
|
||||||
let debug = null;
|
|
||||||
if (params.debug) {
|
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');
|
args.push('-debug');
|
||||||
}
|
}
|
||||||
//console.log('haxe', args.join(' '));
|
//console.log('haxe', args.join(' '));
|
||||||
@@ -287,7 +270,6 @@ class Haxe extends Sdk {
|
|||||||
//contents: fs.createReadStream(tmpFile.path),
|
//contents: fs.createReadStream(tmpFile.path),
|
||||||
contents: fs.readFileSync(tmpFile.path),
|
contents: fs.readFileSync(tmpFile.path),
|
||||||
});
|
});
|
||||||
out.debug = debug;
|
|
||||||
stream.push(out);
|
stream.push(out);
|
||||||
callback();
|
callback();
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
|
|||||||
11
package.json
11
package.json
@@ -1,21 +1,26 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-haxetool",
|
"name": "gulp-haxetool",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"description": "Haxe tool for gulp",
|
"description": "Haxe tool for gulp",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"ansi-colors": "^1.1.0",
|
||||||
"async": "^2.6.0",
|
"async": "^2.6.0",
|
||||||
"dateformat": "^3.0.3",
|
"fancy-log": "^1.3.2",
|
||||||
"fs-extra": "^5.0.0",
|
"fs-extra": "^5.0.0",
|
||||||
"got": "^8.3.0",
|
"got": "^8.3.0",
|
||||||
"gulp": "github:gulpjs/gulp#4.0",
|
"gulp": "github:gulpjs/gulp#4.0",
|
||||||
|
"mkdirp": "^0.5.1",
|
||||||
"plugin-error": "^1.0.1",
|
"plugin-error": "^1.0.1",
|
||||||
"progress": "^2.0.0",
|
"progress": "^2.0.0",
|
||||||
"promise-streams": "^2.1.1",
|
"promise-streams": "^2.1.1",
|
||||||
"rmdir": "^1.2.0",
|
"rmdir": "^1.2.0",
|
||||||
"tar": "^4.4.1",
|
"tar": "^4.4.1",
|
||||||
|
"through2": "^2.0.3",
|
||||||
"tmp-file": "^2.0.1",
|
"tmp-file": "^2.0.1",
|
||||||
"unzip-stream": "^0.3.0"
|
"unzip-stream": "^0.3.0",
|
||||||
|
"vinyl": "^2.1.0",
|
||||||
|
"vinyl-fs": "^3.0.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
|||||||
Reference in New Issue
Block a user