feat(android): up android sdk version
This commit is contained in:
@@ -12,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() {
|
||||||
@@ -43,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));
|
||||||
@@ -54,7 +53,7 @@ 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);
|
||||||
}
|
}
|
||||||
@@ -76,12 +75,15 @@ class Android extends Sdk {
|
|||||||
if (install.size === 0) {
|
if (install.size === 0) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
const androidBin = path.join(this.path, 'tools/bin/sdkmanager');
|
const sdkmanagerBin = this.sdkmanager_bin;
|
||||||
if (fs.existsSync(androidBin)) {
|
if (fs.existsSync(sdkmanagerBin)) {
|
||||||
fs.chmodSync(androidBin, 0o755);
|
fs.chmodSync(sdkmanagerBin, 0o755);
|
||||||
}
|
}
|
||||||
const yes = '(while sleep 3; do echo "y"; done)';
|
const yes = '(while sleep 3; do echo "y"; done)';
|
||||||
const command = [yes, '|', androidBin].concat(Array.from(install).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(() => {
|
return exec('.', command).then(() => {
|
||||||
for (const key of install) {
|
for (const key of install) {
|
||||||
installed.add(key);
|
installed.add(key);
|
||||||
@@ -180,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(() => {
|
||||||
this.push(file);
|
// ToDo: kludge: delay before start
|
||||||
callback();
|
setTimeout(() => {
|
||||||
|
this.push(file);
|
||||||
|
callback();
|
||||||
|
}, 500);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -242,10 +247,10 @@ class Android extends Sdk {
|
|||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class HaxeBuilder extends Builder {
|
|||||||
'build-tools;27.0.3',
|
'build-tools;27.0.3',
|
||||||
'platforms;android-28', //ToDo: lime version 7.6.0 -> 28; 7.0.0 -> 26
|
'platforms;android-28', //ToDo: lime version 7.6.0 -> 28; 7.0.0 -> 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;
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-haxetool",
|
"name": "gulp-haxetool",
|
||||||
"version": "0.1.8",
|
"version": "0.1.9",
|
||||||
"description": "HaXe Tool for Gulp",
|
"description": "HaXe Tool for Gulp",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user