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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Preserve upstream document bytes and original whitespace on every platform.
upstream/** -text -whitespace
112 changes: 112 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read

env:
# compat.slint 1.19.0 and mcpplibs.slintgen 1.19.0 are in an mcpp-index
# PR and not yet in the published index: until they are, the run resolves
# against that PR's candidate commit, the complete unchanged index layout
# installed as the built-in index of the run's home. Drop this pin and the step
# that reads it once the index publishes them.
MCPP_INDEX_CANDIDATE: "4191fe3e1193ae4ce4360201ae0a45ca1c2e5463"

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true


jobs:
mcpp:
name: mcpp (${{ matrix.os }}, ${{ matrix.toolchain }})
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-24.04, toolchain: 'gcc@16.1.0' }
- { os: ubuntu-24.04, toolchain: 'llvm@23.1.3' }
# Linux arm64 waits for an aarch64 xim:fontconfig (compat.slint's payload needs it).
- { os: macos-15, toolchain: 'llvm@23.1.3' }
- { os: windows-2025, toolchain: 'llvm@23.1.3' }
runs-on: ${{ matrix.os }}
timeout-minutes: 90
defaults:
run:
shell: bash
env:
XLINGS_NON_INTERACTIVE: 1
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Mwrap identity and bilingual README contract
run: python3 tools/check_mwrap_release.py

- name: Install Xlings (Linux/macOS)
if: runner.os != 'Windows'
run: |
curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/refs/heads/main/tools/other/quick_install.sh | bash
echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH"

- name: Install Xlings (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
irm https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.ps1 | iex
"$env:USERPROFILE\.xlings\subos\current\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Install project tools (.xlings.json)
run: |
for attempt in 1 2 3; do
xlings update > /dev/null 2>&1 || true
if xlings install; then break; fi
[ "$attempt" = 3 ] && exit 1
sleep 30
done
mcpp --version

- name: Candidate index (compat.slint, slintgen)
run: |
mcpp index update
# No early exit in awk: mcpp would take SIGPIPE, and pipefail report it.
home=$(mcpp self env | awk -F'= *' '/^MCPP_HOME/ && !h {h = $2} END {print h}')
test -n "$home"
git init -q "$RUNNER_TEMP/index"
git -C "$RUNNER_TEMP/index" fetch -q --depth 1 https://github.com/mcpplibs/mcpp-index "$MCPP_INDEX_CANDIDATE"
git -C "$RUNNER_TEMP/index" checkout -q FETCH_HEAD
python3 "$RUNNER_TEMP/index/tests/prepare_builtin_index.py" --home "$home"

- name: Select the toolchain
run: |
name="${{ matrix.toolchain }}"
mcpp toolchain install "${name%@*}" "${name#*@}"
mcpp toolchain default "$name"

- name: Build the modules
run: mcpp build

- name: Tests (the runtime types through the module; a component compiled at run time and driven headless)
run: mcpp test

- name: Tests, release profile
run: mcpp test --profile release

- name: mcpp.plugins.slint generates a component, its module, and runs it headless with the SDK the project declares
run: MCPP="$(command -v mcpp)" bash tests/rule-consumer/check-slint.sh

- name: Export audit (the generated surface is fresh; every public name, key code and feature of the SDK's headers)
if: matrix.os == 'ubuntu-24.04' && matrix.toolchain == 'llvm@23.1.3'
run: |
export CLANGXX="$(ls -d "$HOME"/.mcpp/registry/data/xpkgs/xim-x-llvm/23.1.3/bin/clang++ "$HOME"/.xlings/data/xpkgs/xim-x-llvm/23.1.3/bin/clang++ 2>/dev/null | head -1)"
test -n "$CLANGXX"
python3 tools/check_exports.py
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release
on:
push:
tags: ["mwrap-*"]
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
actions: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Check tag, upstream version and bilingual entry pages
run: python3 tools/check_mwrap_release.py --tag "$GITHUB_REF_NAME"
- name: Require successful source CI at this exact commit
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
result=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow ci.yml --commit "$GITHUB_SHA" --limit 1 --json status,conclusion --jq '.[0] | .status == "completed" and .conclusion == "success"')
test "$result" = true || { echo 'No successful source CI at the tag commit'; exit 1; }
- name: Build immutable source asset and publish
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#mwrap-}"
repo="${GITHUB_REPOSITORY#*/}"
asset="${repo}-${version}.tar.gz"
git archive --format=tar.gz --prefix="${repo}-${version}/" "$GITHUB_SHA" > "$RUNNER_TEMP/$asset"
(cd "$RUNNER_TEMP" && sha256sum "$asset" > "$asset.sha256")
if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
echo 'Release already exists; refusing to change immutable assets'; exit 1
fi
extra=()
if [[ "$version" == *-rc* ]]; then extra+=(--prerelease); fi
gh release create "$GITHUB_REF_NAME" "$RUNNER_TEMP/$asset" "$RUNNER_TEMP/$asset.sha256" \
--repo "$GITHUB_REPOSITORY" --verify-tag --title "$repo $version" \
--notes "Module wrapper for upstream $version. New mwrap package identities become installable after mcpp-index publication; see the bilingual README for the tested support scope." "${extra[@]}"
37 changes: 37 additions & 0 deletions .github/workflows/templates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Actual project templates
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: templates-${{ github.ref }}
cancel-in-progress: true
env:
MCPP_VERSION: "2026.11.18.1"
# See ci.yml: the candidate index until compat.slint and mcpplibs.slintgen are published.
MCPP_INDEX_CANDIDATE: "4191fe3e1193ae4ce4360201ae0a45ca1c2e5463"
jobs:
templates:
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Install the pinned mcpp
shell: bash
run: |
archive="mcpp-${MCPP_VERSION}-linux-x86_64.tar.gz"
curl -L -fsS -o "$archive" "https://github.com/mcpp-community/mcpp/releases/download/v${MCPP_VERSION}/$archive"
tar -xzf "$archive"
echo "$PWD/mcpp-${MCPP_VERSION}-linux-x86_64/bin" >> "$GITHUB_PATH"
- name: Candidate index
run: |
git init -q "$RUNNER_TEMP/index"
git -C "$RUNNER_TEMP/index" fetch -q --depth 1 https://github.com/mcpplibs/mcpp-index "$MCPP_INDEX_CANDIDATE"
git -C "$RUNNER_TEMP/index" checkout -q FETCH_HEAD
- name: Actual scaffold, strict build and headless run of the default template (hello)
env:
SLINT_HEADLESS: "1"
run: python3 tools/test_template.py --toolchain gcc@16.1.0 --index "$RUNNER_TEMP/index"
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
target
compile_commands.json
mcpp.lock
.mcpp/
.xlings/
doctor.log
__pycache__/
5 changes: 5 additions & 0 deletions .xlings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"workspace": {
"xim:mcpp": "2026.11.18.1"
}
}
16 changes: 16 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
slint-m: C++ module wrapper
Copyright (c) 2026 mcpp-community contributors

