Skip to content

Commit 930a8a4

Browse files
committed
fix: use xmake for v0.0.17 macOS build (v0.0.16 has link bug)
v0.0.16 mcpp lacks the -lc++ fix needed for macOS self-host. Use xmake (proven working) for this release. Once v0.0.17 ships with the libc++ link fix, subsequent releases can self-host.
1 parent dd6c932 commit 930a8a4

2 files changed

Lines changed: 58 additions & 33 deletions

File tree

.github/workflows/ci-macos.yml

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -268,21 +268,33 @@ jobs:
268268
*) echo "FAIL: unexpected platform"; exit 1 ;;
269269
esac
270270
271-
- name: Self-host test (v0.0.16 builds current)
271+
- name: Build mcpp from source (xmake + xlings LLVM)
272272
run: |
273-
# Download v0.0.16 macOS mcpp to bootstrap
274-
WORK=$(mktemp -d)
275-
curl -fsSL -o "$WORK/mcpp.tar.gz" \
276-
"https://github.com/mcpp-community/mcpp/releases/download/v0.0.16/mcpp-0.0.16-macosx-arm64.tar.gz"
277-
tar -xzf "$WORK/mcpp.tar.gz" -C "$WORK"
278-
BOOTSTRAP="$WORK/mcpp-0.0.16-macosx-arm64/bin/mcpp"
279-
test -x "$BOOTSTRAP"
280-
"$BOOTSTRAP" --version
281-
# Build current source with bootstrap mcpp
282-
export PATH="$(dirname "$BOOTSTRAP"):$PATH"
283-
mcpp build
284-
# Verify the newly built binary
285-
SELFHOST=$(find target -path "*/bin/mcpp" | head -1)
286-
test -x "$SELFHOST"
287-
"$SELFHOST" --version
288-
echo ":: Self-host successful!"
273+
brew install xmake
274+
# Generate xmake.lua
275+
cat > xmake.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+
xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT"
296+
xmake build -y mcpp
297+
MCPP=$(find build -name mcpp -type f -perm +111 | head -1)
298+
test -x "$MCPP"
299+
"$MCPP" --version
300+
echo ":: Build from source successful!"

.github/workflows/release.yml

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -315,25 +315,38 @@ 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: Bootstrap mcpp from v0.0.16 release
319-
run: |
320-
# Download the v0.0.16 macOS binary to bootstrap this build
321-
WORK=$(mktemp -d)
322-
curl -fsSL -o "$WORK/mcpp.tar.gz" \
323-
"https://github.com/mcpp-community/mcpp/releases/download/v0.0.16/mcpp-0.0.16-macosx-arm64.tar.gz"
324-
tar -xzf "$WORK/mcpp.tar.gz" -C "$WORK"
325-
BOOTSTRAP="$WORK/mcpp-0.0.16-macosx-arm64/bin/mcpp"
326-
test -x "$BOOTSTRAP"
327-
"$BOOTSTRAP" --version
328-
export PATH="$(dirname "$BOOTSTRAP"):$PATH"
329-
echo "PATH=$(dirname "$BOOTSTRAP"):$PATH" >> "$GITHUB_ENV"
330-
331-
- name: Build mcpp (self-host via v0.0.16)
318+
- name: Install xmake
319+
run: brew install xmake
320+
321+
- name: Build mcpp (xmake + xlings LLVM)
332322
run: |
333-
mcpp build
334-
MCPP_BIN=$(find target -path "*/bin/mcpp" | head -1)
323+
# Generate xmake.lua for this build
324+
cat > xmake.lua << 'EOF'
325+
add_rules("mode.release")
326+
set_languages("c++23")
327+
package("cmdline")
328+
set_homepage("https://github.com/mcpplibs/cmdline")
329+
add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz")
330+
add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0")
331+
on_install(function (package)
332+
import("package.tools.xmake").install(package)
333+
end)
334+
package_end()
335+
add_requires("cmdline 0.0.1")
336+
target("mcpp")
337+
set_kind("binary")
338+
add_files("src/main.cpp")
339+
add_files("src/**.cppm")
340+
add_packages("cmdline")
341+
add_includedirs("src/libs/json")
342+
set_policy("build.c++.modules", true)
343+
EOF
344+
xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT"
345+
xmake build -y mcpp
346+
MCPP_BIN=$(find build -name mcpp -type f -perm +111 | head -1)
335347
test -x "$MCPP_BIN"
336348
file "$MCPP_BIN"
349+
otool -L "$MCPP_BIN"
337350
"$MCPP_BIN" --version
338351
echo "MCPP_BIN=$MCPP_BIN" >> "$GITHUB_ENV"
339352

0 commit comments

Comments
 (0)