Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ jobs:
uses: actions/cache@v4
with:
path: ~/.mcpp/registry
key: mcpp-registry-${{ runner.os }}-0.0.41-${{ hashFiles('pkgs/**/*.lua', 'tests/smoke_compat_*.sh', '.github/workflows/validate.yml') }}
key: mcpp-registry-${{ runner.os }}-0.0.45-${{ hashFiles('pkgs/**/*.lua', 'tests/*.sh', '.github/workflows/validate.yml') }}
restore-keys: |
mcpp-registry-${{ runner.os }}-0.0.41-
mcpp-registry-${{ runner.os }}-0.0.45-
- name: Download mcpp
env:
MCPP_VERSION: "0.0.41"
MCPP_VERSION: "0.0.45"
run: |
curl -L -fsS -o mcpp.tar.gz \
"https://github.com/mcpp-community/mcpp/releases/download/v${MCPP_VERSION}/mcpp-${MCPP_VERSION}-linux-x86_64.tar.gz"
Expand All @@ -79,6 +79,7 @@ jobs:
timeout 1800 bash tests/smoke_compat_imgui.sh
timeout 1800 bash tests/smoke_compat_archive.sh
timeout 1800 bash tests/smoke_compat_imgui_window.sh
timeout 1800 bash tests/smoke_imgui_module.sh

