feat: add link module
This commit is contained in:
+27
-24
@@ -2,31 +2,47 @@ import fs from "fs";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
import through from "through2";
|
||||
import download from "../common/download";
|
||||
import env from "../common/env";
|
||||
import exec from "../common/exec";
|
||||
import { System } from "../common/system";
|
||||
import { HandlerWriter } from "../common/tail";
|
||||
import { Sdk } from "../core/sdk";
|
||||
import { Command } from "../run/command";
|
||||
|
||||
export class AndroidNdk extends Sdk {
|
||||
static ID = "android-ndk";
|
||||
|
||||
static VERSION_R15C = "r15c";
|
||||
static VERSION_R21E = "r21e";
|
||||
static VERSION = AndroidNdk.VERSION_R21E;
|
||||
|
||||
url = "https://dl.google.com/android/repository/android-ndk-<%= version %>-<%= os_name_long %>-x86_64.zip";
|
||||
|
||||
constructor(version?: string) {
|
||||
super(AndroidNdk.ID, version || AndroidNdk.VERSION);
|
||||
}
|
||||
|
||||
get prepared(): boolean {
|
||||
try {
|
||||
return fs.existsSync(`${this.path}/build/ndk-build`);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class Android extends Sdk {
|
||||
static ID = "android";
|
||||
|
||||
static VERSION_7302050 = "7302050";
|
||||
static VERSION = Android.VERSION_7302050;
|
||||
|
||||
static NDK_VERSION_R15C = "r15c";
|
||||
static NDK_VERSION_R21E = "r21e";
|
||||
static NDK_VERSION = Android.NDK_VERSION_R21E;
|
||||
private ndk: AndroidNdk;
|
||||
|
||||
private ndk_version: string;
|
||||
private repository: string;
|
||||
url = "https://dl.google.com/android/repository/commandlinetools-<%= os_name %>-<%= version %>_latest.zip";
|
||||
|
||||
constructor(version?: string, ndkVersion?: string) {
|
||||
super(Android.ID, version || Android.VERSION);
|
||||
this.ndk_version = ndkVersion || Android.NDK_VERSION;
|
||||
this.repository = "https://dl.google.com/android/repository";
|
||||
this.ndk = new AndroidNdk(ndkVersion);
|
||||
}
|
||||
|
||||
get prepared(): boolean {
|
||||
@@ -37,16 +53,12 @@ export class Android extends Sdk {
|
||||
}
|
||||
}
|
||||
|
||||
get link(): string {
|
||||
return `${this.repository}/commandlinetools-${System.os}-${this.version}_latest.zip`;
|
||||
}
|
||||
|
||||
get android_home(): string {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
get ndk_home(): string {
|
||||
return Sdk.path('android-ndk', this.ndk_version);
|
||||
return this.ndk.path;
|
||||
}
|
||||
|
||||
get sdkmanager_bin(): string {
|
||||
@@ -56,19 +68,10 @@ export class Android extends Sdk {
|
||||
prepare(): Promise<any> {
|
||||
const result = [];
|
||||
result.push(super.prepare(0));
|
||||
if (!fs.existsSync(path.join(this.ndk_home))) {
|
||||
result.push(this.prepare_ndk());
|
||||
}
|
||||
result.push(this.ndk.prepare());
|
||||
return Promise.all(result);
|
||||
}
|
||||
|
||||
prepare_ndk(): Promise<any> {
|
||||
// TODO: support windows
|
||||
const url = `${this.repository}/android-ndk-${this.ndk_version}-${System.os}-x86_64.zip`;
|
||||
this.log.d("download: *%s*", url);
|
||||
return download(url, this.ndk_home, { executable: true });
|
||||
}
|
||||
|
||||
sdkmanager(packages: string[]) {
|
||||
this.log.i("sdkmanager: *%s*", packages.join(", "));
|
||||
const installedFile = path.join(this.path, ".installed");
|
||||
|
||||
Reference in New Issue
Block a user