summarylogtreecommitdiffstats
path: root/PKGBUILD.fcitx.normal
blob: 6b6747514ec952073693bab37bca520e6b9bc7cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# $Id$
# shellcheck disable=SC2034,SC2148,SC2154
# Maintainer: Masato TOYOSHIMA <phoepsolonix at gmail dot com>
# Contributor: UTUMI Hirosi <utuhiro78 at yahoo dot co dot jp>
# Contributor: BrLi <brli at chakralinux dot org>
# Contributor: Nocifer <apmichalopoulos at gmail dot com>
# Contributor: Felix Yan <felixonmars@gmail.com>
# Contributor: ponsfoot <cabezon dot hashimoto at gmail dot com>

## Mozc compile option
_bldtype=Release
_mozc_commit=671cec2b4239e2b56fa242d765337456edbe3b44
_bcr_commit=f3696c14577aaabeed3dc04e4e9a228dabe52450
_branch=fcitx

## follow the submodule commits in https://github.com/fcitx/mozc/tree/fcitx/src/third_party
_abseil_cpp_commit=4447c756
_breakpad_commit=216cea7b
_gtest_commit=b514bdc8
_gyp_commit=9ecf45e3
_japanese_usage_dictionary_commit=e5b3425
_protobuf_commit=5fda5abda
_wil_commit=fc5dbf5

pkgbase=mozc
pkgname=("fcitx-$pkgbase")
pkgver=2.30.5618.102
pkgrel=18
arch=('x86_64')
url="https://github.com/fcitx/mozc"
license=('Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND MIT AND NAIST-2003 AND Unicode-3.0 AND LicenseRef-Okinawa-Dictionary')
makedepends=('bazel' 'git' 'python' 'mold' 'fcitx-qt6' 'fcitx')
options=(!lto !distcc !ccache)
source=("git+$url.git#commit=${_mozc_commit}"
        "bcr::git+https://github.com/bazelbuild/bazel-central-registry.git#commit=${_bcr_commit}"
        "build-script.patch::https://github.com/fcitx/mozc/commit/83c68ed46093deb037b6c9368d55da7e7a0ec181.patch"
        "git+https://github.com/abseil/abseil-cpp.git#commit=${_abseil_cpp_commit}"
        "git+https://github.com/google/breakpad.git#commit=${_breakpad_commit}"
        "git+https://github.com/google/googletest.git#commit=${_gtest_commit}"
        "git+https://github.com/chromium/gyp.git#commit=${_gyp_commit}"
        "git+https://github.com/hiroyuki-komatsu/japanese-usage-dictionary.git#commit=${_japanese_usage_dictionary_commit}"
        "git+https://github.com/protocolbuffers/protobuf.git#commit=${_protobuf_commit}"
        "git+https://github.com/microsoft/wil.git#commit=${_wil_commit}"
)

sha512sums=('0fff2ebc40401807fccd882450f3f66e824c80f47f8994fb9ff1cabd2c6db8f9e71b73b3316c5dc7cb73959aa393586e2961b799837a2f3afb441e774273f4ca'
            '83281fcd5000cec7fa5b6955bad4d55a341ce84e53a4171fafad0c0a2f0b82df38334d6e6726f1408867413e12025d0ca348aceaedf4fb505ada925cb0c35ed0'
            'e077c843dc717f7e9add0a135762ffe7c3117316f59e504d75764c49a0c06967e54217d3a2fbd7afd3bc118e9ade743746c69af6accbabc4dc5786ce43dba54c'
            '83a6fa68645d138af64ddddcfd15da567c4c46f92fb69be6c10bc5989c3aa6ab85776dfb3fcccdc9e7c32ca9f8260be121ceb7d329792d28ec9a66417a903a68'
            'f69046af8c37a2a8a441a258d5b8677016966cb43d8a3bb48badc78123a885d6179ff77d7885fd6c84130136a1b8931a98d35f9fcce3d03ed31a37a72ece0b9d'
            '44db7d4a09aa7d36f1fb5a89be2234834a58834c76e445f8e9f7bc5685f6a76005b19fc758842c63641e476fa97c10eb968fa13965312fafca25843181fd025b'
            'c8ce90c2493c05a78221befc4cbbcfcbe7a0bafb7bfa55403b085bf8c3fd069c4690d1ff59ef9e0e8a813bd3673588eb38e02ad81c42a6dd0be5246f27442169'
            '91b878735e767ddf6f1fe3de61486c1e78936a0f683855e7c34a21c711f405899d3de369d2ff0a1910d65b1afc8c225d8d8b9398cf98d760f3afcfe42644fca2'
            '4ec946b3e73869c47bb5f52ff91d57ce37b8bf94804174ad278be699a9a9d9f9ba11e20e6ad6017d41653cb99ac41a11d1d4ecadf87556b1c3a189f77c138757'
            '504066a457f77b510f492626c919b6fd7b61f77948bdddef0f7e43ae09bb4bf03cea7000fba91ae0123a94d3b39cac6dfac2010126849afe0a183727fe7b0fc1')

pkgver() {
  cd "${srcdir}/mozc" || exit
  source <(grep = src/data/version/mozc_version_template.bzl| tr -d ' ')
  printf "%s.%s.%s.%s" "$MAJOR" "$MINOR" "$BUILD_OSS" "$((REVISION+2))"
}

