Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 961766a37c | |||
| ca61b68cd9 | |||
| 715f6807d8 | |||
| e0eddbcab5 | |||
| 1bd18caa9a | |||
| 90f1a9b77f | |||
| 141470c519 | |||
| b68ae2f3dc | |||
| 4f3ffe1181 | |||
| 85f2cb8ff7 | |||
| d3e5ffab84 | |||
| cc2c4f19f8 |
6
.editorconfig
Normal file
6
.editorconfig
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
max_line_length = 120
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
target/
|
target/
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
*.iml
|
||||||
39
CHANGELOG.md
39
CHANGELOG.md
@@ -1,24 +1,29 @@
|
|||||||
|
## v0.2.0 (2026-05-15)
|
||||||
|
|
||||||
0.0.18
|
### Feat
|
||||||
------
|
|
||||||
* Add meta.fps project param
|
|
||||||
|
|
||||||
0.0.12
|
- **ruffle**: add alternative ruffle flash target runner
|
||||||
------
|
|
||||||
|
|
||||||
* Openfl android platform support
|
## 0.1.9 (2021-05-24)
|
||||||
* Android sdk module
|
|
||||||
|
|
||||||
0.0.11
|
### Feat
|
||||||
------
|
|
||||||
|
|
||||||
* Added Neko module
|
- **android**: up android sdk version
|
||||||
* FlashPlayer output with stream
|
|
||||||
* Verbose output mode (--verbose)
|
|
||||||
|
|
||||||
0.0.10
|
## 0.1.8 (2020-03-30)
|
||||||
------
|
|
||||||
|
|
||||||
* Windows compatibility
|
## 0.1.7 (2020-03-25)
|
||||||
* Change FlashPlayer download link
|
|
||||||
* Use 'fs-extra' without 'mkdirp' and 'rmdir'
|
## 0.1.6 (2020-02-19)
|
||||||
|
|
||||||
|
## 0.1.5 (2020-02-18)
|
||||||
|
|
||||||
|
## 0.1.0 (2019-09-03)
|
||||||
|
|
||||||
|
## 0.0.18 (2019-05-20)
|
||||||
|
|
||||||
|
## 0.0.17 (2019-03-28)
|
||||||
|
|
||||||
|
## 0.0.16 (2019-03-14)
|
||||||
|
|
||||||
|
## 0.0.15 (2019-03-14)
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="WEB_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const exec = require('./exec');
|
const exec = require('./exec');
|
||||||
const {StringWritable} = require('./tail');
|
const {StringWritable} = require('./tail');
|
||||||
@@ -11,27 +12,22 @@ const Env = require('./env');
|
|||||||
|
|
||||||
class Android extends Sdk {
|
class Android extends Sdk {
|
||||||
|
|
||||||
constructor(version) {
|
constructor(version, ndkVersion) {
|
||||||
super(Android.ID, version || Android.VERSION);
|
super(Android.ID, version || Android.VERSION);
|
||||||
this.ndk_version = 'r15c';
|
this.ndk_version = ndkVersion || Android.NDK_VERSION;
|
||||||
|
this.repository = 'https://dl.google.com/android/repository';
|
||||||
}
|
}
|
||||||
|
|
||||||
get prepared() {
|
get prepared() {
|
||||||
try {
|
try {
|
||||||
return fs.existsSync(`${this.path}/tools/bin/sdkmanager`);
|
return fs.existsSync(this.sdkmanager_bin);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get link() {
|
get link() {
|
||||||
const system = System.isWindows ? 'windows' : System.isLinux ? 'linux' : null;
|
return `${this.repository}/commandlinetools-${System.os}-${this.version}_latest.zip`;
|
||||||
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`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get android_home() {
|
get android_home() {
|
||||||
@@ -42,6 +38,10 @@ class Android extends Sdk {
|
|||||||
return path.join(this.path, 'ndk-bundle')
|
return path.join(this.path, 'ndk-bundle')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get sdkmanager_bin() {
|
||||||
|
return path.join(this.path, 'cmdline-tools/bin/sdkmanager');
|
||||||
|
}
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
const result = [];
|
const result = [];
|
||||||
result.push(super.prepare(0));
|
result.push(super.prepare(0));
|
||||||
@@ -53,19 +53,43 @@ class Android extends Sdk {
|
|||||||
|
|
||||||
prepare_ndk() {
|
prepare_ndk() {
|
||||||
// ToDo: support windows
|
// ToDo: support windows
|
||||||
const url = `https://dl.google.com/android/repository/android-ndk-${this.ndk_version}-linux-x86_64.zip`;
|
const url = `${this.repository}/android-ndk-${this.ndk_version}-${System.os}-x86_64.zip`;
|
||||||
this.log.d('download: *%s*', url);
|
this.log.d('download: *%s*', url);
|
||||||
return Sdk.Downloader.download(url, this.ndk_home, 1, true);
|
return Sdk.Downloader.download(url, this.ndk_home, 1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
sdkmanager(packages) {
|
sdkmanager(packages) {
|
||||||
this.log.i('sdkmanager: *%s*', packages.join(', '));
|
this.log.i('sdkmanager: *%s*', packages.join(', '));
|
||||||
const androidBin = path.join(this.path, 'tools/bin/sdkmanager');
|
const installedFile = path.join(this.path, '.installed');
|
||||||
if (fs.existsSync(androidBin)) {
|
const installed = new Set(
|
||||||
fs.chmodSync(androidBin, 0o755);
|
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)';
|
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() {
|
activate() {
|
||||||
@@ -89,12 +113,16 @@ class Android extends Sdk {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
aapt(args) {
|
buildTool(name) {
|
||||||
let buildToolsVersion = null;
|
let buildToolsVersion = null;
|
||||||
fs.readdirSync(path.join(this.path, 'build-tools')).forEach(file => {
|
fs.readdirSync(path.join(this.path, 'build-tools')).forEach(file => {
|
||||||
buildToolsVersion = 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(' '));
|
return exec('.', [aaptBin].concat(args).join(' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,8 +182,11 @@ class Android extends Sdk {
|
|||||||
const self = this;
|
const self = this;
|
||||||
return through.obj(function(file, enc, callback) {
|
return through.obj(function(file, enc, callback) {
|
||||||
self._installApk(file.path, file.package).then(() => {
|
self._installApk(file.path, file.package).then(() => {
|
||||||
|
// ToDo: kludge: delay before start
|
||||||
|
setTimeout(() => {
|
||||||
this.push(file);
|
this.push(file);
|
||||||
callback();
|
callback();
|
||||||
|
}, 500);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -191,14 +222,35 @@ class Android extends Sdk {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.ID = 'android';
|
||||||
|
|
||||||
Android.VERSION_25_2_3 = '25.2.3';
|
Android.VERSION_7302050 = '7302050';
|
||||||
Android.VERSION_3859397 = '3859397';
|
Android.VERSION = Android.VERSION_7302050;
|
||||||
Android.VERSION_4333796 = '4333796';
|
|
||||||
|
|
||||||
Android.VERSION = Android.VERSION_4333796;
|
Android.NDK_VERSION_R15C = 'r15c';
|
||||||
|
Android.NDK_VERSION = Android.NDK_VERSION_R15C;
|
||||||
|
|
||||||
module.exports = Android;
|
module.exports = Android;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const Platform = {
|
|||||||
WINDOWS: 'windows',
|
WINDOWS: 'windows',
|
||||||
ANDROID: 'android',
|
ANDROID: 'android',
|
||||||
NEKO: 'neko',
|
NEKO: 'neko',
|
||||||
|
CPP: 'cpp',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -46,6 +47,8 @@ class Config {
|
|||||||
mobileHeight: null,
|
mobileHeight: null,
|
||||||
fps: 60,
|
fps: 60,
|
||||||
};
|
};
|
||||||
|
this.key = null;
|
||||||
|
this.android = [];
|
||||||
if (params) {
|
if (params) {
|
||||||
this.update(params);
|
this.update(params);
|
||||||
this.afterUpdate();
|
this.afterUpdate();
|
||||||
@@ -68,12 +71,14 @@ class Config {
|
|||||||
if (params.macros !== undefined) this.macros = this.macros.concat(params.macros);
|
if (params.macros !== undefined) this.macros = this.macros.concat(params.macros);
|
||||||
if (params.flags !== undefined) this.flags = this.flags.concat(params.flags);
|
if (params.flags !== undefined) this.flags = this.flags.concat(params.flags);
|
||||||
if (params.meta !== undefined) this.meta = {...this.meta, ...params.meta};
|
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);
|
if (this.meta.icon) this.icon = Config.absolutePath(this.meta.icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
afterUpdate() {
|
afterUpdate() {
|
||||||
if (this.meta.mobileWidth === null) this.meta.mobileWidth = this.meta.width;
|
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);
|
if (this.meta.mobileHeight === null) this.meta.mobileHeight = Math.round(this.meta.mobileWidth / 2.222222222);
|
||||||
}
|
}
|
||||||
|
|
||||||
branch(params) {
|
branch(params) {
|
||||||
|
|||||||
@@ -5,15 +5,18 @@ const os = require('os');
|
|||||||
const through = require('through2');
|
const through = require('through2');
|
||||||
const Sdk = require('./sdk');
|
const Sdk = require('./sdk');
|
||||||
const System = require('./system');
|
const System = require('./system');
|
||||||
|
const Env = require('./env');
|
||||||
const run = require('../run/index');
|
const run = require('../run/index');
|
||||||
const {TailVinyl} = require('./tail');
|
const {TailVinyl} = require('./tail');
|
||||||
|
|
||||||
|
|
||||||
class FlashPlayer extends Sdk {
|
class FlashPlayer extends Sdk {
|
||||||
|
BASE_URL = 'https://fpdownload.macromedia.com/pub/flashplayer/updaters';
|
||||||
|
|
||||||
constructor(debug, version) {
|
constructor(debug, version, playerId = FlashPlayer.ID) {
|
||||||
super(FlashPlayer.ID, version || FlashPlayer.VERSION);
|
super(playerId, version || FlashPlayer.VERSION);
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
|
this.baseUrl = Env.get('FLASHPLAYER_URL') || this.BASE_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
@@ -29,22 +32,22 @@ class FlashPlayer extends Sdk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get link() {
|
get link() {
|
||||||
const baseUrl = `https://fpdownload.macromedia.com/pub/flashplayer/updaters/${this.version}/`;
|
const baseUrl = `${this.baseUrl}/${this.version}`;
|
||||||
if (System.isWindows) {
|
if (System.isWindows) {
|
||||||
return baseUrl + `flashplayer_${this.version}_sa${this.debug ? '_debug' : ''}.exe`;
|
return this.baseUrl + `/flashplayer_${this.version}_sa${this.debug ? '_debug' : ''}.exe`;
|
||||||
} else if (System.isLinux) {
|
} else if (System.isLinux) {
|
||||||
return baseUrl + `flash_player_sa_linux${this.debug ? '_debug' : ''}.x86_64.tar.gz`;
|
return this.baseUrl + `/flash_player_sa_linux${this.debug ? '_debug' : ''}.x86_64.tar.gz`;
|
||||||
} else {
|
} else {
|
||||||
throw `Unsupported os '${os.type()}'`;
|
throw `Unsupported os '${os.type()}'`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get flashPlayerBin() {
|
get flashPlayerBin() {
|
||||||
if (os.type() === 'Windows_NT') {
|
if (System.isWindows) {
|
||||||
const v = this.version.split('.');
|
const v = this.version.split('.');
|
||||||
const playerName = `flashplayer_${this.version}_sa${this.debug ? '_debug' : ''}.exe`;
|
const playerName = `flashplayer_${this.version}_sa${this.debug ? '_debug' : ''}.exe`;
|
||||||
return path.join(this.path, playerName);
|
return path.join(this.path, playerName);
|
||||||
} else if (os.type() === 'Linux') {
|
} else if (System.isLinux) {
|
||||||
const binPath = path.join(this.path, `flashplayer${this.debug ? 'debugger' : ''}`);
|
const binPath = path.join(this.path, `flashplayer${this.debug ? 'debugger' : ''}`);
|
||||||
fs.chmodSync(binPath, 0o755);
|
fs.chmodSync(binPath, 0o755);
|
||||||
return binPath;
|
return binPath;
|
||||||
|
|||||||
@@ -81,10 +81,14 @@ class Haxe extends Sdk {
|
|||||||
return exec('.', [this.haxelibBin].concat(args).join(' '));
|
return exec('.', [this.haxelibBin].concat(args).join(' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolveBuildDir(config) {
|
||||||
|
return path.join(Haxe.buildDir, config.name);
|
||||||
|
}
|
||||||
|
|
||||||
openfl(command, platform, config, debug=false) {
|
openfl(command, platform, config, debug=false) {
|
||||||
this.log.i('_openfl_ _build_ *%s*', platform);
|
this.log.i('_openfl_ _build_ *%s*', platform);
|
||||||
this.activate();
|
this.activate();
|
||||||
const buildDir = path.join(os.tmpdir(), 'build', config.name);
|
const buildDir = this.resolveBuildDir(config);
|
||||||
fse.ensureDirSync(buildDir);
|
fse.ensureDirSync(buildDir);
|
||||||
|
|
||||||
const projectTemplate = template(fs.readFileSync(path.resolve(__dirname, '..', 'template/project.xml')));
|
const projectTemplate = template(fs.readFileSync(path.resolve(__dirname, '..', 'template/project.xml')));
|
||||||
@@ -101,7 +105,7 @@ class Haxe extends Sdk {
|
|||||||
const target = path.resolve(buildDir, platform, 'bin');
|
const target = path.resolve(buildDir, platform, 'bin');
|
||||||
fse.emptyDirSync(target);
|
fse.emptyDirSync(target);
|
||||||
const result = {
|
const result = {
|
||||||
'android': 'app/build/outputs/apk/*-debug.apk',
|
'android': `app/build/outputs/**/${config.meta.filename}-debug.apk`,
|
||||||
'flash': '*.swf',
|
'flash': '*.swf',
|
||||||
}[platform] || '**/*';
|
}[platform] || '**/*';
|
||||||
return this.haxelib(args).then(() => {
|
return this.haxelib(args).then(() => {
|
||||||
@@ -116,7 +120,7 @@ class Haxe extends Sdk {
|
|||||||
build(platform, config, debug=false) {
|
build(platform, config, debug=false) {
|
||||||
this.log.i('_build_ *%s*', platform);
|
this.log.i('_build_ *%s*', platform);
|
||||||
this.activate();
|
this.activate();
|
||||||
const buildDir = path.join(os.tmpdir(), 'build', config.name);
|
const buildDir = this.resolveBuildDir(config);
|
||||||
fse.ensureDirSync(buildDir);
|
fse.ensureDirSync(buildDir);
|
||||||
|
|
||||||
const projectTemplate = template(fs.readFileSync(path.resolve(__dirname, '..', 'template/project.hxml')));
|
const projectTemplate = template(fs.readFileSync(path.resolve(__dirname, '..', 'template/project.hxml')));
|
||||||
@@ -139,11 +143,22 @@ class Haxe extends Sdk {
|
|||||||
args.push('-debug');
|
args.push('-debug');
|
||||||
}
|
}
|
||||||
const target = path.resolve(buildDir, platform, 'bin');
|
const target = path.resolve(buildDir, platform, 'bin');
|
||||||
|
if (platform !== 'cpp') {
|
||||||
fse.emptyDirSync(target);
|
fse.emptyDirSync(target);
|
||||||
|
}
|
||||||
for (const asset of config.assets) {
|
for (const asset of config.assets) {
|
||||||
fse.copySync(asset, path.join(target, asset.split("/").pop()));
|
fse.copySync(asset, path.join(target, asset.split("/").pop()));
|
||||||
}
|
}
|
||||||
return this.haxe(args).then(() => vfs.src(`${target}/**/*`));
|
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) {
|
install(packages) {
|
||||||
@@ -198,6 +213,8 @@ class Haxe extends Sdk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Haxe.buildDir = path.join(process.cwd(), 'build');
|
||||||
|
|
||||||
Haxe.ID = 'haxe';
|
Haxe.ID = 'haxe';
|
||||||
|
|
||||||
Haxe.VERSION_3_4_0 = '3.4.0';
|
Haxe.VERSION_3_4_0 = '3.4.0';
|
||||||
@@ -205,6 +222,12 @@ Haxe.VERSION_3_4_2 = '3.4.2';
|
|||||||
Haxe.VERSION_3_4_3 = '3.4.3';
|
Haxe.VERSION_3_4_3 = '3.4.3';
|
||||||
Haxe.VERSION_3_4_7 = '3.4.7';
|
Haxe.VERSION_3_4_7 = '3.4.7';
|
||||||
Haxe.VERSION_3 = Haxe.VERSION_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;
|
module.exports = Haxe;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const fs = require('fs');
|
|||||||
const fse = require('fs-extra');
|
const fse = require('fs-extra');
|
||||||
const Haxe = require('./haxe');
|
const Haxe = require('./haxe');
|
||||||
const FlashPlayer = require('./flashplayer');
|
const FlashPlayer = require('./flashplayer');
|
||||||
|
const RufflePlayer = require('./ruffle');
|
||||||
const Android = require('./android');
|
const Android = require('./android');
|
||||||
const Neko = require('./neko');
|
const Neko = require('./neko');
|
||||||
const InnoSetup = require('./innosetup');
|
const InnoSetup = require('./innosetup');
|
||||||
@@ -100,13 +101,13 @@ class HaxeBuilder extends Builder {
|
|||||||
.then(() => this.android.prepare())
|
.then(() => this.android.prepare())
|
||||||
.then(() => this.android.activate())
|
.then(() => this.android.activate())
|
||||||
.then(() => this.android.sdkmanager([
|
.then(() => this.android.sdkmanager([
|
||||||
|
// ToDo: android sdk dependencies config?
|
||||||
'tools',
|
'tools',
|
||||||
'platform-tools',
|
'platform-tools',
|
||||||
'build-tools;27.0.3',
|
'build-tools;27.0.3',
|
||||||
//'platforms;android-19',
|
'platforms;android-28', //ToDo: lime version 7.6.0 -> 28; 7.0.0 -> 26
|
||||||
'platforms;android-26',
|
|
||||||
//'ndk-bundle',
|
//'ndk-bundle',
|
||||||
'lldb;3.1',
|
//'lldb;3.1',
|
||||||
'cmake;3.6.4111459',
|
'cmake;3.6.4111459',
|
||||||
]));
|
]));
|
||||||
const AndroidSDK = this.android.android_home;
|
const AndroidSDK = this.android.android_home;
|
||||||
@@ -125,7 +126,12 @@ class HaxeBuilder extends Builder {
|
|||||||
switch (this.buildSystem) {
|
switch (this.buildSystem) {
|
||||||
case BuildSystem.OPENFL:
|
case BuildSystem.OPENFL:
|
||||||
return this.haxe.openfl('build', this.platform, this.config, this.debug)
|
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:
|
case BuildSystem.HAXE:
|
||||||
return this.haxe.build(this.platform, this.config, this.debug)
|
return this.haxe.build(this.platform, this.config, this.debug)
|
||||||
.then(result => streamToPromise(result.pipe(vfs.dest(target))));
|
.then(result => streamToPromise(result.pipe(vfs.dest(target))));
|
||||||
@@ -327,9 +333,9 @@ Runner.factory = {};
|
|||||||
*/
|
*/
|
||||||
class FlashRunner extends Runner {
|
class FlashRunner extends Runner {
|
||||||
|
|
||||||
constructor(config, debug) {
|
constructor(config, debug, player = FlashPlayer) {
|
||||||
super(config, Platform.FLASH, debug);
|
super(config, Platform.FLASH, debug);
|
||||||
this.player = new FlashPlayer(debug);
|
this.player = new player(debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
@@ -344,6 +350,12 @@ class FlashRunner extends Runner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RuffleRunner extends FlashRunner {
|
||||||
|
constructor(config, debug) {
|
||||||
|
super(config, debug, RufflePlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Runner.register(Platform.FLASH, FlashRunner);
|
Runner.register(Platform.FLASH, FlashRunner);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -387,6 +399,19 @@ class LinuxRunner extends Runner {
|
|||||||
|
|
||||||
Runner.register(Platform.LINUX, LinuxRunner);
|
Runner.register(Platform.LINUX, LinuxRunner);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class CPPRunner extends LinuxRunner {
|
||||||
|
|
||||||
|
constructor(config, debug) {
|
||||||
|
super(config, debug);
|
||||||
|
this.platform = Platform.CPP
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Runner.register(Platform.CPP, CPPRunner);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -446,7 +471,7 @@ class AndroidRunner extends Runner {
|
|||||||
|
|
||||||
call() {
|
call() {
|
||||||
const target = this.targetPath;
|
const target = this.targetPath;
|
||||||
return this.log(gulp.src(`${target}/${this.config.meta.filename}_*.apk`)
|
return this.log(gulp.src(`${target}/${this.config.meta.filename}_${this.config.meta.version}.apk`)
|
||||||
.pipe(this.android.apk())
|
.pipe(this.android.apk())
|
||||||
.pipe(this.android.install())
|
.pipe(this.android.install())
|
||||||
.pipe(this.android.start())
|
.pipe(this.android.start())
|
||||||
@@ -514,6 +539,10 @@ class Project {
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static useRuffle() {
|
||||||
|
Runner.register(Platform.FLASH, RuffleRunner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Project.BuildSystem = BuildSystem;
|
Project.BuildSystem = BuildSystem;
|
||||||
|
|||||||
75
haxetool/ruffle.js
Executable file
75
haxetool/ruffle.js
Executable file
@@ -0,0 +1,75 @@
|
|||||||
|
const path = require("path");
|
||||||
|
const fs = require("fs");
|
||||||
|
const fse = require("fs-extra");
|
||||||
|
const os = require("os");
|
||||||
|
const through = require("through2");
|
||||||
|
const Sdk = require("./sdk");
|
||||||
|
const System = require("./system");
|
||||||
|
const Env = require('./env');
|
||||||
|
const run = require("../run/index");
|
||||||
|
const { TailVinyl } = require("./tail");
|
||||||
|
const FlashPlayer = require("./flashplayer");
|
||||||
|
|
||||||
|
class RufflePlayer extends FlashPlayer {
|
||||||
|
BASE_URL = 'https://github.com/ruffle-rs/ruffle/releases/download';
|
||||||
|
|
||||||
|
constructor(debug, version) {
|
||||||
|
super(debug, version || RufflePlayer.VERSION, RufflePlayer.ID);
|
||||||
|
this.debug = debug;
|
||||||
|
this.baseUrl = Env.get('RUFFLE_URL') || this.BASE_URL;
|
||||||
|
}
|
||||||
|
|
||||||
|
get link() {
|
||||||
|
const baseUrl = `${baseUrl}/${this.version.replaceAll('_', '-')}`;
|
||||||
|
if (System.isWindows) {
|
||||||
|
return baseUrl + `/ruffle-${this.version}-windows-x86_64.zip`;
|
||||||
|
} else if (System.isLinux) {
|
||||||
|
return baseUrl + `/ruffle-${this.version}-linux-x86_64.tar.gz`;
|
||||||
|
} else {
|
||||||
|
throw `Unsupported os '${os.type()}'`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get flashPlayerBin() {
|
||||||
|
if (System.isWindows) {
|
||||||
|
return path.join(this.path, "ruffle.exe");
|
||||||
|
} else if (System.isLinux) {
|
||||||
|
return path.join(this.path, "ruffle");
|
||||||
|
} else {
|
||||||
|
throw `Unsupported os '${os.type()}'`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static get log() {
|
||||||
|
return path.join(os.homedir(), ".cache/ruffle/log/ruffle.log");
|
||||||
|
}
|
||||||
|
|
||||||
|
run(filename, params) {
|
||||||
|
this.log.i("_run_ *%s*", filename);
|
||||||
|
return run(`${this.flashPlayerBin} ${filename}`, params)
|
||||||
|
.exec()
|
||||||
|
.pipe(
|
||||||
|
through.obj(function (file, enc, callback) {
|
||||||
|
const log = new TailVinyl({
|
||||||
|
path: RufflePlayer.log,
|
||||||
|
handler: (line) => {
|
||||||
|
if (line.includes("avm_trace")) {
|
||||||
|
return line.split("avm_trace: ").pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.on("end", () => log.dispose());
|
||||||
|
this.push(log);
|
||||||
|
callback();
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RufflePlayer.ID = "ruffle";
|
||||||
|
|
||||||
|
RufflePlayer.VERSION_2026_05_15 = "nightly-2026_05_15";
|
||||||
|
|
||||||
|
RufflePlayer.VERSION = RufflePlayer.VERSION_2026_05_15;
|
||||||
|
|
||||||
|
module.exports = RufflePlayer;
|
||||||
@@ -55,6 +55,11 @@ class Downloader {
|
|||||||
if (entry.type === 'Directory') {
|
if (entry.type === 'Directory') {
|
||||||
fse.ensureDirSync(path.join(dest, path.normalize(filePath)));
|
fse.ensureDirSync(path.join(dest, path.normalize(filePath)));
|
||||||
} else if (entry.type === 'File') {
|
} 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)), {
|
entry.pipe(fs.createWriteStream(path.join(dest, path.normalize(filePath)), {
|
||||||
// ToDo: zip entry file mode?
|
// ToDo: zip entry file mode?
|
||||||
mode: executable ? 0o755 : undefined,
|
mode: executable ? 0o755 : undefined,
|
||||||
@@ -118,7 +123,7 @@ class Sdk {
|
|||||||
if (this.prepared) {
|
if (this.prepared) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} else {
|
} else {
|
||||||
this.log.d('download: *%s*', this.link);
|
this.log.i('download: *%s*', this.link);
|
||||||
return Downloader.download(this.link, this.path, strip);
|
return Downloader.download(this.link, this.path, strip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,14 @@ class System {
|
|||||||
return os.type() === 'Linux';
|
return os.type() === 'Linux';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get os() {
|
||||||
|
return (
|
||||||
|
this.isWindows ? 'windows' :
|
||||||
|
this.isLinux ? 'linux' :
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static get archInt() {
|
static get archInt() {
|
||||||
if (os.arch() === 'ia32') return 32;
|
if (os.arch() === 'ia32') return 32;
|
||||||
if (os.arch() === 'x64') return 64;
|
if (os.arch() === 'x64') return 64;
|
||||||
|
|||||||
@@ -13,7 +13,14 @@ class TailVinyl extends Vinyl {
|
|||||||
super(params);
|
super(params);
|
||||||
if (params.path) {
|
if (params.path) {
|
||||||
this.tail = new Tail(params.path);
|
this.tail = new Tail(params.path);
|
||||||
this.tail.on('line', data => this.contents.write(data + '\n'));
|
this.tail.on('line', line => {
|
||||||
|
if (params.handler) {
|
||||||
|
line = params.handler(line);
|
||||||
|
}
|
||||||
|
if (line) {
|
||||||
|
this.contents.write(line + '\n');
|
||||||
|
}
|
||||||
|
}),
|
||||||
this.tail.on('error', error => this.contents.write('error: ' + error));
|
this.tail.on('error', error => this.contents.write('error: ' + error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
index.js
1
index.js
@@ -3,6 +3,7 @@ module.exports = {
|
|||||||
Sdk: require('./haxetool/sdk'),
|
Sdk: require('./haxetool/sdk'),
|
||||||
Haxe: require('./haxetool/haxe'),
|
Haxe: require('./haxetool/haxe'),
|
||||||
FlashPlayer: require('./haxetool/flashplayer'),
|
FlashPlayer: require('./haxetool/flashplayer'),
|
||||||
|
RufflePlayer: require('./haxetool/ruffle'),
|
||||||
Android: require('./haxetool/android'),
|
Android: require('./haxetool/android'),
|
||||||
AdobeAir: require('./haxetool/adobe_air'),
|
AdobeAir: require('./haxetool/adobe_air'),
|
||||||
Project: require('./haxetool/project'),
|
Project: require('./haxetool/project'),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-haxetool",
|
"name": "gulp-haxetool",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"description": "HaXe Tool for Gulp",
|
"description": "HaXe Tool for Gulp",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+ssh://git@bitbucket.org/shmyga/gulp-haxetool.git"
|
"url": "https://git.shmyga.ru/InfernalGames/gulp-haxetool.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"gulp",
|
"gulp",
|
||||||
@@ -43,5 +43,5 @@
|
|||||||
],
|
],
|
||||||
"author": "shmyga",
|
"author": "shmyga",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"homepage": "https://bitbucket.org/shmyga/gulp-haxetool#readme"
|
"homepage": "https://git.shmyga.ru/InfernalGames/gulp-haxetool#readme"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
-lib <%=item.name%>:<%=item.version.split('@').shift()%><% }); %>
|
-lib <%=item.name%>:<%=item.version.split('@').shift()%><% }); %>
|
||||||
<% macros.forEach(function(item) { %>
|
<% macros.forEach(function(item) { %>
|
||||||
--macro "<%=item%>"<% }); %>
|
--macro "<%=item%>"<% }); %>
|
||||||
|
<% flags.forEach(function(item) { %>
|
||||||
|
-D <%=item%><% }); %>
|
||||||
|
|
||||||
-main <%=main%>
|
-main <%=main%>
|
||||||
-<%=out%> "<%=buildDir%>/<%=platform%>/bin/<%=meta.filename%><%=ext%>"
|
-<%=out%> "<%=buildDir%>/<%=platform%>/bin/<%=meta.filename%><%=ext%>"
|
||||||
|
|||||||
@@ -23,4 +23,8 @@
|
|||||||
<haxeflag name="-D" value="swf-gpu"/>
|
<haxeflag name="-D" value="swf-gpu"/>
|
||||||
<haxeflag name="-D" value="native-trace"/>
|
<haxeflag name="-D" value="native-trace"/>
|
||||||
<haxeflag name="-dce" value="no"/>
|
<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>
|
</project>
|
||||||
|
|||||||
Reference in New Issue
Block a user