mirror of
https://github.com/logos-co/logos-plugin-qt.git
synced 2026-08-27 08:51:07 +00:00
This repo was the Qt plugin BUILD backend — pure Nix functions plus a CMake
module, with no C++ target at all. But the two things a Qt host actually needs
at runtime lived in logos-qt-sdk, where they are neither a language wrapper over
the protocol C API nor codegen:
LogosAPI / LogosAPIProvider owns a LogosTransportHost per transport,
constructs ModuleProxy / ModuleHandshakeProxy,
publishes the handshake surface, seeds trust
anchors, injects the token validator
LogosProviderBase the base every generated provider derives
PluginInterface the Qt plugin loading contract
the cdylib->Qt glue generator the emitter that wraps a language-neutral
cdylib in a Qt plugin
They move here, so "swap the plugin technology" is a one-repo change.
ADDITIVE: the sources are COPIED and logos-qt-sdk is untouched. Removing them
there now would turn nine downstream masters red at once; that comes later,
after consumers are repointed.
qt_provider_object (and logos_qt_arg_decode, which its QMetaObject dispatch
needs) is carried deliberately even though it is legacy: logos_api_provider
falls back to wrapping a plain QObject in it, and the modules that rely on that
have not been migrated yet. It goes once they are.
The generator links Qt Core and logos-lidl only — never logos-cpp-sdk. It needed
exactly one helper from that SDK's shared frontend, lidlToPascalCase (~12
lines), which is inlined instead, the same way logos-view-module does it. It
also REFUSES `--backend <anything but cdylib>` rather than ignoring the flag:
callers are migrating from a tool where --backend was required and dispatched
on, so silently treating `--backend qt` as cdylib would emit confidently wrong
artifacts with a zero exit.
`rawLib`, `lib` and `cmake-module` deliberately do not reference the new
derivations, so a consumer that only wants the Nix build functions never
realises a Qt/protocol build. Proven, not assumed: with both new inputs
overridden to a bogus flake, cmake-module and rawLib still evaluate while
logos-qt-host fails — so the override bites and the cheap outputs really never
touch it.
Behaviour preservation is the whole claim of a relocation, so it is measured:
the emitted glue is BYTE-IDENTICAL to logos-qt-generator --backend cdylib over
every one of the 20 .lidl contracts in the workspace, in both single and
concurrency:multi mode (40 pairs, exit codes included), and single vs multi do
differ from each other, so both code paths were really exercised. The built
liblogos_qt_host.a is byte-identical to liblogos_qt_sdk.a, exporting the same
390 symbols.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
135 lines
5.0 KiB
Nix
135 lines
5.0 KiB
Nix
{
|
|
description = "Logos Qt Plugin Backend — builds Logos modules as Qt 6 plugins, and the Qt host runtime they link";
|
|
|
|
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";
|
|
# The transport / consumer / token layer logos-qt-host is the Qt face of.
|
|
logos-protocol = {
|
|
url = "github:logos-co/logos-protocol";
|
|
inputs.logos-nix.follows = "logos-nix";
|
|
};
|
|
# The canonical LIDL frontend logos-qt-host-generator parses contracts with.
|
|
logos-lidl = {
|
|
url = "github:logos-co/logos-lidl";
|
|
inputs.logos-nix.follows = "logos-nix";
|
|
};
|
|
};
|
|
|
|
outputs = { self, nixpkgs, logos-module, logos-protocol, logos-lidl, ... }:
|
|
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;
|
|
|
|
# The C++ half of this backend: the Qt host runtime a plugin links, and
|
|
# the generator that emits the plugin around a cdylib module's C ABI.
|
|
#
|
|
# These are deliberately NOT reachable from `lib` / `rawLib` /
|
|
# `cmake-module`. A consumer that only wants the Nix build functions or
|
|
# the CMake module (logos-module-builder's common path) must not be made
|
|
# to realise a Qt + protocol build to get them, and under Nix's laziness
|
|
# it is not — as long as nothing in those attributes mentions these.
|
|
packages = forAllSystems ({ pkgs, system, ... }: {
|
|
cmake-module = pkgs.runCommand "logos-qt-plugin-cmake" {} ''
|
|
mkdir -p $out/share/cmake/LogosModule
|
|
cp ${./cmake/LogosModule.cmake} $out/share/cmake/LogosModule/LogosModule.cmake
|
|
'';
|
|
|
|
logos-qt-host = import ./nix/qt-host.nix {
|
|
inherit pkgs;
|
|
src = ./.;
|
|
protocolLib = logos-protocol.packages.${system}.logos-protocol-lib;
|
|
};
|
|
|
|
logos-qt-host-generator = import ./nix/qt-host-generator.nix {
|
|
inherit pkgs;
|
|
src = ./qt-host-generator;
|
|
logos-lidl = logos-lidl.packages.${system}.logos-lidl;
|
|
};
|
|
|
|
# Unchanged: `default` is still the CMake module, so `nix build` on
|
|
# this repo stays the cheap pure-Nix output it has always been.
|
|
default = self.packages.${pkgs.system}.cmake-module;
|
|
});
|
|
|
|
# Tests
|
|
checks = forAllSystems ({ pkgs, system, ... }: {
|
|
# 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;
|
|
};
|
|
|
|
# The Qt host runtime compiles and installs a usable CMake package.
|
|
qt-host = self.packages.${system}.logos-qt-host;
|
|
|
|
# Drive the glue generator over a real contract and assert on the
|
|
# emitted C++.
|
|
qt-host-generator = import ./tests/test-qt-host-generator.nix {
|
|
inherit pkgs;
|
|
generator = self.packages.${system}.logos-qt-host-generator;
|
|
};
|
|
});
|
|
|
|
# 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"
|
|
'';
|
|
};
|
|
}
|
|
);
|
|
};
|
|
}
|