Skip to content

Commit 298e07f

Browse files
committed
update harmony remote dependency flow
1 parent e9dbb96 commit 298e07f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+5864600
-138
lines changed
Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,20 @@
11
## 运行harmony_use_pushy项目步骤
22

3-
### 1.将项目克隆到本地后在项目根目录创建libs文件夹。
4-
5-
### 2.然后将[`rnoh`](https://github.com/bozaigao/rnoh)克隆到libs文件夹中。
6-
7-
说明:rnoh项目基于react-native 0.72.5版本适配,如果使用最新的RN版本可能会报错,项目适配RN新版本请关注[`gitee仓库`](https://gitee.com/openharmony-sig/ohos_react_native/tree/0.72.5-ohos-5.0-release/tester/harmony/react_native_openharmony/src/main)
8-
9-
### 3.进入rnoh项目执行下面命令对rnoh项目依赖的C++库进行初始化;
10-
```
11-
git submodule update --init --recursive
12-
```
13-
14-
### 4. 确保在react-native-update根目录已经执行过yarn submodule命令。
15-
说明:这个命令会在harmony/src/main/cpp目录生成HDiffPatch和lzma的C++模块依赖。
16-
17-
### 5. 在项目根目录执行下面命令安装第三方依赖。
3+
### 1. 在项目根目录执行下面命令安装第三方依赖。
184
```
195
yarn install
206
```
217

22-
### 6. 在项目根目录执行下面命令生成bundle包文件。
8+
### 2. 在项目根目录执行下面命令生成bundle包文件。
239
```
2410
yarn build
2511
```
2612
说明:这个命令会在harmony/entry/src/main/resources/rawfile目录生成Hbundle.harmony.js和assets文件,同时会基于该内容在.pushy/output目录生成ppk包。
2713

2814
**注意⚠️**:在使用pushy bundle --platform harmony命令进行打包的默认bundle包名是Hbundle.harmony.js,不要随意修改包名,因为diff是匹配该包名进行生成的。
2915

30-
### 7. 使用DevEco Studio IDE打开harmony目录然后执行sync运行项目
16+
### 3. 使用DevEco Studio IDE打开harmony目录然后执行sync运行项目
3117
![image](./sync.png)
3218

33-
### 8 运行效果图
19+
### 4 运行效果图
3420
![image](./demo.png)

Example/harmony_use_pushy/harmony/AppScope/resources/base/element/string.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"string": [
33
{
44
"name": "app_name",
5-
"value": "harmony_use_pushy"
5+
"value": "Pushy"
66
}
77
]
88
}
31.8 KB
Loading

Example/harmony_use_pushy/harmony/build-profile.json5

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@
3737
}
3838
]
3939
},
40-
{
41-
name: 'rnoh',
42-
srcPath: '../libs/rnoh',
43-
},
4440
{
4541
name: 'pushy',
4642
srcPath: '../node_modules/react-native-update/harmony',

Example/harmony_use_pushy/harmony/entry/hvigorfile.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export function generatePushyBuildTime(str?: string) {
1414
if (!fs.existsSync(dirPath)) {
1515
fs.mkdirSync(dirPath, { recursive: true });
1616
}
17-
const moduleJsonPath = path.resolve(__dirname, '../AppScope/app.json5');
17+
const moduleJsonPath = path.resolve(__dirname, './oh-package.json5');
1818
let versionName = '';
1919
if (fs.existsSync(moduleJsonPath)) {
2020
const moduleContent = fs.readFileSync(moduleJsonPath, 'utf-8');
21-
const versionMatch = moduleContent.match(/"versionName":\s*"([^"]+)"/);
21+
const versionMatch = moduleContent.match(/"version":\s*"([^"]+)"/);
2222
if (versionMatch && versionMatch[1]) {
2323
versionName = versionMatch[1];
2424
}
@@ -28,7 +28,7 @@ export function generatePushyBuildTime(str?: string) {
2828
pushy_build_time: buildTime,
2929
versionName: versionName
3030
};
31-
fs.writeFileSync(metaFilePath, JSON.stringify(metaContent, null, 4));
31+
// fs.writeFileSync(metaFilePath, JSON.stringify(metaContent, null, 4));
3232
console.log(`Build time written to ${metaFilePath}`);
3333
},
3434
dependencies: [],

Example/harmony_use_pushy/harmony/entry/oh-package-lock.json5

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/harmony_use_pushy/harmony/entry/oh-package.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"author": "",
77
"license": "",
88
"dependencies": {
9-
"rnoh": "file:../../libs/rnoh",
9+
"@rnoh/react-native-openharmony": "0.72.38",
1010
"pushy": "file:../../node_modules/react-native-update/harmony"
1111
}
1212
}

Example/harmony_use_pushy/harmony/entry/src/main/cpp/CMakeLists.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,24 @@ cmake_minimum_required(VERSION 3.16)
22
project(rnapp)
33
set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
44
set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
5-
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../libs/rnoh/src/main/cpp")
5+
set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
6+
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp")
67
set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
7-
add_subdirectory("${OH_MODULES}/pushy/src/main/cpp" ./pushy)
8+
#set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated")
9+
set(LOG_VERBOSITY_LEVEL 1)
10+
set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
11+
set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
12+
set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
13+
set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
14+
add_compile_definitions(WITH_HITRACE_SYSTRACE)
815

16+
add_subdirectory("${OH_MODULES}/pushy/src/main/cpp" ./pushy)
917
add_subdirectory("${RNOH_CPP_DIR}" ./rn)
18+
19+
file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1
20+
1021
add_library(rnoh_app SHARED
22+
${GENERATED_CPP_FILES}
1123
"./PackageProvider.cpp"
1224
"${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
1325
)

Example/harmony_use_pushy/harmony/entry/src/main/cpp/PackageProvider.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "RNOH/PackageProvider.h"
2+
// #include "generated/RNOHGeneratedPackage.h"
23
#include "PushyPackage.h"
34
using namespace rnoh;
45

Example/harmony_use_pushy/harmony/entry/src/main/ets/RNPackagesFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {RNPackageContext, RNPackage} from 'rnoh/ts';
1+
import type {RNPackageContext, RNPackage} from '@rnoh/react-native-openharmony/ts';
22
import {PushyPackage} from 'pushy/ts';
33

44
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {

0 commit comments

Comments
 (0)