The wrapper contributions are licensed under the Apache License, Version 2.0.
Upstream code, copied interfaces and dependencies retain their original
licenses and copyright notices. Slint is available under the GNU GPLv3, the
Slint Royalty-free License 2.0 or the Slint Commercial License, at the user's
choice:

Copyright © SixtyFPS GmbH <info@slint.dev>

Its README, LICENSE.md and the three license texts are retained in
upstream/slint/. The library and slint-compiler are compat.slint's (xim:slint,
built from the release tag); their own notices, including the third-party
crates linked, are the SDK's licenses/ directory, which compat.slint deploys.
Provenance and checksums are recorded in upstream/documents.json.
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Slint

> Slint, the declarative GUI toolkit, through C++23 modules: its runtime API, the interpreter and `.slint` files compiled into modules.

**English** · [简体中文](README.zh.md) · [Upstream](https://github.com/slint-ui/slint) · [Releases](https://github.com/mcpplibs/slint-m/releases) · [mcpp](https://github.com/mcpp-community/mcpp) · [Index](https://github.com/mcpplibs/mcpp-index)

[![C++23](https://img.shields.io/badge/C%2B%2B-23-blue.svg)](https://en.cppreference.com/w/cpp/23)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
[![mcpp-community](https://img.shields.io/badge/mcpp--community-mwrap-blue)](https://github.com/mcpp-community)
[![CI](https://github.com/mcpplibs/slint-m/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/mcpplibs/slint-m/actions/workflows/ci.yml)

The upstream API is unchanged: `slint::ComponentHandle`, `slint::SharedString`,
`slint::VectorModel`, `slint::interpreter::ComponentCompiler` are the names of
`<slint.h>`. The SDK is `compat.slint` 1.19.0 (xim:slint: `libslint_cpp`, its
headers and `slint-compiler`, built from the release tag with upstream CMake's
default features). A `.slint` file is compiled by `mcpp.plugins.slint` (package
`mcpplibs.slintgen`, in `rules/` of this repository), which the project's `build.mcpp`
imports; with `module` set, each file becomes a module the program imports.

## Modules

- `import mcpplibs.mwrap.slint;`: `slint::` -- windows and components, `SharedString`, `SharedVector`, models, `Color`, `Brush`, `Image`, timers, the event loop, `slint::language`
- `import mcpplibs.mwrap.slint.interpreter;`: `slint::interpreter` -- `.slint` sources loaded at run time
- `import mcpplibs.mwrap.slint.platform;`: `slint::platform` -- a custom platform, the software renderer (Clang; with GCC include `<slint-platform.h>`)
- `import mcpplibs.mwrap.slint.macros;`: `SLINT_FEATURE_*` as `constexpr bool` in `mcpplibs::mwrap::slint::macros`
- `import app.ui;`: a component of yours, from `ui/app.slint` (`mcpp.plugins.slint`, `options::module`)

> More Modules API -> [Usage and API](docs/usage.md)

## Getting started

```sh
mcpp new counter --template mcpplibs.mwrap.slint@1.19.0
cd counter
mcpp run
```

The default template opens a window with a counter; without a display (or with
`SLINT_HEADLESS=1`) it runs on Slint's software renderer and prints the counter.

```toml
[dependencies]
mcpplibs.mwrap.slint = "1.19.0"

[build-dependencies]
mcpplibs.slintgen = { version = "1.19.0", features = ["slint"] } # claims `.slint`

[build]
sources = ["src/*.cpp", "ui/app.slint"]
```

```cpp
// build.mcpp
import mcpp;
import mcpp.plugins.slint;
int main() {
mcpp::plugins::slint::options o;
o.module = "app.ui";
return mcpp::plugins::slint::compile(o) ? 0 : 1;
}
```

```cpp
// src/main.cpp
import mcpplibs.mwrap.slint;
import app.ui;

int main() {
auto ui = AppWindow::create();
ui->on_increase([&] { ui->set_counter(ui->get_counter() + 1); });
ui->run();
}
```

## Features of the SDK

`compat.slint` 1.19.0 is upstream CMake's default desktop set: `interpreter`,
`backend-winit` (X11, Wayland, Windows, macOS), `renderer-femtovg` (OpenGL),
`renderer-software`, `accessibility`, `system-tray`, `testing`, and the compiler.
Skia, LinuxKMS, Qt and gettext are not in it. On Linux the library needs
fontconfig (xim:fontconfig) and the C runtime only; X11, Wayland and GL are loaded
when used. `mcpplibs::mwrap::slint::macros::SLINT_FEATURE_RENDERER_SKIA` and the
others say which features are present.

## Build and testing

Linux, macOS and Windows CI build the modules with GCC and Clang and run the tests:
the runtime types through the module, and a component compiled at run time by
`slint::interpreter` and driven headless through its properties and callbacks. The
export audit ([tools/check_exports.py](tools/check_exports.py)) reads clang's AST of
the SDK's headers: every public name exported, the key codes and features mapped,
the SDK's features upstream CMake's defaults. A separate job scaffolds the default
template as an installed package, builds it with `mcpp.plugins.slint` and runs it
headless.

## License

[Apache-2.0](LICENSE) for the wrapper, by mcpp-community ([NOTICE](NOTICE)). Slint is
available under the GNU GPLv3, the Slint Royalty-free License 2.0 (desktop, mobile
and web; not embedded) or the Slint Commercial License, at your choice
([upstream/slint/LICENSE.md](upstream/slint/LICENSE.md), [LICENSES](upstream/slint/LICENSES)).
The SDK's own notices, including the Rust crates it links, are deployed with programs.
Loading
Loading