From b7c224cf67c2b7af7606b967a1bbd4634a841e7d Mon Sep 17 00:00:00 2001 From: "Aleksei (Faumaray) Selikhov" Date: Sat, 5 Dec 2026 14:31:31 +0300 Subject: [PATCH] feat(install): generate NuGet packages --- docs/agent-workflow/STATE.md | 2 + docs/agent-workflow/TASKS.md | 1 + docs/agent-workflow/VERIFICATION.md | 10 ++ docs/roadmap/22-superiority-and-gaps.md | 4 +- src/Install/Installer.cpp | 131 ++++++++++++++++++++++++ src/Main.cpp | 6 +- tests/FullV1Tests.cpp | 23 +++++ 7 files changed, 172 insertions(+), 5 deletions(-) diff --git a/docs/agent-workflow/STATE.md b/docs/agent-workflow/STATE.md index 53e0d0e..4ec83ba 100644 --- a/docs/agent-workflow/STATE.md +++ b/docs/agent-workflow/STATE.md @@ -379,6 +379,8 @@ Stage: VERIFIED — Plans 01–19 + Plan 20 Slices 1–2C + Track A + Track B (B - **Wave 143 (First Release v0.1.0)**: the Release build (Ninja, GCC 16.2) passed the full suite (8/8, 271.91 s) and the release packaging produced `dist/vbs-v0.1.0-linux-x86_64.tar.gz` (binaries + SDK + headers), `dist/vbs-v0.1.0-source.tar` (`vbs pack`) and `SHA256SUMS`. Tag `v0.1.0` and the [first Gitea release](https://git.faumaray.com/Void/Build-System/releases/tag/v0.1.0) were created; the workflows now target the available Gitea runners (`linux` host). Binary assets cannot be uploaded through the available tooling - the release workflow attaches them when it runs. +- **Wave 144 (NuGet Package Generator)**: `vbs install --archive FILE --archive-format nuget` writes a `.nupkg` - an OPC ZIP with the `.nuspec` manifest, `[Content_Types].xml`, `_rels/.rels` and the installed files mapped to `runtimes//native/**` (headers under `build/native/include`). The RID comes from the profile (e.g. `linux-x64`). Python `zipfile` + ElementTree validate the generated package (id/version/authors parse, CRCs clean); the install test asserts the manifest, layout and native asset paths. + ## Remaining future scope - **Superiority plan ([22-superiority-and-gaps.md](../roadmap/22-superiority-and-gaps.md), 2026-12-05)**: revised platform strategy - **macOS deferred**, **Windows via MinGW-w64 cross-compilation + Wine execution** (`dev cpp-gcc -p pkgsCross.mingwW64.stdenv.cc`, `dev cpp-gcc -p wine64`), native MSVC deferred; plus packaging parity (ZIP/DEB/RPM), IDE ecosystem, migration tooling, test-runner parity, benchmarks, CI runners, and remote execution in prioritized order. diff --git a/docs/agent-workflow/TASKS.md b/docs/agent-workflow/TASKS.md index 0880cb3..fe45b9a 100644 --- a/docs/agent-workflow/TASKS.md +++ b/docs/agent-workflow/TASKS.md @@ -143,4 +143,5 @@ Base HEAD: `fe0d1a6` | Wave 140 (pkg-config discovery) | `.pkgconfig(spec)` dependency, `.pc` parser with variables/Requires/version compare, lock entries | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; E2E builds/runs and checks version errors, full CTest 8/8) | `include/Void/Build.hpp`, `sdk/Build.cpp`, `src/Provider/PkgConfig.cpp`, `src/Graph/Graph.cpp`, `src/Package/Resolver.cpp`, `src/Main.cpp`, `tests/FullV1Tests.cpp`, docs | | Wave 141 (ASM + shader languages) | `.s`/`.S` assembly; `shader_bundle`/`.shader()` lowered to SPIR-V (glslang/slangc/dxc) | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; both E2Es pass, GLSL/Slang/HLSL produce SPIR-V, full CTest 8/8) | `src/Graph/Graph.cpp`, `src/Toolchain/Driver.cpp`, `include/Void/Build.hpp`, `sdk/Build.cpp`, `tests/FullV1Tests.cpp`, docs | | Wave 142 (Gitea CI + release workflow) | Gitea-hosted CI with artifacts; tag-driven release workflow with asset upload | COMPLETE (YAML-validated; unexecuted without a runner) | `.gitea/workflows/ci.yml`, `.gitea/workflows/release.yml`, docs | +| Wave 144 (NuGet generator) | `--archive-format nuget`: `.nupkg` with nuspec, OPC parts and `runtimes//native` assets | COMPLETE & VERIFIED (GCC 16.2, pin `0002e74`; Python validates the package, install test passes, full CTest 8/8) | `src/Install/Installer.cpp`, `src/Main.cpp`, `tests/FullV1Tests.cpp`, docs | | Future (Plan 20 Slice 3 / Tracks C, E3 editor extensions) |"}] Live `conan` CLI verification; macOS/Windows/cross-compile; binary-variant signing and key distribution; daemon-side dependency materialization and editor plugins; `Void::Net`/`Void::Sqlite` alignment | PLANNED (unimplemented) | [21-expansion-roadmap.md](../roadmap/21-expansion-roadmap.md), [20-future-translation-platforms.md](../roadmap/20-future-translation-platforms.md) | diff --git a/docs/agent-workflow/VERIFICATION.md b/docs/agent-workflow/VERIFICATION.md index 6724c90..203370f 100644 --- a/docs/agent-workflow/VERIFICATION.md +++ b/docs/agent-workflow/VERIFICATION.md @@ -1850,6 +1850,16 @@ VOID_INCLUDE_DIR=/tmp/opencode/vl-pin/include dev cpp -c bash fuzz/run.sh 30 manually to valid SPIR-V in this environment. - Full CTest: **8 / 8 passed** in 314.56 s. +## NuGet Package Generation (GCC 16.2, pin `0002e74`) + +- `vbs install --archive cli_hi.nupkg --archive-format nuget` produced a 7-entry ZIP whose + nuspec, `[Content_Types].xml` and `_rels/.rels` all parse with ElementTree, every CRC is + clean (`zipfile.testzip()` is None), and native assets live under + `runtimes/linux-x64/native/`. +- `FullV1Tests.foreign_cmake_meson_providers_bridge_and_relocatable_install` asserts the ZIP + magic, the nuspec id/version, the OPC parts and the runtime asset paths (**passed**, 6.36 s). +- Full CTest: **8 / 8 passed** in 337.44 s. + ## Limits and Unrun Checks 1. **HTTPS git fetch**: the host shell is proxy-restricted, but the Docker container could clone `https://git.faumaray.com/Void/VoidLibrary.git`; the pinned commit `3e254055e081a104f08df68dde39711bc7813518` was fetched directly for the verification above. A separate configure against the local `/home/faumaray/Projects/Library` checkout via `VBS_VOID_SOURCE_DIR` also succeeded (development-only override, checkout unmodified). diff --git a/docs/roadmap/22-superiority-and-gaps.md b/docs/roadmap/22-superiority-and-gaps.md index 4a96cfe..312f4ee 100644 --- a/docs/roadmap/22-superiority-and-gaps.md +++ b/docs/roadmap/22-superiority-and-gaps.md @@ -122,8 +122,8 @@ first, then what makes VBS *better* rather than merely equal. 3. **Platform breadth - deferred.** Native MSVC and Apple Clang/macOS stay deferred by decision; MinGW cross + Wine is the current Windows story. 4. **Package-generator parity.** CPack also ships NuGet, PKG/productbuild, APK and IFW - installers; VBS has tar, `sh`, ZIP, DEB, RPM, WiX and UDIF. NuGet and PKG are the next - useful ones. + installers; VBS has tar, `sh`, ZIP, DEB, RPM, WiX, UDIF and NuGet (Wave 144). PKG is + the next useful one. ### 8.2 Developer experience and IDE integration diff --git a/src/Install/Installer.cpp b/src/Install/Installer.cpp index 486ced0..4b5384b 100644 --- a/src/Install/Installer.cpp +++ b/src/Install/Installer.cpp @@ -635,6 +635,131 @@ write_dmg_archive(const std::filesystem::path &output, const std::filesystem::pa return {}; } +// ── NuGet package (.nupkg) ───────────────────────────────────────────────────────────────── +// A .nupkg is an OPC ZIP (a nuspec manifest plus content parts). Native assets follow the +// `runtimes//native` convention; public headers go to `build/native/include`. +std::string nuget_rid(std::string_view os, std::string_view architecture) { + const std::string arch = architecture == "aarch64" || architecture == "arm64" ? "arm64" + : architecture == "x86" || architecture == "i686" ? "x86" + : "x64"; + const auto lower_os = Void::Str::to_lower_ascii(os); + if (lower_os == "windows" || lower_os == "win32") { + return "win-" + arch; + } + if (lower_os == "darwin" || lower_os == "macos") { + return "osx-" + arch; + } + return "linux-" + arch; +} + +Void::Result::Result +write_nuget_package(const std::filesystem::path &output, const InstallOptions &options, + const Graph::BuildGraph &graph, + const std::vector &entries) { + const std::string id = options.package_name; + const std::string version = + options.package_version.empty() ? std::string{"1.0.0"} : options.package_version; + const std::string rid = nuget_rid(graph.profile.os, graph.profile.architecture); + const std::string authors = + options.maintainer.empty() ? std::string{"Void"} : options.maintainer; + const std::string description = options.package_description.empty() + ? options.package_name + : options.package_description; + + // Map the installed tree onto the NuGet layout. + std::vector> mapped; + std::set extensions; + for (const auto &entry : entries) { + const auto rel = entry.archive_path; + std::string dest; + if (rel.starts_with("include/")) { + dest = "build/native/include/" + rel.substr(std::string{"include/"}.size()); + } else { + dest = "runtimes/" + rid + "/native/" + rel; + } + mapped.emplace_back(dest, entry.source_file); + const auto dot = dest.rfind('.'); + if (dot != std::string::npos && dot > dest.rfind('/')) { + extensions.insert(dest.substr(dot + 1)); + } + } + + const std::string nuspec = + "\n" + "\n" + " \n" + " " + + wix_xml_escape(id) + "\n" + " " + wix_xml_escape(version) + "\n" + " " + wix_xml_escape(authors) + "\n" + " " + wix_xml_escape(description) + "\n" + " native;c++;vbs\n" + " \n" + "\n"; + + std::string content_types = + "\n" + "\n" + " \n" + " \n"; + for (const auto &ext : extensions) { + content_types += " \n"; + } + content_types += "\n"; + + const std::string rels = + "\n" + "\n" + " \n" + "\n"; + + const auto staging = output.parent_path() / (output.filename().string() + ".stage"); + std::error_code ec; + std::filesystem::remove_all(staging, ec); + std::filesystem::create_directories(staging, ec); + if (ec) { + return std::unexpected{Void::System::make_system_error( + Void::System::map_errno_to_system_code(ec.value()), + std::format("cannot create NuGet staging directory '{}'", staging.string()), + ec.value())}; + } + auto cleanup = Void::Scope::on_exit([&] { + std::error_code cleanup_ec; + std::filesystem::remove_all(staging, cleanup_ec); + }); + + std::vector zip_entries; + const auto stage_file = [&](std::string_view name, + std::string_view content) -> std::optional { + const auto path = staging / std::filesystem::path{name}; + std::error_code file_ec; + std::filesystem::create_directories(path.parent_path(), file_ec); + if (auto written = Platform::atomic_write_file(path, content, true); !written) { + return std::nullopt; + } + return path; + }; + const auto nuspec_path = stage_file(id + ".nuspec", nuspec); + const auto types_path = stage_file("[Content_Types].xml", content_types); + const auto rels_path = stage_file("_rels/.rels", rels); + if (!nuspec_path || !types_path || !rels_path) { + return std::unexpected{Void::System::make_system_error( + Void::System::SystemErrorCode::io_error, "cannot stage NuGet metadata")}; + } + zip_entries.push_back({"[Content_Types].xml", *types_path, 0644u}); + zip_entries.push_back({"_rels/.rels", *rels_path, 0644u}); + zip_entries.push_back({id + ".nuspec", *nuspec_path, 0644u}); + for (const auto &[name, source] : mapped) { + zip_entries.push_back({name, source, 0644u}); + } + return Package::create_stored_zip(output, zip_entries); +} + // Debian package: ar container with debian-binary, control.tar and data.tar (uncompressed). Void::Result::Result write_deb_package(const std::filesystem::path &output, const InstallOptions &options, @@ -1090,6 +1215,12 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build if (auto packed = write_dmg_archive(*options.archive_path, payload); !packed) { return std::unexpected{packed.error()}; } + } else if (options.archive_format == "nuget") { + if (auto packed = + write_nuget_package(*options.archive_path, options, graph, archive_entries); + !packed) { + return std::unexpected{packed.error()}; + } } else { const bool archive_as_script = options.archive_format == "sh"; const auto archive_target = archive_as_script diff --git a/src/Main.cpp b/src/Main.cpp index e1be85f..7af397c 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -2547,9 +2547,9 @@ int execute_install_command(const InstallCmdOptions &opts) { if (opts.archive_format_arg != "tar" && opts.archive_format_arg != "sh" && opts.archive_format_arg != "zip" && opts.archive_format_arg != "deb" && opts.archive_format_arg != "rpm" && opts.archive_format_arg != "wix" && - opts.archive_format_arg != "dmg") { + opts.archive_format_arg != "dmg" && opts.archive_format_arg != "nuget") { std::cerr << "vbs install: unsupported --archive-format '" << opts.archive_format_arg - << "' (expected tar, sh, zip, deb, rpm, wix or dmg)\n"; + << "' (expected tar, sh, zip, deb, rpm, wix, dmg or nuget)\n"; return 2; } if (opts.archive_arg && !opts.archive_arg->empty()) { @@ -3762,7 +3762,7 @@ int main(int argc, char **argv) { .option("--archive", "", "Write a deterministic installer archive of the prefix", install_opts.archive_arg) .option_default("--archive-format", "", - "Installer archive format: tar (default), sh, zip, deb, rpm, wix or dmg", + "Installer archive format: tar (default), sh, zip, deb, rpm, wix, dmg or nuget", install_opts.archive_format_arg, "tar") .option("--signing-key", "", "Ed25519 seed file; signs the archive and writes .sha256/.sig/.pub", diff --git a/tests/FullV1Tests.cpp b/tests/FullV1Tests.cpp index c5cac12..032599c 100644 --- a/tests/FullV1Tests.cpp +++ b/tests/FullV1Tests.cpp @@ -1137,6 +1137,29 @@ void build(Void::Build::Project &p) { Void::Testing::expect_eq(read_be64(koly, 492), (data_fork_length + 511) / 512); Void::Testing::expect(dmg_bytes->substr(257, 5) == "ustar"); // tar payload + // NuGet package (.nupkg): OPC ZIP with the nuspec and native runtime assets. + const auto nupkg_archive = tmp / "cli_hi.nupkg"; + auto nuget_req = inst_req; + for (auto &arg : nuget_req.arguments) { + if (arg == installer_archive.string()) { + arg = nupkg_archive.string(); + } + } + nuget_req.arguments.push_back("--archive-format"); + nuget_req.arguments.push_back("nuget"); + auto nuget_res = Platform::run_supervised(nuget_req); + Void::Testing::expect(nuget_res.has_value() && nuget_res->succeeded()); + auto nupkg_bytes = Void::FileSystem::read_file(nupkg_archive); + Void::Testing::require(nupkg_bytes.has_value()); + Void::Testing::expect(nupkg_bytes->starts_with(std::string("PK\x03\x04", 4))); + Void::Testing::expect(nupkg_bytes->find("CliHiPkg.nuspec") != std::string::npos); + Void::Testing::expect(nupkg_bytes->find("CliHiPkg") != std::string::npos); + Void::Testing::expect(nupkg_bytes->find("0.1.0") != std::string::npos); + Void::Testing::expect(nupkg_bytes->find("[Content_Types].xml") != std::string::npos); + Void::Testing::expect(nupkg_bytes->find("_rels/.rels") != std::string::npos); + Void::Testing::expect(nupkg_bytes->find("runtimes/") != std::string::npos); + Void::Testing::expect(nupkg_bytes->find("/native/bin/cli_hi") != std::string::npos); + // RPM package generator: lead + header magic + newc cpio payload. const auto rpm_archive = tmp / "cli_hi.rpm"; auto rpm_req = inst_req;