feat(packaging): ship crafter-build as a Flatpak with its own toolchain
packaging/flatpak/ holds the manifest for net.catcrafts.CrafterBuild and its side files. The runtime is the Freedesktop Sdk, not the Platform: a build tool needs glibc's headers and crt objects, gcc's libgcc_s, cmake, ninja, git and python at run time. Everything compiler-shaped is ours under /app, built from one LLVM 22.1.8 source tree: clang, lld, libclang, libc++ with its std module, compiler-rt for the host and for wasm32, the WASI sysroot (wasi-sdk 34 in sysroot-only mode, driven by the clang just built) and wasmtime for running the result. One tree means the modules crafter-build builds and the compiler that consumes them cannot drift apart, and the toolchain resolver finds all of it beside the executable with no configuration. The crafter-build module runs the bootstrap, the self-host build and the test suite inside the sandbox, so a Flatpak that installs has passed the suite with the toolchain it ships. CRAFTER_BUILD_MARCH is x86-64-v2 for the shipped binary; user projects keep -march=native. WasmHelloRuns compiles a fixture for wasm32-wasip1 and runs it under wasmtime. The existing wasm tests only inspect generated files, so this is the one that proves the sysroot, the std module for wasm and wasm-ld work together; it skips where the sysroot or wasmtime is missing. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
c3485b7ab1
commit
add30b9a4f
9 changed files with 330 additions and 1 deletions
57
tests/WasmHelloRuns/main.cpp
Normal file
57
tests/WasmHelloRuns/main.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
import std;
|
||||
import Crafter.Build;
|
||||
namespace fs = std::filesystem;
|
||||
using namespace Crafter;
|
||||
|
||||
// A wasm build end to end: the fixture is compiled for wasm32-wasip1 against
|
||||
// the resolved toolchain's WASI sysroot and the result is run under
|
||||
// wasmtime. The other wasm tests only inspect generated files; this is the
|
||||
// one that proves the sysroot, the std module for wasm and wasm-ld all work
|
||||
// together. It skips when the sysroot or wasmtime is missing, so a
|
||||
// development box without them is not a failure. Inside the Flatpak both are
|
||||
// bundled, and there the skip would be the failure to look for.
|
||||
int main() {
|
||||
const Toolchain& tc = GetToolchain();
|
||||
if (!fs::exists(tc.wasiSysroot / "include")) {
|
||||
std::println(std::cerr, "SKIP: no WASI sysroot at {}", tc.wasiSysroot.string());
|
||||
return 77;
|
||||
}
|
||||
if (std::system("which wasmtime > /dev/null 2>&1") != 0) {
|
||||
std::println(std::cerr, "SKIP: wasmtime not on PATH");
|
||||
return 77;
|
||||
}
|
||||
|
||||
Configuration cfg;
|
||||
cfg.path = fs::current_path() / "tests" / "WasmHelloRuns" / "fixture";
|
||||
cfg.name = "wasm-hello";
|
||||
cfg.outputName = "wasm-hello";
|
||||
cfg.target = "wasm32-wasip1";
|
||||
cfg.type = ConfigurationType::Executable;
|
||||
std::array<fs::path, 0> ifaces = {};
|
||||
std::array<fs::path, 1> impls = { "main" };
|
||||
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
||||
|
||||
std::unordered_map<fs::path, std::shared_future<BuildResult>> depResults;
|
||||
std::mutex depMutex;
|
||||
BuildResult r = Build(cfg, depResults, depMutex);
|
||||
if (!r.result.empty()) {
|
||||
std::println(std::cerr, "build failed: {}", r.result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const fs::path wasm = ExpectedOutput(cfg);
|
||||
if (!fs::exists(wasm)) {
|
||||
std::println(std::cerr, "no .wasm produced at {}", wasm.string());
|
||||
return 1;
|
||||
}
|
||||
|
||||
const auto run = RunCommandWithTimeout(std::format("wasmtime {}", wasm.string()), std::chrono::seconds(60));
|
||||
if (run.exitCode != 0 || !run.output.contains("hello from wasm")) {
|
||||
std::println(std::cerr, "wasmtime run failed (exit {}): {}", run.exitCode, run.output);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in a new issue