@expo-harmony/prebuild-config 55.0.0-harmony.1
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 +68 -0
- package/build/index.js +26 -0
- package/package.json +87 -0
- package/src/api/signing.ts +4 -0
- package/src/buildDescriptor.ts +277 -0
- package/src/check.ts +390 -0
- package/src/dependencies.ts +123 -0
- package/src/errors.ts +23 -0
- package/src/generatedFiles.ts +39 -0
- package/src/index.ts +25 -0
- package/src/manifest.ts +303 -0
- package/src/mods/withAutolinkingMods.ts +92 -0
- package/src/mods/withEntryMods.ts +332 -0
- package/src/mods/withPreparationMod.ts +85 -0
- package/src/mods/withProjectMods.ts +258 -0
- package/src/mods/withSourceMods.ts +32 -0
- package/src/native.ts +10 -0
- package/src/packageMetadata.ts +8 -0
- package/src/plugin.ts +7 -0
- package/src/reconcile.ts +70 -0
- package/src/renderers.ts +90 -0
- package/src/signing.ts +251 -0
- package/src/stale.ts +103 -0
- package/src/template.ts +172 -0
- package/src/withHarmonyPrebuildConfig.ts +47 -0
- package/tsconfig.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @expo-harmony/prebuild-config
|
|
2
|
+
|
|
3
|
+
[**GitHub 仓库**](https://github.com/renbaoshuo/expo-harmony/tree/master/packages/prebuild-config)
|
|
4
|
+
|
|
5
|
+
为 Expo 项目提供 HarmonyOS 默认预构建配置,将 `expo.harmony` 转换为可重复生成的原生工程状态。它基于 `@expo-harmony/template` 配置 AppScope、Entry 模块、资源、Hvigor、CMake 和 RNOH 宿主代码,同时完成 Expo 原生模块自动链接并生成 CNG 清单。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @expo-harmony/prebuild-config
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 基础用法
|
|
14
|
+
|
|
15
|
+
在 `app.json` 中启用插件并声明 HarmonyOS 配置:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"expo": {
|
|
20
|
+
"name": "Example",
|
|
21
|
+
"slug": "example",
|
|
22
|
+
"version": "1.0.0",
|
|
23
|
+
"plugins": ["@expo-harmony/prebuild-config"],
|
|
24
|
+
"harmony": {
|
|
25
|
+
"bundleName": "com.example.app",
|
|
26
|
+
"versionCode": 1,
|
|
27
|
+
"deviceTypes": ["phone", "tablet"]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
使用 Expo Harmony CLI 生成或更新原生工程:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
npx expo-harmony prebuild
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
需要使用字体、启动屏或其他 HarmonyOS 配置插件时,应将这些插件放在 `@expo-harmony/prebuild-config` 之前,由本包最后注册 Harmony Base Mods:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"expo": {
|
|
44
|
+
"plugins": [
|
|
45
|
+
"@expo-harmony/expo-font",
|
|
46
|
+
[
|
|
47
|
+
"@expo-harmony/expo-splash-screen",
|
|
48
|
+
{
|
|
49
|
+
"image": "./assets/splash.png",
|
|
50
|
+
"backgroundColor": "#FFFFFF"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"@expo-harmony/expo-system-ui",
|
|
54
|
+
"@expo-harmony/prebuild-config"
|
|
55
|
+
],
|
|
56
|
+
"harmony": {
|
|
57
|
+
"bundleName": "com.example.app"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Author
|
|
64
|
+
|
|
65
|
+
**expo-harmony** © [Baoshuo](https://github.com/renbaoshuo), Released under the MIT License.<br>
|
|
66
|
+
Authored and maintained by Baoshuo with help from [contributors](https://github.com/renbaoshuo/expo-harmony/contributors).
|
|
67
|
+
|
|
68
|
+
> [Personal Website](https://baoshuo.ren) · [Blog](https://blog.baoshuo.ren) · GitHub [@renbaoshuo](https://github.com/renbaoshuo) · Twitter [@baoshuo](https://twitter.com/baoshuo)
|
package/build/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withHarmonyPrebuildConfig = exports.validateHarmonySigningConfigFile = exports.isRnohAutolinkingDisabled = exports.validateCngManifest = exports.createCngManifest = exports.CngManifestPath = exports.HarmonyPrebuildError = exports.validateHarmonyBuildDescriptor = exports.resolveHarmonyBuildPath = exports.harmonyModuleSourcePath = exports.createHarmonyBuildDescriptor = exports.HarmonyTemplateMarker = exports.HarmonyPlatformDirectory = exports.BuildModes = exports.BuildDescriptorSchemaVersion = exports.default = void 0;
|
|
4
|
+
var plugin_1 = require("./plugin");
|
|
5
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return plugin_1.HarmonyPrebuildPlugin; } });
|
|
6
|
+
var buildDescriptor_1 = require("./buildDescriptor");
|
|
7
|
+
Object.defineProperty(exports, "BuildDescriptorSchemaVersion", { enumerable: true, get: function () { return buildDescriptor_1.BuildDescriptorSchemaVersion; } });
|
|
8
|
+
Object.defineProperty(exports, "BuildModes", { enumerable: true, get: function () { return buildDescriptor_1.BuildModes; } });
|
|
9
|
+
Object.defineProperty(exports, "HarmonyPlatformDirectory", { enumerable: true, get: function () { return buildDescriptor_1.HarmonyPlatformDirectory; } });
|
|
10
|
+
Object.defineProperty(exports, "HarmonyTemplateMarker", { enumerable: true, get: function () { return buildDescriptor_1.HarmonyTemplateMarker; } });
|
|
11
|
+
Object.defineProperty(exports, "createHarmonyBuildDescriptor", { enumerable: true, get: function () { return buildDescriptor_1.createHarmonyBuildDescriptor; } });
|
|
12
|
+
Object.defineProperty(exports, "harmonyModuleSourcePath", { enumerable: true, get: function () { return buildDescriptor_1.harmonyModuleSourcePath; } });
|
|
13
|
+
Object.defineProperty(exports, "resolveHarmonyBuildPath", { enumerable: true, get: function () { return buildDescriptor_1.resolveHarmonyBuildPath; } });
|
|
14
|
+
Object.defineProperty(exports, "validateHarmonyBuildDescriptor", { enumerable: true, get: function () { return buildDescriptor_1.validateHarmonyBuildDescriptor; } });
|
|
15
|
+
var errors_1 = require("./errors");
|
|
16
|
+
Object.defineProperty(exports, "HarmonyPrebuildError", { enumerable: true, get: function () { return errors_1.HarmonyPrebuildError; } });
|
|
17
|
+
var manifest_1 = require("./manifest");
|
|
18
|
+
Object.defineProperty(exports, "CngManifestPath", { enumerable: true, get: function () { return manifest_1.CngManifestPath; } });
|
|
19
|
+
Object.defineProperty(exports, "createCngManifest", { enumerable: true, get: function () { return manifest_1.createCngManifest; } });
|
|
20
|
+
Object.defineProperty(exports, "validateCngManifest", { enumerable: true, get: function () { return manifest_1.validateCngManifest; } });
|
|
21
|
+
var native_1 = require("./native");
|
|
22
|
+
Object.defineProperty(exports, "isRnohAutolinkingDisabled", { enumerable: true, get: function () { return native_1.isRnohAutolinkingDisabled; } });
|
|
23
|
+
var signing_1 = require("./signing");
|
|
24
|
+
Object.defineProperty(exports, "validateHarmonySigningConfigFile", { enumerable: true, get: function () { return signing_1.validateHarmonySigningConfigFile; } });
|
|
25
|
+
var withHarmonyPrebuildConfig_1 = require("./withHarmonyPrebuildConfig");
|
|
26
|
+
Object.defineProperty(exports, "withHarmonyPrebuildConfig", { enumerable: true, get: function () { return withHarmonyPrebuildConfig_1.withHarmonyPrebuildConfig; } });
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@expo-harmony/prebuild-config",
|
|
3
|
+
"version": "55.0.0-harmony.1",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"react-native",
|
|
6
|
+
"expo",
|
|
7
|
+
"expo-harmony",
|
|
8
|
+
"harmonyos"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/renbaoshuo/expo-harmony/tree/master/packages/prebuild-config#readme",
|
|
11
|
+
"bugs": "https://github.com/renbaoshuo/expo-harmony/issues",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Baoshuo <i@baoshuo.ren>",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/renbaoshuo/expo-harmony.git",
|
|
17
|
+
"directory": "packages/prebuild-config"
|
|
18
|
+
},
|
|
19
|
+
"main": "build/index.js",
|
|
20
|
+
"types": "build/index.d.ts",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"prebuild": "yarn workspace @expo-harmony/config-plugins build && yarn workspace @expo-harmony/expo-modules-autolinking build",
|
|
23
|
+
"build": "tsc -p tsconfig.json",
|
|
24
|
+
"prepare": "yarn build",
|
|
25
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./build/index.d.ts",
|
|
30
|
+
"require": "./build/index.js",
|
|
31
|
+
"default": "./build/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./check": {
|
|
34
|
+
"types": "./build/check.d.ts",
|
|
35
|
+
"require": "./build/check.js",
|
|
36
|
+
"default": "./build/check.js"
|
|
37
|
+
},
|
|
38
|
+
"./build-descriptor": {
|
|
39
|
+
"types": "./build/buildDescriptor.d.ts",
|
|
40
|
+
"require": "./build/buildDescriptor.js",
|
|
41
|
+
"default": "./build/buildDescriptor.js"
|
|
42
|
+
},
|
|
43
|
+
"./native-project": {
|
|
44
|
+
"types": "./build/native.d.ts",
|
|
45
|
+
"require": "./build/native.js",
|
|
46
|
+
"default": "./build/native.js"
|
|
47
|
+
},
|
|
48
|
+
"./signing": {
|
|
49
|
+
"types": "./build/api/signing.d.ts",
|
|
50
|
+
"require": "./build/api/signing.js",
|
|
51
|
+
"default": "./build/api/signing.js"
|
|
52
|
+
},
|
|
53
|
+
"./template": {
|
|
54
|
+
"types": "./build/template.d.ts",
|
|
55
|
+
"require": "./build/template.js",
|
|
56
|
+
"default": "./build/template.js"
|
|
57
|
+
},
|
|
58
|
+
"./package.json": "./package.json"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@expo-harmony/config-plugins": "55.0.10-harmony.1",
|
|
62
|
+
"@expo-harmony/expo-modules-autolinking": "55.0.25-harmony.1",
|
|
63
|
+
"@expo-harmony/template": "55.0.0-harmony.0",
|
|
64
|
+
"@expo/config": "55.0.17",
|
|
65
|
+
"@expo/config-plugins": "55.0.10",
|
|
66
|
+
"@react-native-community/cli-config": "15.1.3",
|
|
67
|
+
"json5": "2.2.3"
|
|
68
|
+
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"expo": "55.0.26"
|
|
71
|
+
},
|
|
72
|
+
"peerDependenciesMeta": {
|
|
73
|
+
"expo": {
|
|
74
|
+
"optional": true
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@types/node": "18.19.0",
|
|
79
|
+
"typescript": "6.0.3"
|
|
80
|
+
},
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": ">=20"
|
|
83
|
+
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
import { HarmonyPaths, type NormalizedHarmonyConfig } from '@expo-harmony/config-plugins';
|
|
4
|
+
|
|
5
|
+
const BuildDescriptorSchemaVersion = 2;
|
|
6
|
+
const BuildModes = Object.freeze(['debug', 'release'] as const);
|
|
7
|
+
const HarmonyPlatformDirectory = 'harmony';
|
|
8
|
+
const HarmonyTemplateMarker = '.expo-harmony-template';
|
|
9
|
+
|
|
10
|
+
type HarmonyBuildMode = typeof BuildModes[number];
|
|
11
|
+
|
|
12
|
+
interface HarmonyBuildVariantDescriptor {
|
|
13
|
+
expectedHap: string;
|
|
14
|
+
hvigorArgs: string[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface HarmonyBuildDescriptor {
|
|
18
|
+
export: {
|
|
19
|
+
bundle: string;
|
|
20
|
+
manifest: string;
|
|
21
|
+
metadataRoot: string;
|
|
22
|
+
rawfileRoot: string;
|
|
23
|
+
sourceMap: string;
|
|
24
|
+
};
|
|
25
|
+
harmonyRoot: string;
|
|
26
|
+
identity: {
|
|
27
|
+
abilityName: string;
|
|
28
|
+
bundleName: string;
|
|
29
|
+
moduleName: string;
|
|
30
|
+
productName: string;
|
|
31
|
+
targetName: string;
|
|
32
|
+
};
|
|
33
|
+
moduleRoot: string;
|
|
34
|
+
nativeCache: {
|
|
35
|
+
invalidationRoots: string[];
|
|
36
|
+
stateFile: string;
|
|
37
|
+
};
|
|
38
|
+
nativeInputs: {
|
|
39
|
+
lockfile: string;
|
|
40
|
+
manifest: string;
|
|
41
|
+
};
|
|
42
|
+
projectFiles: {
|
|
43
|
+
hvigorConfig: string;
|
|
44
|
+
moduleHvigor: string;
|
|
45
|
+
moduleJson: string;
|
|
46
|
+
nativeInputsStamp: string;
|
|
47
|
+
projectBuildProfile: string;
|
|
48
|
+
rootHvigor: string;
|
|
49
|
+
templateMarker: string;
|
|
50
|
+
};
|
|
51
|
+
schemaVersion: typeof BuildDescriptorSchemaVersion;
|
|
52
|
+
variants: Record<HarmonyBuildMode, HarmonyBuildVariantDescriptor>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
56
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isNonEmptyString(value: unknown): value is string {
|
|
60
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function isSafeRelativePath(value: unknown): value is string {
|
|
64
|
+
if (!isNonEmptyString(value)
|
|
65
|
+
|| value.includes('\\')
|
|
66
|
+
|| path.posix.isAbsolute(value)
|
|
67
|
+
|| path.win32.isAbsolute(value)
|
|
68
|
+
|| path.posix.normalize(value) !== value) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const segments = value.split('/');
|
|
73
|
+
return segments.every(segment => segment && segment !== '.' && segment !== '..');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function isStrictDescendant(root: string, target: string): boolean {
|
|
77
|
+
const relative = path.posix.relative(root, target);
|
|
78
|
+
return Boolean(relative)
|
|
79
|
+
&& relative !== '..'
|
|
80
|
+
&& !relative.startsWith('../')
|
|
81
|
+
&& !path.posix.isAbsolute(relative);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function validateVariant(value: unknown): HarmonyBuildVariantDescriptor {
|
|
85
|
+
if (!isRecord(value)
|
|
86
|
+
|| !isSafeRelativePath(value.expectedHap)
|
|
87
|
+
|| !Array.isArray(value.hvigorArgs)
|
|
88
|
+
|| value.hvigorArgs.length === 0
|
|
89
|
+
|| value.hvigorArgs.some(argument => !isNonEmptyString(argument) || /\0|[\r\n]/u.test(argument))) {
|
|
90
|
+
throw new TypeError('Harmony build descriptor contains an invalid build variant.');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return value as unknown as HarmonyBuildVariantDescriptor;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function validateHarmonyBuildDescriptor(value: unknown): HarmonyBuildDescriptor {
|
|
97
|
+
if (!isRecord(value) || value.schemaVersion !== BuildDescriptorSchemaVersion) {
|
|
98
|
+
throw new TypeError(
|
|
99
|
+
`Unsupported Harmony build descriptor schema: ${isRecord(value) ? value.schemaVersion : 'invalid'}.`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (value.harmonyRoot !== HarmonyPlatformDirectory
|
|
104
|
+
|| !isSafeRelativePath(value.moduleRoot)
|
|
105
|
+
|| !isStrictDescendant(value.harmonyRoot, value.moduleRoot)) {
|
|
106
|
+
throw new TypeError('Harmony build descriptor contains invalid project roots.');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const harmonyRoot = value.harmonyRoot;
|
|
110
|
+
const moduleRoot = value.moduleRoot;
|
|
111
|
+
|
|
112
|
+
const identity = value.identity;
|
|
113
|
+
|
|
114
|
+
if (!isRecord(identity)
|
|
115
|
+
|| ['abilityName', 'bundleName', 'moduleName', 'productName', 'targetName']
|
|
116
|
+
.some(field => !isNonEmptyString(identity[field]))) {
|
|
117
|
+
throw new TypeError('Harmony build descriptor contains an invalid identity.');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const inputs = value.nativeInputs;
|
|
121
|
+
|
|
122
|
+
if (!isRecord(inputs)
|
|
123
|
+
|| !isSafeRelativePath(inputs.manifest)
|
|
124
|
+
|| !isSafeRelativePath(inputs.lockfile)
|
|
125
|
+
|| !isStrictDescendant(harmonyRoot, inputs.manifest)
|
|
126
|
+
|| !isStrictDescendant(harmonyRoot, inputs.lockfile)) {
|
|
127
|
+
throw new TypeError('Harmony build descriptor contains invalid native input paths.');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const cache = value.nativeCache;
|
|
131
|
+
|
|
132
|
+
if (!isRecord(cache)
|
|
133
|
+
|| !isSafeRelativePath(cache.stateFile)
|
|
134
|
+
|| !isStrictDescendant(moduleRoot, cache.stateFile)
|
|
135
|
+
|| !Array.isArray(cache.invalidationRoots)
|
|
136
|
+
|| cache.invalidationRoots.length === 0
|
|
137
|
+
|| cache.invalidationRoots.some(item => (
|
|
138
|
+
!isSafeRelativePath(item) || !isStrictDescendant(moduleRoot, item)
|
|
139
|
+
))) {
|
|
140
|
+
throw new TypeError('Harmony build descriptor contains invalid native cache paths.');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const files = value.projectFiles;
|
|
144
|
+
const roots = [
|
|
145
|
+
'hvigorConfig',
|
|
146
|
+
'nativeInputsStamp',
|
|
147
|
+
'projectBuildProfile',
|
|
148
|
+
'rootHvigor',
|
|
149
|
+
'templateMarker',
|
|
150
|
+
];
|
|
151
|
+
const modules = ['moduleHvigor', 'moduleJson'];
|
|
152
|
+
|
|
153
|
+
if (!isRecord(files)
|
|
154
|
+
|| [...roots, ...modules].some(field => !isSafeRelativePath(files[field]))
|
|
155
|
+
|| roots.some(field => !isStrictDescendant(harmonyRoot, files[field] as string))
|
|
156
|
+
|| modules.some(field => !isStrictDescendant(moduleRoot, files[field] as string))) {
|
|
157
|
+
throw new TypeError('Harmony build descriptor contains invalid project file paths.');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const output = value.export;
|
|
161
|
+
|
|
162
|
+
if (!isRecord(output)) {
|
|
163
|
+
throw new TypeError('Harmony build descriptor contains invalid export paths.');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const invalid = ['bundle', 'manifest', 'metadataRoot', 'rawfileRoot', 'sourceMap']
|
|
167
|
+
.some(field => !isSafeRelativePath(output[field]));
|
|
168
|
+
|
|
169
|
+
if (invalid
|
|
170
|
+
|| !isStrictDescendant(moduleRoot, output.rawfileRoot as string)
|
|
171
|
+
|| !isStrictDescendant(output.rawfileRoot as string, output.bundle as string)
|
|
172
|
+
|| !isStrictDescendant(output.metadataRoot as string, output.sourceMap as string)) {
|
|
173
|
+
throw new TypeError('Harmony build descriptor contains invalid export paths.');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (!isRecord(value.variants)
|
|
177
|
+
|| Object.keys(value.variants).length !== BuildModes.length
|
|
178
|
+
|| BuildModes.some(mode => !Object.hasOwn(value.variants as object, mode))) {
|
|
179
|
+
throw new TypeError('Harmony build descriptor must define debug and release variants.');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
for (const mode of BuildModes) {
|
|
183
|
+
const variant = validateVariant(value.variants[mode]);
|
|
184
|
+
|
|
185
|
+
if (!isStrictDescendant(moduleRoot, variant.expectedHap)) {
|
|
186
|
+
throw new TypeError(`Harmony ${mode} HAP output must be inside the module root.`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return value as unknown as HarmonyBuildDescriptor;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function createHarmonyBuildDescriptor(
|
|
194
|
+
config: NormalizedHarmonyConfig,
|
|
195
|
+
signing: string | null
|
|
196
|
+
): HarmonyBuildDescriptor {
|
|
197
|
+
const paths = HarmonyPaths.HARMONY_PATHS;
|
|
198
|
+
const harmony = HarmonyPlatformDirectory;
|
|
199
|
+
const module = `${harmony}/${path.posix.dirname(paths.entryBuildProfile)}`;
|
|
200
|
+
const target = 'default';
|
|
201
|
+
const rawfile = `${module}/src/main/resources/rawfile`;
|
|
202
|
+
const suffix = signing ? 'signed' : 'unsigned';
|
|
203
|
+
|
|
204
|
+
const variants = Object.fromEntries(BuildModes.map(mode => [mode, {
|
|
205
|
+
expectedHap: `${module}/build/${target}/outputs/${target}/${config.moduleName}-${target}-${suffix}.hap`,
|
|
206
|
+
hvigorArgs: [
|
|
207
|
+
'--mode', 'module',
|
|
208
|
+
'-p', `module=${config.moduleName}@${target}`,
|
|
209
|
+
'-p', `product=${config.productName}`,
|
|
210
|
+
'-p', `buildMode=${mode}`,
|
|
211
|
+
'--no-daemon',
|
|
212
|
+
'assembleHap',
|
|
213
|
+
],
|
|
214
|
+
}])) as Record<HarmonyBuildMode, HarmonyBuildVariantDescriptor>;
|
|
215
|
+
|
|
216
|
+
return validateHarmonyBuildDescriptor({
|
|
217
|
+
export: {
|
|
218
|
+
bundle: `${rawfile}/hermes_bundle.hbc`,
|
|
219
|
+
manifest: '.expo/harmony/export-manifest.json',
|
|
220
|
+
metadataRoot: '.expo/harmony/export',
|
|
221
|
+
rawfileRoot: rawfile,
|
|
222
|
+
sourceMap: '.expo/harmony/export/hermes_bundle.hbc.map',
|
|
223
|
+
},
|
|
224
|
+
harmonyRoot: harmony,
|
|
225
|
+
identity: {
|
|
226
|
+
abilityName: config.abilityName,
|
|
227
|
+
bundleName: config.bundleName,
|
|
228
|
+
moduleName: config.moduleName,
|
|
229
|
+
productName: config.productName,
|
|
230
|
+
targetName: target,
|
|
231
|
+
},
|
|
232
|
+
moduleRoot: module,
|
|
233
|
+
nativeCache: {
|
|
234
|
+
invalidationRoots: [`${module}/.cxx`, `${module}/build`],
|
|
235
|
+
stateFile: `${module}/.cxx/.expo-harmony-native-dependencies.json`,
|
|
236
|
+
},
|
|
237
|
+
nativeInputs: {
|
|
238
|
+
lockfile: `${harmony}/oh-package-lock.json5`,
|
|
239
|
+
manifest: `${harmony}/${paths.rootOhPackage}`,
|
|
240
|
+
},
|
|
241
|
+
projectFiles: {
|
|
242
|
+
hvigorConfig: `${harmony}/${paths.hvigorConfig}`,
|
|
243
|
+
moduleHvigor: `${harmony}/${paths.entryHvigor}`,
|
|
244
|
+
moduleJson: `${harmony}/${paths.moduleJson}`,
|
|
245
|
+
nativeInputsStamp: `${harmony}/${paths.nativeInputsStamp}`,
|
|
246
|
+
projectBuildProfile: `${harmony}/${paths.projectBuildProfile}`,
|
|
247
|
+
rootHvigor: `${harmony}/${paths.rootHvigor}`,
|
|
248
|
+
templateMarker: `${harmony}/${HarmonyTemplateMarker}`,
|
|
249
|
+
},
|
|
250
|
+
schemaVersion: BuildDescriptorSchemaVersion,
|
|
251
|
+
variants,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function harmonyModuleSourcePath(build: HarmonyBuildDescriptor): string {
|
|
256
|
+
return `./${path.posix.relative(build.harmonyRoot, build.moduleRoot)}`;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function resolveHarmonyBuildPath(root: string, file: string): string {
|
|
260
|
+
return path.join(root, ...file.split('/'));
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export {
|
|
264
|
+
BuildDescriptorSchemaVersion,
|
|
265
|
+
BuildModes,
|
|
266
|
+
HarmonyPlatformDirectory,
|
|
267
|
+
HarmonyTemplateMarker,
|
|
268
|
+
createHarmonyBuildDescriptor,
|
|
269
|
+
harmonyModuleSourcePath,
|
|
270
|
+
resolveHarmonyBuildPath,
|
|
271
|
+
validateHarmonyBuildDescriptor,
|
|
272
|
+
};
|
|
273
|
+
export type {
|
|
274
|
+
HarmonyBuildDescriptor,
|
|
275
|
+
HarmonyBuildMode,
|
|
276
|
+
HarmonyBuildVariantDescriptor,
|
|
277
|
+
};
|