Skip to content

Commit 9e89b63

Browse files
committed
Merge branch 'fix/npmignore-bun-cache'
2 parents c23886e + e6054e0 commit 9e89b63

4 files changed

Lines changed: 58 additions & 48 deletions

File tree

.github/workflows/publish.yml

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ jobs:
4646
runs-on: ubuntu-latest
4747
container: ghcr.io/sanchuanhehe/harmony-next-pipeline-docker/harmonyos-ci-image:latest
4848
timeout-minutes: 15
49-
env:
50-
BUN_INSTALL_CACHE_DIR: ${{ github.workspace }}/.bun-cache
51-
OHPM_CACHE_DIR: ${{ github.workspace }}/.ohpm-cache
5249
steps:
5350
- uses: actions/checkout@v6
5451
with:
@@ -58,37 +55,11 @@ jobs:
5855
git config --global --add safe.directory "$GITHUB_WORKSPACE"
5956
git submodule foreach --recursive 'git config --global --add safe.directory "$toplevel/$sm_path"'
6057
- uses: oven-sh/setup-bun@v2
61-
- name: Cache Bun dependencies
62-
uses: actions/cache@v4
63-
with:
64-
path: .bun-cache
65-
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
66-
restore-keys: |
67-
${{ runner.os }}-bun-
6858
# Setup .npmrc file to publish to npm
6959
- uses: actions/setup-node@v6
7060
with:
7161
node-version: 24
7262
registry-url: 'https://registry.npmjs.org'
73-
- name: Cache OHPM dependencies
74-
uses: actions/cache@v4
75-
with:
76-
path: |
77-
.ohpm-cache
78-
harmony/pushy/oh_modules
79-
harmony/har-wrapper/oh_modules
80-
key: ${{ runner.os }}-ohpm-${{ hashFiles('harmony/pushy/oh-package-lock.json5') }}
81-
restore-keys: |
82-
${{ runner.os }}-ohpm-
83-
- name: Cache Hvigor build outputs
84-
uses: actions/cache@v4
85-
with:
86-
path: |
87-
harmony/pushy/.hvigor
88-
harmony/har-wrapper/.hvigor
89-
key: ${{ runner.os }}-hvigor-${{ github.sha }}
90-
restore-keys: |
91-
${{ runner.os }}-hvigor-
9263
- run: bun install --frozen-lockfile
9364
- name: Build Harmony HAR
9465
run: npm run build:harmony-har -- --build-mode release
@@ -108,8 +79,6 @@ jobs:
10879
if: needs.check_changes.outputs.harmony_changed == 'false'
10980
runs-on: ubuntu-latest
11081
timeout-minutes: 10
111-
env:
112-
BUN_INSTALL_CACHE_DIR: ${{ github.workspace }}/.bun-cache
11382
steps:
11483
- uses: actions/checkout@v6
11584
with:
@@ -119,13 +88,6 @@ jobs:
11988
git config --global --add safe.directory "$GITHUB_WORKSPACE"
12089
git submodule foreach --recursive 'git config --global --add safe.directory "$toplevel/$sm_path"'
12190
- uses: oven-sh/setup-bun@v2
122-
- name: Cache Bun dependencies
123-
uses: actions/cache@v4
124-
with:
125-
path: .bun-cache
126-
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
127-
restore-keys: |
128-
${{ runner.os }}-bun-
12991
# Setup .npmrc file to publish to npm
13092
- uses: actions/setup-node@v6
13193
with:

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@ harmony/**
7474
android/jni/lzma/bin
7575
android/jni/lzma/DOC
7676

77+
# Ignore unnecessary development files
78+
scripts/**
79+
!scripts/check-expo-version.js
80+
harmony/pushy/src/test/
81+
babel.config.js
82+
tsconfig.json
83+
bunfig.toml
84+
7785

harmony/pushy/src/main/cpp/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,19 @@ if(TARGET rnoh)
6868
target_include_directories(rnoh_pushy PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
6969
target_link_libraries(rnoh_pushy PUBLIC rnoh)
7070
endif()
71+
72+
# Optimize binary size and performance for Release builds
73+
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
74+
# Enable Link Time Optimization (LTO / IPO)
75+
include(CheckIPOSupported)
76+
check_ipo_supported(RESULT ipo_supported OUTPUT error)
77+
if(ipo_supported)
78+
set_property(TARGET rnupdate PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
79+
if(TARGET rnoh_pushy)
80+
set_property(TARGET rnoh_pushy PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
81+
endif()
82+
endif()
83+
84+
# Strip debug symbols and perform garbage collection of unused code sections
85+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -s")
86+
endif()

scripts/build-harmony-har.js

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,30 @@ function buildHar() {
134134
}
135135

136136
if (!skipInstall) {
137-
runCommand(ohpmPath, ['install'], {
138-
cwd: harmonyModuleDir,
139-
env,
140-
label: 'Install Harmony dependencies',
141-
});
137+
if (hasDependencies(harmonyModuleDir)) {
138+
runCommand(ohpmPath, ['install'], {
139+
cwd: harmonyModuleDir,
140+
env,
141+
label: 'Install Harmony dependencies',
142+
});
143+
}
142144

143-
runCommand(ohpmPath, ['install'], {
144-
cwd: wrapperProjectDir,
145-
env,
146-
label: 'Install wrapper project dependencies',
147-
});
145+
if (hasDependencies(wrapperProjectDir)) {
146+
runCommand(ohpmPath, ['install'], {
147+
cwd: wrapperProjectDir,
148+
env,
149+
label: 'Install wrapper project dependencies',
150+
});
151+
}
148152
}
149153

150154
const hvigorArgs = ['assembleHar'];
151155
if (buildMode !== 'debug') {
152156
hvigorArgs.push('-p', `buildMode=${buildMode}`);
153157
}
158+
if (process.env.CI === 'true') {
159+
hvigorArgs.push('--no-daemon');
160+
}
154161

155162
runCommand(hvigorwPath, hvigorArgs, {
156163
cwd: wrapperProjectDir,
@@ -437,3 +444,20 @@ function relativeToProject(filePath) {
437444
function fail(message) {
438445
throw new Error(message);
439446
}
447+
448+
function hasDependencies(dir) {
449+
try {
450+
const pkgPath = path.join(dir, 'oh-package.json5');
451+
if (!fs.existsSync(pkgPath)) {
452+
return false;
453+
}
454+
const pkgContent = fs.readFileSync(pkgPath, 'utf8');
455+
const cleanJson = pkgContent.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, '');
456+
const pkg = eval('(' + cleanJson + ')');
457+
const hasDeps = pkg.dependencies && Object.keys(pkg.dependencies).length > 0;
458+
const hasDevDeps = pkg.devDependencies && Object.keys(pkg.devDependencies).length > 0;
459+
return !!(hasDeps || hasDevDeps);
460+
} catch (e) {
461+
return true;
462+
}
463+
}

0 commit comments

Comments
 (0)