forked from rime/librime
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (155 loc) · 5.26 KB
/
windows-build.yml
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Windows build
on:
workflow_call:
inputs:
repository:
default: ${{ github.repository }}
required: false
type: string
rime_plugins:
required: false
type: string
jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
compiler: [msvc, clang]
arch: [x64]
include:
- { compiler: msvc, cc: cl, cxx: cl }
- { compiler: clang, cc: clang, cxx: clang++ }
- { compiler: msvc, arch: x86, cross_arch: x64_x86 }
env:
boost_version: 1.84.0
BOOST_ROOT: ${{ github.workspace }}\deps\boost-1.84.0
RIME_PLUGINS: ${{ inputs.rime_plugins }}
steps:
- name: Checkout last commit
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
submodules: recursive
- name: Create env.bat
run: |
$envfile = ".\env.bat"
$envcontent = @"
set RIME_ROOT=%CD%
set CXX=${{ matrix.cxx }}
set CC=${{ matrix.cc }}
set CMAKE_GENERATOR=Ninja
"@
Set-Content -Path $envfile -Value $envcontent
cat $envfile
- name: Configure MSVC
if: ${{ matrix.compiler == 'msvc' }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.cross_arch || matrix.arch }}
- name: Configure Ninja
run: pip install ninja
- name: Configure clang
if: ${{ matrix.compiler == 'clang' }}
run: choco upgrade -y llvm
- name: Configure build environment
run: |
$git_ref_name = git describe --always
echo "git_ref_name=$git_ref_name" >> $env:GITHUB_ENV
git submodule > submodule-status
- name: Install boost
run: .\install-boost.bat
- name: Cache dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: |
bin
include
lib
share
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.arch }}-${{ hashFiles('submodule-status') }}
- name: Build dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: .\build.bat deps
- name: Install Rime plugins
run: .\action-install-plugins-windows.bat
- name: Build and test
run: .\build.bat test
- name: Create distributable
run: |
7z a rime-${{ env.git_ref_name }}-${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.arch }}.7z `
dist version-info.txt
7z a -x'!*/.placeholder' rime-deps-${{ env.git_ref_name }}-${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.arch }}.7z `
bin include lib share
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifact-${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.arch }}
path: |
rime-${{ env.git_ref_name }}-${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.arch }}.7z
rime-deps-${{ env.git_ref_name }}-${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.arch }}.7z
build-mingw:
runs-on: windows-latest
env:
RIME_PLUGINS: ${{ inputs.rime_plugins }}
defaults:
run:
shell: msys2 {0}
steps:
- name: Install dependencies with MSYS2
uses: msys2/setup-msys2@v2
with:
release: false
update: true
msystem: UCRT64
install: >-
git
base-devel
mingw-w64-ucrt-x86_64-boost
mingw-w64-ucrt-x86_64-glog
mingw-w64-ucrt-x86_64-gtest
mingw-w64-ucrt-x86_64-yaml-cpp
mingw-w64-ucrt-x86_64-leveldb
mingw-w64-ucrt-x86_64-marisa
mingw-w64-ucrt-x86_64-opencc
pacboy: >-
toolchain:p
cmake:p
ninja:p
- run: git config --global core.autocrlf input
- name: Checkout last commit
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
- name: Configure build environment
run: |
echo git_ref_name="$(git describe --always)" >> $GITHUB_ENV
- name: Install Rime plugins
run: ./action-install-plugins-macos.sh
- name: Build with mingw-w64
run: |
cmake -B build -G Ninja \
-DCMAKE_INSTALL_PREFIX:PATH=`pwd`/dist \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DENABLE_LOGGING:BOOL=ON \
-DBUILD_TEST:BOOL=ON \
-DBUILD_STATIC:BOOL=ON \
-DBUILD_SHARED_LIBS:BOOL=ON
cmake --build build
cmake --install build
cd build && cp ./bin/librime.dll ./test
ctest --output-on-failure
- name: Create distributable
run: |
tar -cjvf rime-${{ env.git_ref_name }}-${{ runner.os }}-mingw.tar.bz2 \
dist version-info.txt
tar -cjvf rime-deps-${{ env.git_ref_name }}-${{ runner.os }}-mingw.tar.bz2 \
--exclude '*/.placeholder' \
bin include lib share
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifact-${{ runner.os }}-mingw
path: |
rime-${{ env.git_ref_name }}-${{ runner.os }}-mingw.tar.bz2