Skip to content

Commit ed7a47b

Browse files
author
Fcitx Bot
committed
Merge remote-tracking branch 'origin/master' into fcitx
2 parents 4ebad5d + 8cb5cc3 commit ed7a47b

18 files changed

Lines changed: 114 additions & 106 deletions

.github/workflows/linux.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: bazel build
3737
working-directory: ./src
3838
run: |
39-
bazelisk build --config oss_linux package --config release_build
39+
bazelisk build package --config release_build
4040
4141
- name: Upload Artifacts
4242
uses: actions/upload-artifact@v6
@@ -68,4 +68,4 @@ jobs:
6868
- name: bazel test
6969
working-directory: ./src
7070
run: |
71-
bazelisk test ... --config oss_linux -c dbg
71+
bazelisk test ... -c dbg

.github/workflows/macos.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ jobs:
4141
working-directory: ./src
4242
run: |
4343
python3 build_tools/build_qt.py --release --confirm_license --macos_cpus=arm64
44-
echo "MOZC_QT_PATH=${PWD}/third_party/qt" >> $GITHUB_ENV
4544
4645
- name: bazel build
4746
working-directory: ./src
4847
run: |
49-
bazelisk build --config oss_macos package --macos_cpus=arm64 --config release_build
48+
bazelisk build package --macos_cpus=arm64 --config release_build
5049
5150
- name: upload artifacts
5251
uses: actions/upload-artifact@v6
@@ -83,12 +82,11 @@ jobs:
8382
working-directory: ./src
8483
run: |
8584
python3 build_tools/build_qt.py --release --confirm_license --macos_cpus=x86_64
86-
echo "MOZC_QT_PATH=${PWD}/third_party/qt" >> $GITHUB_ENV
8785
8886
- name: bazel build
8987
working-directory: ./src
9088
run: |
91-
bazelisk build --config oss_macos package --macos_cpus=x86_64 --config release_build
89+
bazelisk build package --macos_cpus=x86_64 --config release_build
9290
9391
- name: upload artifacts
9492
uses: actions/upload-artifact@v6
@@ -125,12 +123,11 @@ jobs:
125123
working-directory: ./src
126124
run: |
127125
python3 build_tools/build_qt.py --release --confirm_license --macos_cpus=x86_64,arm64
128-
echo "MOZC_QT_PATH=${PWD}/third_party/qt" >> $GITHUB_ENV
129126
130127
- name: bazel build
131128
working-directory: ./src
132129
run: |
133-
bazelisk build --config oss_macos package --macos_cpus=x86_64,arm64 --config release_build
130+
bazelisk build package --macos_cpus=x86_64,arm64 --config release_build
134131
135132
- name: upload artifacts
136133
uses: actions/upload-artifact@v6
@@ -166,7 +163,7 @@ jobs:
166163
- name: bazel test
167164
working-directory: ./src
168165
run: |
169-
bazelisk test ... --config oss_macos --build_tests_only -c dbg
166+
bazelisk test ... --build_tests_only -c dbg
170167
171168
# actions/cache works without this job, but having this would increase the likelihood of cache hit
172169
# in other jobs. Another approach would be to use "needs:".

.github/workflows/windows.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
env:
5858
ANDROID_NDK_HOME: ""
5959
run: |
60-
bazelisk build --config oss_windows --config release_build package
60+
bazelisk build --config release_build package
6161
6262
- name: upload Mozc64_x64.msi
6363
uses: actions/upload-artifact@v6
@@ -110,7 +110,7 @@ jobs:
110110
env:
111111
ANDROID_NDK_HOME: ""
112112
run: |
113-
bazelisk build --config oss_windows --config release_build --config win_universal_installer package
113+
bazelisk build --config release_build --config win_universal_installer package
114114
115115
- name: upload Mozc64_universal.msi
116116
uses: actions/upload-artifact@v6
@@ -163,7 +163,7 @@ jobs:
163163
env:
164164
ANDROID_NDK_HOME: ""
165165
run: |
166-
bazelisk build package --config oss_windows --config release_build --platforms=//:windows-arm64
166+
bazelisk build package --config release_build --platforms=//:windows-arm64
167167
168168
- name: upload Mozc64_arm64.msi
169169
uses: actions/upload-artifact@v6
@@ -203,7 +203,7 @@ jobs:
203203
env:
204204
ANDROID_NDK_HOME: ""
205205
run: |
206-
bazelisk test ... --config oss_windows -c dbg --build_tests_only
206+
bazelisk test ... -c dbg --build_tests_only
207207
208208
# actions/cache works without this job, but having this would increase the likelihood of cache hit
209209
# in other jobs. Another approach would be to use "needs:".

