Skip to content

Commit 42523f1

Browse files
committed
ohos: add the OpenHarmony platform host
Tier-3 community port (maintainer: springmin), rebased onto the merged document-provider abstraction (flectar#84) and the opener seam (flectar#80). - platform/ohos: Slint backend (XComponent window adapter, software renderer with the experimental femtovg/wgpu path, input/IME, clipboard, system fonts), the NAPI cdylib that builds a PlatformContext (app-private paths, DocumentProvider over the ArkTS pickers, Asset Store credential store, loopback OAuth broker, external URL opener, notification publisher) and calls flectar_mail::run, the demo crate, the ArkTS shell and the build and packaging scripts (bundle name configurable, defaults to com.flectar.mail_ohos). - src/platform/ohos.rs: PDFium directory, renderer name, thread priority, preview lifecycle, email font directory; OpenHarmony stays under the mobile capability alias. - patches/fontique + crates/fontique: the Fontconfig opt-out as a patch queue applied by the platform/ohos workspace, verified from quality.yml. - .github/workflows/ohos.yml: manually dispatched tier-3 workflow, unsigned by default, signing material only from the FLECTAR_OHOS_* secrets. - src/documents.rs: run_request blocks the calling thread on mobile hosts; the picker covers the window, and keeping the presentation thread idle is what OpenHarmony needs (verified on device; desktop keeps the runtime request for the native dialog). - The email renderer and the compose editor load platform::email_font_dir() and the Han fallback, so CJK mail bodies and composed text render with the platform fonts. - New-mail notifications: a publisher seam fed by CoreEvent::MailNew; the host publishes through @kit.NotificationKit.
1 parent 6169539 commit 42523f1

104 files changed

Lines changed: 21536 additions & 11 deletions

File tree

Some content is hidden

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

‎.github/workflows/ohos.yml‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: OpenHarmony hap
2+
3+
# Tier 3 (platform/README.md): a community port built by a manually dispatched
4+
# workflow, never on pull requests. The HarmonyOS SDK and hvigor are not
5+
# anonymously downloadable, so the build job targets a self-hosted runner with
6+
# the toolchain described in platform/ohos/README.md.
7+
#
8+
# Pull request checks build unsigned: this workflow only runs on dispatch, and
9+
# signing material exists exclusively as repository secrets.
10+
11+
on:
12+
workflow_dispatch:
13+
inputs:
14+
app:
15+
description: Application to package
16+
type: choice
17+
options:
18+
- mail
19+
- demo
20+
default: mail
21+
profile:
22+
description: Cargo profile
23+
type: choice
24+
options:
25+
- release
26+
- debug
27+
default: release
28+
sign:
29+
description: Sign with the AGC material stored in the repository secrets
30+
type: boolean
31+
default: false
32+
run_quality:
33+
description: Run the shared quality suite first
34+
type: boolean
35+
default: true
36+
37+
permissions:
38+
contents: read
39+
40+
concurrency:
41+
group: ohos-${{ github.ref }}
42+
cancel-in-progress: false
43+
44+
jobs:
45+
quality:
46+
if: inputs.run_quality
47+
name: Shared quality suite
48+
uses: ./.github/workflows/quality.yml
49+
50+
hap:
51+
name: ${{ inputs.app }} hap (${{ inputs.profile }})
52+
needs: quality
53+
if: always() && (needs.quality.result == 'success' || needs.quality.result == 'skipped')
54+
runs-on: [self-hosted, linux, ohos]
55+
timeout-minutes: 180
56+
steps:
57+
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
58+
59+
- name: Check the OHOS workspace formatting
60+
run: cargo fmt --manifest-path platform/ohos/Cargo.toml --all -- --check
61+
62+
- name: Materialize signing material
63+
if: inputs.sign
64+
env:
65+
KEYSTORE_BASE64: ${{ secrets.FLECTAR_OHOS_KEYSTORE_BASE64 }}
66+
CERTIFICATE_BASE64: ${{ secrets.FLECTAR_OHOS_CERTIFICATE_BASE64 }}
67+
PROFILE_BASE64: ${{ secrets.FLECTAR_OHOS_PROFILE_BASE64 }}
68+
run: |
69+
test -n "$KEYSTORE_BASE64"
70+
test -n "$CERTIFICATE_BASE64"
71+
test -n "$PROFILE_BASE64"
72+
material="$RUNNER_TEMP/ohos-signing"
73+
umask 077
74+
mkdir -p "$material"
75+
printf '%s' "$KEYSTORE_BASE64" | base64 --decode > "$material/keystore.p12"
76+
printf '%s' "$CERTIFICATE_BASE64" | base64 --decode > "$material/certificate.cer"
77+
printf '%s' "$PROFILE_BASE64" | base64 --decode > "$material/profile.p7b"
78+
{
79+
echo "RELEASE_SIGN=1"
80+
echo "RELEASE_P12=$material/keystore.p12"
81+
echo "RELEASE_CERT=$material/certificate.cer"
82+
echo "RELEASE_PROFILE=$material/profile.p7b"
83+
echo "RELEASE_KEY_ALIAS=${{ secrets.FLECTAR_OHOS_KEY_ALIAS }}"
84+
echo "RELEASE_KEY_PWD=${{ secrets.FLECTAR_OHOS_KEY_PASSWORD }}"
85+
echo "RELEASE_STORE_PWD=${{ secrets.FLECTAR_OHOS_STORE_PASSWORD }}"
86+
} >> "$GITHUB_ENV"
87+
88+
- name: Build the hap
89+
env:
90+
APP: ${{ inputs.app }}
91+
PROFILE: ${{ inputs.profile }}
92+
CARGO_BUILD_JOBS: "4"
93+
SKIP_SIGN: ${{ inputs.sign && '0' || '1' }}
94+
run: sh platform/ohos/scripts/build-hap.sh
95+
96+
- name: Remove the signing material
97+
if: always() && inputs.sign
98+
run: rm -rf "$RUNNER_TEMP/ohos-signing"
99+
100+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
101+
with:
102+
name: flectar-ohos-${{ inputs.app }}-${{ inputs.profile }}
103+
path: platform/ohos/build/*.hap
104+
if-no-files-found: error

‎.github/workflows/quality.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ jobs:
8383
run: python3 scripts/check-platform-gates.py
8484
- name: Verify the Blitz patch queue
8585
run: bash scripts/blitz-patches.sh verify
86+
- name: Verify the Fontique patch queue
87+
run: bash scripts/fontique-patches.sh verify
8688
- name: Verify and test the Parley backport
8789
run: |
8890
python3 scripts/verify-parley.py

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@
3030

3131
# graft's local graph cache — regenerable, not committed (run `graft build`).
3232
/graft/
33+
34+
# hvigor build metadata (the OHOS shell build regenerates it)
35+
.hvigor/

‎Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
members = ["crates/flectar-mail-core", "crates/renderer-probe"]
3-
exclude = ["crates/candle-core", "crates/blitz-dom", "crates/blitz-paint", "crates/parley", "crates/parley_emoji"]
3+
exclude = ["crates/candle-core", "crates/blitz-dom", "crates/blitz-paint", "crates/fontique", "crates/parley", "crates/parley_emoji"]
44
resolver = "3"
55

66
[workspace.dependencies]
@@ -171,7 +171,7 @@ objc2-foundation = { version = "0.3", default-features = false, features = ["std
171171
objc2-service-management = { version = "0.3", default-features = false, features = ["std", "objc2", "objc2-foundation", "SMAppService"] }
172172

173173
# This is `desktop`; keep it in step with the `mobile` alias in build.rs.
174-
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
174+
[target.'cfg(not(any(target_os = "android", target_os = "ios", target_env = "ohos")))'.dependencies]
175175
arboard = { version = "3.6", default-features = false, features = ["wayland-data-control"] }
176176
rfd = { version = "0.16", default-features = false, features = ["tokio", "xdg-portal"] }
177177

‎build.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn main() {
55
// operating system. A new platform joins these groups here (and in the
66
// core's build.rs) instead of editing call sites. See platform/README.md.
77
cfg_aliases! {
8-
mobile: { any(target_os = "android", target_os = "ios") },
8+
mobile: { any(target_os = "android", target_os = "ios", target_env = "ohos") },
99
desktop: { not(mobile) },
1010
// OpenHarmony reports target_os = "linux" without a desktop session,
1111
// portals, X11 or a Secret Service.

‎crates/flectar-mail-core/build.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() {
1212
// Keep `mobile` identical to the application's build.rs; see
1313
// platform/README.md.
1414
cfg_aliases! {
15-
mobile: { any(target_os = "android", target_os = "ios") },
15+
mobile: { any(target_os = "android", target_os = "ios", target_env = "ohos") },
1616
desktop: { not(mobile) },
1717
// rustix exposes renameat2/renameatx_np with RENAME_NOREPLACE here.
1818
rename_noreplace: { any(target_os = "linux", target_os = "android", target_os = "macos", target_os = "ios") },
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"git": {
3+
"sha1": "eea3503dd6cf17130cbb07348e0ff2c918300e94"
4+
},
5+
"path_in_vcs": "fontique"
6+
}

0 commit comments

Comments
 (0)