smoke-portable:
name: smoke-${{ matrix.platform }}
Expand All @@ -90,14 +91,14 @@ jobs:
include:
- platform: macos
os: macos-15
archive: mcpp-0.0.41-macosx-arm64.tar.gz
root: mcpp-0.0.41-macosx-arm64
archive: mcpp-0.0.45-macosx-arm64.tar.gz
root: mcpp-0.0.45-macosx-arm64
mcpp: bin/mcpp
xlings: registry/bin/xlings
- platform: windows
os: windows-latest
archive: mcpp-0.0.41-windows-x86_64.zip
root: mcpp-0.0.41-windows-x86_64
archive: mcpp-0.0.45-windows-x86_64.zip
root: mcpp-0.0.45-windows-x86_64
mcpp: bin/mcpp.exe
xlings: registry/bin/xlings.exe
steps:
Expand All @@ -106,13 +107,13 @@ jobs:
uses: actions/cache@v4
with:
path: ~/.mcpp/registry
key: mcpp-registry-${{ runner.os }}-0.0.41-${{ hashFiles('pkgs/**/*.lua', 'tests/smoke_compat_*.sh', '.github/workflows/validate.yml') }}
key: mcpp-registry-${{ runner.os }}-0.0.45-${{ hashFiles('pkgs/**/*.lua', 'tests/*.sh', '.github/workflows/validate.yml') }}
restore-keys: |
mcpp-registry-${{ runner.os }}-0.0.41-
mcpp-registry-${{ runner.os }}-0.0.45-
- name: Download mcpp
shell: bash
env:
MCPP_VERSION: "0.0.41"
MCPP_VERSION: "0.0.45"
MCPP_ARCHIVE: ${{ matrix.archive }}
MCPP_ROOT: ${{ matrix.root }}
run: |
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ mcpp build # 自动拉取源码 + 构建
| `mcpplibs.xpkg` | 0.0.40 | xpkg V1 规范的 C++23 参考实现 — `import mcpplibs.xpkg;` | [openxlings/libxpkg](https://github.com/openxlings/libxpkg) |
| `mcpplibs.templates` | 0.0.1 | 最小化模块库模板 — `import mcpplibs.templates;` | [mcpplibs/templates](https://github.com/mcpplibs/templates) |

### 独立模块化库

| 包名 | 版本 | 简介 | 仓库 |
|------|------|------|------|
| `imgui` | 0.0.1 | Dear ImGui C++23 模块封装 — `import imgui.core;` / `import imgui.backend.glfw_opengl3;` | [mcpplibs/imgui-m](https://github.com/mcpplibs/imgui-m) |

### 第三方 C/C++ 库

| 包名 | 版本 | 简介 |
Expand Down Expand Up @@ -68,6 +74,12 @@ mcpplibs.xpkg
└── mcpplibs.capi.lua
└── lua ← 同上

imgui
├── compat.imgui
├── compat.glfw
│ └── compat.opengl
└── compat.opengl ← 消费者只需要 import imgui.* 模块

libarchive
├── zlib
├── bzip2
Expand Down Expand Up @@ -109,6 +121,7 @@ mcpp 0.0.3+ 的 transitive walker 自动沿链路传播头文件和依赖,消费
MCPP=/path/to/mcpp tests/smoke_compat_core.sh
MCPP=/path/to/mcpp tests/smoke_compat_imgui.sh
MCPP=/path/to/mcpp tests/smoke_compat_archive.sh
MCPP=/path/to/mcpp tests/smoke_imgui_module.sh
```

该脚本会通过当前 checkout 作为本地 path index 创建临时 mcpp 项目,验证:
Expand All @@ -117,6 +130,8 @@ MCPP=/path/to/mcpp tests/smoke_compat_archive.sh
`#include <...>` API 构建并运行最小用例
- `compat.opengl`/`compat.khrplatform` 能提供 GLFW/OpenGL 常见头文件闭包
- `compat.imgui@1.92.8` core 能构建并运行一个 headless ImGui frame
- `imgui@0.0.1` 模块包能通过 `[dependencies] imgui = "0.0.1"` 构建并运行
`import imgui.core;` / `import imgui.backend.glfw_opengl3;` 最小用例
- `compat.glfw@3.4` 能构建、运行 `glfwInit()` smoke,并链接 X11 扩展 runtime `.so`
- `compat.xau@1.0.12`/`compat.xdmcp@1.1.5` 能构建、运行并链接 runtime `.so`
- `compat.xcb@1.17.0` 能构建、运行并链接 `libxcb.so`
Expand Down
36 changes: 36 additions & 0 deletions pkgs/i/imgui.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- Form A descriptor: the public imgui module package ships its own
-- mcpp.toml. mcpp's default lookup finds <verdir>/*/mcpp.toml inside
-- the GitHub source tarball wrap.
--
package = {
spec = "1",
name = "imgui",
namespace = "",
description = "C++23 module package for Dear ImGui core and GLFW/OpenGL3 backends",
licenses = {"MIT"},
repo = "https://github.com/mcpplibs/imgui-m",
type = "package",

xpm = {
linux = {
["0.0.1"] = {
url = "https://github.com/mcpplibs/imgui-m/archive/refs/tags/0.0.1.tar.gz",
sha256 = "b87188bd2ca7d8010a695d5ebfccd76eb3e28b3e002885207493225057f5e190",
},
},
macosx = {
["0.0.1"] = {
url = "https://github.com/mcpplibs/imgui-m/archive/refs/tags/0.0.1.tar.gz",
sha256 = "b87188bd2ca7d8010a695d5ebfccd76eb3e28b3e002885207493225057f5e190",
},
},
windows = {
["0.0.1"] = {
url = "https://github.com/mcpplibs/imgui-m/archive/refs/tags/0.0.1.tar.gz",
sha256 = "b87188bd2ca7d8010a695d5ebfccd76eb3e28b3e002885207493225057f5e190",
},
},
},

-- (no `mcpp` field -- default lookup will find <verdir>/*/mcpp.toml)
}
122 changes: 122 additions & 0 deletions tests/smoke_imgui_module.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/usr/bin/env bash
# Smoke-test the public imgui module package through this checkout as a local
# mcpp path index. This validates user-facing import-only consumption.
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
MCPP_BIN="${MCPP:-}"
if [[ -z "$MCPP_BIN" ]]; then
MCPP_BIN="$(command -v mcpp || true)"
fi
if [[ -z "$MCPP_BIN" || ! -x "$MCPP_BIN" ]]; then
echo "FATAL: set MCPP=/path/to/mcpp or put mcpp on PATH" >&2
exit 1
fi

TMP="$(mktemp -d)"
if [[ "${MCPP_INDEX_KEEP_SMOKE_TMP:-0}" == "1" ]]; then
echo "KEEP: $TMP"
else
trap 'rm -rf "$TMP"' EXIT
fi

if [[ -n "${MCPP_INDEX_SMOKE_MCPP_HOME:-}" ]]; then
export MCPP_HOME="$MCPP_INDEX_SMOKE_MCPP_HOME"
else
export MCPP_HOME="$TMP/mcpp-home"
fi
mkdir -p "$MCPP_HOME/registry/data/xpkgs"

USER_MCPP="${HOME}/.mcpp"
link_xpkgs() {
local src="$1"
[[ -d "$src" ]] || return 0
find "$src" -mindepth 1 -maxdepth 1 -type d | while read -r pkg; do
ln -s "$pkg" "$MCPP_HOME/registry/data/xpkgs/$(basename "$pkg")" 2>/dev/null || true
done
}
link_xpkgs "${MCPP_INDEX_SMOKE_XPKGS_DIR:-}"
link_xpkgs "$USER_MCPP/registry/data/xpkgs"
if [[ -d "$USER_MCPP/registry/data/xim-pkgindex" ]]; then
mkdir -p "$MCPP_HOME/registry/data/xim-pkgindex"
cp -a "$USER_MCPP/registry/data/xim-pkgindex/." "$MCPP_HOME/registry/data/xim-pkgindex/" 2>/dev/null || true
rm -f "$MCPP_HOME/registry/data/xim-pkgindex/.xlings-index-cache.json"
fi
if [[ -d "$USER_MCPP/registry/bin" ]]; then
mkdir -p "$MCPP_HOME/registry"
ln -s "$USER_MCPP/registry/bin" "$MCPP_HOME/registry/bin" 2>/dev/null || true
fi
if [[ -f "$USER_MCPP/config.toml" ]]; then
cp -f "$USER_MCPP/config.toml" "$MCPP_HOME/config.toml" 2>/dev/null || true
fi

default_index="$MCPP_HOME/registry/data/mcpplibs"
mkdir -p "$default_index"
cp -a "$ROOT/." "$default_index/"
rm -f "$default_index/.xlings-index-cache.json"
printf 'ok\n' > "$default_index/.mcpp-index-updated"

"$MCPP_BIN" self config --mirror "${MCPP_INDEX_MIRROR:-GLOBAL}" >/dev/null

mkdir -p "$TMP/imgui-module-smoke/src"
cd "$TMP/imgui-module-smoke"
cat > mcpp.toml <<EOF
[package]
name = "imgui-module-smoke"
version = "0.1.0"

[toolchain]
default = "${MCPP_INDEX_IMGUI_MODULE_TOOLCHAIN:-llvm@20.1.7}"

[dependencies]
imgui = "0.0.1"

[targets.imgui-module-smoke]
kind = "bin"
main = "src/main.cpp"
EOF

cat > src/main.cpp <<'EOF'
import std;
import imgui.core;
import imgui.backend.glfw_opengl3;

int main() {
auto init = &ImGui::Backend::GlfwOpenGL3::Init;
auto shutdown = &ImGui::Backend::GlfwOpenGL3::Shutdown;
if (init == nullptr || shutdown == nullptr) {
return 1;
}

ImGuiContext* context = ImGui::CreateContext();
if (context == nullptr) {
return 2;
}
ImGui::SetCurrentContext(context);

ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = ImVec2 { 320.0f, 240.0f };
unsigned char* pixels = nullptr;
int width = 0;
int height = 0;
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
if (pixels == nullptr || width <= 0 || height <= 0) {
ImGui::DestroyContext(context);
return 3;
}

ImGui::NewFrame();
bool open = true;
ImGui::Begin("mcpp-index imgui smoke", &open);
ImGui::TextUnformatted("import imgui.core");
ImGui::End();
ImGui::Render();

std::println("Dear ImGui {} module package ok", ImGui::GetVersion());
ImGui::DestroyContext(context);
return 0;
}
EOF

"$MCPP_BIN" build
"$MCPP_BIN" run
Loading