Skip to content

Commit 1c2542f

Browse files
authored
cross build for x86_64; drop macos-13 runner (#228)
1 parent 0e3bd91 commit 1c2542f

File tree

8 files changed

+63
-40
lines changed

8 files changed

+63
-40
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@ jobs:
2323

2424
build:
2525
needs: lint
26-
runs-on: ${{ matrix.os }}
26+
runs-on: macos-15
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
os: [macos-15, macos-13]
31-
type: [Release, Debug]
3230
include:
33-
- { os: macos-15, arch: arm64, type: Release, postfix: '' }
34-
- { os: macos-15, arch: arm64, type: Debug, postfix: -debug }
35-
- { os: macos-13, arch: x86_64, type: Release, postfix: '' }
36-
- { os: macos-13, arch: x86_64, type: Debug, postfix: -debug }
31+
- { arch: arm64, type: Release, postfix: '' }
32+
- { arch: arm64, type: Debug, postfix: -debug }
33+
- { arch: x86_64, type: Release, postfix: '' }
34+
- { arch: x86_64, type: Debug, postfix: -debug }
3735

3836
steps:
3937
- uses: actions/checkout@v4
@@ -46,7 +44,7 @@ jobs:
4644

4745
- uses: actions/setup-node@v4
4846
with:
49-
node-version: 20.x
47+
node-version: 22.x
5048

5149
- name: Install dependencies
5250
env:
@@ -69,13 +67,13 @@ jobs:
6967
- name: Build
7068
run: |
7169
# Don't log key on any CI artifact.
72-
cmake -B build -G Ninja \
70+
cmake -B build/${{ matrix.arch }} -G Ninja \
7371
-DCMAKE_Swift_COMPILER=`which swiftc` \
7472
-DVERBOSE_LOGGING=OFF \
7573
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \
7674
-DCMAKE_BUILD_TYPE=${{ matrix.type }}
77-
cmake --build build
78-
sudo cmake --install build
75+
cmake --build build/${{ matrix.arch }}
76+
sudo cmake --install build/${{ matrix.arch }}
7977
8078
- name: Package and remove dev files
8179
run: |
@@ -87,7 +85,7 @@ jobs:
8785
./scripts/code-sign.sh # after tar to avoid local signature in tarball
8886
8987
- name: Test
90-
run: ctest --test-dir build --output-on-failure
88+
run: ctest --test-dir build/${{ matrix.arch }} --output-on-failure
9189

9290
- name: Upload artifact
9391
uses: actions/upload-artifact@v4
@@ -102,12 +100,12 @@ jobs:
102100
md5sum -c checksum
103101
104102
- name: Generate meta.json
105-
if: ${{ matrix.os == 'macos-15' && matrix.type == 'Release' }}
103+
if: ${{ matrix.arch == 'arm64' && matrix.type == 'Release' }}
106104
run: |
107105
echo "{\"object\": {\"sha\": \"$(git rev-parse HEAD)\"}}" > meta.json
108106
109107
- name: Upload meta.json
110-
if: ${{ matrix.os == 'macos-15' && matrix.type == 'Release' }}
108+
if: ${{ matrix.arch == 'arm64' && matrix.type == 'Release' }}
111109
uses: actions/upload-artifact@v4
112110
with:
113111
name: meta.json

.vscode/tasks.json

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,56 @@
33
"tasks": [
44
{
55
"type": "shell",
6-
"label": "Install dependencies",
7-
"command": "./scripts/install-deps.sh",
6+
"label": "Install dependencies (arm64)",
7+
"command": "./scripts/install-deps.sh arm64",
88
"group": {
99
"kind": "build"
1010
}
1111
},
1212
{
1313
"type": "shell",
14-
"label": "Configure",
15-
"command": "cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug",
14+
"label": "Install dependencies (x86_64)",
15+
"command": "./scripts/install-deps.sh x86_64",
1616
"group": {
1717
"kind": "build"
1818
}
1919
},
2020
{
2121
"type": "shell",
22-
"label": "Build",
23-
"command": "cmake --build build",
22+
"label": "Configure (arm64)",
23+
"command": "cmake -B build/arm64 -G Ninja -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_BUILD_TYPE=Debug",
24+
"group": {
25+
"kind": "build"
26+
}
27+
},
28+
{
29+
"type": "shell",
30+
"label": "Configure (x86_64)",
31+
"command": "cmake -B build/x86_64 -G Ninja -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_BUILD_TYPE=Debug",
32+
"group": {
33+
"kind": "build"
34+
}
35+
},
36+
{
37+
"type": "shell",
38+
"label": "Build (arm64)",
39+
"command": "cmake --build build/arm64",
40+
"group": {
41+
"kind": "build"
42+
}
43+
},
44+
{
45+
"type": "shell",
46+
"label": "Build (x86_64)",
47+
"command": "cmake --build build/x86_64",
2448
"group": {
2549
"kind": "build"
2650
}
2751
},
2852
{
2953
"type": "shell",
3054
"label": "Install",
31-
"command": "sudo cmake --install build && ./scripts/code-sign.sh",
55+
"command": "sudo cmake --install build/$(uname -m) && ./scripts/code-sign.sh",
3256
"group": {
3357
"kind": "build"
3458
}
@@ -52,7 +76,7 @@
5276
{
5377
"type": "shell",
5478
"label": "Test",
55-
"command": "ctest --test-dir build --output-on-failure",
79+
"command": "ctest --test-dir build/$(uname -m) --output-on-failure",
5680
"group": {
5781
"kind": "build"
5882
}

CMakeLists.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@ project(fcitx5-macos VERSION 0.1.0 LANGUAGES CXX Swift)
44

55
list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
66
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
7-
set(CMAKE_Swift_LANGUAGE_VRSION 5.9)
87

98
# On x86 /Library/Frameworks/Mono.framework will mess up libintl.
109
set(CMAKE_FIND_FRAMEWORK LAST)
1110

11+
if(NOT CMAKE_OSX_ARCHITECTURES)
12+
set(CMAKE_OSX_ARCHITECTURES "${CMAKE_HOST_SYSTEM_PROCESSOR}")
13+
endif()
14+
15+
set(CMAKE_OSX_DEPLOYMENT_TARGET 13)
16+
set(F5M_TARGET "${CMAKE_OSX_ARCHITECTURES}-apple-macos${CMAKE_OSX_DEPLOYMENT_TARGET}")
17+
add_definitions(-target "${F5M_TARGET}")
18+
1219
# Disallow InitializeSwift to execute link_directories which adds Xcode paths to rpath.
1320
set(SWIFT_LIBRARY_SEARCH_PATHS "")
1421
include(InitializeSwift)
1522
include(AddSwift)
1623

1724
set(CMAKE_CXX_STANDARD 17)
1825

19-
if(NOT CMAKE_OSX_ARCHITECTURES)
20-
set(CMAKE_OSX_ARCHITECTURES "${CMAKE_HOST_SYSTEM_PROCESSOR}")
21-
endif()
22-
23-
set(CMAKE_OSX_DEPLOYMENT_TARGET 13)
24-
add_definitions(-target "${CMAKE_OSX_ARCHITECTURES}-apple-macos${CMAKE_OSX_DEPLOYMENT_TARGET}")
25-
26-
set(FIND_ROOT_PATH "${PROJECT_BINARY_DIR}/sysroot/usr")
26+
set(FIND_ROOT_PATH "${PROJECT_BINARY_DIR}/usr")
2727
set(PREBUILDER_INCLUDE_DIR "${FIND_ROOT_PATH}/include")
2828
set(PREBUILDER_LIB_DIR "${FIND_ROOT_PATH}/lib")
2929
set(PREBUILDER_SHARE_DIR "${FIND_ROOT_PATH}/share")
3030

3131
list(APPEND CMAKE_FIND_ROOT_PATH "${FIND_ROOT_PATH}")
3232

33-
set(ENV{PKG_CONFIG_SYSROOT_DIR} "${PROJECT_BINARY_DIR}/sysroot")
33+
set(ENV{PKG_CONFIG_SYSROOT_DIR} "${PROJECT_BINARY_DIR}")
3434
set(ENV{PKG_CONFIG_PATH} "${PREBUILDER_LIB_DIR}/pkgconfig;${PREBUILDER_SHARE_DIR}/pkgconfig")
3535

3636
add_library(Libuv_static STATIC IMPORTED)

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ pnpm --prefix=fcitx5-webview i
2828

2929
### Build with CMake
3030
```sh
31-
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
32-
cmake --build build
33-
sudo cmake --install build
31+
cmake -B build/$(uname -m) -G Ninja -DCMAKE_BUILD_TYPE=Debug
32+
cmake --build build/$(uname -m)
33+
sudo cmake --install build/$(uname -m)
3434
```
3535
After the first time you execute `cmake --install`, you need to logout and login,
3636
then add Fcitx5 in System Setttings -> Keyboard -> Input Sources, Chinese Simplified.
@@ -85,15 +85,15 @@ use the built-in Plugin Manager.
8585
### Swift sources
8686
To update .strings files for each supported locale, run
8787
```sh
88-
cmake --build build --target GenerateStrings
88+
cmake --build build/$(uname -m) --target GenerateStrings
8989
```
9090

9191
This will, e.g., update assets/zh-Hans/Localizable.strings, and then the translator can work on it.
9292

9393
### C++ sources
9494
First, create assets/po/base.pot file:
9595
```sh
96-
cmake --build build --target pot
96+
cmake --build build/$(uname -m) --target pot
9797
```
9898

9999
To add a new language, do

cache/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
This directory caches tarball of build dependencies
22
(downloaded from [prebuilder](https://github.com/fcitx-contrib/fcitx5-prebuilder/releases/macos)),
3-
which will be extracted to `build/sysroot/usr`.
3+
which will be extracted to `build/ARCH/usr`.

cmake/AddSwift.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function(_swift_generate_cxx_header target header)
5858
${ARG_SEARCH_PATHS}
5959
${_SwiftSources}
6060
${SDK_FLAGS}
61+
-target ${F5M_TARGET}
6162
-module-name "${ARG_MODULE_NAME}"
6263
-cxx-interoperability-mode=default
6364
-emit-clang-header-path ${header_path}

cmake/InitializeSwift.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function(_setup_swift_paths)
3434
# To handle it correctly, we would need to pass the target triple and
3535
# flags to this compiler invocation.
3636
execute_process(
37-
COMMAND ${CMAKE_Swift_COMPILER} ${SDK_FLAGS} -print-target-info
37+
COMMAND ${CMAKE_Swift_COMPILER} ${SDK_FLAGS} -target ${F5M_TARGET} -print-target-info
3838
OUTPUT_VARIABLE SWIFT_TARGET_INFO
3939
)
4040

scripts/install-deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ else
66
ARCH=$1
77
fi
88

9-
EXTRACT_DIR=build/sysroot/usr
9+
EXTRACT_DIR=build/$ARCH/usr
1010
mkdir -p $EXTRACT_DIR
1111

1212
deps=(

0 commit comments

Comments
 (0)