Skip to content

Commit

Permalink
Add HarmonyOS platform !macos !ios !js (#7)
Browse files Browse the repository at this point in the history
Co-authored-by: Qijia Liu <liumeo@pku.edu.cn>
  • Loading branch information
WhiredPlanck and eagleoflqj authored Jan 4, 2025
1 parent 9c56760 commit c5c7e14
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ jobs:
with:
mozc_sha: ${{ needs.lint.outputs.MOZC_SHA }}

harmony:
if: "!contains(github.event.head_commit.message, '!harmony')"
needs: lint
uses: ./.github/workflows/harmony.yml

js:
if: "!contains(github.event.head_commit.message, '!js')"
needs: lint
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/harmony.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: HarmonyOS build

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-24.04
env:
SDK_VERSION_MAJOR: 5.0.5
SDK_VERSION_MINOR: 310
strategy:
fail-fast: false
matrix:
arch: [arm64-v8a, x86_64]

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
sudo apt install -y ninja-build
- name: Install OpenHarmony SDK
uses: fcitx-contrib/ohpm-cli-tools@master
with:
major: ${{ env.SDK_VERSION_MAJOR }}
minor: ${{ env.SDK_VERSION_MINOR }}

- name: Build
run: python scripts/build.py harmony ${{ matrix.arch }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: artifact-harmony-${{ matrix.arch }}
path: |
build/harmony-${{ matrix.arch }}/*.tar.bz2
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3

release:
needs: build
if: ${{ github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
pattern: artifact-harmony*
merge-multiple: true

- name: Release
uses: 'marvinpinto/action-automatic-releases@latest'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: harmony
prerelease: true
title: "Harmony Build"
files: |
*.tar.bz2
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Fcitx5 prebuilder

Build static libraries and resources for
[fcitx5-macos](https://github.com/fcitx-contrib/fcitx5-macos),
[fcitx5-ios](https://github.com/fcitx-contrib/fcitx5-ios) and
[fcitx5-js](https://github.com/fcitx-contrib/fcitx5-js).
* [fcitx5-macos](https://github.com/fcitx-contrib/fcitx5-macos)
* [fcitx5-ios](https://github.com/fcitx-contrib/fcitx5-ios)
* [fcitx5-harmony](https//github.com/fcitx-contrib/fcitx5-harmony)
* [fcitx5-js](https://github.com/fcitx-contrib/fcitx5-js)
20 changes: 17 additions & 3 deletions scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@
'ios': IOS_VERSION
}

PLATFORM = cast(Literal['macos', 'ios', 'js'], sys.argv[1])
POSTFIX = '-' + platform.machine() if PLATFORM == 'macos' or 'simulator' in sys.argv[2:] else ''
PLATFORM = cast(Literal['macos', 'ios', 'harmony', 'js'], sys.argv[1])
IOS_PLATFORM = 'SIMULATOR' if 'simulator' in sys.argv[2:] else 'OS'
OHOS_ARCH = sys.argv[2] if PLATFORM == 'harmony' else ''

if PLATFORM == 'macos' or IOS_PLATFORM == 'SIMULATOR':
POSTFIX = '-' + platform.machine()
elif PLATFORM == 'harmony':
POSTFIX = '-' + OHOS_ARCH
else: # iOS real device or JS
POSTFIX = ''

ROOT = os.getcwd()

INSTALL_PREFIX = '/usr'
# macos-x86_64, ios-arm64, js
# macos-x86_64, ios-arm64, js, harmony-arm64-v8a
TARGET = f'{PLATFORM}{POSTFIX}'
# macos-x86_64/usr, ios-arm64/usr, js/usr
USR = f'{TARGET}{INSTALL_PREFIX}'
Expand Down Expand Up @@ -156,6 +164,12 @@ def configure(self):
f'-DCMAKE_FIND_ROOT_PATH={ROOT}/build/{USR}'
]

if PLATFORM == 'harmony':
command += [
'-DCMAKE_TOOLCHAIN_FILE=/tmp/command-line-tools/sdk/default/openharmony/native/build/cmake/ohos.toolchain.cmake',
f'-DOHOS_ARCH={OHOS_ARCH}'
]

if PLATFORM == 'ios':
# IOS_PLATFORM is recognized by ios.cmake.
command += [
Expand Down
5 changes: 5 additions & 0 deletions scripts/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
'zstd'
]

harmony = [
'fmt'
]

js = [
'anthy-cmake',
'boost',
Expand Down Expand Up @@ -84,5 +88,6 @@
platform_projects = {
'macos': macos,
'ios': ios,
'harmony': harmony,
'js': js
}

0 comments on commit c5c7e14

Please sign in to comment.