docs/build_mozc_for_linux.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ descriptions below and make sure the operations before running them.
1313
git clone https://github.com/google/mozc.git
1414
cd mozc/src
1515

16-
bazelisk build package --config oss_linux --config release_build
16+
bazelisk build package --config release_build
1717
```
1818

1919
`bazel-bin/unix/mozc.zip` contains built files.
@@ -114,7 +114,7 @@ You should be able to build Mozc for Linux desktop as follows, assuming
114114
`bazelisk` is in your `$PATH`.
115115

116116
```sh
117-
bazelisk build package --config oss_linux --config release_build
117+
bazelisk build package --config release_build
118118
```
119119

120120
`package` is an alias to build Mozc executables and archive them into
@@ -172,23 +172,23 @@ git update-index --no-assume-unchanged src/config.bzl
172172
### Run all tests
173173

174174
```sh
175-
bazelisk test ... --config oss_linux --build_tests_only -c dbg
175+
bazelisk test ... --build_tests_only -c dbg
176176
```
177177

178178
* `...` means all targets under the current and subdirectories.
179179

180180
### Run tests under the specific directories
181181

182182
```sh
183-
bazelisk test base/... composer/... --config oss_linux --build_tests_only -c dbg
183+
bazelisk test base/... composer/... --build_tests_only -c dbg
184184
```
185185

186186
* `<dir>/...` means all targets under the `<dir>/` directory.
187187

188188
### Run tests without the specific directories
189189

190190
```sh
191-
bazelisk test ... --config oss_linux --build_tests_only -c dbg -- -base/...
191+
bazelisk test ... --build_tests_only -c dbg -- -base/...
192192
```
193193

194194
* `--` means the end of the flags which start from `-`.
@@ -197,15 +197,15 @@ bazelisk test ... --config oss_linux --build_tests_only -c dbg -- -base/...
197197
### Run the specific test
198198

199199
```sh
200-
bazelisk test base:util_test --config oss_linux -c dbg
200+
bazelisk test base:util_test -c dbg
201201
```
202202

203203
* `util_test` is defined in `base/BUILD.bazel`.
204204

205205
### Output logs to stderr
206206

207207
```
208-
bazelisk test base:util_test --config oss_linux --test_arg=--stderrthreshold=0 --test_output=all
208+
bazelisk test base:util_test --test_arg=--stderrthreshold=0 --test_output=all
209209
```
210210

211211
* The `--test_arg=--stderrthreshold=0 --test_output=all` flags show the

docs/build_mozc_in_osx.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ python3 build_tools/update_deps.py
1818
# CMake is also required to build Qt.
1919
python3 build_tools/build_qt.py --release --confirm_license
2020
21-
MOZC_QT_PATH=${PWD}/third_party/qt bazelisk build package --config oss_macos --config release_build
21+
bazelisk build package --config release_build
2222
open bazel-bin/mac/Mozc.pkg
2323
```
2424

@@ -120,7 +120,7 @@ brew install cmake
120120
### Build installer
121121

122122
```
123-
MOZC_QT_PATH=${PWD}/third_party/qt bazelisk build package --config oss_macos --config release_build
123+
bazelisk build package --config release_build
124124
open bazel-bin/mac/Mozc.pkg
125125
```
126126

@@ -130,22 +130,22 @@ To build an Intel64 macOS binary regardless of the host CPU architecture.
130130

131131
```
132132
python3 build_tools/build_qt.py --release --debug --confirm_license --macos_cpus=x64_64
133-
MOZC_QT_PATH=${PWD}/third_party/qt bazelisk build package --config oss_macos --config release_build --macos_cpus=x64_64
133+
bazelisk build package --config release_build --macos_cpus=x64_64
134134
open bazel-bin/mac/Mozc.pkg
135135
```
136136

137137
To build a Universal macOS Binary both x86_64 and arm64.
138138

139139
```
140140
python3 build_tools/build_qt.py --release --debug --confirm_license --macos_cpus=x86_64,arm64
141-
MOZC_QT_PATH=${PWD}/third_party/qt bazelisk build package --config oss_macos --config release_build --macos_cpus=x86_64,arm64
141+
bazelisk build package --config release_build --macos_cpus=x86_64,arm64
142142
open bazel-bin/mac/Mozc.pkg
143143
```
144144

145145
### Unit tests
146146

147147
```
148-
MOZC_QT_PATH=${PWD}/third_party/qt bazelisk test ... --config oss_macos --build_tests_only -c dbg
148+
bazelisk test ... --build_tests_only -c dbg
149149
```
150150

