Skip to content

Commit 57104b7

Browse files
committed
fix: CI macOS uses xmake build (v0.0.16 mcpp has link bug)
v0.0.16 mcpp lacks -lc++ for macOS linking. Use xmake in CI/release workflows as a transitional builder. xmake.lua is NOT committed to the repo — generated at build time and removed after. Once v0.0.17 binary (with the fix) is in xlings-res, future versions can self-host via `xlings install mcpp`.
1 parent d9de4e4 commit 57104b7

2 files changed

Lines changed: 57 additions & 33 deletions

File tree

.github/workflows/ci-macos.yml

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -268,22 +268,35 @@ jobs:
268268
*) echo "FAIL: unexpected platform"; exit 1 ;;
269269
esac
270270
271-
- name: Install mcpp via xlings and self-host build
271+
- name: Build mcpp from source (xmake)
272272
run: |
273-
# Install mcpp (declared in .xlings.json) via xlings
274-
xlings install mcpp -y || {
275-
# Fallback: download release binary directly if pkgindex not updated yet
276-
echo "::warning::xlings install mcpp failed, using direct download"
277-
WORK=$(mktemp -d)
278-
curl -fsSL -o "$WORK/mcpp.tar.gz" \
279-
"https://github.com/mcpp-community/mcpp/releases/download/v0.0.16/mcpp-0.0.16-macosx-arm64.tar.gz"
280-
tar -xzf "$WORK/mcpp.tar.gz" -C "$WORK"
281-
export PATH="$WORK/mcpp-0.0.16-macosx-arm64/bin:$PATH"
282-
}
283-
mcpp --version
284-
# Self-host: build current source
285-
mcpp build
286-
SELFHOST=$(find target -path "*/bin/mcpp" | head -1)
287-
test -x "$SELFHOST"
288-
"$SELFHOST" --version
289-
echo ":: Self-host successful!"
273+
brew install xmake
274+
# Temporary xmake.lua — not committed to repo
275+
cat > /tmp/xmake_bootstrap.lua << 'EOF'
276+
add_rules("mode.release")
277+
set_languages("c++23")
278+
package("cmdline")
279+
set_homepage("https://github.com/mcpplibs/cmdline")
280+
add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz")
281+
add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0")
282+
on_install(function (package)
283+
import("package.tools.xmake").install(package)
284+
end)
285+
package_end()
286+
add_requires("cmdline 0.0.1")
287+
target("mcpp")
288+
set_kind("binary")
289+
add_files("src/main.cpp")
290+
add_files("src/**.cppm")
291+
add_packages("cmdline")
292+
add_includedirs("src/libs/json")
293+
set_policy("build.c++.modules", true)
294+
EOF
295+
cp /tmp/xmake_bootstrap.lua xmake.lua
296+
xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT"
297+
xmake build -y mcpp
298+
rm -f xmake.lua
299+
MCPP=$(find build -name mcpp -type f -perm +111 | head -1)
300+
test -x "$MCPP"
301+
"$MCPP" --version
302+
echo ":: Build successful!"

.github/workflows/release.yml

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -315,22 +315,33 @@ jobs:
315315
LLVM_ROOT=$(find "$HOME/.xlings" -path "*/xpkgs/xim-x-llvm/*/bin/clang++" | head -1 | xargs dirname | xargs dirname)
316316
echo "LLVM_ROOT=$LLVM_ROOT" >> "$GITHUB_ENV"
317317
318-
- name: Install mcpp via xlings and build
318+
- name: Build mcpp (xmake + LLVM)
319319
run: |
320-
export PATH="$HOME/.xlings/subos/default/bin:$PATH"
321-
# Install mcpp (declared in .xlings.json)
322-
xlings install mcpp -y || {
323-
echo "::warning::xlings install mcpp failed, using direct download"
324-
WORK=$(mktemp -d)
325-
curl -fsSL -o "$WORK/mcpp.tar.gz" \
326-
"https://github.com/mcpp-community/mcpp/releases/download/v0.0.16/mcpp-0.0.16-macosx-arm64.tar.gz"
327-
tar -xzf "$WORK/mcpp.tar.gz" -C "$WORK"
328-
export PATH="$WORK/mcpp-0.0.16-macosx-arm64/bin:$PATH"
329-
}
330-
mcpp --version
331-
# Build current source
332-
mcpp build
333-
MCPP_BIN=$(find target -path "*/bin/mcpp" | head -1)
320+
brew install xmake
321+
cat > xmake.lua << 'EOF'
322+
add_rules("mode.release")
323+
set_languages("c++23")
324+
package("cmdline")
325+
set_homepage("https://github.com/mcpplibs/cmdline")
326+
add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz")
327+
add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0")
328+
on_install(function (package)
329+
import("package.tools.xmake").install(package)
330+
end)
331+
package_end()
332+
add_requires("cmdline 0.0.1")
333+
target("mcpp")
334+
set_kind("binary")
335+
add_files("src/main.cpp")
336+
add_files("src/**.cppm")
337+
add_packages("cmdline")
338+
add_includedirs("src/libs/json")
339+
set_policy("build.c++.modules", true)
340+
EOF
341+
xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT"
342+
xmake build -y mcpp
343+
rm -f xmake.lua
344+
MCPP_BIN=$(find build -name mcpp -type f -perm +111 | head -1)
334345
test -x "$MCPP_BIN"
335346
file "$MCPP_BIN"
336347
otool -L "$MCPP_BIN"

0 commit comments

Comments
 (0)