Skip to content

Commit bc523b0

Browse files
build: use pixi in package ci (#326)
1 parent b8da7e7 commit bc523b0

File tree

3 files changed

+44
-70
lines changed

3 files changed

+44
-70
lines changed

.github/workflows/package.yml

Lines changed: 17 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -43,78 +43,38 @@ jobs:
4343
runs-on: ${{ matrix.os }}
4444

4545
steps:
46-
- name: Free disk space (Linux)
47-
if: runner.os == 'Linux'
48-
uses: jlumbroso/free-disk-space@main
49-
50-
- name: Increase swap file size (Linux)
51-
if: runner.os == 'Linux'
52-
run: |
53-
echo "===== Initial Status ====="
54-
sudo swapon --show
55-
free -h
56-
57-
echo "===== Creating Swap File ====="
58-
sudo swapoff -a
59-
sudo fallocate -l 16G /mnt/swapfile
60-
sudo chmod 600 /mnt/swapfile
61-
sudo mkswap /mnt/swapfile
62-
sudo swapon /mnt/swapfile
63-
64-
echo "===== Final Status ====="
65-
sudo swapon --show
66-
free -h
67-
df -h
68-
69-
- name: Setup dependencies (Linux)
70-
if: runner.os == 'Linux'
71-
run: |
72-
sudo apt update
73-
sudo apt install -y gcc-14 g++-14 libstdc++-14-dev cmake ninja-build
74-
75-
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
76-
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
77-
sudo update-alternatives --set gcc /usr/bin/gcc-14
78-
sudo update-alternatives --set g++ /usr/bin/g++-14
79-
80-
wget https://apt.llvm.org/llvm.sh
81-
chmod +x llvm.sh
82-
sudo ./llvm.sh 20 all
83-
84-
- name: Setup dependencies (MacOS)
85-
if: runner.os == 'macOS'
86-
env:
87-
HOMEBREW_NO_AUTO_UPDATE: 1
88-
run: |
89-
brew install llvm@20 lld@20
90-
9146
- name: Checkout repository
9247
uses: actions/checkout@v4
9348

9449
- name: Setup xmake
9550
uses: xmake-io/github-action-setup-xmake@v1
9651
with:
97-
xmake-version: 3.0.4
52+
xmake-version: 3.0.5
9853
actions-cache-folder: ".xmake-cache"
9954
actions-cache-key: ${{ matrix.os }}
10055
package-cache: true
10156
package-cache-key: ${{ matrix.os }}-pkg-release-v1
10257
build-cache: true
10358
build-cache-key: ${{ matrix.os }}-build-release-v1
10459

105-
- name: Configure and Package
106-
shell: bash
60+
- name: Setup Pixi
61+
uses: prefix-dev/setup-pixi@v0.9.3
62+
with:
63+
pixi-version: v0.61.0
64+
activate-environment: true
65+
cache: true
66+
locked: true
67+
68+
- name: Remove ci llvm toolchain on Windows
69+
if: runner.os == 'Windows'
10770
run: |
108-
if [[ "${{ runner.os }}" == "Windows" ]]; then
109-
xmake config --yes --enable_test=n --dev=n --release=y --mode=releasedbg --toolchain=${{ matrix.toolchain }} -p windows
110-
elif [[ "${{ runner.os }}" == "Linux" ]]; then
111-
xmake config --yes --enable_test=n --dev=n --release=y --mode=releasedbg --toolchain=${{ matrix.toolchain }}
112-
elif [[ "${{ runner.os }}" == "macOS" ]]; then
113-
export PATH="/opt/homebrew/opt/llvm@20/bin:/opt/homebrew/opt/lld@20/bin:$PATH"
114-
xmake config --yes --enable_test=n --dev=n --release=y --mode=releasedbg --toolchain=${{ matrix.toolchain }} --sdk=/opt/homebrew/opt/llvm@20
115-
fi
71+
# @see https://github.com/xmake-io/xmake/issues/7158
72+
xmake lua os.rmdir "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/Llvm"
73+
xmake lua os.rmdir "C:/Program Files/LLVM"
11674
117-
xmake pack -v
75+
- name: Package
76+
run: |
77+
pixi run package
11878
11979
- name: Upload Main Package to Release
12080
if: github.event_name == 'push'

pixi.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,6 @@ cmd = [
115115
# delete all workflows generated by "file_name"
116116
args = ["file_name"]
117117
cmd = ["scripts/delete-artifacts.bash", "{{ file_name }}"]
118+
119+
[tasks.package]
120+
cmd = "xmake config --yes --enable_test=n --dev=n --release=y --mode=releasedbg --toolchain=clang && xmake pack --verbose"

xmake.lua

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ option("ci", { default = false })
1212

1313
if has_config("dev") then
1414
set_policy("build.ccache", true)
15+
set_policy("package.install_only", true) -- Don't fetch system package
1516
if is_plat("windows") then
1617
set_runtimes("MD")
1718
if is_mode("debug") then
@@ -31,32 +32,37 @@ local libuv_require = "libuv"
3132
if has_config("release") then
3233
set_policy("build.optimization.lto", true)
3334
set_policy("package.cmake_generator.ninja", true)
35+
set_policy("package.install_only", true) -- Don't fetch system package
3436

3537
if is_plat("windows") then
36-
set_runtimes("MT")
38+
set_runtimes("MD")
3739
-- workaround cmake
3840
libuv_require = "libuv[toolchains=clang-cl]"
3941
end
4042

4143
includes("@builtin/xpack")
4244
end
4345

44-
if is_plat("macosx") then
45-
-- https://conda-forge.org/docs/maintainer/knowledge_base/#newer-c-features-with-old-sdk
46-
add_defines("_LIBCPP_DISABLE_AVAILABILITY=1")
47-
add_ldflags("-fuse-ld=lld")
48-
add_shflags("-fuse-ld=lld")
46+
if is_plat("macosx", "linux") then
47+
local cxflags
48+
if is_plat("macosx") then
49+
-- https://conda-forge.org/docs/maintainer/knowledge_base/#newer-c-features-with-old-sdk
50+
cxflags = "-D_LIBCPP_DISABLE_AVAILABILITY=1"
51+
end
52+
local ldflags = "-fuse-ld=lld"
53+
local shflags = "-fuse-ld=lld"
54+
55+
add_cxflags(cxflags)
56+
add_ldflags(ldflags)
57+
add_shflags(shflags)
4958

5059
add_requireconfs("**|cmake", {
5160
configs = {
52-
ldflags = "-fuse-ld=lld",
53-
shflags = "-fuse-ld=lld",
54-
cxflags = "-D_LIBCPP_DISABLE_AVAILABILITY=1",
61+
cxflags = cxflags,
62+
ldflags = ldflags,
63+
shflags = shflags,
5564
},
5665
})
57-
elseif is_plat("linux") then
58-
-- don't fetch system package
59-
set_policy("package.install_only", true)
6066
end
6167

6268
add_defines("TOML_EXCEPTIONS=0")
@@ -247,12 +253,17 @@ rule("clice_build_config", function()
247253
target:add("ldflags", "-fuse-ld=lld", "-static-libstdc++", "-Wl,--gc-sections")
248254
elseif target:is_plat("macosx") then
249255
target:add("ldflags", "-fuse-ld=lld", "-Wl,-dead_strip,-object_path_lto,clice.lto.o", { force = true })
250-
-- dsymutil so slow, disable it in daily ci
256+
-- dsymutil so slow, disable it in dev ci
251257
if not has_config("release") and is_mode("releasedbg") and has_config("ci") then
252258
target:rule_enable("utils.symbols.extract", false)
253259
end
254260
end
255261

262+
if has_config("release") then
263+
-- pixi clang failed to add lto flags because it need `-fuse-ld=lld`
264+
target:add("ldflags", "-flto=thin", { force = true })
265+
end
266+
256267
if has_config("ci") then
257268
target:add("cxxflags", "-DCLICE_CI_ENVIRONMENT=1")
258269
end

0 commit comments

Comments
 (0)