Skip to content

Commit d9c5182

Browse files
committed
xmake
1 parent 158461b commit d9c5182

File tree

3 files changed

+42
-57
lines changed

3 files changed

+42
-57
lines changed

.github/workflows/xmake.yml

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,6 @@ jobs:
3434
runs-on: ${{ matrix.os }}
3535

3636
steps:
37-
- name: Setup dependencies (Linux)
38-
if: runner.os == 'Linux'
39-
run: |
40-
sudo apt update
41-
sudo apt install -y gcc-14 g++-14 libstdc++-14-dev
42-
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
43-
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
44-
sudo update-alternatives --set gcc /usr/bin/gcc-14
45-
sudo update-alternatives --set g++ /usr/bin/g++-14
46-
wget https://apt.llvm.org/llvm.sh
47-
chmod +x llvm.sh
48-
sudo ./llvm.sh 20 all
49-
sudo apt install -y cmake ninja-build
50-
51-
- name: Setup dependencies (MacOS)
52-
if: runner.os == 'macOS'
53-
env:
54-
HOMEBREW_NO_AUTO_UPDATE: 1
55-
run: |
56-
brew install llvm@20 lld@20
57-
5837
- name: Checkout repository
5938
uses: actions/checkout@v4
6039

@@ -65,37 +44,27 @@ jobs:
6544
actions-cache-folder: ".xmake-cache"
6645
actions-cache-key: ${{ matrix.os }}
6746
package-cache: true
68-
package-cache-key: ${{ matrix.os }}
47+
package-cache-key: ${{ matrix.os }}-pixi
6948
build-cache: true
7049
build-cache-key: ${{ matrix.os }}-${{ matrix.build_type }}
7150

72-
- name: Build clice
73-
shell: bash
74-
run: |
75-
if [[ "${{ runner.os }}" == "Windows" ]]; then
76-
xmake config --yes --ci=y --mode=${{ matrix.build_type }} --toolchain=clang -p windows
77-
elif [[ "${{ runner.os }}" == "Linux" ]]; then
78-
xmake config --yes --ci=y --mode=${{ matrix.build_type }} --toolchain=clang-20
79-
elif [[ "${{ runner.os }}" == "macOS" ]]; then
80-
export PATH="/opt/homebrew/opt/llvm@20/bin:/opt/homebrew/opt/lld@20/bin:$PATH"
81-
xmake config --yes --ci=y --mode=${{ matrix.build_type }} --toolchain=clang --sdk=/opt/homebrew/opt/llvm@20
82-
fi
83-
84-
xmake build --verbose --diagnosis --all
85-
86-
- name: Install uv for integration tests
87-
uses: astral-sh/setup-uv@v6
51+
- name: Setup Pixi
52+
uses: prefix-dev/setup-pixi@v0.9.3
53+
with:
54+
pixi-version: v0.61.0
55+
environments: develop
56+
activate-environment: true
57+
cache: true
58+
locked: true
8859

89-
- name: Run tests
90-
shell: bash
60+
- name: Build
9161
run: |
92-
# Workaround for macOS
93-
if [[ "${{ runner.os }}" == "macOS" ]]; then
94-
export PATH="/opt/homebrew/opt/llvm@20/bin:/opt/homebrew/opt/lld@20/bin:$PATH"
95-
fi
62+
pixi run ci-xmake-build ${{ matrix.build_type }}
9663
97-
xmake test --verbose
64+
- name: Test
65+
run: |
66+
pixi run xmake-test
9867
9968
- name: Remove llvm package (Linux)
10069
if: runner.os == 'Linux'
101-
run: rm -rf /home/runner/.xmake/packages/c/clice-llvm
70+
run: xmake require --uninstall clice-llvm

pixi.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ cmd = "cmake --build build"
6666
unit-test = './build/bin/unit_tests --test-dir="./tests/data"'
6767
integration-test = 'pytest -s --log-cli-level=INFO tests/integration --executable=./build/bin/clice{% if pixi.is_win %}.exe{% endif %}'
6868
ci-check = "pre-commit run --all-files"
69+
xmake-test = "xmake test --verbose"
6970

7071
[tasks.ci-cmake-build]
7172
args = ["build_type"]
@@ -80,6 +81,20 @@ depends-on = [
8081
{ task = "integration-test" },
8182
]
8283

84+
[tasks.ci-xmake-configure]
85+
args = ["build_type"]
86+
cmd = "xmake config --clean --yes --mode={{ build_type }} --toolchain=clang --ci=y"
87+
88+
[tasks.xmake-build]
89+
cmd = "xmake build --verbose --diagnosis --all"
90+
91+
[tasks.ci-xmake-build]
92+
args = ["build_type"]
93+
depends-on = [
94+
{ task = "xmake-configure", args = ["{{ build_type }}"] },
95+
{ task = "xmake-build" },
96+
]
97+
8398
[tasks.build-llvm]
8499
cmd = ["python3", "scripts/build-llvm.py"]
85100

xmake.lua

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,14 @@ target("integration_tests", function()
174174
on_test(function(target, opt)
175175
import("lib.detect.find_tool")
176176

177-
local uv = assert(find_tool("uv"), "uv not found!")
178177
local argv = {
179-
"run",
180-
"--project",
181-
"tests",
182-
"pytest",
183178
"--log-cli-level=INFO",
184179
"-s",
185180
"tests/integration",
186181
"--executable=" .. target:dep("clice"):targetfile(),
187182
}
188183
local run_opt = { curdir = os.projectdir() }
189-
os.vrunv(uv.program, argv, run_opt)
184+
os.vrunv("pytest", argv, run_opt)
190185

191186
return true
192187
end)
@@ -299,15 +294,21 @@ package("clice-llvm", function()
299294
else
300295
on_source(function(package)
301296
import("core.base.json")
302-
local info = json.loadfile("./config/prebuilt-llvm.json")
297+
298+
local build_type = {
299+
Debug = "debug",
300+
Release = "release",
301+
RelWithDebInfo = "releasedbg",
302+
}
303+
local info = json.loadfile("./config/llvm-manifest.json")
303304
for _, info in ipairs(info) do
304305
local current_plat = get_config("plat")
305306
local current_mode = get_config("mode")
306307
local info_plat = info.platform:lower()
307-
local info_mode = info.build_type:lower()
308+
local info_mode = build_type[info.build_type]
308309
local mode_match = (info_mode == current_mode)
309-
or (info_mode == "release" and current_mode == "releasedbg")
310-
if info_plat == current_plat and mode_match and (info.is_lto == has_config("release")) then
310+
or (info_mode == "releasedbg" and current_mode == "release")
311+
if info_plat == current_plat and mode_match and (info.lto == has_config("release")) then
311312
package:add(
312313
"urls",
313314
format(
@@ -340,7 +341,7 @@ package("clice-llvm", function()
340341
package:add("defines", "CLANG_BUILD_STATIC")
341342
end
342343

343-
os.vcp("bin", package:installdir())
344+
os.trycp("bin", package:installdir())
344345
os.vcp("lib", package:installdir())
345346
os.vcp("include", package:installdir())
346347
end)

0 commit comments

Comments
 (0)