Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 715f6807d8 | |||
| e0eddbcab5 | |||
| 1bd18caa9a | |||
| 90f1a9b77f | |||
| 141470c519 | |||
| b68ae2f3dc | |||
| 4f3ffe1181 | |||
| 85f2cb8ff7 | |||
| d3e5ffab84 | |||
| cc2c4f19f8 | |||
| 7fa0174a7b | |||
| 414099bd67 | |||
| 524695b155 | |||
| b71919ee4a | |||
| 35a9074d6c | |||
| bd4fc36ff1 | |||
| 2b703fb66a | |||
| 06af034955 | |||
| c248744c70 | |||
| 8205a4cb0c | |||
| e904b46f4a |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
node_modules/
|
||||
target/
|
||||
package-lock.json
|
||||
*.iml
|
||||
35
CHANGELOG.md
35
CHANGELOG.md
@@ -1,24 +1,51 @@
|
||||
0.1.6
|
||||
-----
|
||||
* Android: fix build result apk path
|
||||
|
||||
0.1.5
|
||||
-----
|
||||
* Haxe: default version 4.0.5
|
||||
|
||||
0.1.4
|
||||
-----
|
||||
* Config: android extensions params
|
||||
|
||||
0.1.3
|
||||
-----
|
||||
* Android: installed packages list
|
||||
* Haxe: buildDir static property
|
||||
|
||||
0.1.2
|
||||
-----
|
||||
* Haxe: move build dir from tmp to project dir
|
||||
|
||||
0.1.1
|
||||
-----
|
||||
* Android sign apk (config.key.store and config.key.pass params)
|
||||
|
||||
0.1.0
|
||||
------
|
||||
* Android build
|
||||
* Windows build
|
||||
* Windows innosetup packer
|
||||
|
||||
0.0.18
|
||||
------
|
||||
* Add meta.fps project param
|
||||
|
||||
0.0.12
|
||||
------
|
||||
|
||||
-----
|
||||
* Openfl android platform support
|
||||
* Android sdk module
|
||||
|
||||
0.0.11
|
||||
------
|
||||
|
||||
* Added Neko module
|
||||
* FlashPlayer output with stream
|
||||
* Verbose output mode (--verbose)
|
||||
|
||||
0.0.10
|
||||
------
|
||||
|
||||
* Windows compatibility
|
||||
* Change FlashPlayer download link
|
||||
* Use 'fs-extra' without 'mkdirp' and 'rmdir'
|
||||
|
||||
59
README.md
Normal file → Executable file
59
README.md
Normal file → Executable file
@@ -8,6 +8,7 @@
|
||||
* Universal project config for simple HaXe build and OpenFL build.
|
||||
* Branch project config for many build presets (many OpenFL apps in one project).
|
||||
* Packaging linux output in DEB.
|
||||
* Packaging windows output in exe install with InnoSetup.
|
||||
* Create html wrapper for flash output.
|
||||
|
||||
### Flaws
|
||||
@@ -15,9 +16,7 @@
|
||||
* Hardcode build output in {projectDir}/target (need param in Project.Config).
|
||||
* HTML5 run output not caught.
|
||||
* Adobe AIR Build System in progress.
|
||||
* Packaging Windows application in progress (with [Inno Setup](http://www.jrsoftware.org/isinfo.php))
|
||||
* OpenFL android build failed due to problems with Android NDK
|
||||
|
||||
* Windows target depends Visual Studio 2017 build tools
|
||||
|
||||
## API
|
||||
|
||||
@@ -60,10 +59,15 @@ create gulp tasks in module:
|
||||
<config.name>:<platform>:test
|
||||
|
||||
<config.name>:flash:html
|
||||
|
||||
<config.name>:linux:archive
|
||||
<config.name>:linux:deb
|
||||
|
||||
<config.name>:windows:archive
|
||||
<config.name>:windows:installer
|
||||
```
|
||||
|
||||
eg: ```gulp app:flash:build```
|
||||
eg: ```gulp app:flash:test```
|
||||
|
||||
## Example
|
||||
|
||||
@@ -75,12 +79,12 @@ eg: ```gulp app:flash:build```
|
||||
"devDependencies": {
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-clean": "^0.4.0",
|
||||
"gulp-haxetool": "^0.0.12"
|
||||
"gulp-haxetool": "^0.1.0"
|
||||
},
|
||||
"haxeDependencies": {
|
||||
"lime": "6.0.1",
|
||||
"openfl": "7.0.0",
|
||||
"hxcpp": "3.4.188"
|
||||
"lime": "7.6.0",
|
||||
"openfl": "8.9.2",
|
||||
"hxcpp": "4.0.19"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -108,7 +112,7 @@ class Main {
|
||||
const gulp = require('gulp');
|
||||
const gulpClean = require('gulp-clean');
|
||||
const packageInfo = require('./package.json');
|
||||
const {Sdk, Haxe, Project} = require('gulp-haxetool');
|
||||
const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
|
||||
|
||||
//Sdk.dir = '/opt/sdk';
|
||||
|
||||
@@ -144,19 +148,38 @@ const project = new Project(
|
||||
Project.Platform.FLASH,
|
||||
Project.Platform.HTML5,
|
||||
Project.Platform.LINUX,
|
||||
Project.Platform.WINDOWS,
|
||||
],
|
||||
config
|
||||
).bind(module);
|
||||
|
||||
module.exports.default = gulp.series(
|
||||
|
||||
const defaultSeries = [
|
||||
exports.clean,
|
||||
exports.install,
|
||||
module.exports['app:flash:build'],
|
||||
module.exports['app:html5:build'],
|
||||
module.exports['app:linux:build'],
|
||||
module.exports['app:flash:html'],
|
||||
module.exports['app:linux:deb'],
|
||||
);
|
||||
module.exports['app:html5:build'],
|
||||
];
|
||||
|
||||
if (System.isLinux) {
|
||||
defaultSeries.push(
|
||||
module.exports['app:linux:build'],
|
||||
module.exports['app:linux:archive'],
|
||||
module.exports['app:linux:deb'],
|
||||
|
||||
module.exports['app:android:build'],
|
||||
);
|
||||
}
|
||||
|
||||
if (System.isWindows) {
|
||||
defaultSeries.push(
|
||||
module.exports['app:windows:build'],
|
||||
module.exports['app:windows:archive'],
|
||||
module.exports['app:windows:installer'],
|
||||
);
|
||||
}
|
||||
|
||||
module.exports.default = gulp.series(defaultSeries);
|
||||
```
|
||||
|
||||
Build for all platforms: `gulp default`
|
||||
@@ -165,6 +188,10 @@ Build app for specific platform: `gulp app:flash:build`
|
||||
|
||||
Build and run flash app in flashplayer: `gulp app:flash:test`
|
||||
|
||||
Build and run html5 app in brpwser: `gulp app:html5:test`
|
||||
Build and run html5 app in browser: `gulp app:html5:test`
|
||||
|
||||
Build and run linux app native: `gulp app:linux:test`
|
||||
|
||||
Build and run windows app native: `gulp app:windows:test`
|
||||
|
||||
Build and run android app: `gulp app:android:test`
|
||||
|
||||
35
example/gulpfile.js
Normal file → Executable file
35
example/gulpfile.js
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
const gulp = require('gulp');
|
||||
const gulpClean = require('gulp-clean');
|
||||
const packageInfo = require('./package.json');
|
||||
const {Sdk, Haxe, Project} = require('gulp-haxetool');
|
||||
const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
|
||||
|
||||
//Sdk.dir = '/opt/sdk';
|
||||
|
||||
@@ -37,16 +37,35 @@ const project = new Project(
|
||||
Project.Platform.FLASH,
|
||||
Project.Platform.HTML5,
|
||||
Project.Platform.LINUX,
|
||||
Project.Platform.WINDOWS,
|
||||
],
|
||||
config
|
||||
).bind(module, gulp);
|
||||
).bind(module);
|
||||
|
||||
module.exports.default = gulp.series(
|
||||
|
||||
const defaultSeries = [
|
||||
exports.clean,
|
||||
exports.install,
|
||||
module.exports['app:flash:build'],
|
||||
module.exports['app:html5:build'],
|
||||
module.exports['app:linux:build'],
|
||||
module.exports['app:flash:html'],
|
||||
module.exports['app:linux:deb'],
|
||||
);
|
||||
module.exports['app:html5:build'],
|
||||
];
|
||||
|
||||
if (System.isLinux) {
|
||||
defaultSeries.push(
|
||||
module.exports['app:linux:build'],
|
||||
module.exports['app:linux:archive'],
|
||||
module.exports['app:linux:deb'],
|
||||
|
||||
module.exports['app:android:build'],
|
||||
);
|
||||
}
|
||||
|
||||
if (System.isWindows) {
|
||||
defaultSeries.push(
|
||||
module.exports['app:windows:build'],
|
||||
module.exports['app:windows:archive'],
|
||||
module.exports['app:windows:installer'],
|
||||
);
|
||||
}
|
||||
|
||||
module.exports.default = gulp.series(defaultSeries);
|
||||
|
||||
8
example/package.json
Normal file → Executable file
8
example/package.json
Normal file → Executable file
@@ -4,11 +4,11 @@
|
||||
"devDependencies": {
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-clean": "^0.4.0",
|
||||
"gulp-haxetool": "^0.0.12"
|
||||
"gulp-haxetool": "^0.1.0"
|
||||
},
|
||||
"haxeDependencies": {
|
||||
"lime": "6.0.1",
|
||||
"openfl": "7.0.0",
|
||||
"hxcpp": "3.4.188"
|
||||
"lime": "7.6.0",
|
||||
"openfl": "8.9.2",
|
||||
"hxcpp": "4.0.19"
|
||||
}
|
||||
}
|
||||
|
||||
175
haxetool/android.js
Normal file → Executable file
175
haxetool/android.js
Normal file → Executable file
@@ -1,6 +1,10 @@
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const exec = require('./exec');
|
||||
const {StringWritable} = require('./tail');
|
||||
const System = require('./system');
|
||||
const Command = require('../run/command');
|
||||
const through = require('through2');
|
||||
const Sdk = require('./sdk');
|
||||
const Env = require('./env');
|
||||
@@ -8,26 +12,22 @@ const Env = require('./env');
|
||||
|
||||
class Android extends Sdk {
|
||||
|
||||
constructor(version) {
|
||||
constructor(version, ndkVersion) {
|
||||
super(Android.ID, version || Android.VERSION);
|
||||
this.ndk_version = ndkVersion || Android.NDK_VERSION;
|
||||
this.repository = 'https://dl.google.com/android/repository';
|
||||
}
|
||||
|
||||
get prepared() {
|
||||
try {
|
||||
return fs.existsSync(`${this.path}/platform-tools/adb`);
|
||||
return fs.existsSync(this.sdkmanager_bin);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
get link() {
|
||||
const system = Sdk.System.isWindows ? 'windows' : Sdk.System.isLinux ? 'linux' : null;
|
||||
if (!system) throw 'Unsupported system';
|
||||
if (this.version.indexOf('.') > -1) {
|
||||
return `https://dl.google.com/android/repository/tools_r${this.version}-${system}.zip`;
|
||||
} else {
|
||||
return `https://dl.google.com/android/repository/sdk-tools-${system}-${this.version}.zip`;
|
||||
}
|
||||
return `${this.repository}/commandlinetools-${System.os}-${this.version}_latest.zip`;
|
||||
}
|
||||
|
||||
get android_home() {
|
||||
@@ -38,17 +38,58 @@ class Android extends Sdk {
|
||||
return path.join(this.path, 'ndk-bundle')
|
||||
}
|
||||
|
||||
get sdkmanager_bin() {
|
||||
return path.join(this.path, 'cmdline-tools/bin/sdkmanager');
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return super.prepare(0);
|
||||
const result = [];
|
||||
result.push(super.prepare(0));
|
||||
if (!fs.existsSync(path.join(this.ndk_home))) {
|
||||
result.push(this.prepare_ndk());
|
||||
}
|
||||
return Promise.all(result);
|
||||
}
|
||||
|
||||
prepare_ndk() {
|
||||
// ToDo: support windows
|
||||
const url = `${this.repository}/android-ndk-${this.ndk_version}-${System.os}-x86_64.zip`;
|
||||
this.log.d('download: *%s*', url);
|
||||
return Sdk.Downloader.download(url, this.ndk_home, 1, true);
|
||||
}
|
||||
|
||||
sdkmanager(packages) {
|
||||
const androidBin = path.join(this.path, 'tools/bin/sdkmanager');
|
||||
if (fs.existsSync(androidBin)) {
|
||||
fs.chmodSync(androidBin, 0o755);
|
||||
this.log.i('sdkmanager: *%s*', packages.join(', '));
|
||||
const installedFile = path.join(this.path, '.installed');
|
||||
const installed = new Set(
|
||||
fs.existsSync(installedFile) ?
|
||||
fs.readFileSync(installedFile, {encoding: 'utf8'}).split('\n') :
|
||||
[]
|
||||
);
|
||||
const install = new Set(packages);
|
||||
for (const key of installed) {
|
||||
if (install.has(key)) {
|
||||
install.delete(key);
|
||||
}
|
||||
}
|
||||
if (install.size === 0) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
const sdkmanagerBin = this.sdkmanager_bin;
|
||||
if (fs.existsSync(sdkmanagerBin)) {
|
||||
fs.chmodSync(sdkmanagerBin, 0o755);
|
||||
}
|
||||
const yes = '(while sleep 3; do echo "y"; done)';
|
||||
return exec('.', [yes, '|', androidBin].concat(packages.map(name => `"${name}"`)).join(' '));
|
||||
const command = [yes, '|', sdkmanagerBin]
|
||||
.concat(Array.from(install).map(name => `"${name}"`))
|
||||
.concat([`--sdk_root="${this.path}"`])
|
||||
.join(' ');
|
||||
return exec('.', command).then(() => {
|
||||
for (const key of install) {
|
||||
installed.add(key);
|
||||
}
|
||||
fs.writeFileSync(installedFile, Array.from(installed).join('\n'), {encoding: 'utf8'});
|
||||
});
|
||||
}
|
||||
|
||||
activate() {
|
||||
@@ -57,23 +98,31 @@ class Android extends Sdk {
|
||||
Env.set('NDK_HOME', this.ndk_home);
|
||||
}
|
||||
|
||||
get adbBin() {
|
||||
return path.join(this.path, 'platform-tools/adb');
|
||||
}
|
||||
|
||||
adb(args) {
|
||||
const adbBin = path.join(this.path, 'platform-tools/adb');
|
||||
return exec('.', [adbBin].concat(args).join(' ')).then(data => {
|
||||
return exec('.', [this.adbBin].concat(args).join(' ')).then(data => {
|
||||
for (let line of data.stderr.split('\n')) {
|
||||
if (line.indexOf('Error') > -1) {
|
||||
throw line;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
aapt(args) {
|
||||
buildTool(name) {
|
||||
let buildToolsVersion = null;
|
||||
fs.readdirSync(path.join(this.path, 'build-tools')).forEach(file => {
|
||||
buildToolsVersion = file;
|
||||
});
|
||||
const aaptBin = path.join(this.path, 'build-tools', buildToolsVersion, 'aapt');
|
||||
return path.join(this.path, 'build-tools', buildToolsVersion, name);
|
||||
}
|
||||
|
||||
aapt(args) {
|
||||
const aaptBin = this.buildTool('aapt');
|
||||
return exec('.', [aaptBin].concat(args).join(' '));
|
||||
}
|
||||
|
||||
@@ -104,30 +153,104 @@ class Android extends Sdk {
|
||||
});
|
||||
}
|
||||
|
||||
_installApk(filename, pack) {
|
||||
this.log.i('install *%s*', filename);
|
||||
return this.adb(['install', '-r', '-d', filename])
|
||||
.then(() => {
|
||||
return false;
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.includes('INSTALL_FAILED_UPDATE_INCOMPATIBLE')) {
|
||||
this.log.w('!INSTALL FAILED UPDATE INCOMPATIBLE!');
|
||||
return true;
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
})
|
||||
.then(reinstall => {
|
||||
if (reinstall) {
|
||||
this.log.i('uninstall *%s*', pack);
|
||||
return this.adb(['uninstall', pack]).then(() => {
|
||||
this.log.i('install *%s*', filename);
|
||||
return this.adb(['install', '-r', '-d', filename]);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
install() {
|
||||
const self = this;
|
||||
return through.obj(function(file, enc, callback) {
|
||||
self.adb(['install', '-r', file.path]).then(() => {
|
||||
this.push(file);
|
||||
callback();
|
||||
self._installApk(file.path, file.package).then(() => {
|
||||
// ToDo: kludge: delay before start
|
||||
setTimeout(() => {
|
||||
this.push(file);
|
||||
callback();
|
||||
}, 500);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
start() {
|
||||
const self = this;
|
||||
return through.obj((file, enc, callback) => {
|
||||
return through.obj(function(file, enc, callback) {
|
||||
const name = `${file.package}/${file.activity}`;
|
||||
self.adb(['shell', 'am', 'start', '-n', name]).then(() => callback());
|
||||
self.log.i('start *%s*', name);
|
||||
self.adb(['shell', 'am', 'start', '-n', name]).then(() => {
|
||||
setTimeout(() => {
|
||||
self.adb(['shell', `"ps | grep ${file.package}"`]).then(result => {
|
||||
file.pid = result.stdout.split(/\s+/)[1];
|
||||
this.push(file);
|
||||
callback();
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
logcat() {
|
||||
const self = this;
|
||||
return through.obj(function(file, enc, callback) {
|
||||
const cmd = `${self.adbBin} logcat --pid ${file.pid}`;
|
||||
const command = new Command(cmd).exec();
|
||||
this.push(command);
|
||||
command.contents.pipe(new StringWritable(line => {
|
||||
if (line.includes('SDL') && (line.includes('onDestroy()') || line.includes('onStop()'))) {
|
||||
callback();
|
||||
throw 'Exit'; // ToDo:
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
sign(keystore, keypass) {
|
||||
const self = this;
|
||||
return through.obj(function(file, enc, callback) {
|
||||
self.log.i('sign *%s*', file.path);
|
||||
const filename = path.join(os.tmpdir(), 'tmp.apk');
|
||||
fs.writeFileSync(filename, file.contents);
|
||||
const cmd = [
|
||||
self.buildTool('apksigner'),
|
||||
'sign',
|
||||
'--ks', keystore,
|
||||
'--ks-pass', `pass:${keypass}`,
|
||||
filename
|
||||
].join(' ');
|
||||
exec('.', cmd).then(() => {
|
||||
file.contents = fs.readFileSync(filename);
|
||||
this.push(file);
|
||||
callback();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Android.ID = 'android';
|
||||
|
||||
Android.VERSION_25_2_3 = '25.2.3';
|
||||
Android.VERSION_3859397 = '3859397';
|
||||
Android.VERSION_7302050 = '7302050';
|
||||
Android.VERSION = Android.VERSION_7302050;
|
||||
|
||||
Android.VERSION = Android.VERSION_3859397;
|
||||
Android.NDK_VERSION_R15C = 'r15c';
|
||||
Android.NDK_VERSION = Android.NDK_VERSION_R15C;
|
||||
|
||||
module.exports = Android;
|
||||
|
||||
@@ -16,6 +16,7 @@ const Platform = {
|
||||
WINDOWS: 'windows',
|
||||
ANDROID: 'android',
|
||||
NEKO: 'neko',
|
||||
CPP: 'cpp',
|
||||
};
|
||||
|
||||
|
||||
@@ -42,10 +43,15 @@ class Config {
|
||||
company: null,
|
||||
width: 800,
|
||||
height: 600,
|
||||
mobileWidth: null,
|
||||
mobileHeight: null,
|
||||
fps: 60,
|
||||
};
|
||||
this.key = null;
|
||||
this.android = [];
|
||||
if (params) {
|
||||
this.update(params);
|
||||
this.afterUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,15 +71,23 @@ class Config {
|
||||
if (params.macros !== undefined) this.macros = this.macros.concat(params.macros);
|
||||
if (params.flags !== undefined) this.flags = this.flags.concat(params.flags);
|
||||
if (params.meta !== undefined) this.meta = {...this.meta, ...params.meta};
|
||||
if (params.key !== undefined) this.key = params.key;
|
||||
if (params.android !== undefined) this.android = this.android.concat(params.android.map(item => ({path: Config.absolutePath(item.path), extensions: item.extensions})));
|
||||
if (this.meta.icon) this.icon = Config.absolutePath(this.meta.icon);
|
||||
}
|
||||
|
||||
afterUpdate() {
|
||||
if (this.meta.mobileWidth === null) this.meta.mobileWidth = this.meta.width;
|
||||
if (this.meta.mobileHeight === null) this.meta.mobileHeight = Math.round(this.meta.mobileWidth / 1.777777778);
|
||||
}
|
||||
|
||||
branch(params) {
|
||||
const result = new Config();
|
||||
for (const params of this._params) {
|
||||
result.update(params);
|
||||
}
|
||||
result.update(params);
|
||||
result.afterUpdate();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
4
haxetool/env.js
Normal file → Executable file
4
haxetool/env.js
Normal file → Executable file
@@ -7,6 +7,10 @@ class Env {
|
||||
process.env[key] = value;
|
||||
}
|
||||
|
||||
static get(key) {
|
||||
return process.env[key];
|
||||
}
|
||||
|
||||
static addPath(value, key='PATH') {
|
||||
if (!process.env[key]) {
|
||||
process.env[key] = value;
|
||||
|
||||
@@ -4,6 +4,7 @@ const fse = require('fs-extra');
|
||||
const os = require('os');
|
||||
const through = require('through2');
|
||||
const Sdk = require('./sdk');
|
||||
const System = require('./system');
|
||||
const run = require('../run/index');
|
||||
const {TailVinyl} = require('./tail');
|
||||
|
||||
@@ -29,9 +30,9 @@ class FlashPlayer extends Sdk {
|
||||
|
||||
get link() {
|
||||
const baseUrl = `https://fpdownload.macromedia.com/pub/flashplayer/updaters/${this.version}/`;
|
||||
if (Sdk.System.isWindows) {
|
||||
if (System.isWindows) {
|
||||
return baseUrl + `flashplayer_${this.version}_sa${this.debug ? '_debug' : ''}.exe`;
|
||||
} else if (Sdk.System.isLinux) {
|
||||
} else if (System.isLinux) {
|
||||
return baseUrl + `flash_player_sa_linux${this.debug ? '_debug' : ''}.x86_64.tar.gz`;
|
||||
} else {
|
||||
throw `Unsupported os '${os.type()}'`;
|
||||
@@ -116,9 +117,12 @@ FlashPlayer.VERSION_24 = '24';
|
||||
FlashPlayer.VERSION_25 = '25';
|
||||
FlashPlayer.VERSION_26 = '26';
|
||||
FlashPlayer.VERSION_27 = '27';
|
||||
FlashPlayer.VERSION_28 = '28';
|
||||
FlashPlayer.VERSION_29 = '29';
|
||||
FlashPlayer.VERSION_30 = '30';
|
||||
FlashPlayer.VERSION_31 = '31';
|
||||
FlashPlayer.VERSION_32 = '32';
|
||||
|
||||
FlashPlayer.VERSION = FlashPlayer.VERSION_30;
|
||||
FlashPlayer.VERSION = FlashPlayer.VERSION_32;
|
||||
|
||||
module.exports = FlashPlayer;
|
||||
@@ -4,18 +4,19 @@ const fse = require('fs-extra');
|
||||
const path = require('path');
|
||||
const exec = require('./exec');
|
||||
const Sdk = require('./sdk');
|
||||
const System = require('./system');
|
||||
const Env = require('./env');
|
||||
const Neko = require('./neko');
|
||||
const vfs = require('vinyl-fs');
|
||||
const template = require('lodash.template');
|
||||
|
||||
const rename = require('gulp-rename');
|
||||
|
||||
class Haxe extends Sdk {
|
||||
|
||||
getBin(name) {
|
||||
if (Sdk.System.isWindows) {
|
||||
if (System.isWindows) {
|
||||
return path.join(this.path, name + '.exe');
|
||||
} else if (Sdk.System.isLinux) {
|
||||
} else if (System.isLinux) {
|
||||
const binPath = path.join(this.path, name);
|
||||
if (fs.existsSync(binPath)) {
|
||||
fs.chmodSync(binPath, 0o755);
|
||||
@@ -57,31 +58,37 @@ class Haxe extends Sdk {
|
||||
|
||||
prepare() {
|
||||
return Promise.all([this.neko.prepare(), super.prepare()]).then(() => {
|
||||
fs.copyFileSync(path.resolve(__dirname, '..', 'template/activate'), path.resolve(this.path, 'activate'));
|
||||
fs.copyFileSync(path.resolve(__dirname, '..', 'template/haxe/activate'), path.resolve(this.path, 'activate'));
|
||||
});
|
||||
}
|
||||
|
||||
get link() {
|
||||
if (Sdk.System.isWindows) {
|
||||
if (System.isWindows) {
|
||||
return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-win.zip`;
|
||||
} else if (Sdk.System.isLinux) {
|
||||
let arch = Sdk.System.archInt;
|
||||
} else if (System.isLinux) {
|
||||
let arch = System.archInt;
|
||||
return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-linux${arch}.tar.gz`;
|
||||
}
|
||||
}
|
||||
|
||||
haxe(args) {
|
||||
this.activate();
|
||||
return exec('.', [this.haxeBin].concat(args).join(' '));
|
||||
}
|
||||
|
||||
haxelib(args) {
|
||||
this.activate();
|
||||
return exec('.', [this.haxelibBin].concat(args).join(' '));
|
||||
}
|
||||
|
||||
resolveBuildDir(config) {
|
||||
return path.join(Haxe.buildDir, config.name);
|
||||
}
|
||||
|
||||
openfl(command, platform, config, debug=false) {
|
||||
this.log.i('_openfl_ _build_ *%s*', platform);
|
||||
this.activate();
|
||||
const buildDir = path.join(os.tmpdir(), 'build', config.name);
|
||||
const buildDir = this.resolveBuildDir(config);
|
||||
fse.ensureDirSync(buildDir);
|
||||
|
||||
const projectTemplate = template(fs.readFileSync(path.resolve(__dirname, '..', 'template/project.xml')));
|
||||
@@ -98,16 +105,22 @@ class Haxe extends Sdk {
|
||||
const target = path.resolve(buildDir, platform, 'bin');
|
||||
fse.emptyDirSync(target);
|
||||
const result = {
|
||||
'android': 'app/build/outputs/apk/*.apk',
|
||||
'android': `app/build/outputs/**/${config.meta.filename}-debug.apk`,
|
||||
'flash': '*.swf',
|
||||
}[platform] || '**/*';
|
||||
return this.haxelib(args).then(() => vfs.src(`${target}/${result}`));
|
||||
return this.haxelib(args).then(() => {
|
||||
let r = vfs.src(`${target}/${result}`);
|
||||
if (platform === 'android') {
|
||||
r = r.pipe(rename(`${config.meta.filename}_${config.meta.version}.apk`));
|
||||
}
|
||||
return r;
|
||||
});
|
||||
}
|
||||
|
||||
build(platform, config, debug=false) {
|
||||
this.log.i('_build_ *%s*', platform);
|
||||
this.activate();
|
||||
const buildDir = path.join(os.tmpdir(), 'build', config.name);
|
||||
const buildDir = this.resolveBuildDir(config);
|
||||
fse.ensureDirSync(buildDir);
|
||||
|
||||
const projectTemplate = template(fs.readFileSync(path.resolve(__dirname, '..', 'template/project.hxml')));
|
||||
@@ -130,11 +143,22 @@ class Haxe extends Sdk {
|
||||
args.push('-debug');
|
||||
}
|
||||
const target = path.resolve(buildDir, platform, 'bin');
|
||||
fse.emptyDirSync(target);
|
||||
for (const asset of config.assets) {
|
||||
fse.copySync(asset, path.join(target, asset.split(path.sep).pop()));
|
||||
if (platform !== 'cpp') {
|
||||
fse.emptyDirSync(target);
|
||||
}
|
||||
return this.haxe(args).then(() => vfs.src(`${target}/**/*`));
|
||||
for (const asset of config.assets) {
|
||||
fse.copySync(asset, path.join(target, asset.split("/").pop()));
|
||||
}
|
||||
const result = {
|
||||
'cpp': `${config.meta.filename}/${config.main.split('.').pop()}${debug ? '-debug' : ''}`,
|
||||
}[platform] || '**/*';
|
||||
return this.haxe(args).then(() => {
|
||||
let r = vfs.src(`${target}/${result}`);
|
||||
if (platform === 'cpp') {
|
||||
r = r.pipe(rename(config.meta.filename));
|
||||
}
|
||||
return r;
|
||||
});
|
||||
}
|
||||
|
||||
install(packages) {
|
||||
@@ -189,6 +213,8 @@ class Haxe extends Sdk {
|
||||
}
|
||||
}
|
||||
|
||||
Haxe.buildDir = path.join(process.cwd(), 'build');
|
||||
|
||||
Haxe.ID = 'haxe';
|
||||
|
||||
Haxe.VERSION_3_4_0 = '3.4.0';
|
||||
@@ -196,6 +222,12 @@ Haxe.VERSION_3_4_2 = '3.4.2';
|
||||
Haxe.VERSION_3_4_3 = '3.4.3';
|
||||
Haxe.VERSION_3_4_7 = '3.4.7';
|
||||
Haxe.VERSION_3 = Haxe.VERSION_3_4_7;
|
||||
Haxe.VERSION = Haxe.VERSION_3;
|
||||
Haxe.VERSION_4_0_0 = '4.0.0';
|
||||
Haxe.VERSION_4_0_1 = '4.0.1';
|
||||
Haxe.VERSION_4_0_2 = '4.0.2';
|
||||
Haxe.VERSION_4_0_3 = '4.0.3';
|
||||
Haxe.VERSION_4_0_5 = '4.0.5';
|
||||
Haxe.VERSION_4 = Haxe.VERSION_4_0_5;
|
||||
Haxe.VERSION = Haxe.VERSION_4;
|
||||
|
||||
module.exports = Haxe;
|
||||
|
||||
57
haxetool/innosetup.js
Executable file
57
haxetool/innosetup.js
Executable file
@@ -0,0 +1,57 @@
|
||||
const fs = require('fs');
|
||||
const fse = require('fs-extra');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const Sdk = require('./sdk');
|
||||
const exec = require('./exec');
|
||||
const template = require('lodash.template');
|
||||
|
||||
class InnoSetup extends Sdk {
|
||||
|
||||
constructor(version) {
|
||||
super(InnoSetup.ID, version || InnoSetup.VERSION);
|
||||
}
|
||||
|
||||
get link() {
|
||||
return 'http://www.jrsoftware.org/download.php/is.exe';
|
||||
}
|
||||
|
||||
prepare(strip = 1) {
|
||||
let result = super.prepare(strip);
|
||||
if (!this.prepared) {
|
||||
result = result.then(() => {
|
||||
return exec(this.path, `is.exe /VERYSILENT /SUPPRESSMSGBOXES /DIR=${this.path}`);
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
get isccBin() {
|
||||
return path.join(this.path, 'ISCC.exe')
|
||||
}
|
||||
|
||||
get prepared() {
|
||||
try {
|
||||
return fs.existsSync(this.isccBin);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
pack(config, source, output) {
|
||||
const buildDir = path.join(os.tmpdir(), 'build', config.name, 'innosetup');
|
||||
const appTemplate = template(fs.readFileSync(path.resolve(__dirname, '..', 'template/windows/app.iss')));
|
||||
const app = appTemplate({...config, buildDir: buildDir, output: output});
|
||||
|
||||
fse.ensureDirSync(buildDir);
|
||||
fse.copySync(`${source}`, `${buildDir}`);
|
||||
|
||||
fs.writeFileSync(path.resolve(buildDir, 'app.iss'), app);
|
||||
return exec(buildDir, [`"${this.isccBin}"`, 'app.iss'].join(' '));
|
||||
}
|
||||
}
|
||||
|
||||
InnoSetup.ID = 'innosetup';
|
||||
InnoSetup.VERSION = '6';
|
||||
|
||||
module.exports = InnoSetup;
|
||||
@@ -61,6 +61,12 @@ class Neko extends Sdk {
|
||||
Env.addPath(this.path, 'LD_LIBRARY_PATH');
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return Promise.all([super.prepare()]).then(() => {
|
||||
fs.copyFileSync(path.resolve(__dirname, '..', 'template/neko/activate'), path.resolve(this.path, 'activate'));
|
||||
});
|
||||
}
|
||||
|
||||
get nekoBin() {
|
||||
let binname = 'neko';
|
||||
if (os.type() === 'Windows_NT') binname += '.exe';
|
||||
|
||||
139
haxetool/project.js
Normal file → Executable file
139
haxetool/project.js
Normal file → Executable file
@@ -7,6 +7,7 @@ const Haxe = require('./haxe');
|
||||
const FlashPlayer = require('./flashplayer');
|
||||
const Android = require('./android');
|
||||
const Neko = require('./neko');
|
||||
const InnoSetup = require('./innosetup');
|
||||
const Env = require('./env');
|
||||
const debug = require('./debug');
|
||||
const webserver = require('gulp-webserver');
|
||||
@@ -18,7 +19,9 @@ const {BuildSystem, Platform, Config} = require('./core');
|
||||
const vfs = require('vinyl-fs');
|
||||
const rename = require('gulp-rename');
|
||||
const template = require('lodash.template');
|
||||
|
||||
const tar = require('gulp-tar');
|
||||
const gzip = require('gulp-gzip');
|
||||
const zip = require('gulp-zip');
|
||||
|
||||
const streamToPromise = (stream) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -47,8 +50,12 @@ class Target {
|
||||
throw 'Not Implemented';
|
||||
}
|
||||
|
||||
resolveTargetPath(platform = this.platform) {
|
||||
return path.resolve(this.target, this.config.name, platform)
|
||||
}
|
||||
|
||||
get targetPath() {
|
||||
return path.resolve(this.target, this.config.name, this.platform);
|
||||
return this.resolveTargetPath();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,12 +100,13 @@ class HaxeBuilder extends Builder {
|
||||
.then(() => this.android.prepare())
|
||||
.then(() => this.android.activate())
|
||||
.then(() => this.android.sdkmanager([
|
||||
// ToDo: android sdk dependencies config?
|
||||
'tools',
|
||||
'platform-tools',
|
||||
'build-tools;27.0.3',
|
||||
'platforms;android-19',
|
||||
'ndk-bundle',
|
||||
'lldb;3.1',
|
||||
'platforms;android-28', //ToDo: lime version 7.6.0 -> 28; 7.0.0 -> 26
|
||||
//'ndk-bundle',
|
||||
//'lldb;3.1',
|
||||
'cmake;3.6.4111459',
|
||||
]));
|
||||
const AndroidSDK = this.android.android_home;
|
||||
@@ -117,7 +125,12 @@ class HaxeBuilder extends Builder {
|
||||
switch (this.buildSystem) {
|
||||
case BuildSystem.OPENFL:
|
||||
return this.haxe.openfl('build', this.platform, this.config, this.debug)
|
||||
.then(result => streamToPromise(result.pipe(vfs.dest(target))));
|
||||
.then(result => {
|
||||
if (this.platform === Platform.ANDROID && this.config.key) {
|
||||
result = result.pipe(this.android.sign(this.config.key.store, this.config.key.pass));
|
||||
}
|
||||
return streamToPromise(result.pipe(vfs.dest(target)));
|
||||
});
|
||||
case BuildSystem.HAXE:
|
||||
return this.haxe.build(this.platform, this.config, this.debug)
|
||||
.then(result => streamToPromise(result.pipe(vfs.dest(target))));
|
||||
@@ -207,7 +220,7 @@ class LinuxDEBPacker extends Packer {
|
||||
'fi'
|
||||
],
|
||||
_target: '/',
|
||||
_out: path.join(target, '..', 'debian'),
|
||||
_out: this.resolveTargetPath('debian'),
|
||||
_clean: true,
|
||||
_verbose: false
|
||||
}));
|
||||
@@ -218,6 +231,74 @@ LinuxDEBPacker.NAME = 'deb';
|
||||
|
||||
Packer.register(Platform.LINUX, LinuxDEBPacker.NAME, LinuxDEBPacker);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class LinuxArchivePacker extends Packer {
|
||||
|
||||
constructor(config) {
|
||||
super(config, Platform.LINUX);
|
||||
}
|
||||
|
||||
call() {
|
||||
const target = this.targetPath;
|
||||
const archiveName = `${this.config.meta.filename}_${this.config.meta.version}_linux.tar`;
|
||||
return gulp.src(`${target}/**/*`)
|
||||
.pipe(tar(archiveName))
|
||||
.pipe(gzip())
|
||||
.pipe(gulp.dest(this.resolveTargetPath('archive')))
|
||||
}
|
||||
}
|
||||
|
||||
LinuxArchivePacker.NAME = 'archive';
|
||||
|
||||
Packer.register(Platform.LINUX, LinuxArchivePacker.NAME, LinuxArchivePacker);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class WindowsInstallerPacker extends Packer {
|
||||
|
||||
constructor(config) {
|
||||
super(config, Platform.WINDOWS);
|
||||
this.innosetup = new InnoSetup();
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return this.innosetup.prepare();
|
||||
}
|
||||
|
||||
call() {
|
||||
return this.innosetup.pack(this.config, this.targetPath, this.resolveTargetPath('installer'));
|
||||
}
|
||||
}
|
||||
|
||||
WindowsInstallerPacker.NAME = 'installer';
|
||||
|
||||
Packer.register(Platform.WINDOWS, WindowsInstallerPacker.NAME, WindowsInstallerPacker);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class WindowsArchivePacker extends Packer {
|
||||
|
||||
constructor(config) {
|
||||
super(config, Platform.WINDOWS);
|
||||
}
|
||||
|
||||
call() {
|
||||
const target = this.targetPath;
|
||||
const archiveName = `${this.config.meta.filename}_${this.config.meta.version}_win.zip`;
|
||||
return gulp.src(`${target}/**/*`)
|
||||
.pipe(zip(archiveName))
|
||||
.pipe(gulp.dest(this.resolveTargetPath('archive')))
|
||||
}
|
||||
}
|
||||
|
||||
WindowsArchivePacker.NAME = 'archive';
|
||||
|
||||
Packer.register(Platform.WINDOWS, WindowsArchivePacker.NAME, WindowsArchivePacker);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -282,7 +363,8 @@ class Html5Runner extends Runner {
|
||||
call() {
|
||||
return gulp.src(this.targetPath)
|
||||
.pipe(webserver({
|
||||
host: 'localhost', port: 3000,
|
||||
// ToDo: config?
|
||||
host: '0.0.0.0', port: 3000,
|
||||
open: true,
|
||||
fallback: 'index.html'
|
||||
}));
|
||||
@@ -309,7 +391,38 @@ class LinuxRunner extends Runner {
|
||||
}
|
||||
|
||||
Runner.register(Platform.LINUX, LinuxRunner);
|
||||
Runner.register(Platform.WINDOWS, LinuxRunner); //ToDo:
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class CPPRunner extends LinuxRunner {
|
||||
|
||||
constructor(config, debug) {
|
||||
super(config, debug);
|
||||
this.platform = Platform.CPP
|
||||
}
|
||||
}
|
||||
|
||||
Runner.register(Platform.CPP, CPPRunner);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class WindowsRunner extends Runner {
|
||||
|
||||
constructor(config, debug) {
|
||||
super(config, Platform.WINDOWS, debug);
|
||||
}
|
||||
|
||||
call() {
|
||||
const target = this.targetPath;
|
||||
const filename = path.resolve(target, this.config.meta.filename + '.exe');
|
||||
const result = gulp.src(filename).pipe(run("<%=file.basename%>", {cwd: target, verbosity: 0}));
|
||||
return this.log(result);
|
||||
}
|
||||
}
|
||||
|
||||
Runner.register(Platform.WINDOWS, WindowsRunner);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -351,12 +464,12 @@ class AndroidRunner extends Runner {
|
||||
|
||||
call() {
|
||||
const target = this.targetPath;
|
||||
const filename = path.resolve(target, this.config.meta.filename+'-debug.apk');
|
||||
console.log(filename);
|
||||
return gulp.src(filename)
|
||||
return this.log(gulp.src(`${target}/${this.config.meta.filename}_${this.config.meta.version}.apk`)
|
||||
.pipe(this.android.apk())
|
||||
.pipe(this.android.install())
|
||||
.pipe(this.android.start());
|
||||
.pipe(this.android.start())
|
||||
.pipe(this.android.logcat())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
108
haxetool/sdk.js
108
haxetool/sdk.js
@@ -5,32 +5,76 @@ const ps = require('promise-streams');
|
||||
const got = require('got');
|
||||
const unzip = require('unzip-stream');
|
||||
const tar = require('tar');
|
||||
const ProgressBar = require('progress');
|
||||
const progress = require('cli-progress');
|
||||
const fse = require('fs-extra');
|
||||
const Log = require('./log');
|
||||
|
||||
class Downloader {
|
||||
|
||||
class System {
|
||||
|
||||
static get isWindows() {
|
||||
return os.type() === 'Windows_NT';
|
||||
static createProgressBar() {
|
||||
if (Downloader.bar == null) {
|
||||
Downloader.bar = new progress.MultiBar({
|
||||
clearOnComplete: true,
|
||||
}, progress.Presets.shades_grey);
|
||||
}
|
||||
return Downloader.bar.create();
|
||||
}
|
||||
|
||||
static get isLinux() {
|
||||
return os.type() === 'Linux';
|
||||
static releaseProgressBar(bar) {
|
||||
bar.stop();
|
||||
if (Downloader.bar != null) {
|
||||
Downloader.bar.remove(bar);
|
||||
if (Downloader.bar.bars.length === 0) {
|
||||
Downloader.bar.stop();
|
||||
Downloader.bar = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static get archInt() {
|
||||
if (os.arch() === 'ia32') return 32;
|
||||
if (os.arch() === 'x64') return 64;
|
||||
}
|
||||
|
||||
static get isArch32() {
|
||||
return this.archInt === 32;
|
||||
}
|
||||
|
||||
static get isArch64() {
|
||||
return this.archInt === 64;
|
||||
static download(url, dest, strip = 1, executable = false) {
|
||||
fse.ensureDirSync(dest);
|
||||
const bar = Downloader.createProgressBar();
|
||||
let stream = got.stream(url);
|
||||
stream = stream
|
||||
.on('request', r => {
|
||||
if (bar) bar.start(1, 0);
|
||||
})
|
||||
.on('downloadProgress', p => {
|
||||
if (bar) {
|
||||
bar.setTotal(p.total);
|
||||
bar.update(p.transferred);
|
||||
if (p.total === p.transferred) {
|
||||
Downloader.releaseProgressBar(bar);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (url.endsWith('.zip')) {
|
||||
stream = stream.pipe(unzip.Parse()).on('entry', entry => {
|
||||
const filePath = entry.path.split('/').slice(strip).join(path.sep);
|
||||
if (filePath.length > 0) {
|
||||
if (entry.type === 'Directory') {
|
||||
fse.ensureDirSync(path.join(dest, path.normalize(filePath)));
|
||||
} else if (entry.type === 'File') {
|
||||
const fullFilePath = path.join(dest, path.normalize(filePath));
|
||||
const dirPath = path.dirname(fullFilePath);
|
||||
if (!fs.existsSync(dirPath)) {
|
||||
fse.ensureDirSync(dirPath);
|
||||
}
|
||||
entry.pipe(fs.createWriteStream(path.join(dest, path.normalize(filePath)), {
|
||||
// ToDo: zip entry file mode?
|
||||
mode: executable ? 0o755 : undefined,
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
entry.autodrain();
|
||||
}
|
||||
});
|
||||
} else if (url.endsWith('tar.gz')) {
|
||||
stream = stream.pipe(tar.x({C: dest, strip: strip}));
|
||||
} else {
|
||||
stream = stream.pipe(fs.createWriteStream(path.join(dest, url.split('/').pop())));
|
||||
}
|
||||
return ps.wait(stream);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,39 +118,17 @@ class Sdk {
|
||||
throw "Not implemented";
|
||||
}
|
||||
|
||||
prepare(strip=1) {
|
||||
prepare(strip = 1) {
|
||||
this.log.i('version: *%s*', this.version);
|
||||
if (this.prepared) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
fse.ensureDirSync(this.path);
|
||||
const bar = new ProgressBar(`${this.tag} [:bar] :percent :etas`, {width: 40, total: 1000, clear: true});
|
||||
this.log.d('download: *%s*', this.link);
|
||||
let stream = got.stream(this.link);
|
||||
stream = stream.on('downloadProgress', (p) => bar.update(p.percent));
|
||||
if (this.link.endsWith('.zip')) {
|
||||
stream = stream.pipe(unzip.Parse()).on('entry', (entry) => {
|
||||
const filePath = entry.path.split('/').slice(strip).join(path.sep);
|
||||
if (filePath.length > 0) {
|
||||
if (entry.type === 'Directory') {
|
||||
fse.ensureDirSync(path.join(this.path, path.normalize(filePath)));
|
||||
} else if (entry.type === 'File') {
|
||||
entry.pipe(fs.createWriteStream(path.join(this.path, path.normalize(filePath))));
|
||||
}
|
||||
} else {
|
||||
entry.autodrain();
|
||||
}
|
||||
});
|
||||
} else if (this.link.endsWith('tar.gz')) {
|
||||
stream = stream.pipe(tar.x({C: this.path, strip: strip}));
|
||||
} else {
|
||||
stream = stream.pipe(fs.createWriteStream(path.join(this.path, this.link.split('/').pop())));
|
||||
}
|
||||
return ps.wait(stream);
|
||||
return Downloader.download(this.link, this.path, strip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Sdk.System = System;
|
||||
Sdk.Downloader = Downloader;
|
||||
|
||||
module.exports = Sdk;
|
||||
|
||||
35
haxetool/system.js
Executable file
35
haxetool/system.js
Executable file
@@ -0,0 +1,35 @@
|
||||
const os = require('os');
|
||||
|
||||
class System {
|
||||
|
||||
static get isWindows() {
|
||||
return os.type() === 'Windows_NT';
|
||||
}
|
||||
|
||||
static get isLinux() {
|
||||
return os.type() === 'Linux';
|
||||
}
|
||||
|
||||
static get os() {
|
||||
return (
|
||||
this.isWindows ? 'windows' :
|
||||
this.isLinux ? 'linux' :
|
||||
undefined
|
||||
);
|
||||
}
|
||||
|
||||
static get archInt() {
|
||||
if (os.arch() === 'ia32') return 32;
|
||||
if (os.arch() === 'x64') return 64;
|
||||
}
|
||||
|
||||
static get isArch32() {
|
||||
return this.archInt === 32;
|
||||
}
|
||||
|
||||
static get isArch64() {
|
||||
return this.archInt === 64;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = System;
|
||||
@@ -67,3 +67,4 @@ module.exports = (handler) => {
|
||||
};
|
||||
|
||||
module.exports.TailVinyl = TailVinyl;
|
||||
module.exports.StringWritable = StringWritable;
|
||||
|
||||
2
index.js
Normal file → Executable file
2
index.js
Normal file → Executable file
@@ -1,7 +1,9 @@
|
||||
module.exports = {
|
||||
System: require('./haxetool/system'),
|
||||
Sdk: require('./haxetool/sdk'),
|
||||
Haxe: require('./haxetool/haxe'),
|
||||
FlashPlayer: require('./haxetool/flashplayer'),
|
||||
Android: require('./haxetool/android'),
|
||||
AdobeAir: require('./haxetool/adobe_air'),
|
||||
Project: require('./haxetool/project'),
|
||||
};
|
||||
11
package.json
Normal file → Executable file
11
package.json
Normal file → Executable file
@@ -1,26 +1,29 @@
|
||||
{
|
||||
"name": "gulp-haxetool",
|
||||
"version": "0.0.19",
|
||||
"version": "0.1.9",
|
||||
"description": "HaXe Tool for Gulp",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"ansi-colors": "^1.1.0",
|
||||
"async": "^2.6.0",
|
||||
"cli-progress": "^3.0.0",
|
||||
"fancy-log": "^1.3.2",
|
||||
"fs-extra": "^5.0.0",
|
||||
"got": "^8.3.0",
|
||||
"got": "^9.6.0",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-debian": "^0.1.9",
|
||||
"gulp-gzip": "^1.4.2",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-spawn": "^0.4.0",
|
||||
"gulp-tar": "^3.0.0",
|
||||
"gulp-webserver": "^0.9.1",
|
||||
"gulp-zip": "^5.0.0",
|
||||
"lodash.defaults": "^4.2.0",
|
||||
"lodash.template": "^4.4.0",
|
||||
"plugin-error": "^1.0.1",
|
||||
"progress": "^2.0.0",
|
||||
"promise-streams": "^2.1.1",
|
||||
"tail": "^1.2.3",
|
||||
"tar": "^4.4.1",
|
||||
"tar": "^4.4.10",
|
||||
"through2": "^2.0.3",
|
||||
"tmp-file": "^2.0.1",
|
||||
"unzip-stream": "^0.3.0",
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
deactivate () {
|
||||
# reset old environment variables
|
||||
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
|
||||
if ! [ -z "${_OLD_VIRTUAL_PATH+_}" ] ; then
|
||||
PATH="$_OLD_VIRTUAL_PATH"
|
||||
if ! [ -z "${_OLD_HAXE_VIRTUAL_PATH+_}" ] ; then
|
||||
PATH="$_OLD_HAXE_VIRTUAL_PATH"
|
||||
export PATH
|
||||
unset _OLD_VIRTUAL_PATH
|
||||
unset _OLD_HAXE_VIRTUAL_PATH
|
||||
fi
|
||||
if ! [ -z "${_OLD_VIRTUAL_LD_LIBRARY_PATH+_}" ] ; then
|
||||
LD_LIBRARY_PATH="$_OLD_VIRTUAL_LD_LIBRARY_PATH"
|
||||
@@ -21,10 +21,10 @@ deactivate () {
|
||||
hash -r 2>/dev/null
|
||||
fi
|
||||
|
||||
if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
|
||||
PS1="$_OLD_VIRTUAL_PS1"
|
||||
if ! [ -z "${_OLD_HAXE_VIRTUAL_PS1+_}" ] ; then
|
||||
PS1="$_OLD_HAXE_VIRTUAL_PS1"
|
||||
export PS1
|
||||
unset _OLD_VIRTUAL_PS1
|
||||
unset _OLD_HAXE_VIRTUAL_PS1
|
||||
fi
|
||||
|
||||
unset HAXE_HOME
|
||||
@@ -43,7 +43,7 @@ export HAXE_HOME
|
||||
HAXE_STD_PATH="${HAXE_HOME}/std"
|
||||
export HAXE_STD_PATH
|
||||
|
||||
_OLD_VIRTUAL_PATH="$PATH"
|
||||
_OLD_HAXE_VIRTUAL_PATH="$PATH"
|
||||
PATH="${PATH}:${HAXE_HOME}"
|
||||
export PATH
|
||||
|
||||
@@ -52,7 +52,7 @@ LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${HAXE_HOME}"
|
||||
export LD_LIBRARY_PATH
|
||||
|
||||
if [ -z "${HAXE_DISABLE_PROMPT-}" ] ; then
|
||||
_OLD_VIRTUAL_PS1="$PS1"
|
||||
_OLD_HAXE_VIRTUAL_PS1="$PS1"
|
||||
if [ "x" != x ] ; then
|
||||
PS1="$PS1"
|
||||
else
|
||||
69
template/neko/activate
Normal file
69
template/neko/activate
Normal file
@@ -0,0 +1,69 @@
|
||||
# From python venv activate
|
||||
|
||||
deactivate () {
|
||||
# reset old environment variables
|
||||
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
|
||||
if ! [ -z "${_OLD_NEKO_VIRTUAL_PATH+_}" ] ; then
|
||||
PATH="$_OLD_NEKO_VIRTUAL_PATH"
|
||||
export PATH
|
||||
unset _OLD_NEKO_VIRTUAL_PATH
|
||||
fi
|
||||
if ! [ -z "${_OLD_VIRTUAL_LD_LIBRARY_PATH+_}" ] ; then
|
||||
LD_LIBRARY_PATH="$_OLD_VIRTUAL_LD_LIBRARY_PATH"
|
||||
export LD_LIBRARY_PATH
|
||||
unset _OLD_VIRTUAL_LD_LIBRARY_PATH
|
||||
fi
|
||||
|
||||
# This should detect bash and zsh, which have a hash command that must
|
||||
# be called to get it to forget past commands. Without forgetting
|
||||
# past commands the $PATH changes we made may not be respected
|
||||
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
|
||||
hash -r 2>/dev/null
|
||||
fi
|
||||
|
||||
if ! [ -z "${_OLD_NEKO_VIRTUAL_PS1+_}" ] ; then
|
||||
PS1="$_OLD_NEKO_VIRTUAL_PS1"
|
||||
export PS1
|
||||
unset _OLD_NEKO_VIRTUAL_PS1
|
||||
fi
|
||||
|
||||
unset NEKO_HOME
|
||||
if [ ! "${1-}" = "nondestructive" ] ; then
|
||||
# Self destruct!
|
||||
unset -f deactivate
|
||||
fi
|
||||
}
|
||||
|
||||
# unset irrelevant variables
|
||||
deactivate nondestructive
|
||||
|
||||
NEKO_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
export NEKO_HOME
|
||||
|
||||
NEKO_STD_PATH="${NEKO_HOME}/std"
|
||||
export NEKO_STD_PATH
|
||||
|
||||
_OLD_NEKO_VIRTUAL_PATH="$PATH"
|
||||
PATH="${PATH}:${NEKO_HOME}"
|
||||
export PATH
|
||||
|
||||
_OLD_VIRTUAL_LD_LIBRARY_PATH="$PATH"
|
||||
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${NEKO_HOME}"
|
||||
export LD_LIBRARY_PATH
|
||||
|
||||
if [ -z "${NEKO_DISABLE_PROMPT-}" ] ; then
|
||||
_OLD_NEKO_VIRTUAL_PS1="$PS1"
|
||||
if [ "x" != x ] ; then
|
||||
PS1="$PS1"
|
||||
else
|
||||
PS1="(neko) $PS1"
|
||||
fi
|
||||
export PS1
|
||||
fi
|
||||
|
||||
# This should detect bash and zsh, which have a hash command that must
|
||||
# be called to get it to forget past commands. Without forgetting
|
||||
# past commands the $PATH changes we made may not be respected
|
||||
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
|
||||
hash -r 2>/dev/null
|
||||
fi
|
||||
@@ -4,6 +4,8 @@
|
||||
-lib <%=item.name%>:<%=item.version.split('@').shift()%><% }); %>
|
||||
<% macros.forEach(function(item) { %>
|
||||
--macro "<%=item%>"<% }); %>
|
||||
<% flags.forEach(function(item) { %>
|
||||
-D <%=item%><% }); %>
|
||||
|
||||
-main <%=main%>
|
||||
-<%=out%> "<%=buildDir%>/<%=platform%>/bin/<%=meta.filename%><%=ext%>"
|
||||
|
||||
@@ -17,8 +17,14 @@
|
||||
|
||||
<window fps="<%=meta.fps%>"/>
|
||||
<window fps="<%=meta.fps%>" width="<%=meta.width%>" height="<%=meta.height%>" unless="html5"/>
|
||||
<window fps="<%=meta.fps%>" width="<%=meta.mobileWidth%>" height="<%=meta.mobileHeight%>"
|
||||
orientation="landscape" resizable="false" if="mobile"/>
|
||||
|
||||
<haxeflag name="-D" value="swf-gpu"/>
|
||||
<haxeflag name="-D" value="native-trace"/>
|
||||
<haxeflag name="-dce" value="no"/>
|
||||
|
||||
<% android.forEach(function(item) { %>
|
||||
<dependency name="android" path="<%=item.path%>" if="android"/>
|
||||
<% item.extensions.forEach(function(extension) { %><android extension="<%=extension%>"/><% }); %><% }); %>
|
||||
</project>
|
||||
|
||||
18
template/windows/app.iss
Executable file
18
template/windows/app.iss
Executable file
@@ -0,0 +1,18 @@
|
||||
[Setup]
|
||||
AppName=<%=meta.title%>
|
||||
AppVersion=<%=meta.version%>
|
||||
WizardStyle=modern
|
||||
DefaultDirName={autopf}\<%=meta.filename%>
|
||||
DefaultGroupName=<%=meta.title%>
|
||||
UninstallDisplayIcon={app}\<%=meta.filename%>.exe
|
||||
Compression=lzma2
|
||||
SolidCompression=yes
|
||||
OutputDir=<%=output%>
|
||||
OutputBaseFilename=<%=meta.filename%>_<%=meta.version%>
|
||||
|
||||
[Files]
|
||||
Source: *; Excludes: "*.iss,*.log"; DestDir: "{app}"; Flags: recursesubdirs
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\<%=meta.title%>"; Filename: "{app}\<%=meta.filename%>.exe"
|
||||
Name: "{group}\Uninstall <%=meta.title%>"; Filename: "{uninstallexe}"
|
||||
Reference in New Issue
Block a user