Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1bd18caa9a | |||
| 90f1a9b77f | |||
| 141470c519 | |||
| b68ae2f3dc | |||
| 4f3ffe1181 | |||
| 85f2cb8ff7 | |||
| d3e5ffab84 | |||
| cc2c4f19f8 |
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'
|
||||
|
||||
@@ -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 os = require('os');
|
||||
const path = require('path');
|
||||
const exec = require('./exec');
|
||||
const {StringWritable} = require('./tail');
|
||||
@@ -60,12 +61,33 @@ class Android extends Sdk {
|
||||
|
||||
sdkmanager(packages) {
|
||||
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 androidBin = path.join(this.path, 'tools/bin/sdkmanager');
|
||||
if (fs.existsSync(androidBin)) {
|
||||
fs.chmodSync(androidBin, 0o755);
|
||||
}
|
||||
const yes = '(while sleep 3; do echo "y"; done)';
|
||||
return exec('.', [yes, '|', androidBin].concat(packages.map(name => `"${name}"`)).join(' '));
|
||||
const command = [yes, '|', androidBin].concat(Array.from(install).map(name => `"${name}"`)).join(' ');
|
||||
return exec('.', command).then(() => {
|
||||
for (const key of install) {
|
||||
installed.add(key);
|
||||
}
|
||||
fs.writeFileSync(installedFile, Array.from(installed).join('\n'), {encoding: 'utf8'});
|
||||
});
|
||||
}
|
||||
|
||||
activate() {
|
||||
@@ -89,12 +111,16 @@ class Android extends Sdk {
|
||||
});
|
||||
}
|
||||
|
||||
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(' '));
|
||||
}
|
||||
|
||||
@@ -191,6 +217,27 @@ 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';
|
||||
|
||||
@@ -16,6 +16,7 @@ const Platform = {
|
||||
WINDOWS: 'windows',
|
||||
ANDROID: 'android',
|
||||
NEKO: 'neko',
|
||||
CPP: 'cpp',
|
||||
};
|
||||
|
||||
|
||||
@@ -46,6 +47,8 @@ class Config {
|
||||
mobileHeight: null,
|
||||
fps: 60,
|
||||
};
|
||||
this.key = null;
|
||||
this.android = [];
|
||||
if (params) {
|
||||
this.update(params);
|
||||
this.afterUpdate();
|
||||
@@ -68,6 +71,8 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,10 +81,14 @@ class Haxe extends Sdk {
|
||||
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')));
|
||||
@@ -101,7 +105,7 @@ class Haxe extends Sdk {
|
||||
const target = path.resolve(buildDir, platform, 'bin');
|
||||
fse.emptyDirSync(target);
|
||||
const result = {
|
||||
'android': 'app/build/outputs/apk/*-debug.apk',
|
||||
'android': `app/build/outputs/**/${config.meta.filename}-debug.apk`,
|
||||
'flash': '*.swf',
|
||||
}[platform] || '**/*';
|
||||
return this.haxelib(args).then(() => {
|
||||
@@ -116,7 +120,7 @@ class Haxe extends Sdk {
|
||||
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')));
|
||||
@@ -139,11 +143,22 @@ class Haxe extends Sdk {
|
||||
args.push('-debug');
|
||||
}
|
||||
const target = path.resolve(buildDir, platform, 'bin');
|
||||
if (platform !== 'cpp') {
|
||||
fse.emptyDirSync(target);
|
||||
}
|
||||
for (const asset of config.assets) {
|
||||
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) {
|
||||
@@ -198,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';
|
||||
@@ -205,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;
|
||||
|
||||
@@ -100,11 +100,11 @@ 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',
|
||||
'platforms;android-26',
|
||||
'platforms;android-28', //ToDo: lime version 7.6.0 -> 28; 7.0.0 -> 26
|
||||
//'ndk-bundle',
|
||||
'lldb;3.1',
|
||||
'cmake;3.6.4111459',
|
||||
@@ -125,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))));
|
||||
@@ -387,6 +392,19 @@ class LinuxRunner extends Runner {
|
||||
|
||||
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 +464,7 @@ class AndroidRunner extends Runner {
|
||||
|
||||
call() {
|
||||
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.install())
|
||||
.pipe(this.android.start())
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gulp-haxetool",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.7",
|
||||
"description": "HaXe Tool for Gulp",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
|
||||
@@ -23,4 +23,8 @@
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user