prepare() {
  cd "$srcdir/mozc"
  git submodule init
  git config submodule.src/third_party/abseil-cpp.url "$srcdir/abseil-cpp"
  git config submodule.src/third_party/breakpad.url "$srcdir/breakpad"
  git config submodule.src/third_party/gtest.url "$srcdir/googletest"
  git config submodule.src/third_party/gyp.url "$srcdir/gyp"
  git config submodule.src/third_party/japanese_usage_dictionary.url "$srcdir/japanese-usage-dictionary"
  git config submodule.src/third_party/protobuf.url "$srcdir/protobuf"
  git config submodule.src/third_party/wil.url "$srcdir/wil"
  git -c protocol.file.allow=always submodule update

  # PR(pull request) #68 for bazel build
  patch -p1 -i ${srcdir}/build-script.patch

  cd "$srcdir/mozc/src"

  # use libstdc++ instead of libc++
  sed '/stdlib=libc++/d;/-lc++/d' -i gyp/common.gypi

  # nm -f posix (llvm-nm -f posix)
  sed 's|nm \(.*\)\-f p |nm \1-f posix |' -i third_party/gyp/pylib/gyp/generator/ninja.py

  # disable warning of ANDROID_NDK_HOME
  sed -e '/register_toolchains("@androidndk\/\/:all")/d' -i MODULE.bazel
}

build() {
  cd "$srcdir/mozc/src" || exit

  # Fix compatibility with google-glog 0.3.3 (symbol conflict)
  CFLAGS="${CFLAGS} -fvisibility=hidden"
  CXXFLAGS="${CXXFLAGS} -fvisibility=hidden"

  BAZEL_COPTS=$(echo ${CPPFLAGS} ${CFLAGS} | xargs -n1 |grep -v _FORTIFY_SOURCE | xargs -n1 echo "--copt")
  BAZEL_CXXOPTS=$(echo ${CPPFLAGS} ${CXXFLAGS} | xargs -n1 |grep -v _FORTIFY_SOURCE | xargs -n1 echo "--cxxopt")
  LDFLAGS="${LDFLAGS} -fuse-ld=mold"
  BAZEL_LDOPTS=$(echo ${LDFLAGS} | xargs -n1 echo "--linkopt")

  # The bazel rules have changed, so the cache will be deleted.
  #bazel clean --expunge

  # fcitx4
  # unix/fcitx:fcitx-mozc.so server:mozc_server gui/tool:mozc_tool
  env _BUILD_TARGETS="unix/fcitx:fcitx-mozc.so server:mozc_server gui/tool:mozc_tool" \
  ../scripts/build_fcitx5_bazel --registry=file://${srcdir}/bcr --config release_build --cxxopt=-Wno-uninitialized --host_cxxopt=-Wno-uninitialized $BAZEL_LDOPTS $BAZEL_COPTS $BAZEL_CXXOPTS
  bazel shutdown
}

install_mozc-common() {
  export PREFIX="$pkgdir/usr"
  export _bldtype
  cd ${srcdir}/mozc/src || exit

  # Extract license part of mozc
  head -n 50 data/unicode/JIS0201.TXT > LICENSE.JIS0201
  head -n 73 data/unicode/JIS0208.TXT > LICENSE.JIS0208
  head -n 22 data/unicode/jisx0213-2004-std.txt > LICENSE.jisx0213-2004-std

  # BSD-3-Clause
  sed -n 67,94p data/installer/credits_en.html > Mozc
  install -Dm644 Mozc "${pkgdir}"/usr/share/licenses/${pkgname}/Mozc
  # BSD-3-Clause
  sed -n 317,344p data/installer/credits_en.html > Breakpad
  install -Dm644 Breakpad "${pkgdir}"/usr/share/licenses/${pkgname}/Breakpad
  # NAIST-2003
  sed -n 355,424p data/installer/credits_en.html > IPAdic
  install -Dm644 IPAdic "${pkgdir}"/usr/share/licenses/${pkgname}/IPAdic
  # BSD-2-Clause
  sed -n 435,457p data/installer/credits_en.html > Japanese-Usage-Dictionary
  install -Dm644 Japanese-Usage-Dictionary "${pkgdir}"/usr/share/licenses/${pkgname}/Japanese-Usage-Dictionary
  # Public Domain Data
  sed -n 468,470p data/installer/credits_en.html > Okinawa-Dictionary
  install -Dm644 Okinawa-Dictionary "${pkgdir}"/usr/share/licenses/${pkgname}/Okinawa-Dictionary
  # BSD-3-Clause
  sed -n 481,513p data/installer/credits_en.html > Protocol-Buffers
  install -Dm644 Protocol-Buffers "${pkgdir}"/usr/share/licenses/${pkgname}/Protocol-Buffers
  # MIT
  sed -n 698,704p data/installer/credits_en.html > Tamachi-Phonetic-Kanji-Alphabet
  install -Dm644 Tamachi-Phonetic-Kanji-Alphabet "${pkgdir}"/usr/share/licenses/${pkgname}/Tamachi-Phonetic-Kanji-Alphabet
  # MIT
  sed -n 762,782p data/installer/credits_en.html > Windows-Implementation-Library
  sed -i -e 's|^[ \t]*||g' Windows-Implementation-Library
  install -Dm644 Windows-Implementation-Library "${pkgdir}"/usr/share/licenses/${pkgname}/Windows-Implementation-Library
}

package_fcitx-mozc() {
  pkgdesc="Fcitx Module for Mozc(the Open Source Edition of Google Japanese Input)"
  depends=('fcitx' 'fcitx-qt6')
  optdepends=('fcitx-configtool')
  replaces=('fcitx-mozc')
  provides=("fcitx-mozc=${pkgver}")
  conflicts=('fcitx-mozc' 'fcitx5-mozc' 'ibus-mozc' fcitx5 fcitx5-qt fcitx5-configtool)

  export PREFIX="$pkgdir/usr"
  export _bldtype
  cd ${srcdir}/mozc/src || exit
  install_mozc-common
  ../scripts/install_server_bazel
  ../scripts/install_fcitx_bazel
}