From 398d144e349536f60327b06a2528f8a6a343d6f9 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 16 May 2026 23:03:01 +0800 Subject: [PATCH 1/8] release: prepare v0.0.17 with macOS ARM64 support - Bump version to 0.0.17 in mcpp.toml - Add CHANGELOG entry for 0.0.17 (macOS ARM64 headline feature) - Fix release.yml macOS job: replace broken self-host approach with proven xmake direct build (matching bootstrap-macos.yml) - Use macosx-arm64 naming convention for tarball artifacts - Remove broken self-host step from ci-macos.yml --- .github/workflows/ci-macos.yml | 10 ----- .github/workflows/release.yml | 76 +++++++++++++++++++++++----------- CHANGELOG.md | 20 +++++++++ mcpp.toml | 2 +- 4 files changed, 72 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 55c57e4..961a37a 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -278,13 +278,3 @@ jobs: export LLVM_ROOT="$LLVM_ROOT" bash scripts/bootstrap-macos.sh "$LLVM_ROOT" ./target/bootstrap/bin/mcpp --version - - - name: Self-host (mcpp builds mcpp) - run: | - # Put bootstrapped mcpp on PATH so build.ninja can find it for dyndep - export PATH="$PWD/target/bootstrap/bin:$PATH" - mcpp build - SELFHOST=$(find target -path "*/bin/mcpp" -not -path "*/bootstrap/*" -not -path "*/build/*" | head -1) - test -x "$SELFHOST" - "$SELFHOST" --version - echo ":: Self-host successful!" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7cce14..66ac625 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -315,37 +315,63 @@ jobs: LLVM_ROOT=$(find "$HOME/.xlings" -path "*/xpkgs/xim-x-llvm/*/bin/clang++" | head -1 | xargs dirname | xargs dirname) echo "LLVM_ROOT=$LLVM_ROOT" >> "$GITHUB_ENV" - - name: Install xmake (for bootstrap) - run: brew install xmake - - - name: Bootstrap-compile mcpp (xmake + LLVM) + - name: Install xmake run: | - export LLVM_ROOT="$LLVM_ROOT" - bash scripts/bootstrap-macos.sh "$LLVM_ROOT" - ./target/bootstrap/bin/mcpp --version + brew install xmake + xmake --version - - name: Self-host rebuild (mcpp builds mcpp) + - name: Build mcpp with xmake + LLVM run: | - # Put bootstrapped mcpp on PATH so build.ninja can find it for dyndep - export PATH="$PWD/target/bootstrap/bin:$PATH" - mcpp build - # Find the self-hosted binary - SELFHOST=$(find target -path "*/bin/mcpp" -not -path "*/bootstrap/*" -not -path "*/build/*" | head -1) - test -x "$SELFHOST" - "$SELFHOST" --version - echo "SELFHOST=$SELFHOST" >> "$GITHUB_ENV" + # Generate xmake.lua if not present + if [ ! -f xmake.lua ]; then + cat > xmake.lua << 'EOF' + add_rules("mode.release") + set_languages("c++23") + + package("cmdline") + set_homepage("https://github.com/mcpplibs/cmdline") + set_description("Modern C++ command-line parsing library") + set_license("Apache-2.0") + add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz") + add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0") + on_install(function (package) + import("package.tools.xmake").install(package) + end) + package_end() + + add_requires("cmdline 0.0.1") + + target("mcpp") + set_kind("binary") + add_files("src/main.cpp") + add_files("src/**.cppm") + add_packages("cmdline") + add_includedirs("src/libs/json") + set_policy("build.c++.modules", true) + EOF + fi + + xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT" + xmake build -y mcpp + + # Locate and verify built binary + MCPP_BIN=$(find build -name mcpp -type f -perm +111 | head -1) + test -x "$MCPP_BIN" + file "$MCPP_BIN" + "$MCPP_BIN" --version + echo "MCPP_BIN=$MCPP_BIN" >> "$GITHUB_ENV" - name: Package macOS release id: stage run: | VERSION="${{ steps.resolve.outputs.version }}" - TARBALL_NAME="mcpp-${VERSION}-darwin-arm64.tar.gz" - WRAPPER="mcpp-${VERSION}-darwin-arm64" + TARBALL_NAME="mcpp-${VERSION}-macosx-arm64.tar.gz" + WRAPPER="mcpp-${VERSION}-macosx-arm64" # Create release layout STAGING=$(mktemp -d) mkdir -p "$STAGING/$WRAPPER/bin" - cp "$SELFHOST" "$STAGING/$WRAPPER/bin/mcpp" + cp "$MCPP_BIN" "$STAGING/$WRAPPER/bin/mcpp" # Strip (Mach-O) strip "$STAGING/$WRAPPER/bin/mcpp" 2>/dev/null || true # Copy metadata @@ -371,10 +397,10 @@ jobs: mkdir -p dist (cd "$STAGING" && tar -czf "$GITHUB_WORKSPACE/dist/${TARBALL_NAME}" "$WRAPPER") # Versionless alias - cp "dist/${TARBALL_NAME}" "dist/mcpp-darwin-arm64.tar.gz" + cp "dist/${TARBALL_NAME}" "dist/mcpp-macosx-arm64.tar.gz" # SHA256 (cd dist && shasum -a 256 "${TARBALL_NAME}" > "${TARBALL_NAME}.sha256") - (cd dist && shasum -a 256 "mcpp-darwin-arm64.tar.gz" > "mcpp-darwin-arm64.tar.gz.sha256") + (cd dist && shasum -a 256 "mcpp-macosx-arm64.tar.gz" > "mcpp-macosx-arm64.tar.gz.sha256") echo "tarball=${TARBALL_NAME}" >> "$GITHUB_OUTPUT" ls -la dist/ @@ -394,7 +420,7 @@ jobs: with: tag_name: ${{ steps.resolve.outputs.tag }} files: | - dist/mcpp-${{ steps.resolve.outputs.version }}-darwin-arm64.tar.gz - dist/mcpp-${{ steps.resolve.outputs.version }}-darwin-arm64.tar.gz.sha256 - dist/mcpp-darwin-arm64.tar.gz - dist/mcpp-darwin-arm64.tar.gz.sha256 + dist/mcpp-${{ steps.resolve.outputs.version }}-macosx-arm64.tar.gz + dist/mcpp-${{ steps.resolve.outputs.version }}-macosx-arm64.tar.gz.sha256 + dist/mcpp-macosx-arm64.tar.gz + dist/mcpp-macosx-arm64.tar.gz.sha256 diff --git a/CHANGELOG.md b/CHANGELOG.md index b77a1c0..bdc50e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,26 @@ > 本文件追踪 `mcpp-community/mcpp` 公开仓的版本演进。 > 格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)。 +## [0.0.17] — 2026-05-16 + +macOS ARM64 正式支持,首次发布 macOS 原生二进制。 + +### 新增 + +- ✅ **macOS ARM64 支持** —— mcpp 现在正式支持 macOS ARM64 (Apple Silicon) + 平台。发布产物包含 `mcpp--macosx-arm64.tar.gz`,基于 xlings LLVM + 20.1.7 + xmake 构建,无需 Xcode 完整安装即可使用。 +- ✅ **Release CI macOS job** —— release.yml 新增 `build-macos` job,使用 + xmake + xlings LLVM 直接编译 macOS ARM64 二进制,与 bootstrap-macos.yml + 验证通过的方案一致。 + +### 改进 + +- 🔧 **Release macOS 构建流程简化** —— 移除有 libc++ 链接问题的 self-host + 步骤,改用已验证的 xmake 直接构建方案,提高 CI 可靠性。 +- 🔧 **CI macOS 流程精简** —— ci-macos.yml 移除存在链接问题的 self-host + 步骤,保留 xlings LLVM 验证测试。 + ## [0.0.14] — 2026-05-13 LLVM / Clang 工具链支持与 xlings 镜像配置完善。 diff --git a/mcpp.toml b/mcpp.toml index 5985952..06c67ae 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -1,6 +1,6 @@ [package] name = "mcpp" -version = "0.0.16" +version = "0.0.17" description = "Modern C++ build & package management tool" license = "Apache-2.0" authors = ["mcpp-community"] From d37bbc3b7a44b1ae87f395be9986f13ba5c2da66 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 16 May 2026 23:47:54 +0800 Subject: [PATCH 2/8] refactor: use v0.0.16 mcpp to self-host macOS builds (drop xmake) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since v0.0.16 macOS binary is available, both release and CI can now self-host: download v0.0.16 → mcpp build → produce new binary. No xmake needed. --- .github/workflows/ci-macos.yml | 26 ++++++++++------ .github/workflows/release.yml | 54 ++++++++++------------------------ 2 files changed, 32 insertions(+), 48 deletions(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 961a37a..43c790a 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -268,13 +268,21 @@ jobs: *) echo "FAIL: unexpected platform"; exit 1 ;; esac - - name: Install xmake (for bootstrap) + - name: Self-host test (v0.0.16 builds current) run: | - brew install xmake - xmake --version - - - name: Bootstrap mcpp from source (xmake) - run: | - export LLVM_ROOT="$LLVM_ROOT" - bash scripts/bootstrap-macos.sh "$LLVM_ROOT" - ./target/bootstrap/bin/mcpp --version + # Download v0.0.16 macOS mcpp to bootstrap + WORK=$(mktemp -d) + curl -fsSL -o "$WORK/mcpp.tar.gz" \ + "https://github.com/mcpp-community/mcpp/releases/download/v0.0.16/mcpp-0.0.16-macosx-arm64.tar.gz" + tar -xzf "$WORK/mcpp.tar.gz" -C "$WORK" + BOOTSTRAP="$WORK/mcpp-0.0.16-macosx-arm64/bin/mcpp" + test -x "$BOOTSTRAP" + "$BOOTSTRAP" --version + # Build current source with bootstrap mcpp + export PATH="$(dirname "$BOOTSTRAP"):$PATH" + mcpp build + # Verify the newly built binary + SELFHOST=$(find target -path "*/bin/mcpp" | head -1) + test -x "$SELFHOST" + "$SELFHOST" --version + echo ":: Self-host successful!" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 66ac625..77fff4d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -315,47 +315,23 @@ jobs: LLVM_ROOT=$(find "$HOME/.xlings" -path "*/xpkgs/xim-x-llvm/*/bin/clang++" | head -1 | xargs dirname | xargs dirname) echo "LLVM_ROOT=$LLVM_ROOT" >> "$GITHUB_ENV" - - name: Install xmake + - name: Bootstrap mcpp from v0.0.16 release run: | - brew install xmake - xmake --version - - - name: Build mcpp with xmake + LLVM + # Download the v0.0.16 macOS binary to bootstrap this build + WORK=$(mktemp -d) + curl -fsSL -o "$WORK/mcpp.tar.gz" \ + "https://github.com/mcpp-community/mcpp/releases/download/v0.0.16/mcpp-0.0.16-macosx-arm64.tar.gz" + tar -xzf "$WORK/mcpp.tar.gz" -C "$WORK" + BOOTSTRAP="$WORK/mcpp-0.0.16-macosx-arm64/bin/mcpp" + test -x "$BOOTSTRAP" + "$BOOTSTRAP" --version + export PATH="$(dirname "$BOOTSTRAP"):$PATH" + echo "PATH=$(dirname "$BOOTSTRAP"):$PATH" >> "$GITHUB_ENV" + + - name: Build mcpp (self-host via v0.0.16) run: | - # Generate xmake.lua if not present - if [ ! -f xmake.lua ]; then - cat > xmake.lua << 'EOF' - add_rules("mode.release") - set_languages("c++23") - - package("cmdline") - set_homepage("https://github.com/mcpplibs/cmdline") - set_description("Modern C++ command-line parsing library") - set_license("Apache-2.0") - add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz") - add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0") - on_install(function (package) - import("package.tools.xmake").install(package) - end) - package_end() - - add_requires("cmdline 0.0.1") - - target("mcpp") - set_kind("binary") - add_files("src/main.cpp") - add_files("src/**.cppm") - add_packages("cmdline") - add_includedirs("src/libs/json") - set_policy("build.c++.modules", true) - EOF - fi - - xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT" - xmake build -y mcpp - - # Locate and verify built binary - MCPP_BIN=$(find build -name mcpp -type f -perm +111 | head -1) + mcpp build + MCPP_BIN=$(find target -path "*/bin/mcpp" | head -1) test -x "$MCPP_BIN" file "$MCPP_BIN" "$MCPP_BIN" --version From dd6c9324c67a88f309b002e8b143c0c82c02201d Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 16 May 2026 23:56:54 +0800 Subject: [PATCH 3/8] fix: explicitly link libc++ on macOS for Clang toolchain xlings LLVM's clang++.cfg uses -nostdinc++ which suppresses the implicit -lc++ that clang++ normally adds during linking. This causes undefined symbol errors for C++ stdlib types. Fix by explicitly adding -lc++ to link flags on macOS. --- src/build/flags.cppm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/build/flags.cppm b/src/build/flags.cppm index 72066e5..b3fc5ca 100644 --- a/src/build/flags.cppm +++ b/src/build/flags.cppm @@ -161,8 +161,15 @@ CompileFlags compute_flags(const BuildPlan& plan) { runtime_dirs += " -L" + escape_path(dir); runtime_dirs += " -Wl,-rpath," + escape_path(dir); } - f.ld = std::format("{}{}{}{}{}", full_static, static_stdlib, sysroot_flag, b_flag, - runtime_dirs); +#if defined(__APPLE__) + // macOS: explicitly link libc++ — xlings LLVM's cfg uses -nostdinc++ + // which may suppress the implicit -lc++ that clang++ normally adds. + std::string stdlib_link = isClang ? " -lc++" : ""; +#else + std::string stdlib_link; +#endif + f.ld = std::format("{}{}{}{}{}{}", full_static, static_stdlib, sysroot_flag, b_flag, + runtime_dirs, stdlib_link); return f; } From 930a8a4a13e25c0dae2bc18d69915b8a2e6495ee Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 16 May 2026 23:57:49 +0800 Subject: [PATCH 4/8] 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. --- .github/workflows/ci-macos.yml | 46 +++++++++++++++++++++------------- .github/workflows/release.yml | 45 +++++++++++++++++++++------------ 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 43c790a..4ae739c 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -268,21 +268,33 @@ jobs: *) echo "FAIL: unexpected platform"; exit 1 ;; esac - - name: Self-host test (v0.0.16 builds current) + - name: Build mcpp from source (xmake + xlings LLVM) run: | - # Download v0.0.16 macOS mcpp to bootstrap - WORK=$(mktemp -d) - curl -fsSL -o "$WORK/mcpp.tar.gz" \ - "https://github.com/mcpp-community/mcpp/releases/download/v0.0.16/mcpp-0.0.16-macosx-arm64.tar.gz" - tar -xzf "$WORK/mcpp.tar.gz" -C "$WORK" - BOOTSTRAP="$WORK/mcpp-0.0.16-macosx-arm64/bin/mcpp" - test -x "$BOOTSTRAP" - "$BOOTSTRAP" --version - # Build current source with bootstrap mcpp - export PATH="$(dirname "$BOOTSTRAP"):$PATH" - mcpp build - # Verify the newly built binary - SELFHOST=$(find target -path "*/bin/mcpp" | head -1) - test -x "$SELFHOST" - "$SELFHOST" --version - echo ":: Self-host successful!" + brew install xmake + # Generate xmake.lua + cat > xmake.lua << 'EOF' + add_rules("mode.release") + set_languages("c++23") + package("cmdline") + set_homepage("https://github.com/mcpplibs/cmdline") + add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz") + add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0") + on_install(function (package) + import("package.tools.xmake").install(package) + end) + package_end() + add_requires("cmdline 0.0.1") + target("mcpp") + set_kind("binary") + add_files("src/main.cpp") + add_files("src/**.cppm") + add_packages("cmdline") + add_includedirs("src/libs/json") + set_policy("build.c++.modules", true) + EOF + xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT" + xmake build -y mcpp + MCPP=$(find build -name mcpp -type f -perm +111 | head -1) + test -x "$MCPP" + "$MCPP" --version + echo ":: Build from source successful!" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 77fff4d..6a6180a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -315,25 +315,38 @@ jobs: LLVM_ROOT=$(find "$HOME/.xlings" -path "*/xpkgs/xim-x-llvm/*/bin/clang++" | head -1 | xargs dirname | xargs dirname) echo "LLVM_ROOT=$LLVM_ROOT" >> "$GITHUB_ENV" - - name: Bootstrap mcpp from v0.0.16 release - run: | - # Download the v0.0.16 macOS binary to bootstrap this build - WORK=$(mktemp -d) - curl -fsSL -o "$WORK/mcpp.tar.gz" \ - "https://github.com/mcpp-community/mcpp/releases/download/v0.0.16/mcpp-0.0.16-macosx-arm64.tar.gz" - tar -xzf "$WORK/mcpp.tar.gz" -C "$WORK" - BOOTSTRAP="$WORK/mcpp-0.0.16-macosx-arm64/bin/mcpp" - test -x "$BOOTSTRAP" - "$BOOTSTRAP" --version - export PATH="$(dirname "$BOOTSTRAP"):$PATH" - echo "PATH=$(dirname "$BOOTSTRAP"):$PATH" >> "$GITHUB_ENV" - - - name: Build mcpp (self-host via v0.0.16) + - name: Install xmake + run: brew install xmake + + - name: Build mcpp (xmake + xlings LLVM) run: | - mcpp build - MCPP_BIN=$(find target -path "*/bin/mcpp" | head -1) + # Generate xmake.lua for this build + cat > xmake.lua << 'EOF' + add_rules("mode.release") + set_languages("c++23") + package("cmdline") + set_homepage("https://github.com/mcpplibs/cmdline") + add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz") + add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0") + on_install(function (package) + import("package.tools.xmake").install(package) + end) + package_end() + add_requires("cmdline 0.0.1") + target("mcpp") + set_kind("binary") + add_files("src/main.cpp") + add_files("src/**.cppm") + add_packages("cmdline") + add_includedirs("src/libs/json") + set_policy("build.c++.modules", true) + EOF + xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT" + xmake build -y mcpp + MCPP_BIN=$(find build -name mcpp -type f -perm +111 | head -1) test -x "$MCPP_BIN" file "$MCPP_BIN" + otool -L "$MCPP_BIN" "$MCPP_BIN" --version echo "MCPP_BIN=$MCPP_BIN" >> "$GITHUB_ENV" From d9de4e4eb2df508db9b33bd419e80346887c3bc1 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 17 May 2026 00:17:32 +0800 Subject: [PATCH 5/8] 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 --- .github/workflows/ci-macos.yml | 47 +++++++++++++--------------------- .github/workflows/release.yml | 43 +++++++++++-------------------- .xlings.json | 2 +- 3 files changed, 34 insertions(+), 58 deletions(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 4ae739c..fef05b6 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -268,33 +268,22 @@ jobs: *) echo "FAIL: unexpected platform"; exit 1 ;; esac - - name: Build mcpp from source (xmake + xlings LLVM) + - name: Install mcpp via xlings and self-host build run: | - brew install xmake - # Generate xmake.lua - cat > xmake.lua << 'EOF' - add_rules("mode.release") - set_languages("c++23") - package("cmdline") - set_homepage("https://github.com/mcpplibs/cmdline") - add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz") - add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0") - on_install(function (package) - import("package.tools.xmake").install(package) - end) - package_end() - add_requires("cmdline 0.0.1") - target("mcpp") - set_kind("binary") - add_files("src/main.cpp") - add_files("src/**.cppm") - add_packages("cmdline") - add_includedirs("src/libs/json") - set_policy("build.c++.modules", true) - EOF - xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT" - xmake build -y mcpp - MCPP=$(find build -name mcpp -type f -perm +111 | head -1) - test -x "$MCPP" - "$MCPP" --version - echo ":: Build from source successful!" + # Install mcpp (declared in .xlings.json) via xlings + xlings install mcpp -y || { + # Fallback: download release binary directly if pkgindex not updated yet + echo "::warning::xlings install mcpp failed, using direct download" + WORK=$(mktemp -d) + curl -fsSL -o "$WORK/mcpp.tar.gz" \ + "https://github.com/mcpp-community/mcpp/releases/download/v0.0.16/mcpp-0.0.16-macosx-arm64.tar.gz" + tar -xzf "$WORK/mcpp.tar.gz" -C "$WORK" + export PATH="$WORK/mcpp-0.0.16-macosx-arm64/bin:$PATH" + } + mcpp --version + # Self-host: build current source + mcpp build + SELFHOST=$(find target -path "*/bin/mcpp" | head -1) + test -x "$SELFHOST" + "$SELFHOST" --version + echo ":: Self-host successful!" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a6180a..f15f3e4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -315,35 +315,22 @@ jobs: LLVM_ROOT=$(find "$HOME/.xlings" -path "*/xpkgs/xim-x-llvm/*/bin/clang++" | head -1 | xargs dirname | xargs dirname) echo "LLVM_ROOT=$LLVM_ROOT" >> "$GITHUB_ENV" - - name: Install xmake - run: brew install xmake - - - name: Build mcpp (xmake + xlings LLVM) + - name: Install mcpp via xlings and build run: | - # Generate xmake.lua for this build - cat > xmake.lua << 'EOF' - add_rules("mode.release") - set_languages("c++23") - package("cmdline") - set_homepage("https://github.com/mcpplibs/cmdline") - add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz") - add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0") - on_install(function (package) - import("package.tools.xmake").install(package) - end) - package_end() - add_requires("cmdline 0.0.1") - target("mcpp") - set_kind("binary") - add_files("src/main.cpp") - add_files("src/**.cppm") - add_packages("cmdline") - add_includedirs("src/libs/json") - set_policy("build.c++.modules", true) - EOF - xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT" - xmake build -y mcpp - MCPP_BIN=$(find build -name mcpp -type f -perm +111 | head -1) + export PATH="$HOME/.xlings/subos/default/bin:$PATH" + # Install mcpp (declared in .xlings.json) + xlings install mcpp -y || { + echo "::warning::xlings install mcpp failed, using direct download" + WORK=$(mktemp -d) + curl -fsSL -o "$WORK/mcpp.tar.gz" \ + "https://github.com/mcpp-community/mcpp/releases/download/v0.0.16/mcpp-0.0.16-macosx-arm64.tar.gz" + tar -xzf "$WORK/mcpp.tar.gz" -C "$WORK" + export PATH="$WORK/mcpp-0.0.16-macosx-arm64/bin:$PATH" + } + mcpp --version + # Build current source + mcpp build + MCPP_BIN=$(find target -path "*/bin/mcpp" | head -1) test -x "$MCPP_BIN" file "$MCPP_BIN" otool -L "$MCPP_BIN" diff --git a/.xlings.json b/.xlings.json index 7ce6add..f7cc6a1 100644 --- a/.xlings.json +++ b/.xlings.json @@ -1,6 +1,6 @@ { "workspace": { - "mcpp": "0.0.9", + "mcpp": "0.0.16", "xmake": "3.0.7" } } From 57104b7a433a166cb8ca2a245ab54bfb98095d4c Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 17 May 2026 00:27:27 +0800 Subject: [PATCH 6/8] fix: CI macOS uses xmake build (v0.0.16 mcpp has link bug) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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`. --- .github/workflows/ci-macos.yml | 49 +++++++++++++++++++++------------- .github/workflows/release.yml | 41 +++++++++++++++++----------- 2 files changed, 57 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index fef05b6..ab3188c 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -268,22 +268,35 @@ jobs: *) echo "FAIL: unexpected platform"; exit 1 ;; esac - - name: Install mcpp via xlings and self-host build + - name: Build mcpp from source (xmake) run: | - # Install mcpp (declared in .xlings.json) via xlings - xlings install mcpp -y || { - # Fallback: download release binary directly if pkgindex not updated yet - echo "::warning::xlings install mcpp failed, using direct download" - WORK=$(mktemp -d) - curl -fsSL -o "$WORK/mcpp.tar.gz" \ - "https://github.com/mcpp-community/mcpp/releases/download/v0.0.16/mcpp-0.0.16-macosx-arm64.tar.gz" - tar -xzf "$WORK/mcpp.tar.gz" -C "$WORK" - export PATH="$WORK/mcpp-0.0.16-macosx-arm64/bin:$PATH" - } - mcpp --version - # Self-host: build current source - mcpp build - SELFHOST=$(find target -path "*/bin/mcpp" | head -1) - test -x "$SELFHOST" - "$SELFHOST" --version - echo ":: Self-host successful!" + brew install xmake + # Temporary xmake.lua — not committed to repo + cat > /tmp/xmake_bootstrap.lua << 'EOF' + add_rules("mode.release") + set_languages("c++23") + package("cmdline") + set_homepage("https://github.com/mcpplibs/cmdline") + add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz") + add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0") + on_install(function (package) + import("package.tools.xmake").install(package) + end) + package_end() + add_requires("cmdline 0.0.1") + target("mcpp") + set_kind("binary") + add_files("src/main.cpp") + add_files("src/**.cppm") + add_packages("cmdline") + add_includedirs("src/libs/json") + set_policy("build.c++.modules", true) + EOF + cp /tmp/xmake_bootstrap.lua xmake.lua + xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT" + xmake build -y mcpp + rm -f xmake.lua + MCPP=$(find build -name mcpp -type f -perm +111 | head -1) + test -x "$MCPP" + "$MCPP" --version + echo ":: Build successful!" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f15f3e4..b06f850 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -315,22 +315,33 @@ jobs: LLVM_ROOT=$(find "$HOME/.xlings" -path "*/xpkgs/xim-x-llvm/*/bin/clang++" | head -1 | xargs dirname | xargs dirname) echo "LLVM_ROOT=$LLVM_ROOT" >> "$GITHUB_ENV" - - name: Install mcpp via xlings and build + - name: Build mcpp (xmake + LLVM) run: | - export PATH="$HOME/.xlings/subos/default/bin:$PATH" - # Install mcpp (declared in .xlings.json) - xlings install mcpp -y || { - echo "::warning::xlings install mcpp failed, using direct download" - WORK=$(mktemp -d) - curl -fsSL -o "$WORK/mcpp.tar.gz" \ - "https://github.com/mcpp-community/mcpp/releases/download/v0.0.16/mcpp-0.0.16-macosx-arm64.tar.gz" - tar -xzf "$WORK/mcpp.tar.gz" -C "$WORK" - export PATH="$WORK/mcpp-0.0.16-macosx-arm64/bin:$PATH" - } - mcpp --version - # Build current source - mcpp build - MCPP_BIN=$(find target -path "*/bin/mcpp" | head -1) + brew install xmake + cat > xmake.lua << 'EOF' + add_rules("mode.release") + set_languages("c++23") + package("cmdline") + set_homepage("https://github.com/mcpplibs/cmdline") + add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz") + add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0") + on_install(function (package) + import("package.tools.xmake").install(package) + end) + package_end() + add_requires("cmdline 0.0.1") + target("mcpp") + set_kind("binary") + add_files("src/main.cpp") + add_files("src/**.cppm") + add_packages("cmdline") + add_includedirs("src/libs/json") + set_policy("build.c++.modules", true) + EOF + xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT" + xmake build -y mcpp + rm -f xmake.lua + MCPP_BIN=$(find build -name mcpp -type f -perm +111 | head -1) test -x "$MCPP_BIN" file "$MCPP_BIN" otool -L "$MCPP_BIN" From 3edf1601bed29e5907e2406bd6866c87333447b9 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 17 May 2026 01:00:39 +0800 Subject: [PATCH 7/8] refactor: use xlings install mcpp@0.0.16 for macOS self-host builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that mcpp@0.0.16 is in xlings-res with the libc++ fix, CI and release workflows can simply: xlings install mcpp → mcpp build No xmake needed — mcpp self-hosts on macOS via xlings ecosystem. --- .github/workflows/ci-macos.yml | 42 +++++++++------------------------- .github/workflows/release.yml | 36 ++++++++--------------------- 2 files changed, 21 insertions(+), 57 deletions(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index ab3188c..ca27553 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -268,35 +268,15 @@ jobs: *) echo "FAIL: unexpected platform"; exit 1 ;; esac - - name: Build mcpp from source (xmake) + - name: Install mcpp@0.0.16 via xlings run: | - brew install xmake - # Temporary xmake.lua — not committed to repo - cat > /tmp/xmake_bootstrap.lua << 'EOF' - add_rules("mode.release") - set_languages("c++23") - package("cmdline") - set_homepage("https://github.com/mcpplibs/cmdline") - add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz") - add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0") - on_install(function (package) - import("package.tools.xmake").install(package) - end) - package_end() - add_requires("cmdline 0.0.1") - target("mcpp") - set_kind("binary") - add_files("src/main.cpp") - add_files("src/**.cppm") - add_packages("cmdline") - add_includedirs("src/libs/json") - set_policy("build.c++.modules", true) - EOF - cp /tmp/xmake_bootstrap.lua xmake.lua - xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT" - xmake build -y mcpp - rm -f xmake.lua - MCPP=$(find build -name mcpp -type f -perm +111 | head -1) - test -x "$MCPP" - "$MCPP" --version - echo ":: Build successful!" + xlings install mcpp -y + mcpp --version + + - name: Self-host (mcpp builds mcpp) + run: | + mcpp build + SELFHOST=$(find target -path "*/bin/mcpp" | head -1) + test -x "$SELFHOST" + "$SELFHOST" --version + echo ":: Self-host successful!" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b06f850..3a82c9a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -315,33 +315,17 @@ jobs: LLVM_ROOT=$(find "$HOME/.xlings" -path "*/xpkgs/xim-x-llvm/*/bin/clang++" | head -1 | xargs dirname | xargs dirname) echo "LLVM_ROOT=$LLVM_ROOT" >> "$GITHUB_ENV" - - name: Build mcpp (xmake + LLVM) + - name: Install mcpp@0.0.16 via xlings run: | - brew install xmake - cat > xmake.lua << 'EOF' - add_rules("mode.release") - set_languages("c++23") - package("cmdline") - set_homepage("https://github.com/mcpplibs/cmdline") - add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/$(version).tar.gz") - add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0") - on_install(function (package) - import("package.tools.xmake").install(package) - end) - package_end() - add_requires("cmdline 0.0.1") - target("mcpp") - set_kind("binary") - add_files("src/main.cpp") - add_files("src/**.cppm") - add_packages("cmdline") - add_includedirs("src/libs/json") - set_policy("build.c++.modules", true) - EOF - xmake f -y -m release --toolchain=llvm --sdk="$LLVM_ROOT" - xmake build -y mcpp - rm -f xmake.lua - MCPP_BIN=$(find build -name mcpp -type f -perm +111 | head -1) + export PATH="$HOME/.xlings/subos/default/bin:$PATH" + xlings install mcpp -y + mcpp --version + + - name: Build mcpp (self-host) + run: | + export PATH="$HOME/.xlings/subos/default/bin:$PATH" + mcpp build + MCPP_BIN=$(find target -path "*/bin/mcpp" | head -1) test -x "$MCPP_BIN" file "$MCPP_BIN" otool -L "$MCPP_BIN" From 0fced2b344b4f81e3be9d9afef258f34ccaf4618 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 17 May 2026 01:12:08 +0800 Subject: [PATCH 8/8] fix: add xlings update + bust cache for macOS mcpp install - Add `xlings update` before install to refresh pkgindex - Bump cache key to invalidate stale xlings data --- .github/workflows/ci-macos.yml | 6 ++++-- .github/workflows/release.yml | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index ca27553..a36cde8 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -33,9 +33,9 @@ jobs: uses: actions/cache@v4 with: path: ~/.xlings - key: xlings-macos15-arm64-${{ hashFiles('.xlings.json') }} + key: xlings-macos15-arm64-v2-${{ hashFiles('.xlings.json') }} restore-keys: | - xlings-macos15-arm64- + xlings-macos15-arm64-v2- - name: Bootstrap xlings env: @@ -270,6 +270,8 @@ jobs: - name: Install mcpp@0.0.16 via xlings run: | + # Update package index to pick up new macOS entries + xlings update -y 2>/dev/null || true xlings install mcpp -y mcpp --version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3a82c9a..13d456e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -318,6 +318,7 @@ jobs: - name: Install mcpp@0.0.16 via xlings run: | export PATH="$HOME/.xlings/subos/default/bin:$PATH" + xlings update -y 2>/dev/null || true xlings install mcpp -y mcpp --version