151151
See [build Mozc in Docker](build_mozc_in_docker.md#unittests) for details.

docs/build_mozc_in_windows.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cd mozc\src
1515
1616
python build_tools/update_deps.py
1717
python build_tools/build_qt.py --release --confirm_license
18-
bazelisk build --config oss_windows --config release_build package
18+
bazelisk build --config release_build package
1919
2020
python build_tools/open.py bazel-bin/win32/installer/Mozc64.msi
2121
```

src/base/win32/win_api_test_helper.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ class HookTargetInfo {
114114
continue;
115115
}
116116
const FunctionPointer original_proc_address =
117-
::GetProcAddress(module_handle, request.proc_name.c_str());
117+
reinterpret_cast<FunctionPointer>(
118+
::GetProcAddress(module_handle, request.proc_name.c_str()));
118119
if (original_proc_address == nullptr) {
119120
LOG(FATAL) << "GetProcAddress returned nullptr.";
120121
continue;

src/base/win32/win_api_test_helper.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class WinAPITestHelper {
7474
class RestoreInfo;
7575
typedef RestoreInfo* RestoreInfoHandle;
7676

77-
typedef void* FunctionPointer;
77+
using FunctionPointer = void (*)();
7878
struct HookRequest {
7979
public:
8080
HookRequest(const std::string& src_module, const std::string& src_proc_name,
@@ -88,7 +88,8 @@ class WinAPITestHelper {
8888
static HookRequest MakeHookRequest(const std::string& module,
8989
const std::string& proc_name,
9090
const NewProcType& new_proc_ref) {
91-
return HookRequest(module, proc_name, &new_proc_ref);
91+
return HookRequest(module, proc_name,
92+
reinterpret_cast<FunctionPointer>(&new_proc_ref));
9293
}
9394

9495
// Overwrites on-memory Import Address Table (IAT) of |target_module| with

src/bazel/bazel_wrapper/bazel.bat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ set TMP_MOZC_BASH_PATH=%TMP_MOZC_SRC_DIR%\third_party\msys64\usr\bin\bash.exe
1313
if exist %TMP_MOZC_BASH_PATH% set BAZEL_SH=%TMP_MOZC_BASH_PATH%
1414
set TMP_MOZC_BASH_PATH=
1515

16+
rem Inject BAZEL_VC via vs_util.py if the user has not set it explicitly.
17+
if not defined BAZEL_VC (
18+
for /f "usebackq delims=" %%P in (`python "%TMP_MOZC_SRC_DIR%\build_tools\vs_util.py"`) do set BAZEL_VC=%%P
19+
)
20+
1621
set TMP_MOZC_BAZEL_WRAPPER_DIR=
1722
set TMP_MOZC_SRC_DIR=
1823

1924
:: For debugging.
2025
echo BAZEL_LLVM=%BAZEL_LLVM%
2126
echo BAZEL_REAL=%BAZEL_REAL%
27+
echo BAZEL_VC=%BAZEL_VC%
2228

2329
%BAZEL_REAL% %* & call:myexit
2430

src/build_tools/vs_util.py

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

3131
"""A helper script to use Visual Studio."""
3232

33+
import argparse
3334
import json
3435
import os
3536
import pathlib
@@ -188,3 +189,37 @@ def get_vs_env_vars(
188189
if exitcode != 0:
189190
raise ChildProcessError(f'Failed to execute {vcvarsall}')
190191
return json.loads(stdout.decode('ascii'))
192+
193+
194+
def get_vc_dir(
195+
arch: str, vcvarsall_path_hint: Union[str, None] = None
196+
) -> pathlib.Path:
197+
"""Returns the VC directory path for use as 'BAZEL_VC'.
198+
199+
Args:
200+
arch: host/target architecture
201+
vcvarsall_path_hint: optional path to vcvarsall.bat
202+
203+
Returns:
204+
The VC directory path, e.g. 'C:\\...\\Community\\VC'.
205+
206+
Raises:
207+
FileNotFoundError: When 'vcvarsall.bat' cannot be found.
208+
"""
209+
# vcvarsall.bat lives at <VC>\Auxiliary\Build\vcvarsall.bat
210+
return get_vcvarsall(arch, vcvarsall_path_hint).parent.parent.parent
211+
212+
213+
def main() -> int:
214+
parser = argparse.ArgumentParser(
215+
description='Print the VC directory (value suitable for BAZEL_VC).'
216+
)
217+
parser.add_argument('--arch', default='x64')
218+
parser.add_argument('--vcvarsall_path', default=None)
219+
args = parser.parse_args()
220+
print(get_vc_dir(args.arch, args.vcvarsall_path))
221+
return 0
222+
223+
224+
if __name__ == '__main__':
225+
sys.exit(main())

0 commit comments

Comments
 (0)