@aiot-toolkit/emulator 2.0.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/lib/avd/index.d.ts +12 -0
- package/lib/avd/index.js +146 -0
- package/lib/avd/index.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +28 -0
- package/lib/index.js.map +1 -0
- package/lib/instance/goldfish.d.ts +35 -0
- package/lib/instance/goldfish.js +312 -0
- package/lib/instance/goldfish.js.map +1 -0
- package/lib/static/avdConfigIni.json +39 -0
- package/lib/static/constants.d.ts +7 -0
- package/lib/static/constants.js +17 -0
- package/lib/static/constants.js.map +1 -0
- package/lib/typing/Avd.d.ts +22 -0
- package/lib/typing/Avd.js +10 -0
- package/lib/typing/Avd.js.map +1 -0
- package/lib/typing/Instance.d.ts +10 -0
- package/lib/typing/Instance.js +4 -0
- package/lib/typing/Instance.js.map +1 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IAvdParams, IAvdResourcePaths } from '../typing/Avd';
|
|
2
|
+
declare class VelaAvdCls {
|
|
3
|
+
private avdHome;
|
|
4
|
+
private sdkHome;
|
|
5
|
+
constructor(avdResourcePaths: IAvdResourcePaths);
|
|
6
|
+
createVelaAvd(avdParams: IAvdParams): boolean;
|
|
7
|
+
getVelaAvdInfo(avdName: string): IAvdParams;
|
|
8
|
+
deleteVelaAvd(avdName: string): boolean;
|
|
9
|
+
getVelaAvdList(): IAvdParams[];
|
|
10
|
+
getVelaSkinList(): string[];
|
|
11
|
+
}
|
|
12
|
+
export default VelaAvdCls;
|
package/lib/avd/index.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const constants_1 = require("../static/constants");
|
|
9
|
+
const Avd_1 = require("../typing/Avd");
|
|
10
|
+
const EAvdParamsToIni = {
|
|
11
|
+
'arm': {
|
|
12
|
+
abiType: 'armeabi-v7a',
|
|
13
|
+
},
|
|
14
|
+
'arm64': {
|
|
15
|
+
abiType: 'arm64-v8a',
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
class VelaAvdCls {
|
|
19
|
+
constructor(avdResourcePaths) {
|
|
20
|
+
const { avdHome, sdkHome } = avdResourcePaths;
|
|
21
|
+
this.avdHome = avdHome || constants_1.defaultAvdHome;
|
|
22
|
+
this.sdkHome = sdkHome || constants_1.defaultSDKHome;
|
|
23
|
+
}
|
|
24
|
+
createVelaAvd(avdParams) {
|
|
25
|
+
const { avdName, avdArch, avdWidth, avdHeight, avdSkin, avdImagePath = constants_1.defaultImageHome } = avdParams;
|
|
26
|
+
const avdDir = path_1.default.resolve(this.avdHome, `${avdName}.avd`);
|
|
27
|
+
const avdIni = path_1.default.resolve(this.avdHome, `${avdName}.ini`);
|
|
28
|
+
const avdConfigIni = path_1.default.resolve(avdDir, 'config.ini');
|
|
29
|
+
const nuttxAvdIniContent = `path=${avdDir}\npath.rel=avd${path_1.default.sep}${avdName}.avd`;
|
|
30
|
+
const abiType = EAvdParamsToIni[avdArch]['abiType'];
|
|
31
|
+
const configIniJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../static/avdConfigIni.json'), 'utf-8'));
|
|
32
|
+
configIniJson['AvdId'] = avdName;
|
|
33
|
+
configIniJson['abi.type'] = abiType;
|
|
34
|
+
configIniJson['avd.ini.displayname'] = avdName;
|
|
35
|
+
configIniJson['hw.cpu.arch'] = avdArch;
|
|
36
|
+
if (avdSkin) {
|
|
37
|
+
delete configIniJson['hw.lcd.height'];
|
|
38
|
+
delete configIniJson['hw.lcd.width'];
|
|
39
|
+
configIniJson['skin.dynamic'] = 'yes';
|
|
40
|
+
configIniJson['skin.name'] = avdSkin;
|
|
41
|
+
configIniJson['skin.path'] = path_1.default.resolve(this.sdkHome, 'skins', avdSkin);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
configIniJson['hw.lcd.height'] = avdHeight;
|
|
45
|
+
configIniJson['hw.lcd.width'] = avdWidth;
|
|
46
|
+
configIniJson['skin.dynamic'] = 'no';
|
|
47
|
+
delete configIniJson['skin.name'];
|
|
48
|
+
delete configIniJson['skin.path'];
|
|
49
|
+
}
|
|
50
|
+
configIniJson['image.sysdir.1'] = avdImagePath;
|
|
51
|
+
try {
|
|
52
|
+
fs_1.default.mkdirSync(avdDir, { recursive: true });
|
|
53
|
+
// 写入Vela_Virtual_Device.ini文件
|
|
54
|
+
fs_1.default.writeFileSync(avdIni, nuttxAvdIniContent);
|
|
55
|
+
// 写入Vela_Virtual_Device.avd/config.ini文件
|
|
56
|
+
const fWrite = fs_1.default.createWriteStream(avdConfigIni);
|
|
57
|
+
for (const item in configIniJson) {
|
|
58
|
+
const line = `${item} = ${configIniJson[item]}\n`;
|
|
59
|
+
fWrite.write(line);
|
|
60
|
+
}
|
|
61
|
+
fWrite.close();
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
getVelaAvdInfo(avdName) {
|
|
69
|
+
const avdInfo = {
|
|
70
|
+
avdName,
|
|
71
|
+
avdArch: Avd_1.IAvdArchType.arm,
|
|
72
|
+
avdHeight: '',
|
|
73
|
+
avdWidth: '',
|
|
74
|
+
avdSkin: '',
|
|
75
|
+
avdImagePath: ''
|
|
76
|
+
};
|
|
77
|
+
const currAvdDir = path_1.default.resolve(this.avdHome, `${avdName}.avd`);
|
|
78
|
+
const configIni = path_1.default.resolve(currAvdDir, 'config.ini');
|
|
79
|
+
const contents = fs_1.default.readFileSync(configIni, 'utf-8');
|
|
80
|
+
// 这里需要使用惰性匹配
|
|
81
|
+
const archRegex = /hw.cpu.arch = ([\d\D]+?)\n/;
|
|
82
|
+
const archMatcher = contents.match(archRegex);
|
|
83
|
+
const heightRegex = /hw.lcd.height = ([\d\D]+?)\n/;
|
|
84
|
+
const heightMatcher = contents.match(heightRegex);
|
|
85
|
+
const widthRegex = /hw.lcd.width = ([\d\D]+?)\n/;
|
|
86
|
+
const widthMatcher = contents.match(widthRegex);
|
|
87
|
+
const skinRegex = /skin.name = ([\d\D]+?)\n/;
|
|
88
|
+
const skinMatcher = contents.match(skinRegex);
|
|
89
|
+
const imagePathRegex = /image.sysdir.1 = ([\d\D]+?)\n/;
|
|
90
|
+
const imagePathMather = contents.match(imagePathRegex);
|
|
91
|
+
archMatcher && (avdInfo.avdArch = archMatcher[1]);
|
|
92
|
+
heightMatcher && (avdInfo.avdHeight = heightMatcher[1]);
|
|
93
|
+
widthMatcher && (avdInfo.avdWidth = widthMatcher[1]);
|
|
94
|
+
skinMatcher && (avdInfo.avdSkin = skinMatcher[1]);
|
|
95
|
+
imagePathMather && (avdInfo.avdImagePath = imagePathMather[1]);
|
|
96
|
+
return avdInfo;
|
|
97
|
+
}
|
|
98
|
+
deleteVelaAvd(avdName) {
|
|
99
|
+
const avdDir = path_1.default.resolve(this.avdHome, `${avdName}.avd`);
|
|
100
|
+
const avdIni = path_1.default.resolve(this.avdHome, `${avdName}.ini`);
|
|
101
|
+
try {
|
|
102
|
+
fs_1.default.rmSync(avdDir, { recursive: true, force: true });
|
|
103
|
+
fs_1.default.rmSync(avdIni, { force: true });
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
getVelaAvdList() {
|
|
111
|
+
try {
|
|
112
|
+
const avdList = [];
|
|
113
|
+
const files = fs_1.default.readdirSync(constants_1.defaultAvdHome);
|
|
114
|
+
const regex = /^(Vela[\d\D]*)\.avd$/;
|
|
115
|
+
for (const fileName of files) {
|
|
116
|
+
const matcher = fileName.match(regex);
|
|
117
|
+
if (matcher) {
|
|
118
|
+
const avdName = matcher[1];
|
|
119
|
+
const avdInfo = this.getVelaAvdInfo(avdName);
|
|
120
|
+
avdList.push(avdInfo);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return avdList;
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
getVelaSkinList() {
|
|
130
|
+
try {
|
|
131
|
+
const skinList = [];
|
|
132
|
+
const skinHome = path_1.default.resolve(this.sdkHome, 'skins');
|
|
133
|
+
let files = fs_1.default.readdirSync(skinHome);
|
|
134
|
+
for (const fileName of files) {
|
|
135
|
+
!fileName.startsWith('.') && skinList.push(fileName);
|
|
136
|
+
}
|
|
137
|
+
return skinList;
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.default = VelaAvdCls;
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["avd/index.ts"],"names":[],"mappings":";;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,mDAAsF;AACtF,uCAA2E;AAE3E,MAAM,eAAe,GAAG;IACpB,KAAK,EAAE;QACH,OAAO,EAAE,aAAa;KACzB;IACD,OAAO,EAAE;QACL,OAAO,EAAE,WAAW;KACvB;CACJ,CAAA;AAED,MAAM,UAAU;IAIZ,YAAY,gBAAmC;QAC3C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAA;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,0BAAc,CAAA;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,0BAAc,CAAA;IAC5C,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,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE;gBAC1B,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;aACvD;YACD,OAAO,QAAQ,CAAA;SAClB;QAAC,OAAO,CAAC,EAAE;YACR,OAAO,EAAE,CAAA;SACZ;IACL,CAAC;CACJ;AAED,kBAAe,UAAU,CAAA","file":"index.js","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport { defaultAvdHome, defaultImageHome, defaultSDKHome } from '../static/constants'\nimport { IAvdArchType, IAvdParams, IAvdResourcePaths } from '../typing/Avd'\n\nconst EAvdParamsToIni = {\n 'arm': {\n abiType: 'armeabi-v7a',\n },\n 'arm64': {\n abiType: 'arm64-v8a',\n }\n}\n\nclass VelaAvdCls {\n private avdHome: string\n private sdkHome: string\n\n constructor(avdResourcePaths: IAvdResourcePaths) {\n const { avdHome, sdkHome } = avdResourcePaths\n this.avdHome = avdHome || defaultAvdHome\n this.sdkHome = sdkHome || defaultSDKHome\n }\n\n createVelaAvd(avdParams: IAvdParams) {\n const { avdName, avdArch, avdWidth, avdHeight, avdSkin, avdImagePath = defaultImageHome } = avdParams\n const avdDir = path.resolve(this.avdHome, `${avdName}.avd`)\n const avdIni = path.resolve(this.avdHome, `${avdName}.ini`)\n const avdConfigIni = path.resolve(avdDir, 'config.ini')\n const nuttxAvdIniContent = `path=${avdDir}\\npath.rel=avd${path.sep}${avdName}.avd`\n const abiType = EAvdParamsToIni[avdArch]['abiType']\n const configIniJson: any = JSON.parse(fs.readFileSync(path.join(__dirname, '../static/avdConfigIni.json'), 'utf-8'))\n configIniJson['AvdId'] = avdName\n configIniJson['abi.type'] = abiType\n configIniJson['avd.ini.displayname'] = avdName\n configIniJson['hw.cpu.arch'] = avdArch\n if (avdSkin) {\n delete configIniJson['hw.lcd.height']\n delete configIniJson['hw.lcd.width']\n configIniJson['skin.dynamic'] = 'yes'\n configIniJson['skin.name'] = avdSkin\n configIniJson['skin.path'] = path.resolve(this.sdkHome, 'skins', avdSkin)\n } else {\n configIniJson['hw.lcd.height'] = avdHeight\n configIniJson['hw.lcd.width'] = avdWidth\n configIniJson['skin.dynamic'] = 'no'\n delete configIniJson['skin.name']\n delete configIniJson['skin.path']\n }\n configIniJson['image.sysdir.1'] = avdImagePath\n try {\n fs.mkdirSync(avdDir, { recursive: true })\n // 写入Vela_Virtual_Device.ini文件\n fs.writeFileSync(avdIni, nuttxAvdIniContent)\n // 写入Vela_Virtual_Device.avd/config.ini文件\n const fWrite = fs.createWriteStream(avdConfigIni)\n for (const item in configIniJson) {\n const line = `${item} = ${configIniJson[item]}\\n`\n fWrite.write(line);\n }\n fWrite.close();\n return true\n } catch (e) {\n return false\n }\n }\n\n getVelaAvdInfo(avdName: string) {\n const avdInfo: IAvdParams = {\n avdName,\n avdArch: IAvdArchType.arm,\n avdHeight: '',\n avdWidth: '',\n avdSkin: '',\n avdImagePath: ''\n }\n const currAvdDir = path.resolve(this.avdHome, `${avdName}.avd`)\n const configIni = path.resolve(currAvdDir, 'config.ini')\n const contents = fs.readFileSync(configIni, 'utf-8')\n // 这里需要使用惰性匹配\n const archRegex = /hw.cpu.arch = ([\\d\\D]+?)\\n/\n const archMatcher = contents.match(archRegex)\n const heightRegex = /hw.lcd.height = ([\\d\\D]+?)\\n/\n const heightMatcher = contents.match(heightRegex)\n const widthRegex = /hw.lcd.width = ([\\d\\D]+?)\\n/\n const widthMatcher = contents.match(widthRegex)\n const skinRegex = /skin.name = ([\\d\\D]+?)\\n/\n const skinMatcher = contents.match(skinRegex)\n const imagePathRegex = /image.sysdir.1 = ([\\d\\D]+?)\\n/\n const imagePathMather = contents.match(imagePathRegex)\n archMatcher && (avdInfo.avdArch = (archMatcher[1] as IAvdArchType))\n heightMatcher && (avdInfo.avdHeight = heightMatcher[1])\n widthMatcher && (avdInfo.avdWidth = widthMatcher[1])\n skinMatcher && (avdInfo.avdSkin = skinMatcher[1])\n imagePathMather && (avdInfo.avdImagePath = imagePathMather[1])\n return avdInfo\n }\n\n deleteVelaAvd(avdName: string) {\n const avdDir = path.resolve(this.avdHome, `${avdName}.avd`)\n const avdIni = path.resolve(this.avdHome, `${avdName}.ini`);\n try {\n fs.rmSync(avdDir, { recursive: true, force: true });\n fs.rmSync(avdIni, { force: true })\n return true\n } catch (e) {\n return false\n }\n }\n\n getVelaAvdList() {\n try {\n const avdList: IAvdParams[] = [];\n const files = fs.readdirSync(defaultAvdHome);\n const regex = /^(Vela[\\d\\D]*)\\.avd$/;\n for (const fileName of files) {\n const matcher = fileName.match(regex);\n if (matcher) {\n const avdName = matcher[1];\n const avdInfo = this.getVelaAvdInfo(avdName);\n avdList.push(avdInfo);\n }\n }\n return avdList;\n } catch (err) {\n return [];\n }\n }\n\n getVelaSkinList() {\n try {\n const skinList = []\n const skinHome = path.resolve(this.sdkHome, 'skins')\n let files = fs.readdirSync(skinHome)\n for (const fileName of files) {\n !fileName.startsWith('.') && skinList.push(fileName)\n }\n return skinList\n } catch (e) {\n return []\n }\n }\n}\n\nexport default VelaAvdCls\n"],"sourceRoot":"../../src"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.VelaAvdCls = exports.GoldfishInstance = void 0;
|
|
21
|
+
const avd_1 = __importDefault(require("./avd"));
|
|
22
|
+
Object.defineProperty(exports, "VelaAvdCls", { enumerable: true, get: function () { return avd_1.default; } });
|
|
23
|
+
const goldfish_1 = __importDefault(require("./instance/goldfish"));
|
|
24
|
+
Object.defineProperty(exports, "GoldfishInstance", { enumerable: true, get: function () { return goldfish_1.default; } });
|
|
25
|
+
__exportStar(require("./typing/Avd"), exports);
|
|
26
|
+
__exportStar(require("./typing/Instance"), exports);
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,gDAA8C;AAM1B,2FANA,aAAU,OAMA;AAL9B,mEAAkE;AAKhE,iGALkB,kBAAgB,OAKlB;AAJlB,+CAA6B;AAC7B,oDAAkC","file":"index.js","sourcesContent":["import { default as VelaAvdCls } from './avd';\nimport { default as GoldfishInstance } from './instance/goldfish';\nexport * from './typing/Avd';\nexport * from './typing/Instance';\n\nexport {\n GoldfishInstance, VelaAvdCls\n};\n\n"],"sourceRoot":"../src"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ChildProcess } from 'child_process';
|
|
3
|
+
import { INewGoldfishInstanceParams, IStartOptions } from '../typing/Instance';
|
|
4
|
+
declare class GoldfishInstance {
|
|
5
|
+
private projectPath;
|
|
6
|
+
private sdkHome;
|
|
7
|
+
private avdHome;
|
|
8
|
+
private adbPort;
|
|
9
|
+
debugPort: number;
|
|
10
|
+
private host9pPort;
|
|
11
|
+
private velaAvdCls;
|
|
12
|
+
private packageName;
|
|
13
|
+
goldfishProcess: ChildProcess | undefined;
|
|
14
|
+
v9fsProcess: ChildProcess | undefined;
|
|
15
|
+
constructor(params: INewGoldfishInstanceParams);
|
|
16
|
+
/** 获取模拟器二进制文件所在位置 */
|
|
17
|
+
getEmulatorBinPath(): string;
|
|
18
|
+
/** 在goldfish模拟器中运行快应用 */
|
|
19
|
+
start(options: IStartOptions): Promise<void>;
|
|
20
|
+
/** 在goldfish中启动快应用 */
|
|
21
|
+
startupQuickApp(options: IStartOptions): void;
|
|
22
|
+
/** host启动9pServer */
|
|
23
|
+
ensure9pServerRunnning(): Promise<void>;
|
|
24
|
+
/** 启动goldfish模拟器 */
|
|
25
|
+
startGoldfish(options: IStartOptions): Promise<void>;
|
|
26
|
+
/** 通过adb连接模拟器 */
|
|
27
|
+
connectGoldfish(): Promise<boolean>;
|
|
28
|
+
/** 将打包后的文件推到挂载的快应用目录 */
|
|
29
|
+
pushRpk(): void;
|
|
30
|
+
/** 杀死进程 */
|
|
31
|
+
killProcess(currProcess?: ChildProcess): void;
|
|
32
|
+
/** 停止模拟器并释放相关资源 */
|
|
33
|
+
stop(): void;
|
|
34
|
+
}
|
|
35
|
+
export default GoldfishInstance;
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
const UxFileUtils_1 = __importDefault(require("@aiot-toolkit/aiotpack/lib/utils/ux/UxFileUtils"));
|
|
39
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
40
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
41
|
+
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
42
|
+
const adbMiwt = __importStar(require("@miwt/adb"));
|
|
43
|
+
const child_process_1 = require("child_process");
|
|
44
|
+
const find_process_1 = __importDefault(require("find-process"));
|
|
45
|
+
const fs_1 = __importDefault(require("fs"));
|
|
46
|
+
const os_1 = __importDefault(require("os"));
|
|
47
|
+
const path_1 = __importDefault(require("path"));
|
|
48
|
+
const portfinder_1 = __importDefault(require("portfinder"));
|
|
49
|
+
const avd_1 = __importDefault(require("../avd"));
|
|
50
|
+
const constants_1 = require("../static/constants");
|
|
51
|
+
class GoldfishInstance {
|
|
52
|
+
constructor(params) {
|
|
53
|
+
this.adbPort = 15555;
|
|
54
|
+
this.debugPort = 10055;
|
|
55
|
+
this.host9pPort = 7878;
|
|
56
|
+
this.projectPath = params.projectPath;
|
|
57
|
+
this.sdkHome = params.sdkHome || constants_1.defaultSDKHome;
|
|
58
|
+
this.avdHome = params.avdHome || constants_1.defaultAvdHome;
|
|
59
|
+
this.velaAvdCls = new avd_1.default({
|
|
60
|
+
sdkHome: this.sdkHome,
|
|
61
|
+
avdHome: this.avdHome
|
|
62
|
+
});
|
|
63
|
+
const { package: appPackageName } = UxFileUtils_1.default.getMainfestInfo(this.projectPath, params.sourceRoot);
|
|
64
|
+
this.packageName = appPackageName;
|
|
65
|
+
}
|
|
66
|
+
/** 获取模拟器二进制文件所在位置 */
|
|
67
|
+
getEmulatorBinPath() {
|
|
68
|
+
const osPlatform = os_1.default.platform();
|
|
69
|
+
const osArch = os_1.default.arch();
|
|
70
|
+
const platform = osPlatform === 'win32' ? 'windows' : osPlatform;
|
|
71
|
+
const arch = (osArch === 'arm64' || osArch === 'aarch64') ? 'aarch64' : 'x86_64';
|
|
72
|
+
return path_1.default.resolve(constants_1.defaultEmulatorHome, `${platform}-${arch}`, 'emulator');
|
|
73
|
+
}
|
|
74
|
+
/** 在goldfish模拟器中运行快应用 */
|
|
75
|
+
start(options) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
// host启动9p server
|
|
78
|
+
yield this.ensure9pServerRunnning();
|
|
79
|
+
// TODO: 打包快应用
|
|
80
|
+
// 将rpk推到host的defaultQuickappHome目录
|
|
81
|
+
this.pushRpk();
|
|
82
|
+
// 启动模拟器
|
|
83
|
+
yield this.startGoldfish(options);
|
|
84
|
+
const connected = yield this.connectGoldfish();
|
|
85
|
+
if (connected) {
|
|
86
|
+
ColorConsole_1.default.log({
|
|
87
|
+
message: '### Emulator ### Goldfish emulator connected successfully'
|
|
88
|
+
});
|
|
89
|
+
// 在模拟器中启动快应用
|
|
90
|
+
this.startupQuickApp(options);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
ColorConsole_1.default.log({
|
|
94
|
+
level: shared_utils_1.LOG_LEVEL.Error,
|
|
95
|
+
message: '### Emulator ### Failed to connect emulator, please check whether the adb is normal'
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/** 在goldfish中启动快应用 */
|
|
101
|
+
startupQuickApp(options) {
|
|
102
|
+
try {
|
|
103
|
+
const appMountDir = path_1.default.resolve(this.sdkHome, 'qa');
|
|
104
|
+
const mountCmd = `adb -s 127.0.0.1:${this.adbPort} shell mount -t v9fs -o tag=10.0.2.2,port=${this.host9pPort},aname=${appMountDir} /data`;
|
|
105
|
+
ColorConsole_1.default.log({ message: `### Emulator ### Excuting adb cmd: ${mountCmd}` });
|
|
106
|
+
adbMiwt.execAdbCmdSync(mountCmd);
|
|
107
|
+
let vappCmd = `adb -s 127.0.0.1:${this.adbPort} shell vapp app/${this.packageName} &`;
|
|
108
|
+
if (options.devtool) {
|
|
109
|
+
vappCmd = `adb -s 127.0.0.1:${this.adbPort} shell vapp --jsdebugger=10.0.2.15:101 app/${this.packageName} &`;
|
|
110
|
+
}
|
|
111
|
+
ColorConsole_1.default.log({ message: `### Emulator ### Excuting adb cmd: ${vappCmd}` });
|
|
112
|
+
// vapp进程会一直pending,不会退出。这里必须加stdio: 'ignore',否则快应用无法运行成功
|
|
113
|
+
adbMiwt.execAdbCmdAsync(vappCmd, { stdio: 'ignore', encoding: 'utf-8' });
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
ColorConsole_1.default.log({
|
|
117
|
+
level: shared_utils_1.LOG_LEVEL.Error,
|
|
118
|
+
message: `### Emulator ### Failed to startup quickapp: ${e.message}`,
|
|
119
|
+
isOnlyPrintError: true
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/** host启动9pServer */
|
|
124
|
+
ensure9pServerRunnning() {
|
|
125
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
var _a;
|
|
127
|
+
const yaFileName = os_1.default.platform() === 'win32' ? 'ya-vm-file-server.exe' : 'ya-vm-file-server';
|
|
128
|
+
const pidList = yield (0, find_process_1.default)('name', yaFileName);
|
|
129
|
+
if (pidList.length > 0) {
|
|
130
|
+
ColorConsole_1.default.log({ message: '### Emulator ### 9p server started in host' });
|
|
131
|
+
return resolve();
|
|
132
|
+
}
|
|
133
|
+
ColorConsole_1.default.log({ message: '### Emulator ### Starting 9p server in host' });
|
|
134
|
+
const quickappMountDir = path_1.default.resolve(this.sdkHome, 'qa');
|
|
135
|
+
const serverBinPath = path_1.default.resolve(constants_1.defaultToolsHome, yaFileName);
|
|
136
|
+
fs_1.default.chmodSync(serverBinPath, 0o777);
|
|
137
|
+
this.host9pPort = yield portfinder_1.default.getPortPromise({ port: 7878 });
|
|
138
|
+
const address = `127.0.0.1:${this.host9pPort}`;
|
|
139
|
+
this.v9fsProcess = (0, child_process_1.spawn)(serverBinPath, [
|
|
140
|
+
'--mount-point',
|
|
141
|
+
quickappMountDir,
|
|
142
|
+
'--network-address',
|
|
143
|
+
address,
|
|
144
|
+
'--debug'
|
|
145
|
+
]);
|
|
146
|
+
(_a = this.v9fsProcess.stderr) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
|
|
147
|
+
const output = data.toString();
|
|
148
|
+
if (output.match(/Server started, listening on: 127.0.0.1:(\d+)/)) {
|
|
149
|
+
ColorConsole_1.default.log({ message: output });
|
|
150
|
+
ColorConsole_1.default.log({ message: '### Emulator ### 9p server starts successfully' });
|
|
151
|
+
return resolve();
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
this.v9fsProcess.on('exit', (code) => {
|
|
155
|
+
ColorConsole_1.default.log({
|
|
156
|
+
level: shared_utils_1.LOG_LEVEL.Error,
|
|
157
|
+
message: `### Emulator ### ya-vm-file-server exited with code ${code}`,
|
|
158
|
+
isOnlyPrintError: true
|
|
159
|
+
});
|
|
160
|
+
return reject();
|
|
161
|
+
});
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
/** 启动goldfish模拟器 */
|
|
165
|
+
startGoldfish(options) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
const { avdName, devtool } = options;
|
|
168
|
+
const emulatorBin = this.getEmulatorBinPath();
|
|
169
|
+
ColorConsole_1.default.log({ message: `### Emulator ### emulator path: ${emulatorBin}` });
|
|
170
|
+
const avdInfo = this.velaAvdCls.getVelaAvdInfo(avdName);
|
|
171
|
+
const { avdArch, avdImagePath } = avdInfo;
|
|
172
|
+
this.adbPort = yield portfinder_1.default.getPortPromise({ port: this.adbPort });
|
|
173
|
+
ColorConsole_1.default.log({ message: `### Emulator ### adb port: ${this.adbPort}` });
|
|
174
|
+
if (!avdImagePath) {
|
|
175
|
+
ColorConsole_1.default.log({
|
|
176
|
+
level: shared_utils_1.LOG_LEVEL.Error,
|
|
177
|
+
message: `### Emulator ### Unable to find vela image via avd`
|
|
178
|
+
});
|
|
179
|
+
process.exit();
|
|
180
|
+
}
|
|
181
|
+
const nuttxBinPath = path_1.default.resolve(avdImagePath, 'nuttx');
|
|
182
|
+
ColorConsole_1.default.log({ message: `### Emulator ### nuttx path: ${nuttxBinPath}` });
|
|
183
|
+
let portMappingStr = `user,id=u1,hostfwd=tcp:127.0.0.1:${this.adbPort}-10.0.2.15:5555`;
|
|
184
|
+
if (devtool) {
|
|
185
|
+
this.debugPort = yield portfinder_1.default.getPortPromise({ port: this.debugPort });
|
|
186
|
+
ColorConsole_1.default.log({ message: `### Emulator ### debug port: ${this.debugPort}` });
|
|
187
|
+
portMappingStr += `,hostfwd=tcp:127.0.0.1:${this.debugPort}-10.0.2.15:101`;
|
|
188
|
+
}
|
|
189
|
+
ColorConsole_1.default.log({ message: `### Emulator ### Start qemu with TCP: ${portMappingStr}` });
|
|
190
|
+
const stdioType = options.disableNSH ? 'pipe' : 'inherit';
|
|
191
|
+
return new Promise((resolve) => {
|
|
192
|
+
var _a, _b;
|
|
193
|
+
this.goldfishProcess = (0, child_process_1.spawn)(emulatorBin, [
|
|
194
|
+
'-nuttx',
|
|
195
|
+
'-avd',
|
|
196
|
+
avdName,
|
|
197
|
+
'-avd-arch',
|
|
198
|
+
avdArch,
|
|
199
|
+
'-show-kernel',
|
|
200
|
+
'-kernel',
|
|
201
|
+
nuttxBinPath,
|
|
202
|
+
'-qemu',
|
|
203
|
+
'-netdev',
|
|
204
|
+
portMappingStr,
|
|
205
|
+
'-device',
|
|
206
|
+
'virtio-net-device,netdev=u1,bus=virtio-mmio-bus.3'
|
|
207
|
+
], { stdio: stdioType });
|
|
208
|
+
if (options.disableNSH) {
|
|
209
|
+
(_a = this.goldfishProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
|
|
210
|
+
console.log(data.toString());
|
|
211
|
+
if (data.toString().includes('(NSH)')) {
|
|
212
|
+
ColorConsole_1.default.log({ message: `### Emulator ### Goldfish emulator starts successfully` });
|
|
213
|
+
resolve();
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
(_b = this.goldfishProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
|
|
217
|
+
console.log(data.toString());
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
setTimeout(() => {
|
|
222
|
+
ColorConsole_1.default.log({ message: `### Emulator ### Goldfish emulator starts successfully` });
|
|
223
|
+
resolve();
|
|
224
|
+
}, 2000);
|
|
225
|
+
}
|
|
226
|
+
this.goldfishProcess.on('exit', (code) => {
|
|
227
|
+
ColorConsole_1.default.log({
|
|
228
|
+
level: shared_utils_1.LOG_LEVEL.Error,
|
|
229
|
+
message: `### Emulator ### Goldfish emulator exited with code ${code}`,
|
|
230
|
+
isOnlyPrintError: true
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
/** 通过adb连接模拟器 */
|
|
237
|
+
connectGoldfish() {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
+
let adbConnected = false;
|
|
240
|
+
const connectFn = () => __awaiter(this, void 0, void 0, function* () {
|
|
241
|
+
const sn = `127.0.0.1:${this.adbPort}`;
|
|
242
|
+
while (!adbConnected) {
|
|
243
|
+
const adbKillCmd = `adb kill-server`;
|
|
244
|
+
ColorConsole_1.default.log({ message: `### Emulator ### Excuting adb cmd: ${adbKillCmd}` });
|
|
245
|
+
adbMiwt.execAdbCmdSync(adbKillCmd);
|
|
246
|
+
const adbConnectCmd = `adb connect ${sn}`;
|
|
247
|
+
ColorConsole_1.default.log({ message: `### Emulator ### Excuting adb cmd: ${adbConnectCmd}` });
|
|
248
|
+
const str = adbMiwt.execAdbCmdSync(adbConnectCmd);
|
|
249
|
+
ColorConsole_1.default.log({ message: `### Emulator ### ${str}` });
|
|
250
|
+
const devices = yield adbMiwt.getAdbDevices();
|
|
251
|
+
ColorConsole_1.default.log({ message: `### Emulator ### adb devices: ${JSON.stringify(devices)}` });
|
|
252
|
+
adbConnected =
|
|
253
|
+
devices.filter((item) => item.sn === sn && item.status === 'device').length > 0;
|
|
254
|
+
}
|
|
255
|
+
Promise.resolve(adbConnected);
|
|
256
|
+
});
|
|
257
|
+
yield Promise.race([
|
|
258
|
+
connectFn(),
|
|
259
|
+
new Promise((resolve) => {
|
|
260
|
+
setTimeout(() => resolve(false), 600 * 1000);
|
|
261
|
+
})
|
|
262
|
+
]);
|
|
263
|
+
return adbConnected;
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
/** 将打包后的文件推到挂载的快应用目录 */
|
|
267
|
+
pushRpk() {
|
|
268
|
+
const buildDir = path_1.default.resolve(this.projectPath, 'build');
|
|
269
|
+
const { package: appPackageName } = UxFileUtils_1.default.getMainfestInfo(this.projectPath);
|
|
270
|
+
const appRunDir = path_1.default.resolve(this.sdkHome, 'qa/app', appPackageName);
|
|
271
|
+
ColorConsole_1.default.log({ message: `### Emulator ### Pushing ${appPackageName} to ${appRunDir}` });
|
|
272
|
+
fs_1.default.rmSync(appRunDir, { recursive: true, force: true });
|
|
273
|
+
FileUtil_1.default.copyFiles(buildDir, appRunDir);
|
|
274
|
+
ColorConsole_1.default.log({
|
|
275
|
+
message: `### Emulator ### Push ${appPackageName} to ${appRunDir} successfully`
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
/** 杀死进程 */
|
|
279
|
+
killProcess(currProcess) {
|
|
280
|
+
if (currProcess && currProcess.pid && currProcess.exitCode === null) {
|
|
281
|
+
console.log('process pid:', currProcess.pid);
|
|
282
|
+
try {
|
|
283
|
+
if (os_1.default.platform() === 'win32') {
|
|
284
|
+
(0, child_process_1.execSync)(`taskkill /pid ${currProcess.pid} /T /F`);
|
|
285
|
+
}
|
|
286
|
+
else if (os_1.default.platform() === 'darwin') {
|
|
287
|
+
process.kill(currProcess.pid);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
currProcess.kill();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
catch (err) {
|
|
294
|
+
ColorConsole_1.default.log({ message: `kill process get error :\n${err.stack}` });
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/** 停止模拟器并释放相关资源 */
|
|
299
|
+
stop() {
|
|
300
|
+
if (this.goldfishProcess) {
|
|
301
|
+
this.killProcess(this.goldfishProcess);
|
|
302
|
+
this.goldfishProcess = undefined;
|
|
303
|
+
}
|
|
304
|
+
if (this.v9fsProcess) {
|
|
305
|
+
this.killProcess(this.v9fsProcess);
|
|
306
|
+
this.v9fsProcess = undefined;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
exports.default = GoldfishInstance;
|
|
311
|
+
|
|
312
|
+
//# sourceMappingURL=goldfish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["instance/goldfish.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kGAAyE;AACzE,6DAAsD;AACtD,+FAAsE;AACtE,6FAAoE;AACpE,mDAAoC;AACpC,iDAA6D;AAC7D,gEAAsC;AACtC,4CAAmB;AACnB,4CAAmB;AACnB,gDAAuB;AACvB,4DAAmC;AACnC,iDAA+B;AAC/B,mDAK4B;AAG5B,MAAM,gBAAgB;IAYpB,YAAY,MAAkC;QARtC,YAAO,GAAW,KAAK,CAAA;QACxB,cAAS,GAAW,KAAK,CAAA;QACxB,eAAU,GAAW,IAAI,CAAA;QAO/B,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAA;QACrC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,0BAAc,CAAA;QAC/C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,0BAAc,CAAA;QAC/C,IAAI,CAAC,UAAU,GAAG,IAAI,aAAU,CAAC;YAC/B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAA;QACF,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,qBAAW,CAAC,eAAe,CAC7D,IAAI,CAAC,WAAW,EAChB,MAAM,CAAC,UAAU,CAClB,CA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AG,SAAS,CAAA;SACjC;QACD,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;YAClC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;SAC7B;IACH,CAAC;CACF;AAED,kBAAe,gBAAgB,CAAA","file":"goldfish.js","sourcesContent":["import UxFileUtils from '@aiot-toolkit/aiotpack/lib/utils/ux/UxFileUtils'\nimport { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport FileUtil from '@aiot-toolkit/shared-utils/lib/utils/FileUtil'\nimport * as adbMiwt from '@miwt/adb'\nimport { ChildProcess, execSync, spawn } from 'child_process'\nimport findProcess from 'find-process'\nimport fs from 'fs'\nimport os from 'os'\nimport path from 'path'\nimport portfinder from 'portfinder'\nimport VelaAvdCls from '../avd'\nimport {\n defaultAvdHome,\n defaultEmulatorHome,\n defaultSDKHome,\n defaultToolsHome\n} from '../static/constants'\nimport { INewGoldfishInstanceParams, IStartOptions } from '../typing/Instance'\n\nclass GoldfishInstance {\n private projectPath: string\n private sdkHome: string\n private avdHome: string\n private adbPort: number = 15555\n public debugPort: number = 10055\n private host9pPort: number = 7878\n private velaAvdCls: VelaAvdCls\n private packageName: string\n public goldfishProcess: ChildProcess | undefined\n public v9fsProcess: ChildProcess | undefined\n\n constructor(params: INewGoldfishInstanceParams) {\n this.projectPath = params.projectPath\n this.sdkHome = params.sdkHome || defaultSDKHome\n this.avdHome = params.avdHome || defaultAvdHome\n this.velaAvdCls = new VelaAvdCls({\n sdkHome: this.sdkHome,\n avdHome: this.avdHome\n })\n const { package: appPackageName } = UxFileUtils.getMainfestInfo(\n this.projectPath,\n params.sourceRoot\n )\n this.packageName = appPackageName\n }\n\n /** 获取模拟器二进制文件所在位置 */\n getEmulatorBinPath() {\n const osPlatform = os.platform()\n const osArch = os.arch()\n const platform = osPlatform === 'win32' ? 'windows' : osPlatform\n const arch = (osArch === 'arm64' || osArch === 'aarch64') ? 'aarch64' : 'x86_64'\n return path.resolve(defaultEmulatorHome, `${platform}-${arch}`, 'emulator')\n }\n\n /** 在goldfish模拟器中运行快应用 */\n async start(options: IStartOptions) {\n // host启动9p server\n await this.ensure9pServerRunnning()\n // TODO: 打包快应用\n // 将rpk推到host的defaultQuickappHome目录\n this.pushRpk()\n // 启动模拟器\n await this.startGoldfish(options)\n const connected = await this.connectGoldfish()\n if (connected) {\n ColorConsole.log({\n message: '### Emulator ### Goldfish emulator connected successfully'\n })\n // 在模拟器中启动快应用\n this.startupQuickApp(options)\n } else {\n ColorConsole.log({\n level: LOG_LEVEL.Error,\n message:\n '### Emulator ### Failed to connect emulator, please check whether the adb is normal'\n })\n }\n }\n\n /** 在goldfish中启动快应用 */\n startupQuickApp(options: IStartOptions) {\n try {\n const appMountDir = path.resolve(this.sdkHome, 'qa')\n const mountCmd = `adb -s 127.0.0.1:${this.adbPort} shell mount -t v9fs -o tag=10.0.2.2,port=${this.host9pPort},aname=${appMountDir} /data`\n ColorConsole.log({ message: `### Emulator ### Excuting adb cmd: ${mountCmd}` })\n adbMiwt.execAdbCmdSync(mountCmd)\n let vappCmd = `adb -s 127.0.0.1:${this.adbPort} shell vapp app/${this.packageName} &`\n if (options.devtool) {\n vappCmd = `adb -s 127.0.0.1:${this.adbPort} shell vapp --jsdebugger=10.0.2.15:101 app/${this.packageName} &`\n }\n ColorConsole.log({ message: `### Emulator ### Excuting adb cmd: ${vappCmd}` })\n // vapp进程会一直pending,不会退出。这里必须加stdio: 'ignore',否则快应用无法运行成功\n adbMiwt.execAdbCmdAsync(vappCmd, { stdio: 'ignore', encoding: 'utf-8' })\n } catch (e: any) {\n ColorConsole.log({\n level: LOG_LEVEL.Error,\n message: `### Emulator ### Failed to startup quickapp: ${e.message}`,\n isOnlyPrintError: true\n })\n }\n }\n /** host启动9pServer */\n ensure9pServerRunnning(): Promise<void> {\n return new Promise(async (resolve, reject) => {\n const yaFileName = os.platform() === 'win32' ? 'ya-vm-file-server.exe' : 'ya-vm-file-server'\n const pidList = await findProcess('name', yaFileName)\n if (pidList.length > 0) {\n ColorConsole.log({ message: '### Emulator ### 9p server started in host' })\n return resolve()\n }\n ColorConsole.log({ message: '### Emulator ### Starting 9p server in host' })\n const quickappMountDir = path.resolve(this.sdkHome, 'qa')\n const serverBinPath = path.resolve(defaultToolsHome, yaFileName)\n fs.chmodSync(serverBinPath, 0o777)\n this.host9pPort = await portfinder.getPortPromise({ port: 7878 })\n const address = `127.0.0.1:${this.host9pPort}`\n this.v9fsProcess = spawn(serverBinPath, [\n '--mount-point',\n quickappMountDir,\n '--network-address',\n address,\n '--debug'\n ])\n\n this.v9fsProcess.stderr?.on('data', (data) => {\n const output = data.toString()\n if (output.match(/Server started, listening on: 127.0.0.1:(\\d+)/)) {\n ColorConsole.log({ message: output })\n ColorConsole.log({ message: '### Emulator ### 9p server starts successfully' })\n return resolve()\n }\n })\n\n this.v9fsProcess.on('exit', (code) => {\n ColorConsole.log({\n level: LOG_LEVEL.Error,\n message: `### Emulator ### ya-vm-file-server exited with code ${code}`,\n isOnlyPrintError: true\n })\n return reject()\n })\n })\n }\n\n /** 启动goldfish模拟器 */\n async startGoldfish(options: IStartOptions) {\n const { avdName, devtool } = options\n const emulatorBin = this.getEmulatorBinPath()\n ColorConsole.log({ message: `### Emulator ### emulator path: ${emulatorBin}` })\n const avdInfo = this.velaAvdCls.getVelaAvdInfo(avdName)\n const { avdArch, avdImagePath } = avdInfo\n this.adbPort = await portfinder.getPortPromise({ port: this.adbPort })\n ColorConsole.log({ message: `### Emulator ### adb port: ${this.adbPort}` })\n if (!avdImagePath) {\n ColorConsole.log({\n level: LOG_LEVEL.Error,\n message: `### Emulator ### Unable to find vela image via avd`\n })\n process.exit()\n }\n const nuttxBinPath = path.resolve(avdImagePath, 'nuttx')\n ColorConsole.log({ message: `### Emulator ### nuttx path: ${nuttxBinPath}` })\n let portMappingStr = `user,id=u1,hostfwd=tcp:127.0.0.1:${this.adbPort}-10.0.2.15:5555`\n if (devtool) {\n this.debugPort = await portfinder.getPortPromise({ port: this.debugPort })\n ColorConsole.log({ message: `### Emulator ### debug port: ${this.debugPort}` })\n portMappingStr += `,hostfwd=tcp:127.0.0.1:${this.debugPort}-10.0.2.15:101`\n }\n ColorConsole.log({ message: `### Emulator ### Start qemu with TCP: ${portMappingStr}` })\n const stdioType = options.disableNSH ? 'pipe' : 'inherit'\n\n return new Promise<void>((resolve) => {\n this.goldfishProcess = spawn(\n emulatorBin,\n [\n '-nuttx',\n '-avd',\n avdName,\n '-avd-arch',\n avdArch,\n '-show-kernel',\n '-kernel',\n nuttxBinPath,\n '-qemu',\n '-netdev',\n portMappingStr,\n '-device',\n 'virtio-net-device,netdev=u1,bus=virtio-mmio-bus.3'\n ],\n { stdio: stdioType }\n )\n if (options.disableNSH) {\n this.goldfishProcess.stdout?.on('data', (data: Buffer) => {\n console.log(data.toString())\n if (data.toString().includes('(NSH)')) {\n ColorConsole.log({ message: `### Emulator ### Goldfish emulator starts successfully` })\n resolve()\n }\n })\n this.goldfishProcess.stderr?.on('data', (data) => {\n console.log(data.toString())\n })\n } else {\n setTimeout(() => {\n ColorConsole.log({ message: `### Emulator ### Goldfish emulator starts successfully` })\n resolve()\n }, 2000)\n }\n this.goldfishProcess.on('exit', (code) => {\n ColorConsole.log({\n level: LOG_LEVEL.Error,\n message: `### Emulator ### Goldfish emulator exited with code ${code}`,\n isOnlyPrintError: true\n })\n })\n })\n }\n\n /** 通过adb连接模拟器 */\n async connectGoldfish() {\n let adbConnected = false\n const connectFn = async () => {\n const sn = `127.0.0.1:${this.adbPort}`\n while (!adbConnected) {\n const adbKillCmd = `adb kill-server`\n ColorConsole.log({ message: `### Emulator ### Excuting adb cmd: ${adbKillCmd}` })\n adbMiwt.execAdbCmdSync(adbKillCmd)\n const adbConnectCmd = `adb connect ${sn}`\n ColorConsole.log({ message: `### Emulator ### Excuting adb cmd: ${adbConnectCmd}` })\n const str = adbMiwt.execAdbCmdSync(adbConnectCmd)\n ColorConsole.log({ message: `### Emulator ### ${str}` })\n const devices = await adbMiwt.getAdbDevices()\n ColorConsole.log({ message: `### Emulator ### adb devices: ${JSON.stringify(devices)}` })\n adbConnected =\n devices.filter((item) => item.sn === sn && item.status === 'device').length > 0\n }\n Promise.resolve(adbConnected)\n }\n await Promise.race([\n connectFn(),\n new Promise((resolve) => {\n setTimeout(() => resolve(false), 600 * 1000)\n })\n ])\n return adbConnected\n }\n\n /** 将打包后的文件推到挂载的快应用目录 */\n pushRpk() {\n const buildDir = path.resolve(this.projectPath, 'build')\n const { package: appPackageName } = UxFileUtils.getMainfestInfo(this.projectPath)\n const appRunDir = path.resolve(this.sdkHome, 'qa/app', appPackageName)\n ColorConsole.log({ message: `### Emulator ### Pushing ${appPackageName} to ${appRunDir}` })\n fs.rmSync(appRunDir, { recursive: true, force: true })\n FileUtil.copyFiles(buildDir, appRunDir)\n ColorConsole.log({\n message: `### Emulator ### Push ${appPackageName} to ${appRunDir} successfully`\n })\n }\n\n /** 杀死进程 */\n killProcess(currProcess?: ChildProcess) {\n if (currProcess && currProcess.pid && currProcess.exitCode === null) {\n console.log('process pid:', currProcess.pid)\n try {\n if (os.platform() === 'win32') {\n execSync(`taskkill /pid ${currProcess.pid} /T /F`)\n } else if (os.platform() === 'darwin') {\n process.kill(currProcess.pid)\n } else {\n currProcess.kill()\n }\n } catch (err) {\n ColorConsole.log({ message: `kill process get error :\\n${(err as Error).stack}` })\n }\n }\n }\n\n /** 停止模拟器并释放相关资源 */\n stop() {\n if (this.goldfishProcess) {\n this.killProcess(this.goldfishProcess)\n this.goldfishProcess = undefined\n }\n if (this.v9fsProcess) {\n this.killProcess(this.v9fsProcess)\n this.v9fsProcess = undefined\n }\n }\n}\n\nexport default GoldfishInstance\n"],"sourceRoot":"../../src"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"AvdId": "Vela_Virtual_Device",
|
|
3
|
+
"abi.type": "armeabi-v7a",
|
|
4
|
+
"avd.ini.displayname": "Vela_Virtual_Device",
|
|
5
|
+
"avd.ini.encoding": "UTF-8",
|
|
6
|
+
"fastboot.forceChosenSnapshotBoot": "no",
|
|
7
|
+
"fastboot.forceColdBoot": "yes",
|
|
8
|
+
"fastboot.forceFastBoot": "no",
|
|
9
|
+
"hw.accelerometer": "no",
|
|
10
|
+
"hw.arc": false,
|
|
11
|
+
"hw.audioInput": "yes",
|
|
12
|
+
"hw.battery": "yes",
|
|
13
|
+
"hw.camera.back": "virtualscene",
|
|
14
|
+
"hw.camera.front": "emulated",
|
|
15
|
+
"hw.cpu.arch": "arm",
|
|
16
|
+
"hw.cpu.ncore": 4,
|
|
17
|
+
"hw.dPad": "no",
|
|
18
|
+
"hw.gps": "yes",
|
|
19
|
+
"hw.gpu.enabled": "no",
|
|
20
|
+
"hw.gpu.mode ": "off",
|
|
21
|
+
"hw.initialOrientation": "Portrait",
|
|
22
|
+
"hw.keyboard": "yes",
|
|
23
|
+
"hw.lcd.density": 420,
|
|
24
|
+
"hw.lcd.height": 480,
|
|
25
|
+
"hw.lcd.width": 480,
|
|
26
|
+
"hw.mainKeys": "no",
|
|
27
|
+
"hw.ramSize": 512,
|
|
28
|
+
"hw.sdCard": "no",
|
|
29
|
+
"hw.sensors.orientation": "yes",
|
|
30
|
+
"hw.sensors.proximity": "yes",
|
|
31
|
+
"hw.trackBall": "no",
|
|
32
|
+
"image.sysdir.1": "",
|
|
33
|
+
"runtime.network.latency": "none",
|
|
34
|
+
"runtime.network.speed": "full",
|
|
35
|
+
"showDeviceFrame": "yes",
|
|
36
|
+
"skin.dynamic": "no",
|
|
37
|
+
"skin.name": "",
|
|
38
|
+
"skin.path": ""
|
|
39
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const defaultSDKHome: string;
|
|
2
|
+
export declare const defaultAvdHome: string;
|
|
3
|
+
export declare const defaultImageHome: string;
|
|
4
|
+
export declare const defaultEmulatorHome: string;
|
|
5
|
+
export declare const defaultSkinHome: string;
|
|
6
|
+
export declare const defaultQuickappHome: string;
|
|
7
|
+
export declare const defaultToolsHome: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.defaultToolsHome = exports.defaultQuickappHome = exports.defaultSkinHome = exports.defaultEmulatorHome = exports.defaultImageHome = exports.defaultAvdHome = exports.defaultSDKHome = void 0;
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
exports.defaultSDKHome = path_1.default.resolve(os_1.default.homedir(), '.export');
|
|
10
|
+
exports.defaultAvdHome = path_1.default.resolve(os_1.default.homedir(), '.android', 'avd');
|
|
11
|
+
exports.defaultImageHome = path_1.default.resolve(exports.defaultSDKHome, 'system-images/arm');
|
|
12
|
+
exports.defaultEmulatorHome = path_1.default.resolve(exports.defaultSDKHome, 'emulator');
|
|
13
|
+
exports.defaultSkinHome = path_1.default.resolve(exports.defaultSDKHome, 'skins');
|
|
14
|
+
exports.defaultQuickappHome = path_1.default.resolve(exports.defaultSDKHome, 'qa');
|
|
15
|
+
exports.defaultToolsHome = path_1.default.resolve(exports.defaultSDKHome, 'tools');
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["static/constants.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AAEV,QAAA,cAAc,GAAG,cAAI,CAAC,OAAO,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;AACtD,QAAA,cAAc,GAAG,cAAI,CAAC,OAAO,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,CAAA;AAC9D,QAAA,gBAAgB,GAAG,cAAI,CAAC,OAAO,CAAC,sBAAc,EAAE,mBAAmB,CAAC,CAAA;AACpE,QAAA,mBAAmB,GAAG,cAAI,CAAC,OAAO,CAAC,sBAAc,EAAE,UAAU,CAAC,CAAA;AAC9D,QAAA,eAAe,GAAG,cAAI,CAAC,OAAO,CAAC,sBAAc,EAAE,OAAO,CAAC,CAAA;AACvD,QAAA,mBAAmB,GAAG,cAAI,CAAC,OAAO,CAAC,sBAAc,EAAE,IAAI,CAAC,CAAA;AACxD,QAAA,gBAAgB,GAAG,cAAI,CAAC,OAAO,CAAC,sBAAc,EAAE,OAAO,CAAC,CAAA","file":"constants.js","sourcesContent":["import os from 'os'\nimport path from 'path'\n\nexport const defaultSDKHome = path.resolve(os.homedir(), '.export')\nexport const defaultAvdHome = path.resolve(os.homedir(), '.android', 'avd')\nexport const defaultImageHome = path.resolve(defaultSDKHome, 'system-images/arm')\nexport const defaultEmulatorHome = path.resolve(defaultSDKHome, 'emulator')\nexport const defaultSkinHome = path.resolve(defaultSDKHome, 'skins')\nexport const defaultQuickappHome = path.resolve(defaultSDKHome, 'qa')\nexport const defaultToolsHome = path.resolve(defaultSDKHome, 'tools')"],"sourceRoot":"../../src"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface IAvdResourcePaths {
|
|
2
|
+
avdHome?: string;
|
|
3
|
+
sdkHome?: string;
|
|
4
|
+
imageHome?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare enum IAvdArchType {
|
|
7
|
+
arm = "arm",
|
|
8
|
+
arm64 = "arm64"
|
|
9
|
+
}
|
|
10
|
+
export interface IAvdParams {
|
|
11
|
+
avdName: string;
|
|
12
|
+
avdArch: IAvdArchType;
|
|
13
|
+
avdWidth: string;
|
|
14
|
+
avdHeight: string;
|
|
15
|
+
avdSkin?: string;
|
|
16
|
+
avdImagePath?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ISkinInfo {
|
|
19
|
+
skinName: string;
|
|
20
|
+
skinPath: string;
|
|
21
|
+
skinBackBase64: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IAvdArchType = void 0;
|
|
4
|
+
var IAvdArchType;
|
|
5
|
+
(function (IAvdArchType) {
|
|
6
|
+
IAvdArchType["arm"] = "arm";
|
|
7
|
+
IAvdArchType["arm64"] = "arm64";
|
|
8
|
+
})(IAvdArchType || (exports.IAvdArchType = IAvdArchType = {}));
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=Avd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["typing/Avd.ts"],"names":[],"mappings":";;;AAMA,IAAY,YAA4C;AAAxD,WAAY,YAAY;IAAG,2BAAW,CAAA;IAAE,+BAAe,CAAA;AAAA,CAAC,EAA5C,YAAY,4BAAZ,YAAY,QAAgC","file":"Avd.js","sourcesContent":["export interface IAvdResourcePaths {\n avdHome?: string\n sdkHome?: string\n imageHome?: string\n}\n\nexport enum IAvdArchType { arm = 'arm', arm64 = 'arm64'}\n\nexport interface IAvdParams {\n avdName: string\n avdArch: IAvdArchType\n avdWidth: string\n avdHeight: string\n avdSkin?: string\n avdImagePath?: string\n}\n\nexport interface ISkinInfo {\n skinName: string\n skinPath: string\n skinBackBase64: string // 背景图的base64\n}"],"sourceRoot":"../../src"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IAvdResourcePaths } from "./Avd";
|
|
2
|
+
export interface INewGoldfishInstanceParams extends IAvdResourcePaths {
|
|
3
|
+
projectPath: string;
|
|
4
|
+
sourceRoot?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface IStartOptions {
|
|
7
|
+
avdName: string;
|
|
8
|
+
devtool?: string;
|
|
9
|
+
disableNSH?: boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["typing/Instance.ts"],"names":[],"mappings":"","file":"Instance.js","sourcesContent":["import { IAvdResourcePaths } from \"./Avd\";\n\nexport interface INewGoldfishInstanceParams extends IAvdResourcePaths {\n projectPath: string\n sourceRoot?: string\n}\n\nexport interface IStartOptions {\n avdName: string;\n devtool?: string;\n disableNSH?: boolean;\n}"],"sourceRoot":"../../src"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aiot-toolkit/emulator",
|
|
3
|
+
"version": "2.0.1-alpha.0",
|
|
4
|
+
"description": "vela emulator tool.",
|
|
5
|
+
"homepage": "",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"main": "lib/index.js",
|
|
8
|
+
"directories": {
|
|
9
|
+
"lib": "lib",
|
|
10
|
+
"test": "__tests__"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"lib"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"clean": "rm -rf ./dist/",
|
|
17
|
+
"lint": "eslint ./src/ --fix",
|
|
18
|
+
"test:watch": "jest --watch",
|
|
19
|
+
"test": "node ./__tests__/emulator.test.js"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": ""
|
|
24
|
+
},
|
|
25
|
+
"author": {
|
|
26
|
+
"name": "juancao816",
|
|
27
|
+
"email": "caojuan2019@163.com"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=12.0"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"aiot",
|
|
34
|
+
"vela",
|
|
35
|
+
"emulator"
|
|
36
|
+
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@aiot-toolkit/aiotpack": "2.0.1-alpha.0",
|
|
39
|
+
"@aiot-toolkit/shared-utils": "2.0.1-alpha.0",
|
|
40
|
+
"find-process": "^1.4.7",
|
|
41
|
+
"portfinder": "^1.0.32"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "cde5c75fa09622188ee4f1322ff9d53faf4d8520"
|
|
44
|
+
}
|