mirror of
https://github.com/logos-co/logos-liblogos.git
synced 2026-08-27 12:51:10 +00:00
Adds the x86_64-windows pseudo-system to `packages` (checks and devShells stay native). liblogos's own src/ needed NO portability work at all -- verified exhaustively, not assumed: 17 files, 2304 lines, zero POSIX headers and zero POSIX APIs. All process, plugin and socket work already lives in logos-container-subprocess and logos-module-loader-qt, which were ported first. Two real blockers, one of them silent: * install(TARGETS logos_core ...) named only LIBRARY and ARCHIVE destinations. A DLL is a RUNTIME artifact, so CMake SKIPPED IT WITHOUT COMMENT: the build succeeded and shipped a lib/ containing liblogos_core.dll.a and no DLL at all -- a link-only package that would have handed logosctl.exe an import library with nothing behind it. Proven by reverting the fix: rc=0, no DLL. lib.nix now refuses to produce an output with no loadable logos_core. * The test suite is genuinely POSIX-only (spawn.h, sys/wait.h, mkdtemp, kill), and CMake put it in the default `all` target, so it broke the cross build before anything else could. Tests are now gated behind LOGOS_BUILD_TESTS, with the gate wrapping the gtest FetchContent fallback too -- otherwise dropping gtest sends CMake to the network inside the sandbox and it dies on a misleading "downloading ... failed". Also: package_manager_lib needed IMPORTED_IMPLIB (mingw links against the import library, not the DLL), and Qt's host tools come in via logosQtCrossCmakeFlags. Verified: liblogos_core.dll is a PE32+ DLL whose export table carries the C ABI (logos_core_init / _start / _load_module / _get_loaded_modules). The output also ships logos_host_qt.exe with its 15 runtime DLLs and capability_module_plugin.dll. Native unchanged: 181 tests, 174 passed, 7 skipped -- the same 7 ProcessManagerTest cases skipped before this change.
213 lines
11 KiB
Nix
213 lines
11 KiB
Nix
{
|
|
description = "Logos liblogos core library";
|
|
|
|
inputs = {
|
|
logos-nix.url = "github:logos-co/logos-nix";
|
|
nixpkgs.follows = "logos-nix/nixpkgs";
|
|
logos-cpp-sdk.url = "github:logos-co/logos-cpp-sdk";
|
|
logos-cpp-sdk.inputs.logos-protocol.follows = "logos-protocol";
|
|
logos-protocol.url = "github:logos-co/logos-protocol";
|
|
logos-qt-sdk.url = "github:logos-co/logos-qt-sdk";
|
|
logos-qt-sdk.inputs.logos-protocol.follows = "logos-protocol";
|
|
logos-qt-sdk.inputs.logos-cpp-sdk.follows = "logos-cpp-sdk";
|
|
logos-capability-module.url = "github:logos-co/logos-capability-module";
|
|
logos-module.url = "github:logos-co/logos-module";
|
|
process-stats.url = "github:logos-co/process-stats";
|
|
logos-container.url = "github:logos-co/logos-container";
|
|
logos-module-loader.url = "github:logos-co/logos-module-loader";
|
|
# The built-in default container + format-loader implementations. Named for
|
|
# their ROLE rather than the backing repo, so `--override-input
|
|
# default-container <other>` reads clearly. They point at the subprocess /
|
|
# qt-plugin repos by default; swap the url (or override the input) to change
|
|
# the default implementation.
|
|
default-container.url = "github:logos-co/logos-container-subprocess";
|
|
default-module-loader.url = "github:logos-co/logos-module-loader-qt";
|
|
# The host transport (logos_host_qt) must be built against the SAME
|
|
# logos-protocol as liblogos_core; otherwise the QtRO capability-token
|
|
# handshake fails across the host<->plugin boundary. Pin it via follows so a
|
|
# protocol bump here rebuilds the bundled host instead of leaving it on a
|
|
# stale rev.
|
|
default-module-loader.inputs.logos-protocol.follows = "logos-protocol";
|
|
default-module-loader.inputs.logos-cpp-sdk.follows = "logos-cpp-sdk";
|
|
default-module-loader.inputs.logos-qt-sdk.follows = "logos-qt-sdk";
|
|
logos-package-manager.url = "github:logos-co/logos-package-manager";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, logos-nix, logos-cpp-sdk, logos-protocol, logos-qt-sdk, logos-capability-module, logos-module, logos-package-manager, process-stats, logos-container, default-container, logos-module-loader, default-module-loader }:
|
|
|
|
let
|
|
systems = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ];
|
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f {
|
|
inherit system;
|
|
pkgs = import nixpkgs { inherit system; };
|
|
logosSdk = logos-cpp-sdk.packages.${system}.default;
|
|
logosProtocolPkg = logos-protocol.packages.${system}.default;
|
|
logosQtSdk = logos-qt-sdk.packages.${system}.default;
|
|
capabilityModule = logos-capability-module.packages.${system}.default;
|
|
logosModule = logos-module.packages.${system}.default;
|
|
processStats = process-stats.packages.${system}.default;
|
|
logosContainer = logos-container.packages.${system}.default;
|
|
logosModuleLoader = logos-module-loader.packages.${system}.default;
|
|
defaultContainer = default-container.packages.${system}.default;
|
|
defaultModuleLoader = default-module-loader.packages.${system}.default;
|
|
logosPackageManager = logos-package-manager.packages.${system}.lib;
|
|
logosPackageManagerPortable = logos-package-manager.packages.${system}.lib-portable;
|
|
});
|
|
|
|
# Same as forAllSystems, plus the "x86_64-windows" pseudo-system. This
|
|
# cannot just be logos-nix.lib.forAllTargets, because that only supplies
|
|
# { system, pkgs } and this flake threads a dozen per-system dependencies
|
|
# through.
|
|
#
|
|
# Every dependency below is a TARGET-side artifact (headers, archives, or
|
|
# DLLs linked into logos_core, plus the host binary / plugin that are
|
|
# merely re-exported). liblogos runs NO code generator at build time
|
|
# (verified: no logos-cpp-generator / qt-generator anywhere in this repo),
|
|
# so nothing here needs to come from the build platform's package set.
|
|
#
|
|
# Applied to `packages` ONLY: `checks` would have to execute PE test
|
|
# binaries on the Linux builder, and a cross devShell offers no way to run
|
|
# what it produces.
|
|
windowsBuildSystem = "x86_64-linux";
|
|
forAllTargets = f:
|
|
nixpkgs.lib.genAttrs (systems ++ [ "x86_64-windows" ]) (system: f {
|
|
inherit system;
|
|
pkgs =
|
|
if system == "x86_64-windows"
|
|
then logos-nix.lib.mkWindowsPkgs { buildSystem = windowsBuildSystem; }
|
|
else import nixpkgs { inherit system; };
|
|
logosSdk = logos-cpp-sdk.packages.${system}.default;
|
|
logosProtocolPkg = logos-protocol.packages.${system}.default;
|
|
logosQtSdk = logos-qt-sdk.packages.${system}.default;
|
|
capabilityModule = logos-capability-module.packages.${system}.default;
|
|
logosModule = logos-module.packages.${system}.default;
|
|
processStats = process-stats.packages.${system}.default;
|
|
logosContainer = logos-container.packages.${system}.default;
|
|
logosModuleLoader = logos-module-loader.packages.${system}.default;
|
|
defaultContainer = default-container.packages.${system}.default;
|
|
defaultModuleLoader = default-module-loader.packages.${system}.default;
|
|
logosPackageManager = logos-package-manager.packages.${system}.lib;
|
|
logosPackageManagerPortable = logos-package-manager.packages.${system}.lib-portable;
|
|
});
|
|
in
|
|
{
|
|
packages = forAllTargets ({ pkgs, system, logosSdk, logosProtocolPkg, logosQtSdk, capabilityModule, logosModule, processStats, logosContainer, logosModuleLoader, defaultContainer, defaultModuleLoader, logosPackageManager, logosPackageManagerPortable }:
|
|
let
|
|
# The built-in default container + format-loader implementations — the
|
|
# single place the default is chosen. Each is just the package; it
|
|
# ships a generic CMake config (LogosContainerImpl / LogosFormatLoaderImpl)
|
|
# that carries its library and deps, which liblogos find_package's. Swap
|
|
# an entry to change the default — no C++, CMake, or nix-flag change.
|
|
containerImpl = defaultContainer;
|
|
formatLoaderImpl = defaultModuleLoader;
|
|
|
|
# Common configuration (dev, default)
|
|
common = import ./nix/default.nix {
|
|
inherit pkgs logosSdk logosProtocolPkg logosQtSdk logosModule processStats logosContainer logosModuleLoader logosPackageManager containerImpl formatLoaderImpl;
|
|
};
|
|
# Common configuration (portable)
|
|
commonPortable = import ./nix/default.nix {
|
|
inherit pkgs logosSdk logosProtocolPkg logosQtSdk logosModule processStats logosContainer logosModuleLoader containerImpl formatLoaderImpl;
|
|
logosPackageManager = logosPackageManagerPortable;
|
|
portableBuild = true;
|
|
};
|
|
src = ./.;
|
|
|
|
# Shared build that compiles everything (dev)
|
|
build = import ./nix/build.nix { inherit pkgs common src; };
|
|
|
|
# Shared build (portable)
|
|
buildPortable = import ./nix/build.nix { inherit pkgs src; common = commonPortable; };
|
|
|
|
# Individual package components (reference the shared build)
|
|
lib = import ./nix/lib.nix { inherit pkgs common build; };
|
|
modules = import ./nix/modules.nix { inherit pkgs common capabilityModule; };
|
|
modulesPortable = import ./nix/modules.nix { inherit pkgs capabilityModule; common = commonPortable; portableBuild = true; };
|
|
bin = import ./nix/bin.nix { inherit pkgs common build lib modules formatLoaderImpl; };
|
|
include = import ./nix/include.nix { inherit pkgs common src logosSdk; inherit logosProtocolPkg logosQtSdk; };
|
|
tests = import ./nix/tests.nix { inherit pkgs common build; };
|
|
|
|
# Portable package components
|
|
libPortable = import ./nix/lib.nix { inherit pkgs; common = commonPortable; build = buildPortable; };
|
|
binPortable = import ./nix/bin.nix { inherit pkgs formatLoaderImpl; common = commonPortable; build = buildPortable; lib = libPortable; modules = modulesPortable; };
|
|
includePortable = import ./nix/include.nix { inherit pkgs src logosSdk; inherit logosProtocolPkg logosQtSdk; common = commonPortable; };
|
|
|
|
# Combined package (dev)
|
|
liblogos = pkgs.symlinkJoin {
|
|
name = "logos-liblogos";
|
|
paths = [ bin lib include ];
|
|
};
|
|
|
|
# Combined package (portable)
|
|
liblogosPortable = pkgs.symlinkJoin {
|
|
name = "logos-liblogos-portable";
|
|
paths = [ binPortable libPortable includePortable ];
|
|
};
|
|
in
|
|
{
|
|
# Individual outputs
|
|
logos-liblogos-bin = bin;
|
|
logos-liblogos-lib = lib;
|
|
logos-liblogos-include = include;
|
|
logos-liblogos-modules = modules;
|
|
|
|
# Combined output
|
|
logos-liblogos = liblogos;
|
|
|
|
# Portable output (compiled with LOGOS_PORTABLE_BUILD)
|
|
portable = liblogosPortable;
|
|
|
|
# Default package (dev)
|
|
default = liblogos;
|
|
}
|
|
# The test suite is POSIX-only (posix_spawn/waitpid/kill, /bin/sh) and
|
|
# CMake gates it off for a Windows host, so `ninja logos_core_tests`
|
|
# would have no such target. Not exposing the output at all beats
|
|
# shipping one that cannot be built.
|
|
// pkgs.lib.optionalAttrs (!pkgs.stdenv.hostPlatform.isWindows) {
|
|
logos-liblogos-tests = tests;
|
|
}
|
|
);
|
|
|
|
checks = forAllSystems ({ pkgs, system, ... }:
|
|
let
|
|
testsPkg = self.packages.${system}.logos-liblogos-tests;
|
|
# Real Qt plugin used by RealPluginRegistryTest (TEST_PLUGIN env var).
|
|
# capability_module is already a flake input and builds a real plugin.
|
|
capabilityModulePkg = logos-capability-module.packages.${system}.default;
|
|
pluginExt = if pkgs.stdenv.isDarwin then "dylib" else "so";
|
|
in {
|
|
tests = pkgs.runCommand "logos-liblogos-tests" {
|
|
nativeBuildInputs = [ testsPkg ] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ pkgs.qt6.qtbase ];
|
|
} ''
|
|
export QT_QPA_PLATFORM=offscreen
|
|
${pkgs.lib.optionalString pkgs.stdenv.isLinux ''
|
|
export QT_PLUGIN_PATH="${pkgs.qt6.qtbase}/${pkgs.qt6.qtbase.qtPluginPrefix}"
|
|
''}
|
|
export TEST_PLUGIN="${capabilityModulePkg}/lib/capability_module_plugin.${pluginExt}"
|
|
mkdir -p $out
|
|
echo "Running logos-liblogos tests..."
|
|
echo "TEST_PLUGIN=$TEST_PLUGIN"
|
|
${testsPkg}/bin/logos_core_tests --gtest_output=xml:$out/test-results.xml
|
|
'';
|
|
}
|
|
);
|
|
|
|
devShells = forAllSystems ({ pkgs, ... }: {
|
|
default = pkgs.mkShell {
|
|
nativeBuildInputs = [
|
|
pkgs.cmake
|
|
pkgs.ninja
|
|
pkgs.pkg-config
|
|
];
|
|
buildInputs = [
|
|
pkgs.qt6.qtbase
|
|
pkgs.qt6.qtremoteobjects
|
|
pkgs.zstd
|
|
pkgs.spdlog
|
|
];
|
|
};
|
|
});
|
|
};
|
|
}
|