Skip to content

Commit d9de4e4

Browse files
committed
refactor: use xlings install mcpp@0.0.16 for macOS bootstrap
- .xlings.json: bump mcpp to 0.0.16 - CI/release: use `xlings install mcpp` with fallback to direct download - Removes xmake dependency from main build path
1 parent 930a8a4 commit d9de4e4

3 files changed

Lines changed: 34 additions & 58 deletions

File tree

.github/workflows/ci-macos.yml

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -268,33 +268,22 @@ jobs:
268268
*) echo "FAIL: unexpected platform"; exit 1 ;;
269269
esac
270270
271-
- name: Build mcpp from source (xmake + xlings LLVM)
271+
- name: Install mcpp via xlings and self-host build
272272
run: |
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!"
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!"

.github/workflows/release.yml

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -315,35 +315,22 @@ 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 xmake
319-
run: brew install xmake
320-
321-
- name: Build mcpp (xmake + xlings LLVM)
318+
- name: Install mcpp via xlings and build
322319
run: |
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)
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)
347334
test -x "$MCPP_BIN"
348335
file "$MCPP_BIN"
349336
otool -L "$MCPP_BIN"

.xlings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"workspace": {
3-
"mcpp": "0.0.9",
3+
"mcpp": "0.0.16",
44
"xmake": "3.0.7"
55
}
66
}

0 commit comments

Comments
 (0)