Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add libmozc rule #32

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ jobs:
NDK_VERSION: "25.2.9519653"
CMAKE_VERSION: "3.22.1"
ANDROID_PLATFORM: "23"
MOZC_SHA: ad0e97b8b8dcfd4c841a02c5d6a043fb5e741405

steps:
- name: Install build dependencies
run: |
pacman -Syu --needed --noconfirm \
git unzip ghc cabal-install haskell-shake haskell-aeson-pretty \
cmake extra-cmake-modules ninja fmt fcitx5 boost python opencc jre-openjdk gperf
cmake extra-cmake-modules ninja fmt fcitx5 boost python opencc jre-openjdk gperf bazel

- name: Fetch source code
uses: actions/checkout@v4
Expand All @@ -36,11 +37,27 @@ jobs:
# fetch libime submodule kenlm since it's not in .gitmodules
git submodule update --init --recursive libime

- name: Fetch mozc
uses: actions/checkout@v4
with:
submodules: recursive
repository: google/mozc
path: libmozc/mozc
ref: ${{ env.MOZC_SHA }}

- name: Setup Android NDK
uses: android-actions/setup-android@v3
with:
packages: "ndk;${{ env.NDK_VERSION }} cmake;${{ env.CMAKE_VERSION }}"

- name: Build mozc_data.inc
run: |
git apply --directory=libmozc/mozc/src/third_party/protobuf libmozc/patches/protobuf.patch
cd libmozc/mozc/src
useradd -m builduser
chown -R builduser:builduser .
sudo -u builduser JAVA_HOME=/usr/lib/jvm/java-21-openjdk bazel build --config oss_linux --host_cxxopt=-Wno-uninitialized //data_manager/oss:mozc_data.inc

- name: Build everything
env:
ANDROID_NDK_ROOT: ${{ env.ANDROID_HOME }}/ndk/${{ env.NDK_VERSION }}
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@
[submodule "libiconv"]
path = libiconv
url = https://git.savannah.gnu.org/git/libiconv
[submodule "libmozc"]
path = libmozc
url = https://github.com/fcitx-contrib/fcitx5-mozc
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ Cabal is required to build this project.
* libchewing: [chewing/libchewing](https://github.com/chewing/libchewing)
* libthai: [tlwg/libthai](https://github.com/tlwg/libthai)
* libiconv: [GNU/libiconv](https://savannah.gnu.org/projects/libiconv)
* mozc: [google/mozc](https://github.com/google/mozc)
1 change: 1 addition & 0 deletions libmozc
Submodule libmozc added at 5580d5
1 change: 1 addition & 0 deletions prebuilder.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ executable prebuilder
Rules.LibIMEJyutping
Rules.LibIconv
Rules.LibIntlLite
Rules.LibMozc
Rules.LibRime
Rules.LibThai
Rules.Lua
Expand Down
3 changes: 3 additions & 0 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Rules.LibHangul
import Rules.LibIME
import Rules.LibIMEJyutping
import Rules.LibIntlLite
import Rules.LibMozc
import Rules.LibRime
import Rules.LibThai
import Rules.Lua
Expand Down Expand Up @@ -71,6 +72,7 @@ main = do
libthaiRule
libiconvRule
anthyDictRule
libmozcRule
isInGitHubActionRule
getOutputDirRule
"everything" ~> do
Expand All @@ -90,6 +92,7 @@ main = do
"yaml-cpp",
"leveldb",
"marisa",
"libmozc",
"librime",
"libhangul",
"chewing-dict",
Expand Down
35 changes: 35 additions & 0 deletions src/Rules/LibMozc.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}

module Rules.LibMozc where

import Base
import CMakeBuilder

data LibMozc = LibMozc
deriving stock (Eq, Show, Typeable, Generic)
deriving anyclass (Hashable, Binary, NFData)

type instance RuleResult LibMozc = ()

libmozcRule :: Rules ()
libmozcRule = do
buildLibmozc <-
useCMake $
(cmakeBuilder "libmozc")
{ preBuild = BuildAction $ \_ src -> do
cmd_ (Cwd src) "cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_MOZC_ADDON=OFF"
cmd_ (Cwd src) "cmake --build build --target protoc",
cmakeFlags =
const
[ "-DPROTOC_EXECUTABLE=../../build/protoc",
"-DCMAKE_CXX_FLAGS=-I../../libmozc/mozc/src/bazel-bin",
"-DBUILD_MOZC_ADDON=OFF"
],
postBuildEachABI = BuildActionABI $ \_ BuildEnv {..} -> do
cmd_ (Cwd buildEnvBuildDir) Shell "ar rc" (buildEnvOutPrefix </> "lib" </> "libabsl.a") "$(find mozc/src/third_party/abseil-cpp -name '*.o')"
}
"libmozc" ~> buildWithAndroidEnv buildLibmozc LibMozc
Loading