[haxe] lib, cp, main params for openfl
This commit is contained in:
@@ -139,6 +139,7 @@ class Haxe extends Sdk {
|
|||||||
* command: 'build',
|
* command: 'build',
|
||||||
* platform: 'flash',
|
* platform: 'flash',
|
||||||
* version: '1.0.0',
|
* version: '1.0.0',
|
||||||
|
* lib: {},
|
||||||
* values: {},
|
* values: {},
|
||||||
* macro: [],
|
* macro: [],
|
||||||
* outputFile: 'out.swf',
|
* outputFile: 'out.swf',
|
||||||
@@ -147,6 +148,9 @@ class Haxe extends Sdk {
|
|||||||
openfl(params) {
|
openfl(params) {
|
||||||
params = Object.assign({
|
params = Object.assign({
|
||||||
version: null,
|
version: null,
|
||||||
|
lib: [],
|
||||||
|
cp: [],
|
||||||
|
main: null,
|
||||||
values: {},
|
values: {},
|
||||||
macro: [],
|
macro: [],
|
||||||
debug: false,
|
debug: false,
|
||||||
@@ -164,6 +168,22 @@ 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];
|
||||||
|
// lib
|
||||||
|
let lib = params.lib;
|
||||||
|
if (!Array.isArray(lib)) {
|
||||||
|
lib = Object.entries(lib).map(([k, v]) => `${k}:${v.split('@')[0]}`);
|
||||||
|
}
|
||||||
|
for (const item of lib) {
|
||||||
|
args.push(`--haxelib="${item}"`);
|
||||||
|
}
|
||||||
|
// cp
|
||||||
|
for (const item of params.cp) {
|
||||||
|
args.push(`--source="${item}"`);
|
||||||
|
}
|
||||||
|
if (params.main) {
|
||||||
|
args.push(`--app-main="${params.main}"`);
|
||||||
|
}
|
||||||
|
// macro
|
||||||
for (const macro of params.macro) {
|
for (const macro of params.macro) {
|
||||||
args.push(`--haxeflag="--macro ${macro}"`);
|
args.push(`--haxeflag="--macro ${macro}"`);
|
||||||
}
|
}
|
||||||
@@ -176,9 +196,9 @@ class Haxe extends Sdk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const buildDir = path.join(os.tmpdir(), 'build');
|
const buildDir = path.join(os.tmpdir(), 'build');
|
||||||
args.push(`--app-path=${buildDir}`);
|
args.push(`--app-path="${buildDir}"`);
|
||||||
if (params.outputFile) {
|
if (params.outputFile) {
|
||||||
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.debug) {
|
if (params.debug) {
|
||||||
@@ -224,6 +244,7 @@ class Haxe extends Sdk {
|
|||||||
params = Object.assign({
|
params = Object.assign({
|
||||||
version: null,
|
version: null,
|
||||||
values: {},
|
values: {},
|
||||||
|
lib: [],
|
||||||
macro: [],
|
macro: [],
|
||||||
debug: false,
|
debug: false,
|
||||||
}, params);
|
}, params);
|
||||||
@@ -240,13 +261,21 @@ class Haxe extends Sdk {
|
|||||||
const endStream = (callback) => {
|
const endStream = (callback) => {
|
||||||
log(this.tag, colors.cyan("haxe", params.platform), '=>', colors.magenta(params.outputFile));
|
log(this.tag, colors.cyan("haxe", params.platform), '=>', colors.magenta(params.outputFile));
|
||||||
const args = [];
|
const args = [];
|
||||||
|
// main
|
||||||
args.push('-main', params.main);
|
args.push('-main', params.main);
|
||||||
for (const lib of params.lib) {
|
// lib
|
||||||
args.push('-lib', lib);
|
let lib = params.lib;
|
||||||
|
if (!Array.isArray(lib)) {
|
||||||
|
lib = Object.entries(lib).map(([k, v]) => `${k}:${v.split('@')[0]}`);
|
||||||
}
|
}
|
||||||
|
for (const item of lib) {
|
||||||
|
args.push('-lib', item);
|
||||||
|
}
|
||||||
|
// cp
|
||||||
for (const cp of params.cp) {
|
for (const cp of params.cp) {
|
||||||
args.push('-cp', cp);
|
args.push('-cp', cp);
|
||||||
}
|
}
|
||||||
|
// macro
|
||||||
for (const macro of params.macro) {
|
for (const macro of params.macro) {
|
||||||
args.push('--macro', `"${macro}"`);
|
args.push('--macro', `"${macro}"`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-haxetool",
|
"name": "gulp-haxetool",
|
||||||
"version": "0.0.2",
|
"version": "0.0.3",
|
||||||
"description": "Haxe tool for gulp",
|
"description": "Haxe tool for gulp",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user