已合并
feat: Add a new internal HVigor plugin for compiling release and bytecode HAR packages. #431
xiedairong创建于 2025年1月11日
feat: Add a new internal HVigor plugin for compiling release and bytecode HAR packages. #431
已合并
xiedairong创建于 2025年1月11日
refs/pull/431/head合入到master
23 个文件变更+628-65
@@ -5,4 +5,5 @@
5*.drawio.*5*.drawio.*
6package-lock.json6package-lock.json
7# build7# build
8-.hvigor/8+tester/harmony/react_native_openharmony/src/main/cpp/include
9+.hvigor/
Areact-native-harmony-inner-hvigor-plugin/.gitignore+2-0文件内容审核中,请稍后刷新重试
@@ -0,0 +1,3 @@
1+src
2+tests
3+/*.tgz
@@ -0,0 +1 @@
1+@ohos:registry=https://repo.harmonyos.com/npm
@@ -0,0 +1,25 @@
1+{
2+ "name": "@rnoh/inner-hvigor-plugin",
3+ "version": "0.0.1",
4+ "description": "",
5+ "main": "dist/index.js",
6+ "scripts": {
7+ "build": "tsc -p ./tsconfig.build.json",
8+ "prepack": "tsc -p ./tsconfig.build.json"
9+ },
10+ "keywords": [],
11+ "author": "",
12+ "license": "ISC",
13+ "dependencies": {
14+ "fs-extra": "^11.2.0"
15+ },
16+ "devDependencies": {
17+ "@ohos/hvigor": "^5.13.1",
18+ "@ohos/hvigor-ohos-plugin": "^5.13.1",
19+ "@tsconfig/node18": "^18.2.4",
20+ "@types/fs-extra": "^11.0.4",
21+ "@types/mustache": "^4.2.5",
22+ "ts-node": "^10.9.2",
23+ "typescript": "^5.6.2"
24+ }
25+}
Areact-native-harmony-inner-hvigor-plugin/src/PluginFactory.ts+56-0文件内容审核中,请稍后刷新重试
@@ -0,0 +1,235 @@
1+/**
2+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE-MIT file in the root directory of this source tree.
6+ */
7+ 
8+import { OhosHarContext } from '@ohos/hvigor-ohos-plugin';
9+import fse from 'fs-extra';
10+import fs from 'node:fs';
11+import { BuildOptionSetOfABC, BuildOptionSetOfRelease, BuildProfile, CMakeContent } from './Template';
12+ 
13+// RNOH module path
14+const RNOH_PATH = 'react_native_openharmony';
15+// main path of RNOH
16+const MAIN_PATH = `${RNOH_PATH}/src/main`;
17+// build mode: release
18+const RELEASE_BUILD_MODE = 'release';
19+// product name: abc
20+const ABC_PRODUCT_NAME = 'abc';
21+// build-profile.json5 content type
22+const BUILD_PROFILE_TYPE = {
23+ DEFAULT: 0,
24+ ABC: 1,
25+ RELEASE: 2,
26+};
27+ 
28+/**
29+ * Logger interface.
30+ * @interface Logger
31+ * @method info Log an informational message.
32+ * @method warn Log a warning message.
33+ * @method error Log an error message.
34+ */
35+export interface Logger {
36+ info(message: string): void;
37+ 
38+ warn(message: string): void;
39+ 
40+ error(message: string): void;
41+}
42+ 
43+interface Subtask {
44+ run(): void;
45+}
46+ 
47+/**
48+ * Adjust the build-profile.json5 file of RNOH according to the
49+ * mode(eg: ABC, Release, or default).
50+ */
51+class OverwriteBuildProfileSubtask implements Subtask {
52+ constructor(
53+ private context: OhosHarContext,
54+ private logger: Logger,
55+ private type: number,
56+ ) {}
57+
58+ run(): void {
59+ const buildProfileOpt = Object.assign({}, BuildProfile);
60+ if (this.type === BUILD_PROFILE_TYPE.ABC) {
61+ // @ts-ignore
62+ buildProfileOpt.buildOptionSet = BuildOptionSetOfABC;
63+ } else if (this.type === BUILD_PROFILE_TYPE.RELEASE) {
64+ // @ts-ignore
65+ buildProfileOpt.buildOptionSet = BuildOptionSetOfRelease;
66+ }
67+ // @ts-ignore
68+ this.context.setBuildProfileOpt(buildProfileOpt);
69+ this.logger.info(`[OverwriteBuildProfile]\nbuild-profile.json5 has been successfully overwritten.`);
70+ }
71+}
72+ 
73+/**
74+ * Adjust the CMakeLists.txt of RNOH based on whether it is in release mode.
75+ */
76+class OverwriteMakefileSubtask implements Subtask {
77+ constructor(
78+ private mainPath: string,
79+ private logger: Logger,
80+ private isRealseMode: boolean,
81+ ) {}
82+ 
83+ run(): void {
84+ fs.readFile(`${this.mainPath}/cpp/CMakeLists.txt`, 'utf8', (err, data) => {
85+ if (err) {
86+ this.logger.error(`[OverwriteMakefile]\n${JSON.stringify(err)}`);
87+ return;
88+ }
89+ if (this.isRealseMode && !/if\(USE_HERMES\)/gm.test(data)) {
90+ this.logger.info(`[OverwriteMakefile]\nThe CMakeLists.txt has been converted to release mode.`);
91+ return;
92+ }
93+ if (!this.isRealseMode && /if\(USE_HERMES\)/gm.test(data)) {
94+ this.logger.info(`[OverwriteMakefile]\nThe CMakeLists.txt has been converted to default mode.`)
95+ return;
96+ }
97+ 
98+ let replaceData = ''
99+ if (this.isRealseMode) {
100+ replaceData = data
101+ .replace(/if\(USE_HERMES\)([\s\S]*?)endif\(\)/, 'add_hermes_executor(OFF)\nadd_jsvm_executor(OFF)')
102+ .replace(/if\(\"\$ENV\{RNOH_C_API_ARCH\}\" STREQUAL \"1\"\)([\s\S]*?)endif\(\)/, '$1');
103+ } else {
104+ replaceData = data
105+ .replace(/add_hermes_executor\(OFF\)\s*add_jsvm_executor\(OFF\)/, 'if(USE_HERMES)\n add_hermes_executor(ON)\nelse()\n add_jsvm_executor(ON)\nendif()');
106+ }
107+ fs.writeFile(`${this.mainPath}/cpp/CMakeLists.txt`, replaceData, 'utf8', err => {
108+ if (err) {
109+ this.logger.error(`[OverwriteMakefile]\n${JSON.stringify(err)}`);
110+ return;
111+ }
112+ this.logger.info(`[OverwriteMakefile]\nSuccessfully converted CMakeLists.txt to ${this.isRealseMode ? 'release' : 'default'} mode.`);
113+ });
114+ });
115+ }
116+}
117+ 
118+const filterFileByExt = (dir: string, exts: string[] = [], target: string, logger: Logger) => {
119+ const files = fs.readdirSync(dir);
120+ files.forEach(filename => {
121+ const stat = fs.lstatSync(`${dir}/${filename}`);
122+ if (`${dir}/${filename}` === target) {
123+ // Skip the target folder
124+ } else if (stat.isDirectory()) {
125+ filterFileByExt(`${dir}/${filename}`, exts, `${target}/${filename}`, logger);
126+ } else {
127+ for (let j = 0; j < exts.length; j++) {
128+ let ext = exts[j];
129+ if (filename.split('.').pop()?.toLowerCase() === ext.trim().toLowerCase()) {
130+ try {
131+ fse.copySync(`${dir}/${filename}`, `${target}/${filename}`);
132+ } catch (err) {
133+ logger.error(`${JSON.stringify(err)}`);
134+ }
135+ break;
136+ }
137+ }
138+ }
139+ });
140+}
141+ 
142+/**
143+ * Extract all header files from the RNOH source code.
144+ */
145+class ExtractHeadFileSubtask implements Subtask {
146+ constructor(
147+ private mainPath: string,
148+ private logger: Logger,
149+ ) {}
150+ 
151+ run(): void {
152+ this.logger.info('[ExtractHeadFile]');
153+ filterFileByExt(`${this.mainPath}/cpp`, ['h', 'hpp', 'ipp'], `${this.mainPath}/cpp/include`, this.logger);
154+ }
155+}
156+ 
157+class CopyOtherFileSubtask implements Subtask {
158+ constructor(
159+ private mainPath: string,
160+ private logger: Logger,
161+ ) {}
162+ 
163+ run(): void {
164+ const sourceList = [
165+ 'RNOHAppNapiBridge.cpp',
166+ ];
167+ sourceList.forEach(filePath => {
168+ try {
169+ fse.copySync(`${this.mainPath}/cpp/${filePath}`, `${this.mainPath}/cpp/include/${filePath}`);
170+ } catch (err) {
171+ this.logger.error(`[CopyOtherFile]\n${JSON.stringify(err)}`);
172+ }
173+ });
174+ 
175+ fse.writeFile(`${this.mainPath}/cpp/include/react-native-harmony.cmake`, CMakeContent).catch((err) => {
176+ this.logger.error(`[CopyOtherFile]\n${JSON.stringify(err)}`);
177+ });
178+ }
179+}
180+ 
181+/**
182+ * Delete a Specified Folder.
183+ */
184+class CleanSubtask implements Subtask {
185+ constructor(
186+ private folder: string,
187+ private logger: Logger,
188+ ) {}
189+ 
190+ run(): void {
191+ try {
192+ fse.removeSync(this.folder);
193+ this.logger.info(`[Clean]\nFolder(${this.folder}) deleted successfully`);
194+ } catch (err) {
195+ this.logger.error(`[Clean]\nError while deleting folder(${this.folder}):\n${JSON.stringify(err)}`);
196+ }
197+ }
198+}
199+ 
200+export type RealsePrebuildOptions = {
201+ productName: string;
202+ buildMode: string;
203+};
204+ 
205+export class RealsePrebuildTask {
206+ constructor(
207+ private logger: Logger,
208+ private context: OhosHarContext,
209+ private options: RealsePrebuildOptions
210+ ) {}
211+
212+ run(): void {
213+ const { productName, buildMode } = this.options;
214+ const type = buildMode === RELEASE_BUILD_MODE ?
215+ (productName === ABC_PRODUCT_NAME ? BUILD_PROFILE_TYPE.ABC : BUILD_PROFILE_TYPE.RELEASE) :
216+ BUILD_PROFILE_TYPE.DEFAULT;
217+ const isRelease = type !== BUILD_PROFILE_TYPE.DEFAULT;
218+
219+ let subtasks: Subtask[] = [
220+ new OverwriteBuildProfileSubtask(this.context, this.logger, type),
221+ new OverwriteMakefileSubtask(MAIN_PATH, this.logger, isRelease),
222+ new CleanSubtask(`${RNOH_PATH}/generated`, this.logger)
223+ ];
224+ if (isRelease) {
225+ subtasks = subtasks.concat([
226+ new ExtractHeadFileSubtask(MAIN_PATH, this.logger),
227+ new CopyOtherFileSubtask(MAIN_PATH, this.logger)
228+ ]);
229+ } else {
230+ subtasks.push(new CleanSubtask(`${MAIN_PATH}/cpp/include`, this.logger));
231+ }
232+
233+ subtasks.forEach((subtask) => subtask.run());
234+ }
235+}
@@ -0,0 +1,143 @@
1+/**
2+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE-MIT file in the root directory of this source tree.
6+ */
7+export const BuildProfile = {
8+ apiType: "stageMode",
9+ targets: [
10+ {
11+ name: "default",
12+ runtimeOS: "HarmonyOS",
13+ }
14+ ]
15+};
16+ 
17+export const BuildOptionSetOfRelease = [
18+ {
19+ name: "release",
20+ externalNativeOptions: {
21+ path: "./src/main/cpp/CMakeLists.txt",
22+ arguments: "",
23+ cppFlags: ""
24+ },
25+ nativeLib: {
26+ headerPath: ["./src/main/cpp/include"],
27+ librariesInfo: [
28+ {
29+ name: "librnoh.so",
30+ linkLibraries: [
31+ "libace_napi.z.so",
32+ "libace_ndk.z.so",
33+ "librawfile.z.so",
34+ "libhilog_ndk.z.so",
35+ "libnative_vsync.so",
36+ "libnative_drawing.so",
37+ "libhitrace_ndk.z.so",
38+ "libqos.so",
39+ "react-native-openharmony::folly_runtime",
40+ "react-native-openharmony::glog",
41+ "react-native-openharmony::jsi",
42+ "react-native-openharmony::react_debug",
43+ "react-native-openharmony::react_render_attributedstring",
44+ "react-native-openharmony::react_nativemodule_core",
45+ "react-native-openharmony::react_codegen_rncore",
46+ "react-native-openharmony::react_render_componentregistry",
47+ "react-native-openharmony::react_render_core",
48+ "react-native-openharmony::react_render_debug",
49+ "react-native-openharmony::react_render_graphics",
50+ "react-native-openharmony::react_render_imagemanager",
51+ "react-native-openharmony::react_render_mapbuffer",
52+ "react-native-openharmony::rrc_image",
53+ "react-native-openharmony::rrc_text",
54+ "react-native-openharmony::rrc_textinput",
55+ "react-native-openharmony::rrc_scrollview",
56+ "react-native-openharmony::rrc_view",
57+ "react-native-openharmony::runtimeexecutor",
58+ "react-native-openharmony::yoga"
59+ ]
60+ }
61+ ]
62+ }
63+ }
64+];
65+ 
66+export const BuildOptionSetOfABC = BuildOptionSetOfRelease.map(item => {
67+ return {
68+ ...item,
69+ arkOptions: {
70+ byteCodeHar: true,
71+ }
72+ };
73+});
74+ 
75+export const CMakeContent = `set(REACT_COMMON_PATCH_DIR "\${RNOH_CPP_DIR}/patches/react_native_core")
76+ 
77+# folly的编译选项
78+set(folly_compile_options
79+ -DFOLLY_NO_CONFIG=1
80+ -DFOLLY_MOBILE=1
81+ -DFOLLY_USE_LIBCPP=1
82+ -DFOLLY_HAVE_RECVMMSG=1
83+ -DFOLLY_HAVE_PTHREAD=1
84+ -Wno-comma
85+ -Wno-shorten-64-to-32
86+ -Wno-documentation
87+ -faligned-new
88+)
89+ 
90+if(DEFINED PACKAGE_FIND_FILE)
91+ include(\${PACKAGE_FIND_FILE})
92+endif()
93+ 
94+# 添加rnoh
95+target_compile_definitions(react-native-openharmony::rnoh INTERFACE C_API_ARCH)
96+target_compile_options(react-native-openharmony::rnoh INTERFACE \${folly_compile_options} -DRAW_PROPS_ENABLED -DNDEBUG -std=c++17)
97+#JSExecutorFactory
98+if(USE_HERMES)
99+ target_link_libraries(react-native-openharmony::rnoh INTERFACE react-native-openharmony::hermes_executor)
100+ target_compile_definitions(react-native-openharmony::rnoh INTERFACE USE_HERMES=1)
101+else()
102+ target_link_libraries(react-native-openharmony::rnoh INTERFACE react-native-openharmony::jsvm_executor)
103+ target_compile_definitions(react-native-openharmony::rnoh INTERFACE USE_HERMES=0)
104+endif()
105+ 
106+add_library(rnoh ALIAS react-native-openharmony::rnoh)
107+ 
108+# 添加头文件目录
109+include_directories(\${RNOH_APP_DIR}
110+ \${RNOH_CPP_DIR}
111+ \${REACT_COMMON_PATCH_DIR}
112+ \${RNOH_CPP_DIR}/third-party/folly
113+ \${RNOH_CPP_DIR}/third-party/rn/ReactCommon
114+ \${RNOH_CPP_DIR}/third-party/rn/ReactCommon/react/nativemodule/core
115+ \${RNOH_CPP_DIR}/third-party/rn/ReactCommon/jsi
116+ \${RNOH_CPP_DIR}/third-party/rn/ReactCommon/callinvoker
117+ \${RNOH_CPP_DIR}/third-party/boost/libs/utility/include
118+ \${RNOH_CPP_DIR}/third-party/boost/libs/stacktrace/include
119+ \${RNOH_CPP_DIR}/third-party/boost/libs/predef/include
120+ \${RNOH_CPP_DIR}/third-party/boost/libs/array/include
121+ \${RNOH_CPP_DIR}/third-party/boost/libs/throw_exception/include
122+ \${RNOH_CPP_DIR}/third-party/boost/libs/config/include
123+ \${RNOH_CPP_DIR}/third-party/boost/libs/core/include
124+ \${RNOH_CPP_DIR}/third-party/boost/libs/preprocessor/include
125+ \${RNOH_CPP_DIR}/third-party/double-conversion
126+ \${RNOH_CPP_DIR}/third-party/rn/ReactCommon/react/renderer/graphics/platform/cxx
127+ \${RNOH_CPP_DIR}/third-party/rn/ReactCommon/runtimeexecutor
128+ \${RNOH_CPP_DIR}/third-party/glog/src
129+ \${RNOH_CPP_DIR}/third-party/boost/libs/mpl/include
130+ \${RNOH_CPP_DIR}/third-party/boost/libs/type_traits/include
131+ \${RNOH_CPP_DIR}/third-party/rn/ReactCommon/yoga
132+ \${RNOH_CPP_DIR}/third-party/boost/libs/intrusive/include
133+ \${RNOH_CPP_DIR}/third-party/boost/libs/assert/include
134+ \${RNOH_CPP_DIR}/third-party/boost/libs/move/include
135+ \${RNOH_CPP_DIR}/third-party/boost/libs/static_assert/include
136+ \${RNOH_CPP_DIR}/third-party/boost/libs/container_hash/include
137+ \${RNOH_CPP_DIR}/third-party/boost/libs/describe/include
138+ \${RNOH_CPP_DIR}/third-party/boost/libs/mp11/include
139+ \${RNOH_CPP_DIR}/third-party/boost/libs/iterator/include
140+ \${RNOH_CPP_DIR}/third-party/boost/libs/detail/include
141+ \${RNOH_CPP_DIR}/patches/react_native_core/react/renderer/textlayoutmanager/platform/harmony
142+ )
143+`;
@@ -0,0 +1,8 @@
1+/**
2+ * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE-MIT file in the root directory of this source tree.
6+ */
7+ 
8+export * from './PluginFactory';
@@ -0,0 +1,8 @@
1+{
2+ "extends": "./tsconfig.json",
3+ "exclude": [
4+ "tests",
5+ "**/*.test.ts",
6+ "dist",
7+ ]
8+}
@@ -0,0 +1,9 @@
1+{
2+ "extends": "@tsconfig/node18/tsconfig.json",
3+ "compilerOptions": {
4+ "outDir": "./dist",
5+ "esModuleInterop": true,
6+ "allowSyntheticDefaultImports": true,
7+ "declaration": true
8+ },
9+}
@@ -10,6 +10,17 @@
10 "nativeCompiler": "BiSheng"10 "nativeCompiler": "BiSheng"
11 }11 }
12 },12 },
13+ {
14+ name: 'abc',
15+ signingConfig: 'default',
16+ compatibleSdkVersion: '5.0.0(12)',
17+ runtimeOS: 'HarmonyOS',
18+ buildOption: {
19+ strictMode: {
20+ useNormalizedOHMUrl: true
21+ }
22+ }
23+ }
13 ],24 ],
14 buildModeSet: [25 buildModeSet: [
15 {26 {
@@ -2,6 +2,7 @@
2 "modelVersion": "5.0.0",2 "modelVersion": "5.0.0",
3 "dependencies": {3 "dependencies": {
4 "@rnoh/hvigor-plugin": "../../../react-native-harmony/harmony/rnoh-hvigor-plugin-0.2.0.tgz", // <PROJECT_ROOT>/node_modules/<RNOH>/harmony/rnoh-hvigor-plugin-X.X.X.tgz4 "@rnoh/hvigor-plugin": "../../../react-native-harmony/harmony/rnoh-hvigor-plugin-0.2.0.tgz", // <PROJECT_ROOT>/node_modules/<RNOH>/harmony/rnoh-hvigor-plugin-X.X.X.tgz
5+ "@rnoh/inner-hvigor-plugin": "../../../react-native-harmony-inner-hvigor-plugin/rnoh-inner-hvigor-plugin-0.0.1.tgz",
5 },6 },
6 "execution": {7 "execution": {
7 // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */8 // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */
@@ -6,4 +6,10 @@
6 */6 */
7 7 
8// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.8// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
9-export { appTasks } from '@ohos/hvigor-ohos-plugin';9+export { appTasks } from '@ohos/hvigor-ohos-plugin';
10+import { appTasks } from '@ohos/hvigor-ohos-plugin';
11+ 
12+export default {
13+ system: appTasks,
14+ plugins: []
15+}
@@ -9,6 +9,6 @@
9 repository: {},9 repository: {},
10 version: "1.0.0",10 version: "1.0.0",
11 dependencies: {11 dependencies: {
12- "@rnoh/react-native-openharmony/": "./react_native_openharmony",12+ "@rnoh/react-native-openharmony": "./react_native_openharmony",
13 },13 },
14}14}
@@ -6,4 +6,13 @@
6 */6 */
7 7 
8// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.8// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
9-export { harTasks } from '@ohos/hvigor-ohos-plugin';9+export { harTasks } from '@ohos/hvigor-ohos-plugin';
10+import { harTasks } from '@ohos/hvigor-ohos-plugin';
11+import { createInnerHarHvigorPlugin } from "@rnoh/inner-hvigor-plugin";
12+ 
13+export default {
14+ system: harTasks,
15+ plugins: [
16+ createInnerHarHvigorPlugin()
17+ ]
18+}
Mtester/harmony/react_native_openharmony/src/main/cpp/CMakeLists.txt+33-23文件内容审核中,请稍后刷新重试
@@ -13,17 +13,14 @@
13#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>13#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
14#include <react/renderer/debug/SystraceSection.h>14#include <react/renderer/debug/SystraceSection.h>
15#include <react/renderer/scheduler/Scheduler.h>15#include <react/renderer/scheduler/Scheduler.h>
16-#include "NativeLogger.h"
17#include "RNOH/EventBeat.h"16#include "RNOH/EventBeat.h"
18#include "RNOH/MessageQueueThread.h"17#include "RNOH/MessageQueueThread.h"
19-#include "RNOH/Performance/NativeTracing.h"
20#include "RNOH/RNOHError.h"18#include "RNOH/RNOHError.h"
21#include "RNOH/SchedulerDelegate.h"19#include "RNOH/SchedulerDelegate.h"
22#include "RNOH/ShadowViewRegistry.h"20#include "RNOH/ShadowViewRegistry.h"
23#include "RNOH/TurboModuleFactory.h"21#include "RNOH/TurboModuleFactory.h"
24#include "RNOH/TurboModuleProvider.h"22#include "RNOH/TurboModuleProvider.h"
25#include "RNOH/SchedulerDelegate.h"23#include "RNOH/SchedulerDelegate.h"
26-#include "hermes/executor/HermesExecutorFactory.h"
27 24 
28using namespace facebook;25using namespace facebook;
29using namespace rnoh;26using namespace rnoh;
@@ -2,39 +2,78 @@
2#2#
3# This source code is licensed under the MIT license found in the3# This source code is licensed under the MIT license found in the
4# LICENSE-MIT file in the root directory of this source tree.4# LICENSE-MIT file in the root directory of this source tree.
5-set(CMAKE_CXX_STANDARD 17)
6 5 
7-# HERMES6+function(add_hermes_executor link)
8-add_library(hermes-engine::libhermes SHARED IMPORTED)7+ # HERMES
9-add_compile_options(8+ add_library(hermes-engine::libhermes SHARED IMPORTED)
10- # TODO: check if building in debug mode9+ add_compile_options(
11- -DHERMES_ENABLE_DEBUGGER10+ # TODO: check if building in debug mode
12-)11+ -DHERMES_ENABLE_DEBUGGER
13-set(hermes_include_dirs12+ )
14- "${third_party_dir}/hermes/API"13+ set(hermes_include_dirs
15- "${third_party_dir}/hermes/public"14+ "${third_party_dir}/hermes/API"
16-)15+ "${third_party_dir}/hermes/public"
17-set_property(TARGET hermes-engine::libhermes PROPERTY16+ )
18- IMPORTED_LOCATION "${third_party_dir}/prebuilt/${OHOS_ARCH}/libhermes.so")17+ set_property(TARGET hermes-engine::libhermes PROPERTY
18+ IMPORTED_LOCATION "${third_party_dir}/prebuilt/${OHOS_ARCH}/libhermes.so")
19 19 
20-# HERMES INSPECTOR20+ # HERMES INSPECTOR
21-add_subdirectory("${REACT_COMMON_DIR}/hermes/inspector" ./hermes_inspector)21+ add_subdirectory("${REACT_COMMON_DIR}/hermes/inspector" ./hermes_inspector)
22-target_include_directories(hermes_inspector PRIVATE22+ target_include_directories(hermes_inspector PRIVATE
23- "${folly_include_dir}"23+ "${folly_include_dir}"
24- "${boost_include_dirs}"24+ "${boost_include_dirs}"
25- "${hermes_include_dirs}"25+ "${hermes_include_dirs}"
26- "${libevent_include_dirs}"26+ "${libevent_include_dirs}"
27-)27+ )
28-target_compile_options(hermes_inspector PRIVATE ${folly_compile_options})28+ target_compile_options(hermes_inspector PRIVATE ${folly_compile_options})
29 29 
30-# HERMES EXECUTOR COMMON30+ # HERMES EXECUTOR COMMON
31-add_subdirectory(${REACT_COMMON_DIR}/hermes/executor ./hermes_executor_common)31+ add_subdirectory(${REACT_COMMON_DIR}/hermes/executor ./hermes_executor_common)
32-target_include_directories(hermes_executor_common PUBLIC32+ target_include_directories(hermes_executor_common PUBLIC
33- "${folly_include_dir}"33+ "${folly_include_dir}"
34- "${boost_include_dirs}"34+ "${boost_include_dirs}"
35- "${hermes_include_dirs}"35+ "${hermes_include_dirs}"
36-)36+ )
37+ 
38+ # hermesExecutor
39+ add_library(hermes_executor SHARED
40+ "${RNOH_CPP_DIR}/RNOH/executor/hermesExecutor.cpp"
41+ "${RNOH_CPP_DIR}/RNOH/NativeLogger.cpp"
42+ "${RNOH_CPP_DIR}/RNOH/Performance/NativeTracing.cpp"
43+ )
44+ 
45+ target_link_libraries(hermes_executor PUBLIC
46+ Boost::context
47+ hermes_executor_common
48+ libhilog_ndk.z.so
49+ )
50+ 
51+ if(link)
52+ target_link_libraries(rnoh PUBLIC hermes_executor)
53+ target_compile_definitions(rnoh PUBLIC USE_HERMES=1)
54+ endif()
55+endfunction()
37 56 
38# ----------------------------------------------------------------------------------------------------------------------57# ----------------------------------------------------------------------------------------------------------------------
39 58 
40-add_subdirectory("${RNOH_CPP_DIR}/RNOH/react-native-jsvm" ./jsvm)59+function(add_jsvm_executor link)
60+ set(CMAKE_CXX_STANDARD 17)
61+ add_subdirectory("${RNOH_CPP_DIR}/RNOH/react-native-jsvm" ./jsvm)
62+ 
63+ # jsvmExecutor
64+ add_library(jsvm_executor SHARED
65+ "${RNOH_CPP_DIR}/RNOH/executor/jsvmExecutor.cpp"
66+ "${RNOH_CPP_DIR}/RNOH/NativeLogger.cpp"
67+ "${RNOH_CPP_DIR}/RNOH/Performance/NativeTracing.cpp"
68+ )
69+ 
70+ target_link_libraries(jsvm_executor PUBLIC
71+ jsvm_executor_common
72+ libhilog_ndk.z.so
73+ )
74+ 
75+ if(link)
76+ target_link_libraries(rnoh PUBLIC jsvm_executor)
77+ target_compile_definitions(rnoh PUBLIC USE_HERMES=0)
78+ endif()
79+endfunction()
@@ -11,7 +11,7 @@ add_compile_options(
11 -DLOG_TAG=\"Fabric\")11 -DLOG_TAG=\"Fabric\")
12 12 
13file(GLOB react_codegen_rncore_SRC CONFIGURE_DEPENDS *.cpp)13file(GLOB react_codegen_rncore_SRC CONFIGURE_DEPENDS *.cpp)
14-add_library(react_codegen_rncore STATIC ${react_codegen_rncore_SRC})14+add_library(react_codegen_rncore SHARED ${react_codegen_rncore_SRC})
15 15 
16target_include_directories(react_codegen_rncore PUBLIC ${REACT_COMMON_DIR})16target_include_directories(react_codegen_rncore PUBLIC ${REACT_COMMON_DIR})
17 17 
@@ -21,6 +21,7 @@ extern const char AndroidHorizontalScrollContentViewComponentName[] = "AndroidHo
21extern const char SwitchComponentName[] = "Switch";21extern const char SwitchComponentName[] = "Switch";
22extern const char TraceUpdateOverlayComponentName[] = "TraceUpdateOverlay";22extern const char TraceUpdateOverlayComponentName[] = "TraceUpdateOverlay";
23extern const char UnimplementedNativeViewComponentName[] = "UnimplementedNativeView";23extern const char UnimplementedNativeViewComponentName[] = "UnimplementedNativeView";
24+extern const char ModalHostViewComponentName[] = "ModalHostView";
24 25 
25} // namespace react26} // namespace react
26} // namespace facebook27} // namespace facebook
Mtester/package.json+2-1文件内容审核中,请稍后刷新重试