mirror of
https://github.com/logos-co/logos-module-builder.git
synced 2026-08-30 19:51:07 +00:00
* fix(cmake): one LogosModule.cmake, the union of the two that had diverged
There were two copies — here and in logos-plugin-qt — and the received wisdom
that "the builder's shadows the backend's" is wrong. Selection is BY MODULE
CLASS, and each copy was missing what the other had:
mkLogosModule.nix:79 tests the BUILDER root, always true, so CORE
modules take this copy;
buildCppPlugin.nix:191 tests the MODULE'S OWN src, almost never true, so
every ui_qml module falls through to the backend's.
This copy had no REP_FILE, no logos_replica_factory, no LogosViewPluginBase — a
core module passing REP_FILE had it silently swallowed into
MODULE_UNPARSED_ARGUMENTS. The backend's had no generated_code/*.cpp glob, no
metadata.json configure_file, no LOGOS_API_STYLE and no Rust static-lib block.
Merged as a strict union, 721 -> 888 lines. logos_find_qt stays a macro(): the
function() form is the older one, and the macro IS the mingw fix. The four
LogosView*.in templates come along because the replica-factory function
resolves them as siblings through CMAKE_CURRENT_FUNCTION_LIST_DIR.
Prerequisite for relocating the view-plugin templates, not a cleanup — that
move cannot be reasoned about while two files disagree about what a view module
even is.
Verified: a core module (test_basic_module_cpp) and a ui_qml module
(test_fullapi_ui) both build through this copy, and all five of the builder's
own checks pass, including rust-native-dep, which is what exercises the
LOGOS_MODULE_RUST_STATIC_LIBS block the merge carried.
NOTE this de-duplicates nothing yet: buildCppPlugin.nix still routes ui_qml at
the backend's copy, so every in-tree REP_FILE consumer still compiles against
logos-plugin-qt's. Flipping that routing, and having the backend re-export this
file, is the follow-up.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(qml): resolve interface_dependencies in the QML pipeline
buildCppPlugin.nix never resolved interface_dependencies, so a ui_qml module's
interfaces reached the generator only through cpp-generator's own re-read of
metadata.json — invisible to the plugin backend, and silently skipping any entry
with an `input:` (a cross-repo interface), which can only be resolved to a path
by the builder.
Now resolved and passed as interfaceDeps, exactly as mkLogosModule.nix does for
core modules. Needed because the qt consumer wrappers are now emitted per
dependency and per interface by the backend, which has to be told what they are.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat: retire interface "provider"; throw instead of generating nothing
Drops providerCodegen and the PROVIDER_HEADER plumbing in LogosModule.cmake.
autoCodegen ends in a catch-all `else ""`, so simply deleting the branch would
make `interface: "provider"` mean "generate no glue at all": the module builds
green and is then un-callable from every consumer, with nothing in the log to
say why. It throws instead, naming the replacement.
tests/test-module-pre-configure.nix covers exactly that: a mutation control
confirms the suite fails with `expected expression to throw, but it succeeded
with ""` when the throw is removed. 258 -> 265 tests.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat: parse and validate metadata.json#host_services (C2)
A closed set — token_registry, token_delivery, dynamic_calls — parsed and
VALIDATED, unlike the older `capabilities` field, which parseMetadata.nix never
reads. A security decision must not ride on a key nothing looks at, which is why
this is a new field rather than a new meaning for that one.
Two tiers, and the distinction is the point:
* token_registry / token_delivery are TRUST-ROOT — a module holding them can
enumerate the token store or hand authority to an arbitrary target — so they
are additionally restricted to a hardcoded allowlist of module names
(capability_module). Hardcoded rather than configurable: an allowlist a
module could extend from its own metadata would not be an allowlist.
* dynamic_calls is elevated but NOT name-restricted, because a third-party
module that genuinely forwards untyped calls (a webview shell) has to be
able to ask for it.
An unknown service name is refused OUTRIGHT rather than filtered out: it means
the module believes it holds a privilege that does not exist, and silently
dropping the entry hides that from whoever wrote it. Same reasoning as
lp_grant_host_services, which rejects an unknown name wholesale and leaves the
existing grant untouched.
The declaration is advisory. Authority is the host's grant, pushed into the
module's own image over the module-impl C ABI.
265 -> 273 tests. The allowlist case carries a mutation control: with the
trust-root check removed the suite fails with `expected expression to throw, but
it succeeded with ... "name":"sneaky_module","host_services":["token_registry"]`,
so the test genuinely guards the boundary rather than restating it. Includes the
bypass attempt of mixing a permitted service in with a restricted one.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix: emit cdylib glue with logos-qt-host-generator, not qt-sdk's stale copy
B1 relocated the cdylib Qt-plugin glue generator to logos-plugin-qt (the Qt
plugin BACKEND owns the glue; the SDK does not), but universalCodegen and
cdylibCodegen still called `logos-qt-generator` from logos-qt-sdk, which ships
an OLDER copy of the same emitter. Both copies compile and both emit working
glue, so nothing failed — the builds simply used stale glue.
That is not theoretical. It is why the Phase C host-services grant never
reached a module: the new glue reads the `hostServices` property and forwards
it across the C ABI, the old one does not, and every build stayed green while
capability_module refused every requestModule for want of a grant that was
delivered to its process and then dropped on the floor.
Measured: `hostServices` appears 4 times in logos-plugin-qt's copy and 0 times
in logos-qt-sdk's. After the switch the built capability_module plugin
references logos_module_grant_host_services twice (the export plus the glue's
call) where it previously referenced it once.
Threads the plugin-qt FLAKE (not its lib — the generator is a package of it)
from flake.nix through lib/default.nix into buildCppPlugin, mkLogosModule and
mkLogosModuleTests, and puts logos-qt-host-generator on PATH everywhere
logos-qt-generator already was. `--backend ui` still uses qt-sdk's generator:
the view backend has not moved.
logos-test-modules ipc-tests: FAIL -> PASS, which is the end-to-end proof that
a universal capability_module now mints tokens under a host-granted privilege.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix: thread logos-plugin-qt through the ui_qml build path too
mkLogosQmlModule imports buildCppPlugin at its OWN call site, separate from
lib/default.nix's, and that one was left unwired — so every ui_qml module with a
C++ backend hit `logos-plugin-qt = null` and failed to evaluate.
Caught by the regression batch: logos-accounts-ui went from building to FAIL
while all five test-modules checks passed, which is the shape of a defect in one
module CLASS rather than in the generator switch itself.
logos-accounts-ui builds again.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* test: pin the cdylib glue to the maintained generator
The existing assertion ("universal still emits the cdylib Qt glue") checked for
the string `logos-qt-generator` and so failed the moment the builder switched to
`logos-qt-host-generator` — the test doing its job. Retargeted at the invariant
that actually matters (`--backend cdylib` is still emitted) and extended into a
drift guard:
* both codegen paths MUST name logos-qt-host-generator
* neither may fall back to `logos-qt-generator ` (trailing space, so it cannot
match the host generator; `--backend ui` still legitimately uses qt-sdk's)
Worth the four assertions because the failure they catch is invisible: both
copies of the emitter compile and both produce loadable glue, so reverting to
qt-sdk's would emit stale glue and stay green — which is precisely how the
host-services grant went undelivered for a whole phase.
265 -> 277 tests.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* test(fixtures): declare universal authoring where the fixture already claimed it
The `core-universal-module` fixture is named "universal", is described as a
"Universal interface module fixture (mirrors logos-accounts-module pattern)",
and sits under a test section headed "Universal interface core module" -- but
it carried no `interface` key at all, so parseMetadata resolved it to
"legacy". The fixture was not testing the thing its name claims. The real
logos-accounts-module is `interface: universal`.
Declare `interface: universal` on the three `type: core` fixtures whose
legacy-ness was incidental, and pin the value so it cannot silently regress:
core-universal-module mirrors logos-accounts-module (universal)
core-module mirrors the minimal template (universal)
extlib-module mirrors the external-lib template and the real
vendor-extlib core modules (storage/wallet/libp2p/
blockchain) -- all universal
No `type: core` module in the workspace is still legacy-authored.
The other four legacy fixtures are LEFT legacy on purpose, and are now pinned
with an assertion + the evidence, so the coverage is deliberate instead of
accidental:
ui-qml-backend-module mirrors logos-package-manager-ui, which is STILL
legacy; the universal ui_qml shape is already covered
on disk by the ui-qml-backend TEMPLATE
qml-module QML-only: no C++ backend to derive a contract from;
module-with-deps mkLogosQmlModule never reads `interface`, and
universal+ui_qml routes to uiCodegen which demands a
.rep neither fixture has
ui-module `type: ui` has no template and one real instance
(logos-basecamp), which is legacy
These are metadata-parse fixtures only -- none of the three edited fixtures
contains any C++, so this is a metadata-shape correction, not a code port.
No fixture in this repo held a hand-written Qt plugin to migrate.
Verified: all 5 checks run BY NAME (default, qml-integration, rust-native-dep,
static-extlib, test-framework-integration) pass before and after. `default`
goes 277 -> 284 assertions, exactly the 7 added. qml-integration,
static-extlib and test-framework-integration produce byte-identical store
paths to baseline. rust-native-dep's path changes only because mkLogosModule
embeds the builder's own flake source (its fixture src is byte-identical:
xa6m5ci38fc5adcbi0hfyqvgzrmyr3j9) -- attributed by rebuilding with the change
stashed. Positive control: reverting core-universal-module to legacy makes
`default` FAIL on the new assertion, so it bites.
NOT verified: no plugin is built from any edited fixture (they are metadata
only), so there is no `lm methods` surface to diff -- the method-surface check
does not apply here. Nothing downstream of this repo was rebuilt.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat: hand buildHeaders the qt generator, so a contract can drive the wrapper
`contractLidl` already reached buildHeaders on every call — the qt backend just
declined to read it outside cross-compilation. What was missing was the tool:
logos-qt-generator went into buildPlugin's extraNativeBuildInputs and nowhere
near buildHeaders, so the contract-driven branch could not have run even if it
had been selected.
Passing it is the whole change on this side. `logosQtGenerator` is already the
BUILD-platform binary (buildSystemFor), which is what a cross build needs from
a pure tool role, and the backend puts only the generator its selected emitter
actually uses on PATH — so an lp variant and a contract-less module keep the
derivation they had.
Deliberately NOT passed to moduleIncludeLp: logos-qt-generator has no lp
backend. The lp wrapper still comes from logos-cpp-generator's lp emitter,
which is not the legacy Qt one and is not what this migration is about.
buildCppPlugin — the ui_qml pipeline — is left on the legacy path and now says
why. It computes no `lidl` output for the module it builds, so it has no
contract to hand over; and it costs nothing today, because mkLogosQmlModule
reads `moduleLib` and never `moduleInclude`, so that derivation is never
realised. A ui_qml module is a leaf and nothing consumes its client wrapper.
Fixing it therefore starts with giving that pipeline a contract, not with
adding a flag here.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat: link the Qt host runtime from logos-qt-host, not logos-qt-sdk
The Qt host runtime -- LogosAPI, LogosAPIProvider, LogosProviderBase and the
legacy PluginInterface -- moved out of logos-qt-sdk into logos-plugin-qt, where
it ships as the `logos-qt-host` CMake package. LogosModule.cmake now takes it
from LOGOS_QT_HOST_ROOT and links logos-qt-host::logos_qt_host; mkLogosModule,
buildCppPlugin, mkLogosModuleTests and the module dev shell all pass that root.
logos-qt-sdk is NOT dropped. It stays required for the Qt-typed headers that
were never part of the host runtime -- logos_qt_lp_bridge.h and logos_qt_wire.h,
which the generated Qt consumer wrappers #include by name, and
logos_ui_plugin_context.h -- and for the logos-qt-generator that emits them. Its
include dirs are kept, but AFTER the host runtime's, so the host headers win the
five names the two roots share.
mkLogosModuleTests now also passes -DLOGOS_QT_HOST_ROOT to logos-test-framework,
whose LogosTest.cmake already prefers it and falls back to LOGOS_QT_SDK_ROOT.
logos-plugin-qt's logos-protocol input gains a `follows` (as logos-qt-sdk's
already had). Building logos-qt-host makes that input load-bearing for the first
time, and a second logos-protocol on the link line would mean a second
TokenManager singleton.
Nothing here fails open. A LOGOS_QT_HOST_ROOT with no runtime under it is a
FATAL_ERROR rather than a fall-through to logos-qt-sdk; a host package that
resolves without defining its target is a FATAL_ERROR rather than a plugin
linked without a runtime; and the legacy logos-qt-sdk fallback, which stays
available while other consumers migrate, announces itself in the configure log.
The new `qt-host-repoint` check pins all four selection paths plus both guards.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat(b2b): probe logos-qt-sdk by a header it owns, and drop the qt-sdk fallback
Two changes, both forced by logos-qt-sdk no longer forwarding the host runtime's
headers.
The presence probe tested ${LOGOS_QT_SDK_ROOT}/cpp/logos_api.h or
include/cpp/logos_api.h. Neither exists any more: the host split moved
logos_api.h out of qt-sdk's cpp/, and the forwarder that kept it in include/cpp/
is gone. A correct root would have been reported as "logos-qt-sdk not found"
while CMake was looking straight at it. It now probes logos_qt_wire.h, which
this SDK does own -- along with logos_qt_lp_bridge.h and
logos_ui_plugin_context.h, the only reason the root is still required at all.
(The source branch was already dead on arrival: qt-sdk's cpp/ has held no
logos_api.h since B1, so LOGOS_QT_SDK_IS_SOURCE could never be TRUE.)
The legacy fallback -- no LOGOS_QT_HOST_ROOT means take the host runtime from
logos-qt-sdk's forwarding package -- is deleted. Its premise is false now, and
what it would do instead is worse than failing: find_package(logos-qt-sdk)
still succeeds and its INTERFACE target still chains logos-qt-host, so the
build would work by accident through one more hop while the include path it set
up (${LOGOS_QT_SDK_ROOT}/include{,/cpp,/core}) contained none of the headers it
was chosen for. LOGOS_QT_HOST_ROOT is now the one source, and its absence is a
FATAL_ERROR that says so.
test-qt-host-repoint.nix follows: its test 3 asserted the fallback happened and
was announced; it now asserts the fallback is gone -- a build with no
LOGOS_QT_HOST_ROOT aborts even with a good logos-qt-sdk root present. Test 3b is
new and pins the probe fix directly: that same run must NOT say "logos-qt-sdk
not found", and a qt-sdk root scaffolded the way the real prefix now looks
(logos_qt_wire.h, no logos_api.h) is still found.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat: LogosModule.cmake is this repo's, and every module type now gets it
logos-plugin-qt shipped a second copy of cmake/LogosModule.cmake, and which
one a module configured with was decided by its TYPE:
buildCppPlugin.nix set LOGOS_MODULE_BUILDER_ROOT only when the MODULE's own
repo carried a cmake/LogosModule.cmake. No module does, so every ui_qml
plugin fell through to the value logos-plugin-qt's lib/default.nix sets --
its own root -- while mkLogosModule's core path used this repo's copy.
Both compiled, so the two drifted with nothing to say so: this copy carried
A1's union (the generated_code/*.cpp glob, LOGOS_API_STYLE, the metadata
configure_file, Go/Rust static-lib linking, the external-library FATAL_ERRORs,
logos_find_qt as a Windows-safe macro) while plugin-qt's had B2b's addition of
logos_qt_arg_decode.{cpp,h} to the host-runtime source list -- which
qt_provider_object.cpp's dispatch needs, and whose absence is a link error, not
a configure error. That file is ported here.
Routing: both nix entry points now pass LOGOS_MODULE_BUILDER_ROOT
unconditionally, so a ui_qml plugin and a core module configure with the same
file. The old module-local branch is gone with it -- an unconditional value is
what makes "there is one copy" a property of the code rather than of what
happens to be on disk -- and a missing file now throws instead of falling back
to something that quietly configures differently.
logos_module() prints the file it came from, so a future fork shows up in any
configure log rather than after a phase of debugging.
Verified: counter, counter_qml, logos-storage-ui, logos-package-manager-ui,
test_fullapi_ui, logos-accounts-ui, logos-blockchain-ui, logos-wallet-ui and
logos-evm-wallet-ui (ui_qml) plus test_basic_module_cpp and capability_module
(core) all build, and their configure logs name this file. Checks by name:
default, qml-integration, qt-host-repoint, static-extlib OK; rust-native-dep
and test-framework-integration fail identically at the pre-change baseline
(this repo's own lock pins a logos-protocol without TokenManager::forIdentity,
so logos-qt-host will not compile from it -- green in the workspace closure).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat: read the view templates from their owner, and check the ABI they declare
Two changes, one theme: nothing in this build should be able to pick a second
copy of a file without saying so.
1. cmake/LogosView*.in are deleted. They now live once, in logos-plugin-qt's
cmake/, and _logos_module_add_replica_factory takes the directory from
LOGOS_VIEW_TEMPLATE_DIR (cache variable, then environment) instead of
probing for a sibling of this .cmake file.
The sibling probe is what made the duplication possible: it meant the
templates had to sit next to LogosModule.cmake, but logos-plugin-qt's
rep-file-plugin fixture instantiates them too and cannot depend on this
repo, so it kept a byte-identical copy. logos-plugin-qt is the only place
both consumers can read one copy from; see its cmake/README.md.
There is no fallback. An unset variable, or a directory missing any of the
four templates, is a FATAL_ERROR naming what it wanted.
2. A new `view-interface-abi` check, in CI.
LogosViewPlugin and LogosViewReplicaFactory are declared TWICE and always
will be: module side in logos-plugin-qt's templates, host side in
logos-view-module-runtime's headers. They cannot share a header — a module
plugin has to compile against Qt alone, and logos-view-module-runtime
depends on logos-plugin-qt, so the include could only point the wrong way.
They bind at runtime through the IID string, and a mismatch there is silent
the whole way: both sides compile, the plugin loads, qobject_cast returns
nullptr, the view is blank.
Until now the only thing holding those two in agreement was a comment
asking a human to keep them in sync — which had already rotted (it pointed
at src/, the headers are in include/) and prevented none of the five
duplicate-source defects in this refactor.
This repo depends on logos-plugin-qt AND on logos-view-module-runtime, and
is the only one that does, so the comparison lives here. tests/
view-interface-abi.py extracts the IID and the ordered pure-virtual list
from both sides and fails on any difference — including a class rename,
which would otherwise turn the comparison into a vacuous pass.
Proven by mutation: adding an argument to enableRemoting on the module side,
bumping the IID on the host side, and renaming the host-side class each turn
the check red with a specific message; reverting each turns it green.
Note: like the already-red rust-native-dep and test-framework-integration
checks, view-interface-abi does not evaluate until this repo's logos-plugin-qt
pin advances past the commit that adds packages.<sys>.logos-view-templates. It
says exactly that, and names logos-plugin-qt as the input to move.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(view-abi): check the class that actually binds at runtime, and let it run
The guard had two independent faults; either one alone made it decorative.
1. IT DID NOT CATCH WHAT IT NAMED. The script read `#define <Name>_iid` and
the `virtual ...;` list inside `class <Name>`. Both of those are the
abstract shape. The runtime binding is declared on the CONCRETE class the
template also contains — @LOGOS_FACTORY_CLASS@, with Q_OBJECT,
Q_PLUGIN_METADATA and Q_INTERFACES — and that class was never inspected.
Two mutations that both reach production were run against it and it stayed
green on both:
Q_PLUGIN_METADATA(IID LogosViewReplicaFactory_iid)
-> Q_PLUGIN_METADATA(IID "logos.view.replica_factory/2.0")
Q_INTERFACES(LogosViewReplicaFactory) deleted
It now parses every class in the file, finds the ones deriving from the
interface, and requires: at least one exists (so a dropped base class or a
rename cannot make the comparison vacuous); a QObject-derived one has
Q_OBJECT; a QObject-derived one names the interface in Q_INTERFACES; and
any Q_PLUGIN_METADATA IID resolves to the IID the HOST casts on.
Two more windows were open and are now closed: the argument of
Q_DECLARE_INTERFACE was only checked for EXISTENCE, though it is the string
qobject_cast compares and need not be the #define — it is now resolved
through the file's #defines and compared both across sides and against that
side's own #define; and the interface's own base list, which is its vtable
layout, was not compared at all.
Proven by mutation, 12 cases, each reverted to green afterwards: the 2
above, plus a changed Q_DECLARE_INTERFACE IID, a dropped interface base, a
renamed interface, a dropped Q_OBJECT, a base added to the interface, a
*ViewPluginBase that stops implementing LogosViewPlugin, the 2 the old
guard already caught (regression), and 2 null controls — a comment edit and
a reflowed declaration — which must stay GREEN and do.
The nix wrapper also sets `set -o pipefail` explicitly and folds stderr
into $out. `... | tee $out` takes tee's exit status; that it worked at all
depended on stdenv happening to set pipefail, which is not a thing a guard
should rest on.
2. IT COULD NOT EXECUTE. With no overrides — the CI condition — the check
EVAL-THREW: this flake pinned logos-plugin-qt at b8b9b414, which predates
packages.<sys>.logos-view-templates. So the step was unconditionally red
from the day it landed, camouflaged by test-framework-integration being red
beside it for the same stale pin.
Both logos-plugin-qt and logos-plugin-core (the same repo, selected per
module type — a split pin gives core and ui modules two different
LogosModule.cmake and two Qt host runtimes) now name rev fcf5a29 in the
URL, not just in the lock, so `nix flake update` cannot walk them back onto
a master that still lacks those outputs.
That bump fixes the EVAL failure for all three affected checks.
view-interface-abi is now GREEN with no overrides. rust-native-dep and
test-framework-integration now evaluate and build, and fail later on an
unrelated pre-existing problem: logos-qt-host does not compile against the
pinned logos-protocol, whose TokenManager has no forIdentity /
isolateIdentity. That is the same failure logos-plugin-qt's own #qt-host
check has at fcf5a29 with its own lock and no overrides, so it is not
introduced here and cannot be fixed here.
CI: qt-host-repoint is added — it is hermetic and it existed without ever
being listed. rust-native-dep is deliberately still not listed, with the
reason recorded next to it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(view-abi): follow bases transitively, or the guard watches an empty window
Implementor detection matched only the immediate base clause, so one level of
indirection skipped every concrete-class check — and the "no implementors"
backstop did not fire either, because the helper base still counted as an
implementor in its own right.
That is not a hypothetical shape. lidl_gen_ui.cpp emits every real ui_qml
plugin deriving from LogosViewPlugin INDIRECTLY, via <Rep>ViewPluginBase, so
for that half of the pair the window this guard exists to watch was empty in
production.
Resolve each class's transitive base set through the other classes in the file
before testing membership, and make the QObject check transitive with it. The
two mutations that escaped — an indirect base with the IID bumped to /2.0, and
an indirect base with Q_INTERFACES deleted — now fail, each naming its own
cause; indirection alone stays green and reports both implementors.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore(deps): bump the B3/B4 stack, and rev-pin the inputs update cannot reach
Moves every input this builder shares with the SDK codegen stack onto the
revisions that stack has actually pushed:
logos-protocol 03842db -> c8bab12 feat/per-client-token-store
logos-cpp-sdk e3744fb -> a04b278 feat/sdk-codegen-b3-d11
logos-qt-sdk c6be61d -> 8a06b87 feat/sdk-codegen-b3-d11
logos-plugin-qt fcf5a29 -> cc24fa1 feat/b4-qt-host-windows-target
logos-plugin-core fcf5a29 -> cc24fa1 same rev, per the type split
logos-view-module-runtime 471dd56 -> 5510acd feat/sdk-codegen-b4-qt-host
logos-standalone-app 288fec2 -> 39f4f2b feat/sdk-codegen-b4-qt-host
logos-test-framework eb1600c -> c382ab1 feat/sdk-codegen-b4-test-framework
Every one of those is a BRANCH TIP, not master. Six of them were plain
`github:logos-co/<repo>` urls, so `nix flake update` would have relocked them
onto master and the bump would silently not have happened -- the update
succeeds, the lock changes, and the rev is still wrong. They are rev-pinned
here for the same reason logos-plugin-qt already was. Each is a fast-forward
from its own master (03842db, e3744fb, c6be61d, 8846fc5, 471dd56, 288fec2 and
eb1600c are ancestors of their targets), so pinning gives up nothing; drop the
revs as the branches land.
logos-plugin-qt/-core go to cc24fa1, the tip of feat/b4-qt-host-windows-target,
NOT to the sibling feat/b4-qt-host-windows-target-8ccb1fc. The sibling
re-baselines onto 8ccb1fc and drops the LogosModule.cmake repoint and the
view-templates commit, so its flake exposes no packages.<sys>.logos-view-templates
and `view-interface-abi` would hit its own throw instead of running. cc24fa1
carries the old fcf5a29 pin's content under rebased shas (4c581a6/e4ea357/fcf5a29
are fe780a6/34704d1/3d7e3e6 there).
logos-test-framework's pin is the least obvious and the one worth keeping: this
branch teaches mkLogosModuleTests to pass -DLOGOS_QT_HOST_ROOT, and it is
LogosTest.cmake on c382ab1 that prefers it -- master's copy knows only
LOGOS_QT_SDK_ROOT, so a master lock links the unit tests against the wrong
runtime root without failing.
The follows keep one logos-protocol on the link line: root, logos-plugin-qt,
logos-plugin-core, logos-qt-sdk and logos-cpp-sdk all resolve to c8bab12.
All seven checks build on aarch64-darwin: default, qml-integration,
qt-host-repoint, rust-native-dep, static-extlib, test-framework-integration,
view-interface-abi.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat(metadata): codegen.consumer_api_style, gated on how the image gets tokens
Lets a module declare its CONSUMER type surface independently of its provider
packaging. A cdylib-packaged module can now hold Qt-typed dependency wrappers —
the combination that was previously inexpressible, and the only reason
`interface: "provider"` and `--provider-header` are still alive.
The enabling codegen landed first (logos-cpp-sdk 620f2e1, logos-qt-sdk 6b88630):
a default-constructible Qt umbrella and a consumer binding that takes an
explicit origin instead of a LogosAPI. An earlier attempt at this key FAILED
because it was added without that codegen, so its only reachable outcome was a
compile error inside generated code. It is meaningful now.
── The predicate ───────────────────────────────────────────────────────────
packagedAsCdylib = interface == "cdylib"
|| (interface == "universal" && type != "ui_qml")
character-for-character what modulePreConfigure.autoCodegen branches on when it
decides to emit the module-impl C ABI, so the two cannot drift.
The distinction is NOT "this image has no LogosAPI" — a cdylib module's plugin
does contain one, in the Qt glue that receives tokens. What separates the two
worlds is where the image's own TokenManager is FILLED:
cdylib-packaged : logos_module_accept_token -> lp_token_save, same image.
An origin-bound wrapper's null sync hook costs nothing.
Qt plugin : only LpBridge::syncTokens, installed exclusively by
forTarget(api, …). An origin-bound wrapper there would be
silently unauthenticated — the exact defect syncTokens
exists for.
Measured with `nm -gU`, not argued: `logos_module_accept_token` is defined in
exactly the shapes the predicate calls true, across six real plugins.
`universal` + `ui_qml` is the trap — it looks cdylib-shaped but uiCodegen emits
only view glue, so it is a Qt object holding a LogosAPI. Excluded.
`--binding origin` is not selectable from metadata at all: it is derived as
`isQt && packagedAsCdylib` in the backend, an AND no key can reach from the
wrong side. What a key CAN express wrongly is the mirror move — `lp` on a Qt
plugin — unsafe for the identical reason, and refused at eval naming the key.
Verified additive on seven modules spanning legacy/core, universal/core,
universal/ui_qml and QML-only: `diff -r` clean, narHash identical where
comparable, and `test_qml_only` byte-identical by store path. Note compiled
modules cannot share a store path across any builder edit, since mkLogosModule
bakes LOGOS_MODULE_BUILDER_ROOT — narHash is the honest comparison.
Three mutation controls, each failing loudly: removing the eval throw, nulling
the backend's own assertion, and dropping the packagedAsCdylib conjunct from
`originBound` — the last being the one that pins the token-mirror hazard rather
than just the lp refusal.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore(deps): take the backend that honours consumer_api_style
08ae7ac added the metadata key but this repo still pinned logos-plugin-qt at
cc24fa1c, which predates 2d25069's `originBound` derivation. Both backend
inputs resolved there, so the key parsed and validated and then reached a
backend that ignored it: a module asking for Qt-typed consumers still got
lp-typed wrappers, and failed to compile with a type mismatch 20 errors deep
rather than anything naming the key.
Both `logos-plugin-qt` and `logos-plugin-core` move — they are two inputs onto
the same repo, selected by module type, and a split pin would give core and ui
modules different backends.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore(deps): take the SDKs that carry the origin-bound consumer codegen
The backend pin (723244b) was necessary but not sufficient. consumer_api_style
= "qt" on a cdylib emits `new LogosModules()` against the Qt umbrella, which is
default-constructible only from logos-cpp-sdk 620f2e1; and the wrapper it
constructs binds through LpBridge::forOrigin, which arrives with logos-qt-sdk
aca2951. Pinned at a04b278 / 8a06b87 the key resolved, reached a backend that
honoured it, and then failed at
no matching constructor for initialization of 'LogosModules'
in generated code — three pin levels away from anything naming the feature.
Recording the chain, because it took four bumps to find: a module's consumer
surface is decided by test-modules -> module-builder -> {plugin-qt, cpp-sdk,
qt-sdk}, and every level has to move together. Each intermediate state built
something; none of them built the right thing.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat: refuse a core module that ships a plugin with no interface
`interface` defaults to "legacy", and legacy generates no glue. For a CONSUMER
that is correct: a ui_qml view plugin is never loaded by liblogos, and a fixture
that only builds tests has nothing to expose. For a module that ships a plugin
liblogos loads and other modules call, it is the silent form of exactly what the
`provider` branch already throws for — the module builds green and is
un-callable from every consumer, with the first symptom arriving at runtime in a
different process.
`main` is the discriminator, and measurement is why. `type` alone cannot do it:
of the modules that reach autoCodegen with no interface, the ten ui_qml ones are
consumers and test_framework_module is core but ships no plugin at all — it has
no plugin source, only calculator.{h,cpp}, and exists to drive mkLogosModuleTests.
Gating on `type == "core"` would have thrown for it. A provider ships a plugin,
so it names one in `main`; that fixture's `main` was vestigial and is dropped
here, which is also the honest description of what it always was.
Both directions checked, not just the quiet one: with the vestigial `main` put
back, test-framework-integration fails to evaluate with this message; with it
dropped, the same attribute evaluates and the check builds. The workspace still
evaluates on aarch64-darwin (624 packages) and x86_64-windows (386).
Depends on logos-test-modules retiring test_ipc_module, which was the last
module this would have thrown for.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(metadata): drop `dynamic_calls`, which broke the grants it sat beside
`dynamic_calls` was listed as a host service and is not one. It gated nothing
and could not: the by-name path is ungated at every layer, so any module could
always make dynamic calls without asking.
What the declaration actually did was break the asking module. `hostServiceBit`
(logos_protocol.cpp:109-111) recognises exactly `token_registry` and
`token_delivery`; `lp_grant_host_services` returns LP_ERR_INVALID_ARG on the
first entry it does not recognise (:695-702), which fails the WHOLE grant. So a
module asking for `dynamic_calls` alongside a real service silently lost the
real one — the opposite of the "ADVISORY … an ungranted module gets
LP_ERR_UNSUPPORTED" the comment here promised.
Removed from `known` rather than made inert, so asking is now a build error
instead of a silent downgrade. No module in the tree declares it.
The supported surface for by-name calls is LogosModules::dynamic(target) plus
LpClient::getMethods(), added in logos-cpp-sdk alongside this. Neither needs a
grant, which is the whole point.
Two tests move with it. The "accepted for any module" case becomes an
assertThrows. The "allowlist is not bypassed by mixing in a permitted service"
case loses its premise — both remaining services are trust-root, so there is no
"permitted for anyone" name left to mix, and keeping the old form would have
passed for the wrong reason (unknown name, not the allowlist). It now pins that
asking for BOTH trust-root services does not slip past.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* ci: use logos-co/setup-nix-cache-action for Nix setup and caching
Replaces the per-repo installer + cachix pair with the shared action, which
installs Nix with the Logos Attic cache (cache.nix.logos.co) preconfigured and
publishes what the job builds — master to the public cache, every other ref to
ci.
Each converted job also gains
environment: ${{ github.ref == 'refs/heads/master' && 'public-cache' || '' }}
because ATTIC_TOKEN_PUBLIC only exists inside that environment. Without it the
secret resolves empty on master and publishing is silently skipped — the job
still passes, so the omission would not show up as a failure.
The action installs Nix itself on every runner, macOS included. That is a
deliberate reversal of the workaround these files carried: the comments here
said cachix/install-nix-action collides with the runner's pre-existing _nixbld
users (eDSRecordAlreadyExists), so DeterminateSystems' installer was used
instead. It no longer reproduces — logos-delivery-module has already been
converted the plain way and its `build-and-test (macos-latest)` leg passes.
Keeping the workaround would have meant a second installer plus a duplicated
substituter/key block in ten files, guarding against something two green runs
say does not happen. If it ever recurs it fails loudly at install, which is
recoverable; the silent-skip above is the failure mode worth engineering
against.
One property is deliberately NOT carried over: the old cachix step ran with
`continue-on-error: true` so a failed cache push could not fail a job whose
tests passed. The action exposes no equivalent, and adding one here would also
swallow genuine setup failures now that the same step installs Nix rather than
only publishing at the end.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* docs: align guides and skills with the universal codegen pipeline
The docs/ set, the authoring skills and the CMakeLists template still told
authors to write `interface: "provider"` classes with LOGOS_METHOD, or claimed
the builder runs `logos-cpp-generator --from-header` to emit the Qt glue. The
universal path is three steps — `--header-to-lidl` to derive the contract, then
`logos-qt-host-generator --backend cdylib` for the plugin glue, then
`logos-cpp-generator --lidl --backend cdylib` for the C-ABI exports — and
`--from-header` drives the separate `interface: "cdylib"` authoring path.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* feat: take the view templates from logos-view-module
The LogosView*.in templates moved out of logos-plugin-qt, which is now limited
to making a cdylib loadable by logos-module-loader-qt. Add logos-view-module as
an input and read them from there.
- view-interface-abi now reads logos-view-module's logos-view-templates and
diffs it against logos-view-module-runtime's host headers. The throw fallback
named logos-plugin-qt and told the reader to bump that pin; it names
logos-view-module now.
- This repo supplies LOGOS_VIEW_TEMPLATE_DIR itself, since the backend no
longer does, via the extraCmakeFlags/extraEnv seams already carrying
LOGOS_CPP_SDK_ROOT and the other four roots. Both channels are load-bearing:
the cmake flag drives the nix build, the env var is what a dev shell resolves
when someone runs cmake by hand.
- Indexed through common.buildSystemFor, NOT the raw system: logos-view-module
publishes only the four native systems, while this repo's systems list adds
x86_64-windows, so a raw index would EVAL-fail the Windows leg.
- LogosModule.cmake's hard error named logos-plugin-qt as the caller that
passes the variable; it names this repo now.
The input is left on master rather than rev-pinned: the output does not exist
on any pushed branch yet, so view-interface-abi hits the throw until the move
lands and the pin can be set. Verified locally with
--override-input logos-view-module path:...
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore(deps): pin logos-view-module at the merged template move
logos-view-module#2 merged as 1f95a75, so packages.<sys>.logos-view-templates
now exists on its master and the input no longer has to sit unpinned.
Rev-pinned for the same reason logos-plugin-qt is: `nix flake update` must not
be able to walk this back to a commit without that output, which
view-interface-abi and every ui_qml plugin build need.
view-interface-abi now passes with NO --override-input, which is what the
unpinned state could not demonstrate.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore(deps): pin logos-standalone-app at the branch that absorbed master
The last pin on this branch that walked master backward. master's b960f44 had
bumped logos-standalone-app to e582e6c; this branch pinned 39f4f2b, which is on
feat/sdk-codegen-b4-qt-host only and does not contain it — so merging would
have reverted the hot-reload fix (#36) and the capability-bundling removal.
That branch has now absorbed master (logos-standalone-app b67eddd, `nix build
.#default` green) and this pins the result, exactly as logos-view-module-runtime
was handled in 8484fbb.
Every root input on this branch now CONTAINS master's rev: cpp-sdk, plugin-qt,
plugin-core, protocol, qt-sdk, test-framework, standalone-app and
view-module-runtime all check out as ancestors. Nothing walks master backward
any more.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore(deps): track master for every input whose PR has merged
logos-protocol (#59), logos-cpp-sdk (#138), logos-plugin-qt (#19) and
logos-qt-sdk (#33) have all landed, so the four rev pins bridging to them are
retired and each stale rationale is rewritten to name the PR that closed it.
logos-plugin-core moves in lockstep with logos-plugin-qt — it is the same repo
under a second input name, and a split pin would put two logos-qt-hosts in one
closure.
All four were SQUASH-merged, so `merge-base --is-ancestor <pin> master` is
correctly false while the content is in master. Every retirement was confirmed
against master's FILES via gh api, not ancestry.
The qt-sdk pin is worth a note: nothing makes logos-qt-sdk `follows` anywhere, so
one revision across consumers was upheld by hand-pinning the same rev — and it
had already drifted (this repo pinned aca2951 while logos-test-framework and
logos-basecamp pinned 8a06b870). Tracking master makes it structural.
Kept: logos-test-framework @ c382ab1 (master's LogosTest.cmake still knows only
LOGOS_QT_SDK_ROOT, not LOGOS_QT_HOST_ROOT — verified, 0 hits) and logos-rust-sdk
@ 0b4b8ed (no confirmed upstream merge).
All 7 checks build on aarch64-darwin and the flake evaluates on all 4 systems.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore(deps): retire four more pins, now that their PRs have merged
Takes this flake from five rev pins to one.
* logos-test-framework c382ab1 -> master. The pin existed because master's
cmake/LogosTest.cmake knew only LOGOS_QT_SDK_ROOT, so an unpinned input made
`test-framework-integration` link the unit tests against the wrong runtime
root. logos-test-framework#6 merged and master now has LOGOS_QT_HOST_ROOT
(6 references) — the exact gap the comment named.
* logos-standalone-app b67eddd -> master (13b81c9, #37). The host shell for
ui_qml `nix run` / integration tests carries the qt-host repoint, the
hot-reload fix (#36) and the capability-bundling removal on master now.
* logos-view-module-runtime 3ef779c -> master (b9a6778f, #25). Master no longer
rev-pins logos-plugin-qt itself, so both sides of the view ABI check are back
in step.
* logos-view-module 1f95a75 -> master. 1f95a75 IS that repo's master tip (the #2
merge), so this pin was already a no-op.
Every rationale is rewritten to name the PR that closed it rather than deleted.
All four upstreams were SQUASH-merged, so the old revs are not ancestors of the
new masters even though their content is in them; the retirements were confirmed
against master's FILES.
Relocked with an explicit --update-input per retired input, NOT a bare
`nix flake lock`: that does not re-resolve an input which is already locked, even
once its url stops carrying a rev, and it silently walked pins backward twice
earlier today. All eight now read master — view-module-runtime b9a6778f,
view-module 1f95a75f, standalone-app 13b81c9e, test-framework 5f75c941,
cpp-sdk 95d7b3a9, protocol f4407ff4, plugin-qt 9b2c64e5, qt-sdk 19c844f2.
logos-rust-sdk @0b4b8ed stays: no merged upstream confirmed for it.
All 7 checks build, including test-framework-integration — the one that would
actually catch a mislocked test-framework rather than compile around it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore(deps): retire the last rev pin, logos-rust-sdk
This flake now pins nothing by rev.
0b4b8ed was kept on the grounds that no merged upstream could be confirmed for
it. That was wrong: it is an ANCESTOR of logos-rust-sdk's master (7c65d31), so it
was never waiting on anything — just behind. Unlike every other pin here it also
carried no stated reason; the comment beside it explains the `follows` that cuts
the rust-sdk -> module-builder test cycle, not the rev.
Master adds exactly two commits over it, neither touching what this builder
consumes (logos-lidl-gen and the SDK source the crate links):
671bcc6 chore(lidl-gen): delete the dead gen_provider example (#39)
7c65d31 ci: use logos-co/setup-nix-cache-action for Nix setup and caching (#40)
checks.rust-native-dep — the one that compiles a Rust module through lidl-gen —
rebuilds from source against rust-sdk master and passes, as do `default` and
view-interface-abi.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore(deps): take the rust-sdk that emits the 11th module-impl export
logos-rust-sdk#41 merged (52f0c6f), so its provider scaffold now emits
logos_module_grant_host_services — the one module-impl C ABI export it was
missing.
That is what broke this branch's cross-language doctests. Since ed50731 the
cdylib Qt glue comes from logos-plugin-qt's logos-qt-host-generator, and the
protocol bump turned on that glue's LOGOS_PROTOCOL_VERSION_MINOR >= 3 call to
the export. logos-protocol only declares it; each language backend owes the
definition, and logos-cpp-sdk had one where logos-rust-sdk did not. Every Rust
plugin therefore linked a call with no definition — not a link error on ELF, but
nixpkgs' -Wl,-z,now forces eager binding, so the module's host process aborted at
dlopen. It died AFTER the token exchange, so the runtime reported a successful
load and only the post-load registry snapshot showed the module gone, which is
why it looked like the dependency resolver dropping the Rust module.
doctests/cross-language-composition.test.yaml: 19 passed, 0 failed — including
the assertion that failed in CI (load-module cpp_frontdesk_module listing
rust_orchestrator_module) and every typed call across the boundary in both
directions. checks.rust-native-dep also builds.
Caveat: this was verified on macOS, which links plugins -undefined
dynamic_lookup and so never binds the symbol at all — that is exactly why the
bug was invisible there and fatal on Linux. What macOS proves is that nothing
regressed and the qt-sdk/cpp-sdk skew is gone; the ubuntu doc-tests are what
confirm the Rust modules now load.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* chore(deps): take the rust-sdk that calls grant_host_services publicly
logos-rust-sdk#42 merged (a3d0d71). #41 had emitted
`logos_rust_sdk::ffi::lp_grant_host_services(...)`, but `mod ffi` is private, so
every Rust module generated against protocol >= 0.3 failed to COMPILE with
error[E0603] — which is why this branch's doctests went from "the Rust module
does not load" to "Build it FAILED". #42 routes the call through a public
wrapper, matching how the crate already exposes save_token.
checks.rust-native-dep rebuilds a real Rust module through the generator against
a3d0d71 and passes, and doctests/cross-language-composition.test.yaml is 19
passed / 0 failed — including the load-module assertion that started this and
every typed call across the C++/Rust boundary in both directions.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1044 lines
48 KiB
CMake
1044 lines
48 KiB
CMake
# LogosModule.cmake
|
|
# Reusable CMake module for building Logos plugins
|
|
# This handles all the boilerplate configuration for Logos modules
|
|
#
|
|
# THIS IS THE ONLY COPY. Do not fork it into a backend repo.
|
|
#
|
|
# logos-plugin-qt used to ship a second copy, and because
|
|
# buildCppPlugin.nix set LOGOS_MODULE_BUILDER_ROOT only when the MODULE's own
|
|
# repo carried a cmake/LogosModule.cmake (no module does), the two were
|
|
# selected by module type: every ui_qml plugin configured with the backend's
|
|
# copy while every core module configured with this one. Both compiled, so the
|
|
# divergence was invisible — it is how a stale generator, a stale host-runtime
|
|
# repoint, and a missing source file each shipped green. Both nix entry points
|
|
# (mkLogosModule and buildCppPlugin) now point LOGOS_MODULE_BUILDER_ROOT here
|
|
# unconditionally; `logos_module()` echoes the file it came from so a future
|
|
# fork shows up in any configure log.
|
|
|
|
cmake_minimum_required(VERSION 3.14)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
# Enable CMake automoc for Qt
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
#[=======================================================================[.rst:
|
|
logos_find_dependencies
|
|
-----------------------
|
|
|
|
Find and configure Logos SDK and logos-module dependencies.
|
|
This function sets up include directories and library paths.
|
|
|
|
Usage:
|
|
logos_find_dependencies()
|
|
|
|
Sets:
|
|
LOGOS_MODULE_ROOT - Path to logos-module
|
|
LOGOS_CPP_SDK_ROOT - Path to logos-cpp-sdk
|
|
LOGOS_MODULE_IS_SOURCE - TRUE if using source layout
|
|
LOGOS_CPP_SDK_IS_SOURCE - TRUE if using source layout
|
|
LOGOS_QT_HOST_ROOT - Path the Qt HOST RUNTIME is taken from
|
|
LOGOS_QT_HOST_IS_SOURCE - TRUE if that root is a repo checkout
|
|
LOGOS_QT_HOST_PACKAGE - CMake package name for the host runtime
|
|
LOGOS_QT_HOST_TARGET - Imported target for the host runtime
|
|
#]=======================================================================]
|
|
function(logos_find_dependencies)
|
|
# Allow override from environment or command line
|
|
if(NOT DEFINED LOGOS_MODULE_ROOT)
|
|
set(_parent_module "${CMAKE_SOURCE_DIR}/../logos-module")
|
|
if(DEFINED ENV{LOGOS_MODULE_ROOT})
|
|
set(LOGOS_MODULE_ROOT "$ENV{LOGOS_MODULE_ROOT}" PARENT_SCOPE)
|
|
set(LOGOS_MODULE_ROOT "$ENV{LOGOS_MODULE_ROOT}")
|
|
elseif(EXISTS "${_parent_module}/src/interface.h")
|
|
set(LOGOS_MODULE_ROOT "${_parent_module}" PARENT_SCOPE)
|
|
set(LOGOS_MODULE_ROOT "${_parent_module}")
|
|
else()
|
|
set(LOGOS_MODULE_ROOT "${CMAKE_SOURCE_DIR}/vendor/logos-module" PARENT_SCOPE)
|
|
set(LOGOS_MODULE_ROOT "${CMAKE_SOURCE_DIR}/vendor/logos-module")
|
|
endif()
|
|
endif()
|
|
|
|
if(NOT DEFINED LOGOS_CPP_SDK_ROOT)
|
|
set(_parent_cpp_sdk "${CMAKE_SOURCE_DIR}/../logos-cpp-sdk")
|
|
if(DEFINED ENV{LOGOS_CPP_SDK_ROOT})
|
|
set(LOGOS_CPP_SDK_ROOT "$ENV{LOGOS_CPP_SDK_ROOT}" PARENT_SCOPE)
|
|
set(LOGOS_CPP_SDK_ROOT "$ENV{LOGOS_CPP_SDK_ROOT}")
|
|
elseif(EXISTS "${_parent_cpp_sdk}/cpp/logos_module_context.h")
|
|
set(LOGOS_CPP_SDK_ROOT "${_parent_cpp_sdk}" PARENT_SCOPE)
|
|
set(LOGOS_CPP_SDK_ROOT "${_parent_cpp_sdk}")
|
|
else()
|
|
set(LOGOS_CPP_SDK_ROOT "${CMAKE_SOURCE_DIR}/vendor/logos-cpp-sdk" PARENT_SCOPE)
|
|
set(LOGOS_CPP_SDK_ROOT "${CMAKE_SOURCE_DIR}/vendor/logos-cpp-sdk")
|
|
endif()
|
|
endif()
|
|
|
|
# Check if dependencies are available (support both source and installed layouts)
|
|
set(_module_found FALSE)
|
|
if(EXISTS "${LOGOS_MODULE_ROOT}/src/interface.h")
|
|
set(_module_found TRUE)
|
|
set(LOGOS_MODULE_IS_SOURCE TRUE PARENT_SCOPE)
|
|
elseif(EXISTS "${LOGOS_MODULE_ROOT}/include/module_lib/interface.h")
|
|
set(_module_found TRUE)
|
|
set(LOGOS_MODULE_IS_SOURCE FALSE PARENT_SCOPE)
|
|
endif()
|
|
|
|
set(_cpp_sdk_found FALSE)
|
|
# The base SDK is Qt-free/header-only since the qt split — detect it by
|
|
# logos_module_context.h (logos_api.h lives in logos-qt-host).
|
|
if(EXISTS "${LOGOS_CPP_SDK_ROOT}/cpp/logos_module_context.h")
|
|
set(_cpp_sdk_found TRUE)
|
|
set(LOGOS_CPP_SDK_IS_SOURCE TRUE PARENT_SCOPE)
|
|
elseif(EXISTS "${LOGOS_CPP_SDK_ROOT}/include/cpp/logos_module_context.h")
|
|
set(_cpp_sdk_found TRUE)
|
|
set(LOGOS_CPP_SDK_IS_SOURCE FALSE PARENT_SCOPE)
|
|
endif()
|
|
|
|
# logos-qt-sdk — the Qt developer layer. Since the Qt host runtime moved to
|
|
# logos-plugin-qt (see LOGOS_QT_HOST_ROOT below) what this root is still
|
|
# REQUIRED for is the Qt-typed headers that were never part of the host
|
|
# runtime: logos_qt_lp_bridge.h and logos_qt_wire.h (emitted by name into
|
|
# every generated Qt consumer wrapper) and logos_ui_plugin_context.h.
|
|
#
|
|
# Probed by logos_qt_wire.h, deliberately. logos_api.h used to be the
|
|
# discriminator here and is not there any more in EITHER layout: the host
|
|
# split moved it out of cpp/, and the forwarder that kept it in
|
|
# include/cpp/ went away when the consumers were repointed. Probing a name
|
|
# this SDK does not own is how a correct root gets reported as "not found".
|
|
if(NOT DEFINED LOGOS_QT_SDK_ROOT)
|
|
set(_parent_qt_sdk "${CMAKE_SOURCE_DIR}/../logos-qt-sdk")
|
|
if(DEFINED ENV{LOGOS_QT_SDK_ROOT})
|
|
set(LOGOS_QT_SDK_ROOT "$ENV{LOGOS_QT_SDK_ROOT}" PARENT_SCOPE)
|
|
set(LOGOS_QT_SDK_ROOT "$ENV{LOGOS_QT_SDK_ROOT}")
|
|
elseif(EXISTS "${_parent_qt_sdk}/cpp/logos_qt_wire.h")
|
|
set(LOGOS_QT_SDK_ROOT "${_parent_qt_sdk}" PARENT_SCOPE)
|
|
set(LOGOS_QT_SDK_ROOT "${_parent_qt_sdk}")
|
|
else()
|
|
set(LOGOS_QT_SDK_ROOT "${CMAKE_SOURCE_DIR}/vendor/logos-qt-sdk" PARENT_SCOPE)
|
|
set(LOGOS_QT_SDK_ROOT "${CMAKE_SOURCE_DIR}/vendor/logos-qt-sdk")
|
|
endif()
|
|
endif()
|
|
set(_qt_sdk_found FALSE)
|
|
if(EXISTS "${LOGOS_QT_SDK_ROOT}/cpp/logos_qt_wire.h")
|
|
set(_qt_sdk_found TRUE)
|
|
set(LOGOS_QT_SDK_IS_SOURCE TRUE PARENT_SCOPE)
|
|
set(LOGOS_QT_SDK_IS_SOURCE TRUE)
|
|
elseif(EXISTS "${LOGOS_QT_SDK_ROOT}/include/cpp/logos_qt_wire.h")
|
|
set(_qt_sdk_found TRUE)
|
|
set(LOGOS_QT_SDK_IS_SOURCE FALSE PARENT_SCOPE)
|
|
set(LOGOS_QT_SDK_IS_SOURCE FALSE)
|
|
endif()
|
|
|
|
# logos-qt-host — the Qt HOST RUNTIME a plugin links: LogosAPI (the object
|
|
# handed to initLogos), LogosAPIProvider, LogosProviderBase + the
|
|
# LOGOS_PROVIDER/LOGOS_METHOD macros, the legacy QMetaObject adapter and
|
|
# core/interface.h. It moved out of logos-qt-sdk into logos-plugin-qt and
|
|
# ships as the `logos-qt-host` CMake package. LOGOS_QT_HOST_ROOT is the ONE
|
|
# place it comes from; logos-qt-sdk forwarded the same headers during the
|
|
# migration and no longer does, so there is no qt-sdk fallback to take.
|
|
#
|
|
# There is deliberately no silent branch: a build that cannot name a host
|
|
# runtime stops with FATAL_ERROR rather than quietly producing a plugin
|
|
# with no LogosAPI in it.
|
|
if(NOT DEFINED LOGOS_QT_HOST_ROOT)
|
|
set(_parent_qt_host "${CMAKE_SOURCE_DIR}/../logos-plugin-qt")
|
|
if(DEFINED ENV{LOGOS_QT_HOST_ROOT})
|
|
set(LOGOS_QT_HOST_ROOT "$ENV{LOGOS_QT_HOST_ROOT}")
|
|
elseif(EXISTS "${_parent_qt_host}/cpp/logos_api.h")
|
|
set(LOGOS_QT_HOST_ROOT "${_parent_qt_host}")
|
|
endif()
|
|
endif()
|
|
set(_qt_host_found FALSE)
|
|
if(DEFINED LOGOS_QT_HOST_ROOT)
|
|
if(EXISTS "${LOGOS_QT_HOST_ROOT}/cpp/logos_api.h")
|
|
set(_qt_host_found TRUE)
|
|
set(_qt_host_is_source TRUE)
|
|
elseif(EXISTS "${LOGOS_QT_HOST_ROOT}/include/cpp/logos_api.h")
|
|
set(_qt_host_found TRUE)
|
|
set(_qt_host_is_source FALSE)
|
|
else()
|
|
message(FATAL_ERROR
|
|
"LOGOS_QT_HOST_ROOT is set to ${LOGOS_QT_HOST_ROOT} but no Qt host "
|
|
"runtime is there (expected cpp/logos_api.h in a logos-plugin-qt "
|
|
"checkout, or include/cpp/logos_api.h in an installed logos-qt-host "
|
|
"prefix).")
|
|
endif()
|
|
endif()
|
|
if(_qt_host_found)
|
|
set(LOGOS_QT_HOST_ROOT "${LOGOS_QT_HOST_ROOT}" PARENT_SCOPE)
|
|
set(LOGOS_QT_HOST_IS_SOURCE ${_qt_host_is_source} PARENT_SCOPE)
|
|
set(LOGOS_QT_HOST_PACKAGE "logos-qt-host" PARENT_SCOPE)
|
|
set(LOGOS_QT_HOST_TARGET "logos-qt-host::logos_qt_host" PARENT_SCOPE)
|
|
endif()
|
|
|
|
# logos-protocol — transports + lp_* C ABI (linked by the Qt host runtime;
|
|
# needed directly for its headers and, in source layouts, its library).
|
|
if(NOT DEFINED LOGOS_PROTOCOL_ROOT)
|
|
set(_parent_protocol "${CMAKE_SOURCE_DIR}/../logos-protocol")
|
|
if(DEFINED ENV{LOGOS_PROTOCOL_ROOT})
|
|
set(LOGOS_PROTOCOL_ROOT "$ENV{LOGOS_PROTOCOL_ROOT}" PARENT_SCOPE)
|
|
set(LOGOS_PROTOCOL_ROOT "$ENV{LOGOS_PROTOCOL_ROOT}")
|
|
elseif(EXISTS "${_parent_protocol}/cpp/logos_protocol.h")
|
|
set(LOGOS_PROTOCOL_ROOT "${_parent_protocol}" PARENT_SCOPE)
|
|
set(LOGOS_PROTOCOL_ROOT "${_parent_protocol}")
|
|
else()
|
|
set(LOGOS_PROTOCOL_ROOT "${CMAKE_SOURCE_DIR}/vendor/logos-protocol" PARENT_SCOPE)
|
|
set(LOGOS_PROTOCOL_ROOT "${CMAKE_SOURCE_DIR}/vendor/logos-protocol")
|
|
endif()
|
|
endif()
|
|
set(_protocol_found FALSE)
|
|
if(EXISTS "${LOGOS_PROTOCOL_ROOT}/cpp/logos_protocol.h" OR EXISTS "${LOGOS_PROTOCOL_ROOT}/include/cpp/logos_protocol.h")
|
|
set(_protocol_found TRUE)
|
|
endif()
|
|
|
|
if(NOT _module_found)
|
|
message(FATAL_ERROR "logos-module not found at ${LOGOS_MODULE_ROOT}. "
|
|
"Set LOGOS_MODULE_ROOT environment variable or CMake variable.")
|
|
endif()
|
|
|
|
if(NOT _cpp_sdk_found)
|
|
message(FATAL_ERROR "logos-cpp-sdk not found at ${LOGOS_CPP_SDK_ROOT}. "
|
|
"Set LOGOS_CPP_SDK_ROOT environment variable or CMake variable.")
|
|
endif()
|
|
if(NOT _qt_sdk_found)
|
|
message(FATAL_ERROR "logos-qt-sdk not found at ${LOGOS_QT_SDK_ROOT}. "
|
|
"Set LOGOS_QT_SDK_ROOT environment variable or CMake variable.")
|
|
endif()
|
|
if(NOT _qt_host_found)
|
|
message(FATAL_ERROR "No Qt host runtime found. Set LOGOS_QT_HOST_ROOT to an "
|
|
"installed logos-qt-host prefix (or a logos-plugin-qt "
|
|
"checkout) via environment or CMake variable. "
|
|
"LOGOS_QT_SDK_ROOT is not a substitute: logos-qt-sdk no "
|
|
"longer carries the host runtime's headers.")
|
|
endif()
|
|
if(NOT _protocol_found)
|
|
message(FATAL_ERROR "logos-protocol not found at ${LOGOS_PROTOCOL_ROOT}. "
|
|
"Set LOGOS_PROTOCOL_ROOT environment variable or CMake variable.")
|
|
endif()
|
|
|
|
message(STATUS "Found logos-module at: ${LOGOS_MODULE_ROOT}")
|
|
message(STATUS "Found logos-cpp-sdk at: ${LOGOS_CPP_SDK_ROOT}")
|
|
message(STATUS "Found logos-qt-sdk at: ${LOGOS_QT_SDK_ROOT}")
|
|
message(STATUS "Found logos-protocol at: ${LOGOS_PROTOCOL_ROOT}")
|
|
message(STATUS "Qt host runtime: logos-qt-host::logos_qt_host at ${LOGOS_QT_HOST_ROOT}")
|
|
endfunction()
|
|
|
|
#[=======================================================================[.rst:
|
|
logos_find_qt
|
|
-------------
|
|
|
|
Find Qt6 (or Qt5 as fallback) with required components.
|
|
|
|
Usage:
|
|
logos_find_qt()
|
|
|
|
Sets:
|
|
QT_VERSION_MAJOR - The major Qt version found (5 or 6)
|
|
#]=======================================================================]
|
|
# NOTE: this MUST be a macro, not a function. Qt's mingw
|
|
# Qt6EntryPointMinGW32Target.cmake guards itself with a bare include_guard()
|
|
# (variable-scoped) while creating a DIRECTORY-scoped imported target. If the
|
|
# first find_package(Qt6) runs inside a function scope, the guard variable and
|
|
# every <pkg>_FOUND marker die at endfunction() while the EntryPointMinGW32
|
|
# target survives, so the next find_package(Qt6) (via logos-protocol's /
|
|
# logos-qt-sdk's find_dependency) re-enters and hits
|
|
# "add_library cannot create imported target EntryPointMinGW32".
|
|
macro(logos_find_qt)
|
|
if(NOT DEFINED QT_VERSION_MAJOR)
|
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core RemoteObjects)
|
|
if(Qt6_FOUND)
|
|
set(QT_VERSION_MAJOR 6)
|
|
else()
|
|
set(QT_VERSION_MAJOR 5)
|
|
endif()
|
|
endif()
|
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core RemoteObjects)
|
|
endmacro()
|
|
|
|
#[=======================================================================[.rst:
|
|
logos_module
|
|
------------
|
|
|
|
Main function to define a Logos module plugin.
|
|
|
|
Usage:
|
|
logos_module(
|
|
NAME <module_name>
|
|
SOURCES <source_files...>
|
|
[EXTERNAL_LIBS <lib_names...>]
|
|
[FIND_PACKAGES <package_names...>]
|
|
[LINK_LIBRARIES <library_names...>]
|
|
[LINK_TARGETS <target_names...>]
|
|
[AUTOGEN_DEPENDS <target_names...>]
|
|
[INCLUDE_DIRS <directories...>]
|
|
[REP_FILE <path_to_rep_file>]
|
|
[QML_URI <uri>]
|
|
[QML_TYPE_NAME <type_name>]
|
|
)
|
|
|
|
Parameters:
|
|
NAME - (required) Module name
|
|
SOURCES - (required) Source files for the plugin
|
|
REP_FILE - Qt .rep file; builds a typed ``<name>_replica_factory`` plugin
|
|
and adds repc source/replica targets automatically
|
|
QML_URI - QML import URI for the replica factory (default: Logos.<ClassName>)
|
|
QML_TYPE_NAME - QML type name for the replica (default: <ClassName> from .rep)
|
|
|
|
Example:
|
|
logos_module(
|
|
NAME my_module
|
|
SOURCES
|
|
my_module_plugin.cpp
|
|
my_module_plugin.h
|
|
my_module_interface.h
|
|
EXTERNAL_LIBS
|
|
libfoo
|
|
LINK_TARGETS
|
|
my_custom_lib
|
|
AUTOGEN_DEPENDS
|
|
my_custom_lib
|
|
INCLUDE_DIRS
|
|
${CMAKE_CURRENT_BINARY_DIR}/generated
|
|
REP_FILE
|
|
my_module.rep
|
|
)
|
|
#]=======================================================================]
|
|
function(logos_module)
|
|
cmake_parse_arguments(
|
|
MODULE
|
|
""
|
|
"NAME;REP_FILE;QML_URI;QML_TYPE_NAME"
|
|
"SOURCES;EXTERNAL_LIBS;FIND_PACKAGES;LINK_LIBRARIES;LINK_TARGETS;AUTOGEN_DEPENDS;INCLUDE_DIRS"
|
|
${ARGN}
|
|
)
|
|
|
|
if(NOT MODULE_NAME)
|
|
message(FATAL_ERROR "logos_module: NAME is required")
|
|
endif()
|
|
|
|
# Which LogosModule.cmake configured this module. There is exactly one, and
|
|
# this line is how that stays true: a second copy anywhere in the tree names
|
|
# itself here instead of being silently selected.
|
|
message(STATUS "LogosModule.cmake: ${CMAKE_CURRENT_FUNCTION_LIST_FILE}")
|
|
|
|
# Find dependencies
|
|
logos_find_dependencies()
|
|
logos_find_qt()
|
|
|
|
# Embed metadata next to plugin sources (AUTOMOC / Q_PLUGIN_METADATA)
|
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/metadata.json")
|
|
configure_file(
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/metadata.json"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/metadata.json"
|
|
COPYONLY
|
|
)
|
|
endif()
|
|
|
|
# Root for dependencies
|
|
get_filename_component(LOGOS_DEPS_ROOT "${LOGOS_CPP_SDK_ROOT}" DIRECTORY)
|
|
|
|
# Set up generated code directory
|
|
if(LOGOS_CPP_SDK_IS_SOURCE)
|
|
set(PLUGINS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/generated_code")
|
|
else()
|
|
# For nix builds, generated files are in source tree
|
|
set(PLUGINS_OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated_code")
|
|
endif()
|
|
|
|
# Locate metadata.json - check build directory first, then source
|
|
set(METADATA_FILE "${CMAKE_CURRENT_SOURCE_DIR}/metadata.json")
|
|
if(NOT EXISTS "${METADATA_FILE}" AND EXISTS "${CMAKE_CURRENT_BINARY_DIR}/metadata.json")
|
|
set(METADATA_FILE "${CMAKE_CURRENT_BINARY_DIR}/metadata.json")
|
|
endif()
|
|
|
|
# Find additional packages
|
|
foreach(pkg ${MODULE_FIND_PACKAGES})
|
|
find_package(${pkg} REQUIRED)
|
|
endforeach()
|
|
|
|
# Collect sources
|
|
set(PLUGIN_SOURCES ${MODULE_SOURCES})
|
|
|
|
# Add logos-module interface header
|
|
if(LOGOS_MODULE_IS_SOURCE)
|
|
list(APPEND PLUGIN_SOURCES ${LOGOS_MODULE_ROOT}/src/interface.h)
|
|
else()
|
|
list(APPEND PLUGIN_SOURCES ${LOGOS_MODULE_ROOT}/include/module_lib/interface.h)
|
|
endif()
|
|
|
|
# Add Qt HOST RUNTIME sources (only if that root is a repo checkout — an
|
|
# installed prefix ships them as a static library, linked below). The
|
|
# transport/consumer core (token_manager, module_proxy, api_client/consumer)
|
|
# lives in the logos-protocol LIBRARY and is linked, never compiled in.
|
|
# LOGOS_QT_HOST_ROOT is a logos-plugin-qt checkout since the host-runtime
|
|
# split; it carries these files at exactly the paths logos-qt-sdk's did.
|
|
if(LOGOS_QT_HOST_IS_SOURCE)
|
|
list(APPEND PLUGIN_SOURCES
|
|
${LOGOS_QT_HOST_ROOT}/cpp/logos_api.cpp
|
|
${LOGOS_QT_HOST_ROOT}/cpp/logos_api.h
|
|
${LOGOS_QT_HOST_ROOT}/cpp/logos_api_provider.cpp
|
|
${LOGOS_QT_HOST_ROOT}/cpp/logos_api_provider.h
|
|
${LOGOS_QT_HOST_ROOT}/cpp/logos_provider_object.cpp
|
|
${LOGOS_QT_HOST_ROOT}/cpp/logos_provider_object.h
|
|
${LOGOS_QT_HOST_ROOT}/cpp/qt_provider_object.cpp
|
|
${LOGOS_QT_HOST_ROOT}/cpp/qt_provider_object.h
|
|
# qt_provider_object.cpp's dispatch calls into this; omitting it is
|
|
# an undefined symbol at link time, not a configure error.
|
|
${LOGOS_QT_HOST_ROOT}/cpp/logos_qt_arg_decode.cpp
|
|
${LOGOS_QT_HOST_ROOT}/cpp/logos_qt_arg_decode.h
|
|
)
|
|
endif()
|
|
if(LOGOS_CPP_SDK_IS_SOURCE)
|
|
# Add generated logos_sdk.cpp
|
|
list(APPEND PLUGIN_SOURCES ${PLUGINS_OUTPUT_DIR}/logos_sdk.cpp)
|
|
set_source_files_properties(
|
|
${PLUGINS_OUTPUT_DIR}/logos_sdk.cpp
|
|
PROPERTIES GENERATED TRUE
|
|
)
|
|
|
|
# Set up code generator
|
|
set(CPP_GENERATOR_BUILD_DIR "${LOGOS_DEPS_ROOT}/build/cpp-generator")
|
|
set(CPP_GENERATOR "${CPP_GENERATOR_BUILD_DIR}/bin/logos-cpp-generator")
|
|
|
|
if(NOT TARGET cpp_generator_build)
|
|
add_custom_target(cpp_generator_build
|
|
COMMAND bash "${LOGOS_CPP_SDK_ROOT}/cpp-generator/compile.sh"
|
|
WORKING_DIRECTORY "${LOGOS_DEPS_ROOT}"
|
|
COMMENT "Building logos-cpp-generator"
|
|
VERBATIM
|
|
)
|
|
endif()
|
|
|
|
# LOGOS_API_STYLE selects between Qt-typed and lp (Qt-free,
|
|
# logos-protocol C ABI) wrapper signatures on the generated
|
|
# `<Module>` client class. Defaults to "qt" — every existing
|
|
# handcrafted module keeps its Qt-typed LogosModules. Core
|
|
# universal modules (those declaring `interface: "universal"`
|
|
# in metadata.json, minus `type: ui_qml` view backends) get this
|
|
# set to "lp" automatically by mkLogosModule.nix.
|
|
if(NOT DEFINED LOGOS_API_STYLE OR LOGOS_API_STYLE STREQUAL "")
|
|
set(LOGOS_API_STYLE "qt")
|
|
endif()
|
|
add_custom_target(run_cpp_generator_${MODULE_NAME}
|
|
COMMAND "${CPP_GENERATOR}" --metadata "${METADATA_FILE}"
|
|
--general-only --api-style "${LOGOS_API_STYLE}"
|
|
--output-dir "${PLUGINS_OUTPUT_DIR}"
|
|
WORKING_DIRECTORY "${LOGOS_DEPS_ROOT}"
|
|
COMMENT "Running logos-cpp-generator for ${MODULE_NAME} (api-style=${LOGOS_API_STYLE})"
|
|
VERBATIM
|
|
)
|
|
add_dependencies(run_cpp_generator_${MODULE_NAME} cpp_generator_build)
|
|
else()
|
|
# For nix builds, logos_sdk.cpp is already generated
|
|
if(EXISTS "${PLUGINS_OUTPUT_DIR}/logos_sdk.cpp")
|
|
list(APPEND PLUGIN_SOURCES ${PLUGINS_OUTPUT_DIR}/logos_sdk.cpp)
|
|
elseif(EXISTS "${PLUGINS_OUTPUT_DIR}/include/logos_sdk.cpp")
|
|
list(APPEND PLUGIN_SOURCES ${PLUGINS_OUTPUT_DIR}/include/logos_sdk.cpp)
|
|
endif()
|
|
endif()
|
|
|
|
# Universal UI backends (type: ui_qml + interface: universal): the
|
|
# generated glue plugin — derived from the impl class by
|
|
# logos-qt-generator, carrying Q_PLUGIN_METADATA and the initLogos
|
|
# wiring — must be compiled into the target (the .h rides along so
|
|
# AUTOMOC picks up the plugin metadata).
|
|
if(EXISTS "${PLUGINS_OUTPUT_DIR}/${MODULE_NAME}_ui_glue.cpp")
|
|
list(APPEND PLUGIN_SOURCES
|
|
${PLUGINS_OUTPUT_DIR}/${MODULE_NAME}_ui_glue.cpp
|
|
${PLUGINS_OUTPUT_DIR}/${MODULE_NAME}_ui_glue.h)
|
|
endif()
|
|
|
|
|
|
# Create the plugin library
|
|
add_library(${MODULE_NAME}_module_plugin SHARED ${PLUGIN_SOURCES})
|
|
|
|
# Pre-generated sources from logos-cpp-generator (Nix preConfigure, universal/provider modules)
|
|
set(_LOGOS_GEN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated_code")
|
|
if(IS_DIRECTORY "${_LOGOS_GEN_DIR}")
|
|
file(GLOB _LOGOS_GEN_CPPS CONFIGURE_DEPENDS "${_LOGOS_GEN_DIR}/*.cpp")
|
|
file(GLOB _LOGOS_GEN_HS CONFIGURE_DEPENDS "${_LOGOS_GEN_DIR}/*.h")
|
|
# Exclude files that are #include'd by logos_sdk.cpp (not compiled separately):
|
|
# logos_sdk.cpp and per-dependency *_api.cpp files. core_manager
|
|
# is no longer generated (universal modules expose only their
|
|
# declared dependencies; apps that need to manage the core use
|
|
# liblogos' C API directly).
|
|
list(FILTER _LOGOS_GEN_CPPS EXCLUDE REGEX ".*/(logos_sdk|.*_api)\\.cpp$")
|
|
if(_LOGOS_GEN_CPPS OR _LOGOS_GEN_HS)
|
|
target_sources(${MODULE_NAME}_module_plugin PRIVATE ${_LOGOS_GEN_CPPS} ${_LOGOS_GEN_HS})
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE "${_LOGOS_GEN_DIR}")
|
|
endif()
|
|
endif()
|
|
|
|
# Set output name without lib prefix
|
|
set_target_properties(${MODULE_NAME}_module_plugin PROPERTIES
|
|
PREFIX ""
|
|
OUTPUT_NAME "${MODULE_NAME}_plugin"
|
|
)
|
|
|
|
# Add dependency on code generator for source layout
|
|
if(LOGOS_CPP_SDK_IS_SOURCE)
|
|
add_dependencies(${MODULE_NAME}_module_plugin run_cpp_generator_${MODULE_NAME})
|
|
endif()
|
|
|
|
# Link additional targets (e.g., protobuf libs defined by module)
|
|
foreach(target ${MODULE_LINK_TARGETS})
|
|
if(TARGET ${target})
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE ${target})
|
|
else()
|
|
message(FATAL_ERROR
|
|
"LINK_TARGETS target '${target}' was not defined before "
|
|
"logos_module(). Define it (e.g. add_library(${target} ...)) or "
|
|
"remove it from LINK_TARGETS. Refusing to silently drop a "
|
|
"configured link target.")
|
|
endif()
|
|
endforeach()
|
|
|
|
# Set AUTOGEN dependencies if specified (ensures AUTOMOC waits for these targets)
|
|
if(MODULE_AUTOGEN_DEPENDS)
|
|
set_target_properties(${MODULE_NAME}_module_plugin PROPERTIES
|
|
AUTOGEN_TARGET_DEPENDS "${MODULE_AUTOGEN_DEPENDS}"
|
|
)
|
|
endif()
|
|
|
|
# Include directories
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
${PLUGINS_OUTPUT_DIR}
|
|
)
|
|
|
|
# Add include directories based on layout type
|
|
if(LOGOS_MODULE_IS_SOURCE)
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE ${LOGOS_MODULE_ROOT}/src)
|
|
else()
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE ${LOGOS_MODULE_ROOT}/include/module_lib)
|
|
endif()
|
|
|
|
if(LOGOS_CPP_SDK_IS_SOURCE)
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE
|
|
${LOGOS_CPP_SDK_ROOT}/cpp
|
|
${LOGOS_CPP_SDK_ROOT}/cpp/generated
|
|
)
|
|
else()
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE
|
|
${LOGOS_CPP_SDK_ROOT}/include
|
|
${LOGOS_CPP_SDK_ROOT}/include/cpp
|
|
${PLUGINS_OUTPUT_DIR}/include
|
|
)
|
|
endif()
|
|
# Qt HOST RUNTIME headers (LogosAPI, provider glue, legacy PluginInterface
|
|
# at core/interface.h). Both roots have the same two shapes — a repo
|
|
# checkout (cpp/, core/) and an installed prefix (include/cpp,
|
|
# include/core) — so only the root changes with the repoint.
|
|
if(LOGOS_QT_HOST_IS_SOURCE)
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE
|
|
${LOGOS_QT_HOST_ROOT}/cpp
|
|
${LOGOS_QT_HOST_ROOT}/core
|
|
)
|
|
else()
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE
|
|
${LOGOS_QT_HOST_ROOT}/include
|
|
${LOGOS_QT_HOST_ROOT}/include/cpp
|
|
${LOGOS_QT_HOST_ROOT}/include/core
|
|
)
|
|
endif()
|
|
# The Qt-typed headers logos-qt-sdk owns — logos_qt_lp_bridge.h /
|
|
# logos_qt_wire.h (emitted by name into generated Qt consumer wrappers) and
|
|
# logos_ui_plugin_context.h. The two roots no longer share a header name, so
|
|
# the ordering against the host runtime's dirs is no longer load-bearing.
|
|
if(NOT "${LOGOS_QT_SDK_ROOT}" STREQUAL "${LOGOS_QT_HOST_ROOT}")
|
|
if(LOGOS_QT_SDK_IS_SOURCE)
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE
|
|
${LOGOS_QT_SDK_ROOT}/cpp
|
|
)
|
|
else()
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE
|
|
${LOGOS_QT_SDK_ROOT}/include
|
|
${LOGOS_QT_SDK_ROOT}/include/cpp
|
|
)
|
|
endif()
|
|
endif()
|
|
# Protocol layer headers (transports, consumer core, lp_* C ABI)
|
|
if(EXISTS "${LOGOS_PROTOCOL_ROOT}/cpp/logos_protocol.h")
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE
|
|
${LOGOS_PROTOCOL_ROOT}/cpp
|
|
)
|
|
else()
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE
|
|
${LOGOS_PROTOCOL_ROOT}/include
|
|
${LOGOS_PROTOCOL_ROOT}/include/cpp
|
|
)
|
|
endif()
|
|
|
|
# Add custom include directories
|
|
foreach(dir ${MODULE_INCLUDE_DIRS})
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE ${dir})
|
|
endforeach()
|
|
|
|
# Link Qt libraries
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE
|
|
Qt${QT_VERSION_MAJOR}::Core
|
|
Qt${QT_VERSION_MAJOR}::RemoteObjects
|
|
)
|
|
|
|
# Link the Qt HOST RUNTIME via its exported CMake target so the consumer
|
|
# inherits the full transitive link interface (logos-protocol, and through
|
|
# it OpenSSL, Boost::system, nlohmann_json). The protocol layer must come
|
|
# from an exported target — a bare archive on the link line would leave
|
|
# every Boost.Asio TLS symbol undefined.
|
|
if(NOT LOGOS_QT_HOST_IS_SOURCE)
|
|
find_package(logos-protocol REQUIRED CONFIG
|
|
PATHS ${LOGOS_PROTOCOL_ROOT}/lib/cmake/logos-protocol
|
|
NO_DEFAULT_PATH)
|
|
find_package(${LOGOS_QT_HOST_PACKAGE} REQUIRED CONFIG
|
|
PATHS ${LOGOS_QT_HOST_ROOT}/lib/cmake/${LOGOS_QT_HOST_PACKAGE}
|
|
NO_DEFAULT_PATH)
|
|
# find_package(... REQUIRED) already stops on a missing package, but a
|
|
# package that resolves without defining its target would leave the
|
|
# plugin with no host runtime and no diagnostic. Refuse that too.
|
|
if(NOT TARGET ${LOGOS_QT_HOST_TARGET})
|
|
message(FATAL_ERROR
|
|
"${LOGOS_QT_HOST_PACKAGE} was found at ${LOGOS_QT_HOST_ROOT} but did not "
|
|
"define ${LOGOS_QT_HOST_TARGET}. The Qt host runtime is not optional — "
|
|
"refusing to link ${MODULE_NAME}_module_plugin without it.")
|
|
endif()
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE ${LOGOS_QT_HOST_TARGET})
|
|
else()
|
|
# Source-layout host runtime: its sources are compiled into the plugin
|
|
# above; the protocol layer is linked installed-or-source here.
|
|
if(EXISTS "${LOGOS_PROTOCOL_ROOT}/lib/cmake/logos-protocol")
|
|
find_package(logos-protocol REQUIRED CONFIG
|
|
PATHS ${LOGOS_PROTOCOL_ROOT}/lib/cmake/logos-protocol
|
|
NO_DEFAULT_PATH)
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE logos-protocol::logos_protocol)
|
|
elseif(EXISTS "${LOGOS_PROTOCOL_ROOT}/cpp/CMakeLists.txt")
|
|
if(NOT TARGET logos_protocol)
|
|
add_subdirectory("${LOGOS_PROTOCOL_ROOT}/cpp"
|
|
"${CMAKE_BINARY_DIR}/logos-protocol-build")
|
|
endif()
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE logos_protocol)
|
|
else()
|
|
message(FATAL_ERROR "logos-protocol not usable at ${LOGOS_PROTOCOL_ROOT} "
|
|
"(need an installed prefix or a source checkout).")
|
|
endif()
|
|
endif()
|
|
|
|
# Qt-free base SDK headers (logos_module_context.h / logos_json.h /
|
|
# logos_result.h → nlohmann_json include path).
|
|
if(EXISTS "${LOGOS_CPP_SDK_ROOT}/lib/cmake/logos-cpp-sdk")
|
|
find_package(logos-cpp-sdk REQUIRED CONFIG
|
|
PATHS ${LOGOS_CPP_SDK_ROOT}/lib/cmake/logos-cpp-sdk
|
|
NO_DEFAULT_PATH)
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE logos-cpp-sdk::logos_headers)
|
|
else()
|
|
find_package(nlohmann_json REQUIRED)
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE nlohmann_json::nlohmann_json)
|
|
endif()
|
|
|
|
# Handle external libraries
|
|
foreach(ext_lib ${MODULE_EXTERNAL_LIBS})
|
|
# Allow nix dev shell (or any caller) to point directly at a store path
|
|
# by exporting LOGOS_EXT_ROOT_<NAME>=/nix/store/…, skipping the ./lib/ staging copy.
|
|
# The expected format is a package root laid out as lib/+include/ (a Nix
|
|
# derivation), unlike the ./lib/ fallback, which is one flat directory
|
|
# holding both the library and its headers.
|
|
string(TOUPPER "${ext_lib}" _ext_lib_upper)
|
|
set(_ext_root_var "LOGOS_EXT_ROOT_${_ext_lib_upper}")
|
|
if(DEFINED ENV{${_ext_root_var}})
|
|
set(EXT_LIB_DIR "$ENV{${_ext_root_var}}/lib")
|
|
set(EXT_INCLUDE_DIR "$ENV{${_ext_root_var}}/include")
|
|
else()
|
|
set(EXT_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
|
set(EXT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
|
endif()
|
|
|
|
# Find the library (prefer shared, fall back to static).
|
|
# On Windows a shared library is TWO files: you LINK against the import
|
|
# library (lib<x>.dll.a under mingw) and SHIP the .dll. Neither spelling
|
|
# appeared in these lists, so every external-library module failed to
|
|
# cross-compile with "was not found in .../lib".
|
|
if(WIN32)
|
|
set(EXT_LIB_NAMES lib${ext_lib}.dll.a ${ext_lib}.dll.a lib${ext_lib}.lib ${ext_lib}.lib lib${ext_lib}.dll ${ext_lib}.dll lib${ext_lib}.a ${ext_lib}.a)
|
|
elseif(APPLE)
|
|
set(EXT_LIB_NAMES lib${ext_lib}.dylib lib${ext_lib}.so ${ext_lib}.dylib ${ext_lib}.so lib${ext_lib}.a ${ext_lib}.a)
|
|
else()
|
|
set(EXT_LIB_NAMES lib${ext_lib}.so lib${ext_lib}.dylib ${ext_lib}.so ${ext_lib}.dylib lib${ext_lib}.a ${ext_lib}.a)
|
|
endif()
|
|
|
|
find_library(${ext_lib}_PATH NAMES ${EXT_LIB_NAMES} PATHS ${EXT_LIB_DIR} NO_DEFAULT_PATH)
|
|
|
|
if(${ext_lib}_PATH)
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE ${${ext_lib}_PATH})
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE ${EXT_INCLUDE_DIR})
|
|
|
|
# Copy shared libraries to output directory (static archives are
|
|
# linked in, no runtime copy needed).
|
|
#
|
|
# Windows needs care: what we just linked is usually the IMPORT
|
|
# library lib<x>.dll.a, whose name ends in ".a" and would therefore
|
|
# be mistaken for a static archive and skipped -- shipping a plugin
|
|
# with no runtime DLL beside it. Resolve the companion .dll and copy
|
|
# THAT instead.
|
|
get_filename_component(EXT_LIB_FILENAME "${${ext_lib}_PATH}" NAME)
|
|
set(EXT_RUNTIME_LIB "")
|
|
if(EXT_LIB_FILENAME MATCHES "\\.dll\\.a$" OR EXT_LIB_FILENAME MATCHES "\\.lib$")
|
|
get_filename_component(_ext_dir "${${ext_lib}_PATH}" DIRECTORY)
|
|
foreach(_dll_name lib${ext_lib}.dll ${ext_lib}.dll)
|
|
if(EXISTS "${_ext_dir}/${_dll_name}")
|
|
set(EXT_RUNTIME_LIB "${_ext_dir}/${_dll_name}")
|
|
set(EXT_LIB_FILENAME "${_dll_name}")
|
|
break()
|
|
endif()
|
|
endforeach()
|
|
if(NOT EXT_RUNTIME_LIB)
|
|
message(FATAL_ERROR
|
|
"External library '${ext_lib}': linked ${EXT_LIB_FILENAME} but found no "
|
|
"companion DLL in ${_ext_dir}. The plugin would build and then fail to "
|
|
"load at runtime, so refusing to continue.")
|
|
endif()
|
|
elseif(NOT EXT_LIB_FILENAME MATCHES "\\.a$")
|
|
set(EXT_RUNTIME_LIB "${${ext_lib}_PATH}")
|
|
endif()
|
|
if(EXT_RUNTIME_LIB)
|
|
add_custom_command(TARGET ${MODULE_NAME}_module_plugin PRE_LINK
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
${EXT_RUNTIME_LIB}
|
|
${CMAKE_BINARY_DIR}/modules/${EXT_LIB_FILENAME}
|
|
COMMENT "Copying ${EXT_LIB_FILENAME} to modules directory"
|
|
)
|
|
endif()
|
|
else()
|
|
message(FATAL_ERROR
|
|
"External library '${ext_lib}' (declared in EXTERNAL_LIBS / "
|
|
"metadata.json nix.external_libraries) was not found in "
|
|
"${EXT_LIB_DIR}. A configured external library must be present at "
|
|
"build time — check its vendor_path, externalLibInputs, or "
|
|
"build_command/output_pattern. Refusing to build a plugin with a "
|
|
"missing dependency.")
|
|
endif()
|
|
endforeach()
|
|
|
|
# Go/cgo static archives (whole-archive link). Set by mkLogosModule when metadata lists go_build externals.
|
|
if(DEFINED LOGOS_MODULE_GO_STATIC_LIBS AND NOT LOGOS_MODULE_GO_STATIC_LIBS STREQUAL "")
|
|
set(EXT_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
|
foreach(_golib IN LISTS LOGOS_MODULE_GO_STATIC_LIBS)
|
|
if(_golib STREQUAL "")
|
|
continue()
|
|
endif()
|
|
find_library(_LOGOS_GO_${_golib}
|
|
NAMES lib${_golib}.a lib${_golib}.lib ${_golib}.a ${_golib}.lib
|
|
PATHS ${EXT_LIB_DIR} NO_DEFAULT_PATH)
|
|
if(_LOGOS_GO_${_golib})
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE ${_LOGOS_GO_${_golib}})
|
|
if(APPLE)
|
|
target_link_options(${MODULE_NAME}_module_plugin PRIVATE -Wl,-force_load ${_LOGOS_GO_${_golib}})
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PUBLIC "-framework CoreFoundation" "-framework Security")
|
|
else()
|
|
target_link_options(${MODULE_NAME}_module_plugin PRIVATE
|
|
-Wl,--whole-archive ${_LOGOS_GO_${_golib}} -Wl,--no-whole-archive)
|
|
endif()
|
|
else()
|
|
message(FATAL_ERROR
|
|
"Go static library '${_golib}' (a go_build external library) "
|
|
"was not found in ${EXT_LIB_DIR}. Check the external build "
|
|
"produced lib${_golib}.a. Refusing to build a plugin with a "
|
|
"missing dependency.")
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
|
|
# Rust static archives. Set by mkLogosModule when a cdylib module is authored
|
|
# in Rust (metadata codegen.rust): the builder compiles the crate to a
|
|
# staticlib and stages it in lib/. The archive provides the logos_module_*
|
|
# exports the generated Qt glue calls; its own lp_* undefineds resolve against
|
|
# the logos-protocol archive already linked above (via logos-qt-sdk). Plain
|
|
# link (NOT whole-archive: the Rust install hook is pulled in lazily by a
|
|
# symbol reference), with the protocol target re-mentioned AFTER the archive
|
|
# so single-pass linkers (GNU ld) see it later on the line — one protocol
|
|
# stack shared by the glue and the Rust code.
|
|
if(DEFINED LOGOS_MODULE_RUST_STATIC_LIBS AND NOT LOGOS_MODULE_RUST_STATIC_LIBS STREQUAL "")
|
|
set(_LOGOS_RUST_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
|
foreach(_rustlib IN LISTS LOGOS_MODULE_RUST_STATIC_LIBS)
|
|
if(_rustlib STREQUAL "")
|
|
continue()
|
|
endif()
|
|
find_library(_LOGOS_RUST_${_rustlib}
|
|
NAMES lib${_rustlib}.a ${_rustlib}
|
|
PATHS ${_LOGOS_RUST_LIB_DIR} NO_DEFAULT_PATH)
|
|
if(_LOGOS_RUST_${_rustlib})
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE ${_LOGOS_RUST_${_rustlib}})
|
|
if(TARGET logos-protocol::logos_protocol)
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE logos-protocol::logos_protocol)
|
|
elseif(TARGET logos_protocol)
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE logos_protocol)
|
|
endif()
|
|
# Native libraries Rust's `std` leaves undefined in a staticlib.
|
|
# These are per-platform and NOT interchangeable: the old
|
|
# two-way APPLE/else split silently meant "else == Linux" and
|
|
# put `pthread dl` on the Windows link line, where `dl` does not
|
|
# exist at all and `pthread` lives in a separate
|
|
# mingw_w64-pthreads package that is not on the sysroot search
|
|
# path -- so a Rust module could never link for Windows.
|
|
if(APPLE)
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE
|
|
"-framework CoreFoundation" "-framework Security")
|
|
elseif(WIN32)
|
|
# Derived from the archive's own undefined symbols, not
|
|
# guessed: BCryptGenRandom -> bcrypt; Nt*/Rtl* (file I/O and
|
|
# the unwinder) -> ntdll; GetUserProfileDirectoryW ->
|
|
# userenv; WaitOnAddress/WakeByAddress* -> synchronization
|
|
# (kernel32's mingw import lib does not carry them); the
|
|
# WSA*/socket set -> ws2_32. `ProcessPrng` needs nothing
|
|
# here -- std bundles its own bcryptprimitives import stubs
|
|
# inside the archive. Qt happens to drag several of these in
|
|
# already, but naming them keeps the Rust link independent
|
|
# of Qt's link interface.
|
|
# `pthread` is winpthreads, which mkLogosModule adds as a
|
|
# build input for a cross Rust module (see the note there).
|
|
# It is NOT part of the mingw sysroot -- nixpkgs builds mingw
|
|
# against mcfgthread -- but a crate's vendored C can still
|
|
# want it: aws-lc-sys compiles aws-lc's thread_pthread.c.
|
|
# ld pulls archive members on demand, so naming it costs
|
|
# nothing for a module that references no pthread symbol.
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE
|
|
ws2_32 bcrypt ntdll userenv synchronization advapi32 pthread)
|
|
else()
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE pthread dl)
|
|
endif()
|
|
else()
|
|
message(FATAL_ERROR
|
|
"Rust static library '${_rustlib}' (a codegen.rust module) was not "
|
|
"found in ${_LOGOS_RUST_LIB_DIR}. The builder stages the compiled "
|
|
"staticlib there before the plugin link; this usually means the "
|
|
"crate build or staging step did not run.")
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
|
|
# Link additional libraries
|
|
foreach(lib ${MODULE_LINK_LIBRARIES})
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE ${lib})
|
|
endforeach()
|
|
|
|
# Output directory and RPATH settings
|
|
set_target_properties(${MODULE_NAME}_module_plugin PROPERTIES
|
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules"
|
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules"
|
|
BUILD_WITH_INSTALL_RPATH TRUE
|
|
SKIP_BUILD_RPATH FALSE
|
|
)
|
|
|
|
if(APPLE)
|
|
# Allow unresolved symbols at link time for external libs
|
|
target_link_options(${MODULE_NAME}_module_plugin PRIVATE -undefined dynamic_lookup)
|
|
|
|
set_target_properties(${MODULE_NAME}_module_plugin PROPERTIES
|
|
INSTALL_RPATH "@loader_path"
|
|
INSTALL_NAME_DIR "@rpath"
|
|
BUILD_WITH_INSTALL_NAME_DIR TRUE
|
|
)
|
|
|
|
add_custom_command(TARGET ${MODULE_NAME}_module_plugin POST_BUILD
|
|
COMMAND install_name_tool -id "@rpath/${MODULE_NAME}_plugin.dylib"
|
|
$<TARGET_FILE:${MODULE_NAME}_module_plugin>
|
|
COMMENT "Updating library paths for macOS"
|
|
)
|
|
else()
|
|
set_target_properties(${MODULE_NAME}_module_plugin PROPERTIES
|
|
INSTALL_RPATH "$ORIGIN"
|
|
INSTALL_RPATH_USE_LINK_PATH FALSE
|
|
)
|
|
endif()
|
|
|
|
# Install targets
|
|
install(TARGETS ${MODULE_NAME}_module_plugin
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/logos/modules
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/logos/modules
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/logos/modules
|
|
)
|
|
|
|
install(DIRECTORY "${PLUGINS_OUTPUT_DIR}/"
|
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/logos-${MODULE_NAME}-module/generated
|
|
OPTIONAL
|
|
)
|
|
|
|
# ── Optional: typed replica factory plugin from a .rep file ─────────────
|
|
if(MODULE_REP_FILE)
|
|
_logos_module_add_replica_factory(${MODULE_NAME} "${MODULE_REP_FILE}"
|
|
"${MODULE_QML_URI}" "${MODULE_QML_TYPE_NAME}")
|
|
endif()
|
|
|
|
message(STATUS "Logos module ${MODULE_NAME} configured successfully")
|
|
endfunction()
|
|
|
|
# ── Internal: build a <name>_replica_factory Qt plugin from a .rep file ─────
|
|
function(_logos_module_add_replica_factory MODULE_NAME REP_FILE QML_URI QML_TYPE_NAME)
|
|
# Need repc replica generation + Qml for qmlRegisterUncreatableMetaObject
|
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core RemoteObjects Qml)
|
|
|
|
# Also attach the source-side repc to the plugin target so the backend has
|
|
# the generated SimpleSource base class available.
|
|
if(QT_VERSION_MAJOR EQUAL 6)
|
|
qt6_add_repc_sources(${MODULE_NAME}_module_plugin ${REP_FILE})
|
|
else()
|
|
qt5_add_repc_sources(${MODULE_NAME}_module_plugin ${REP_FILE})
|
|
endif()
|
|
|
|
# Parse class name out of the .rep (first `class Foo` line).
|
|
set(_REP_FILE_ABS "${REP_FILE}")
|
|
if(NOT IS_ABSOLUTE "${_REP_FILE_ABS}")
|
|
set(_REP_FILE_ABS "${CMAKE_CURRENT_SOURCE_DIR}/${REP_FILE}")
|
|
endif()
|
|
file(READ "${_REP_FILE_ABS}" _REP_CONTENTS)
|
|
string(REGEX MATCH "class[ \t]+([A-Za-z_][A-Za-z0-9_]*)" _ "${_REP_CONTENTS}")
|
|
set(LOGOS_REP_CLASS "${CMAKE_MATCH_1}")
|
|
if(NOT LOGOS_REP_CLASS)
|
|
message(FATAL_ERROR "logos_module: could not parse class name from ${REP_FILE}")
|
|
endif()
|
|
|
|
get_filename_component(LOGOS_REP_BASE "${REP_FILE}" NAME_WE)
|
|
set(LOGOS_FACTORY_CLASS "${LOGOS_REP_CLASS}ReplicaFactoryPlugin")
|
|
|
|
if(NOT QML_URI)
|
|
set(QML_URI "Logos.${LOGOS_REP_CLASS}")
|
|
endif()
|
|
if(NOT QML_TYPE_NAME)
|
|
set(QML_TYPE_NAME "${LOGOS_REP_CLASS}")
|
|
endif()
|
|
set(LOGOS_QML_URI "${QML_URI}")
|
|
set(LOGOS_QML_TYPE_NAME "${QML_TYPE_NAME}")
|
|
|
|
# WHERE the LogosView*.in templates come from: logos-view-module's cmake/,
|
|
# handed in as LOGOS_VIEW_TEMPLATE_DIR (a cmake flag and an env var, both
|
|
# set by logos-module-builder — i.e. by THIS repo, the one shipping this
|
|
# file: lib/mkLogosModule.nix and lib/buildCppPlugin.nix set them on every
|
|
# plugin build and export the env var in every module dev shell).
|
|
#
|
|
# This used to be "sibling of this .cmake file", with a pathExists probe
|
|
# falling through to CMAKE_CURRENT_LIST_DIR. The templates therefore lived
|
|
# next to this file, in logos-module-builder — but a second consumer
|
|
# instantiates them too (the rep-file-plugin fixture that proves a built
|
|
# plugin still loads and casts), and it cannot depend on
|
|
# logos-module-builder, so it kept its own byte-identical copy and nothing
|
|
# compared the two. Ownership went first to logos-plugin-qt, and then on to
|
|
# logos-view-module, which owns the whole ui_qml authoring flavour — the
|
|
# fixture included — and is a LEAF, so every consumer can reach it. See
|
|
# logos-view-module/cmake/README.md.
|
|
#
|
|
# There is no fallback. A sibling-directory fallback is what let a second
|
|
# copy be picked silently, and the whole point of naming the directory is
|
|
# that a wrong or absent answer is loud.
|
|
if(NOT LOGOS_VIEW_TEMPLATE_DIR AND DEFINED ENV{LOGOS_VIEW_TEMPLATE_DIR})
|
|
set(LOGOS_VIEW_TEMPLATE_DIR "$ENV{LOGOS_VIEW_TEMPLATE_DIR}")
|
|
endif()
|
|
if(NOT LOGOS_VIEW_TEMPLATE_DIR)
|
|
message(FATAL_ERROR
|
|
"logos_module(REP_FILE ...): LOGOS_VIEW_TEMPLATE_DIR is not set. "
|
|
"The LogosView*.in templates are owned by logos-view-module "
|
|
"(cmake/), and logos-module-builder — the repo shipping this "
|
|
"LogosModule.cmake — passes this in for every plugin build and "
|
|
"exports it in every module dev shell. Set it to that directory; "
|
|
"there is no local copy to fall back to.")
|
|
endif()
|
|
set(_TEMPLATE_DIR "${LOGOS_VIEW_TEMPLATE_DIR}")
|
|
foreach(_tpl LogosViewReplicaFactory.h.in LogosViewReplicaFactory.cpp.in
|
|
LogosViewPluginBase.h.in LogosViewPluginBase.cpp.in)
|
|
if(NOT EXISTS "${_TEMPLATE_DIR}/${_tpl}")
|
|
message(FATAL_ERROR
|
|
"logos_module(REP_FILE ...): ${_tpl} is missing from "
|
|
"LOGOS_VIEW_TEMPLATE_DIR (${_TEMPLATE_DIR}).")
|
|
endif()
|
|
endforeach()
|
|
|
|
set(_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/replica_factory_${MODULE_NAME}")
|
|
file(MAKE_DIRECTORY "${_GEN_DIR}")
|
|
configure_file("${_TEMPLATE_DIR}/LogosViewReplicaFactory.h.in"
|
|
"${_GEN_DIR}/LogosViewReplicaFactory.h" @ONLY)
|
|
configure_file("${_TEMPLATE_DIR}/LogosViewReplicaFactory.cpp.in"
|
|
"${_GEN_DIR}/LogosViewReplicaFactory.cpp" @ONLY)
|
|
|
|
# Generate the per-module LogosViewPlugin base that plugins inherit
|
|
# from. It implements viewObject() + enableRemoting() so ui-host can
|
|
# drive the plugin via a plain qobject_cast<LogosViewPlugin*> instead
|
|
# of QMetaObject::invokeMethod reflection.
|
|
set(_VIEW_PLUGIN_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/view_plugin_base_${MODULE_NAME}")
|
|
file(MAKE_DIRECTORY "${_VIEW_PLUGIN_GEN_DIR}")
|
|
configure_file("${_TEMPLATE_DIR}/LogosViewPluginBase.h.in"
|
|
"${_VIEW_PLUGIN_GEN_DIR}/LogosViewPluginBase.h" @ONLY)
|
|
configure_file("${_TEMPLATE_DIR}/LogosViewPluginBase.cpp.in"
|
|
"${_VIEW_PLUGIN_GEN_DIR}/LogosViewPluginBase.cpp" @ONLY)
|
|
target_sources(${MODULE_NAME}_module_plugin PRIVATE
|
|
"${_VIEW_PLUGIN_GEN_DIR}/LogosViewPluginBase.h"
|
|
"${_VIEW_PLUGIN_GEN_DIR}/LogosViewPluginBase.cpp"
|
|
)
|
|
target_include_directories(${MODULE_NAME}_module_plugin PRIVATE
|
|
"${_VIEW_PLUGIN_GEN_DIR}"
|
|
)
|
|
target_link_libraries(${MODULE_NAME}_module_plugin PRIVATE
|
|
Qt${QT_VERSION_MAJOR}::RemoteObjects
|
|
)
|
|
|
|
set(_FACTORY_TARGET ${MODULE_NAME}_replica_factory)
|
|
add_library(${_FACTORY_TARGET} SHARED
|
|
"${_GEN_DIR}/LogosViewReplicaFactory.h"
|
|
"${_GEN_DIR}/LogosViewReplicaFactory.cpp"
|
|
)
|
|
|
|
set_target_properties(${_FACTORY_TARGET} PROPERTIES
|
|
AUTOMOC ON
|
|
PREFIX ""
|
|
OUTPUT_NAME "${MODULE_NAME}_replica_factory"
|
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules"
|
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/modules"
|
|
BUILD_WITH_INSTALL_RPATH TRUE
|
|
SKIP_BUILD_RPATH FALSE
|
|
INSTALL_NAME_DIR "@rpath"
|
|
)
|
|
if(APPLE)
|
|
target_link_options(${_FACTORY_TARGET} PRIVATE "-Wl,-headerpad_max_install_names")
|
|
endif()
|
|
|
|
target_include_directories(${_FACTORY_TARGET} PRIVATE
|
|
"${_GEN_DIR}"
|
|
"${CMAKE_CURRENT_BINARY_DIR}"
|
|
)
|
|
if(QT_VERSION_MAJOR EQUAL 6)
|
|
qt6_add_repc_replicas(${_FACTORY_TARGET} ${REP_FILE})
|
|
else()
|
|
qt5_add_repc_replicas(${_FACTORY_TARGET} ${REP_FILE})
|
|
endif()
|
|
|
|
target_link_libraries(${_FACTORY_TARGET} PRIVATE
|
|
Qt${QT_VERSION_MAJOR}::Core
|
|
Qt${QT_VERSION_MAJOR}::RemoteObjects
|
|
Qt${QT_VERSION_MAJOR}::Qml
|
|
)
|
|
|
|
if(APPLE)
|
|
set_target_properties(${_FACTORY_TARGET} PROPERTIES
|
|
INSTALL_RPATH "@loader_path"
|
|
INSTALL_NAME_DIR "@rpath"
|
|
BUILD_WITH_INSTALL_NAME_DIR TRUE
|
|
)
|
|
add_custom_command(TARGET ${_FACTORY_TARGET} POST_BUILD
|
|
COMMAND install_name_tool -id "@rpath/${MODULE_NAME}_replica_factory.dylib"
|
|
$<TARGET_FILE:${_FACTORY_TARGET}>
|
|
COMMENT "Updating library paths for macOS"
|
|
)
|
|
else()
|
|
set_target_properties(${_FACTORY_TARGET} PROPERTIES
|
|
INSTALL_RPATH "$ORIGIN"
|
|
INSTALL_RPATH_USE_LINK_PATH FALSE
|
|
)
|
|
endif()
|
|
|
|
install(TARGETS ${_FACTORY_TARGET}
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/logos/modules
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/logos/modules
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/logos/modules
|
|
)
|
|
|
|
message(STATUS "Logos module ${MODULE_NAME}: replica factory plugin from ${REP_FILE} "
|
|
"(class ${LOGOS_REP_CLASS}, QML ${LOGOS_QML_URI}.${LOGOS_QML_TYPE_NAME})")
|
|
endfunction()
|