[android] update
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const exec = require('./exec');
|
||||
const through = require('through2');
|
||||
const Sdk = require('./sdk');
|
||||
@@ -22,24 +23,27 @@ class Android extends Sdk {
|
||||
get link() {
|
||||
const system = Sdk.System.isWindows ? 'windows' : Sdk.System.isLinux ? 'linux' : null;
|
||||
if (!system) throw 'Unsupported system';
|
||||
//return `https://dl.google.com/android/repository/sdk-tools-${system}-${this.version}.zip`;
|
||||
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() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
get ndk_home() {
|
||||
return path.join(this.path, 'ndk-bundle')
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return this.prepared ? Promise.resolve() : super.prepare(0).then(() => {
|
||||
return this.sdkmanager([
|
||||
'ndk-bundle',
|
||||
'tools',
|
||||
'platform-tools',
|
||||
'build-tools;27.0.3',
|
||||
'platforms;android-27',
|
||||
]);
|
||||
});
|
||||
return super.prepare(0);
|
||||
}
|
||||
|
||||
sdkmanager(packages) {
|
||||
const androidBin = `${this.path}/tools/bin/sdkmanager`;
|
||||
const androidBin = path.join(this.path, 'tools/bin/sdkmanager');
|
||||
if (fs.existsSync(androidBin)) {
|
||||
fs.chmodSync(androidBin, 0o755);
|
||||
}
|
||||
@@ -48,11 +52,13 @@ class Android extends Sdk {
|
||||
}
|
||||
|
||||
activate() {
|
||||
Env.set('ANDROID_HOME', this.path);
|
||||
Env.set('ANDROID_HOME', this.android_home);
|
||||
Env.set('ANDROID_NDK_HOME', this.ndk_home);
|
||||
Env.set('NDK_HOME', this.ndk_home);
|
||||
}
|
||||
|
||||
adb(args) {
|
||||
const adbBin = `${this.path}/platform-tools/adb`;
|
||||
const adbBin = path.join(this.path, 'platform-tools/adb');
|
||||
return exec('.', [adbBin].concat(args).join(' ')).then(data => {
|
||||
for (let line of data.stderr.split('\n')) {
|
||||
if (line.indexOf('Error') > -1) {
|
||||
@@ -64,10 +70,10 @@ class Android extends Sdk {
|
||||
|
||||
aapt(args) {
|
||||
let buildToolsVersion = null;
|
||||
fs.readdirSync(`${this.path}/build-tools`).forEach(file => {
|
||||
fs.readdirSync(path.join(this.path, 'build-tools')).forEach(file => {
|
||||
buildToolsVersion = file;
|
||||
});
|
||||
const aaptBin = `${this.path}/build-tools/${buildToolsVersion}/aapt`;
|
||||
const aaptBin = path.join(this.path, 'build-tools', buildToolsVersion, 'aapt');
|
||||
return exec('.', [aaptBin].concat(args).join(' '));
|
||||
}
|
||||
|
||||
@@ -122,6 +128,6 @@ Android.ID = 'android';
|
||||
Android.VERSION_25_2_3 = '25.2.3';
|
||||
Android.VERSION_3859397 = '3859397';
|
||||
|
||||
Android.VERSION = Android.VERSION_25_2_3;
|
||||
Android.VERSION = Android.VERSION_3859397;
|
||||
|
||||
module.exports = Android;
|
||||
|
||||
@@ -6,7 +6,7 @@ const log = require('./log')('exec');
|
||||
const queue = async.queue((task, done) => {
|
||||
log.d('*%s*', task.command);
|
||||
//process.chdir(task.dir);
|
||||
child_process.exec(task.command, {cwd: task.dir, maxBuffer: 1024 * 5000}, (err, stdout, stderr) => {
|
||||
child_process.exec(task.command, {cwd: task.dir, maxBuffer: 1024 * 10000}, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
log.v('!%s!', err);
|
||||
task.failure(stderr || stdout || err);
|
||||
|
||||
@@ -7,6 +7,7 @@ const Haxe = require('./haxe');
|
||||
const FlashPlayer = require('./flashplayer');
|
||||
const Android = require('./android');
|
||||
const Neko = require('./neko');
|
||||
const Env = require('./env');
|
||||
const debug = require('./debug');
|
||||
const webserver = require('gulp-webserver');
|
||||
const run = require('../run/index');
|
||||
@@ -88,19 +89,26 @@ class HaxeBuilder extends Builder {
|
||||
let result = this.haxe.prepare().then(() => this.haxe.install(this.config.libs));
|
||||
if (this.buildSystem === BuildSystem.OPENFL) {
|
||||
if (this.platform === Platform.ANDROID) {
|
||||
result = result.then(() => this.android.prepare()).then(() => this.android.activate());
|
||||
}
|
||||
result = result
|
||||
.then(() => this.android.prepare())
|
||||
.then(() => this.android.activate())
|
||||
.then(() => this.android.sdkmanager([
|
||||
'tools',
|
||||
'platform-tools',
|
||||
'build-tools;27.0.3',
|
||||
'platforms;android-19',
|
||||
'ndk-bundle',
|
||||
'lldb;3.1',
|
||||
'cmake;3.6.4111459',
|
||||
]));
|
||||
const AndroidSDK = this.android.android_home;
|
||||
const AndroidNDK = this.android.ndk_home;
|
||||
const answer = `echo "${[AndroidSDK, AndroidNDK].join('\n')}"`;
|
||||
result = result.then(() => {
|
||||
return exec('.', [
|
||||
'echo',
|
||||
`"${this.android.path}"`,
|
||||
`"${this.android.path + '/ndk-bundle'}"`,
|
||||
'|',
|
||||
this.haxe.haxelibBin, 'run', 'openfl', 'setup', this.platform,
|
||||
].join(' '));
|
||||
//return this.haxe.haxelib(['echo'].concat(answers.map(item => `"${item}"`)).concat(['|', 'run', 'openfl', 'setup', this.platform]));
|
||||
return exec('.', [answer, '|', this.haxe.haxelibBin, 'run', 'openfl', 'setup', this.platform].join(' '));
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user