mirror of
https://github.com/logos-co/logos-plugin-qt.git
synced 2026-08-27 08:51:07 +00:00
buildHeaders.nix swallowed the generator's exit status:
logos-cpp-generator ... || {
echo "Warning: ... may be expected if the module has no public API"
touch ./generated_headers/.no-api
}
so every real failure — a plugin the generator cannot dlopen (SDK/ABI
skew), an --api-style the pinned SDK rejects, a missing plugin file —
produced an EMPTY header set and exit 0. `nix build .#headers-<style>`
looked green with an include/ holding nothing but a `.generated`
placeholder, and the first symptom was an unresolved symbol when a
downstream module linked, far from the cause.
The escape hatch was aimed at a case that does not exist in this mode:
the generator introspects the plugin's QMetaObject, so a module with no
Q_INVOKABLE method still yields a wrapper class (with zero methods) and
exits 0. Measured against logos-cpp-sdk's generator:
Q_INVOKABLE present -> exit 0, <name>_api.{h,cpp}
no Q_INVOKABLE at all -> exit 0, <name>_api.{h,cpp} (no methods)
plugin fails to dlopen -> exit 3, nothing written
retired/unknown api-style-> exit 1, nothing written
plugin file missing -> exit 2, nothing written
So "no public API" is signalled by SUCCESS, not by a status, and every
non-zero status is a build error. buildPlugin.nix already treats the
generator's status as fatal; buildHeaders.nix was the outlier.
The generator call moves to lib/generate-module-headers.sh, which:
* fails the build on any non-zero status, echoing the status, the
plugin, the api style and the likely causes (pin mismatch first);
* fails a zero status that produced no <module>_api.{h,cpp} pair, so
an empty include/ can never be installed;
* reports a missing generator instead of a bare "command not found".
The install phase's "no headers -> empty include/" branch becomes an
error for the same reason.
tests/test-header-generator-guard.nix drives that script directly (so
the guard under test is the guard the build runs) across: no-public-API
success, generator failure, rejected api style, exit-0-with-no-output,
half-written output, missing generator, and argument forwarding
(--module-only / --api-style / --events-from).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
93 lines
3.1 KiB
Nix
93 lines
3.1 KiB
Nix
{
|
|
description = "Logos Qt Plugin Backend — builds Logos modules as Qt 6 plugins";
|
|
|
|
inputs = {
|
|
logos-nix.url = "github:logos-co/logos-nix";
|
|
# Only needed for standalone dev/testing and the convenience lib wrapper.
|
|
# When used via logos-module-builder, logosModule is injected by the builder.
|
|
logos-module.url = "github:logos-co/logos-module";
|
|
nixpkgs.follows = "logos-nix/nixpkgs";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, logos-module, ... }:
|
|
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; };
|
|
});
|
|
|
|
# Raw backend lib — no deps baked in.
|
|
# Callers (logos-module-builder) inject logosModule per call.
|
|
rawLib = import ./lib {
|
|
inherit nixpkgs;
|
|
inherit (nixpkgs) lib;
|
|
backendRoot = ./.;
|
|
};
|
|
|
|
# Convenience wrapper that pre-fills logosModule from this flake's inputs.
|
|
# Used for standalone dev/testing.
|
|
wrappedLib = rawLib // {
|
|
buildPlugin = args: rawLib.buildPlugin (args // {
|
|
logosModule = logos-module.packages.${args.pkgs.system}.default;
|
|
});
|
|
buildHeaders = args: rawLib.buildHeaders args;
|
|
devShellInputs = pkgs: rawLib.devShellInputs pkgs {
|
|
logosModule = logos-module.packages.${pkgs.system}.default;
|
|
};
|
|
};
|
|
|
|
in {
|
|
# Default export: wrapped with logosModule pre-filled
|
|
lib = wrappedLib;
|
|
|
|
# Raw export: no deps — for use by logos-module-builder
|
|
rawLib = rawLib;
|
|
|
|
# Provide the cmake module as a package
|
|
packages = forAllSystems ({ pkgs, ... }: {
|
|
cmake-module = pkgs.runCommand "logos-qt-plugin-cmake" {} ''
|
|
mkdir -p $out/share/cmake/LogosModule
|
|
cp ${./cmake/LogosModule.cmake} $out/share/cmake/LogosModule/LogosModule.cmake
|
|
'';
|
|
default = self.packages.${pkgs.system}.cmake-module;
|
|
});
|
|
|
|
# Tests
|
|
checks = forAllSystems ({ pkgs, ... }: {
|
|
# Build a vanilla Qt plugin with no Logos SDK deps
|
|
vanilla-plugin = import ./tests/test-vanilla-plugin.nix {
|
|
inherit pkgs;
|
|
backendCommon = rawLib.common;
|
|
};
|
|
# Build a replica factory plugin from a .rep file
|
|
rep-file-plugin = import ./tests/test-rep-file-plugin.nix {
|
|
inherit pkgs;
|
|
backendCommon = rawLib.common;
|
|
};
|
|
# A failing logos-cpp-generator must fail the headers build; a module
|
|
# with no public API must not.
|
|
header-generator-guard = import ./tests/test-header-generator-guard.nix {
|
|
inherit pkgs;
|
|
};
|
|
});
|
|
|
|
# Dev shell for working on the backend itself
|
|
devShells = forAllSystems ({ pkgs, ... }:
|
|
let
|
|
shell = wrappedLib.devShellInputs pkgs;
|
|
in {
|
|
default = pkgs.mkShell {
|
|
nativeBuildInputs = shell.nativeBuildInputs;
|
|
buildInputs = shell.buildInputs;
|
|
shellHook = ''
|
|
${shell.shellHook}
|
|
echo "Logos Qt Plugin Backend development environment"
|
|
'';
|
|
};
|
|
}
|
|
);
|
|
};
|
|
}
|