From c5c7e14fb6289bd933b2b7bc4a6fcd638598039a Mon Sep 17 00:00:00 2001 From: WhiredPlanck Date: Sat, 4 Jan 2025 08:08:11 +0800 Subject: [PATCH] Add HarmonyOS platform !macos !ios !js (#7) Co-authored-by: Qijia Liu --- .github/workflows/ci.yml | 5 +++ .github/workflows/harmony.yml | 69 +++++++++++++++++++++++++++++++++++ README.md | 7 ++-- scripts/common.py | 20 ++++++++-- scripts/dependencies.py | 5 +++ 5 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/harmony.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 597c8a7..a6e5aaa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/harmony.yml b/.github/workflows/harmony.yml new file mode 100644 index 0000000..463cff7 --- /dev/null +++ b/.github/workflows/harmony.yml @@ -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 diff --git a/README.md b/README.md index bd0f7db..3dca164 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/scripts/common.py b/scripts/common.py index 8589ac7..08e3b38 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -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}' @@ -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 += [ diff --git a/scripts/dependencies.py b/scripts/dependencies.py index 27b7aad..161fb93 100644 --- a/scripts/dependencies.py +++ b/scripts/dependencies.py @@ -56,6 +56,10 @@ 'zstd' ] +harmony = [ + 'fmt' +] + js = [ 'anthy-cmake', 'boost', @@ -84,5 +88,6 @@ platform_projects = { 'macos': macos, 'ios': ios, + 'harmony': harmony, 'js': js }