mirror of
https://github.com/logos-co/logos-cpp-sdk.git
synced 2026-08-30 09:11:13 +00:00
* fix: read dependency entries declared in object form The manifest schema lets a dependency entry be an object carrying the name alongside the constraints an installer resolves it by, but every reader took the element as a plain string and skipped what came back empty, so an object entry disappeared: the module it names was left out of the generated LogosModules aggregate, and every call through it failed to compile. The rule lives in one place now, since the copies of it are how the gap spread. It ships in share/lidl-frontend alongside the parser that includes it, which consumers compile from there. * fix: read every dependency entry through one pass over the array The object form reached the umbrella's members and constructor but not its includes: that emitter still read each element as a plain string, so a module declared in object form came out as a member whose type was never included, and the aggregate no longer compiled. It is the Qt-free umbrella, which is what every universal core module and every cdylib module generates, so the form the previous commit set out to support failed there in a new way rather than working. Reading the array element by element is what let one pass disagree with the next, so no reader does that any more: dependencyNames() answers what an array declares, once, and the emitters walk names. That leaves the entry form knowable in exactly one place, and the includes and members of an aggregate can no longer be built from different answers. The umbrella emission moves to generator_lib alongside the per-module wrapper emitters it mirrors, returning the text instead of writing it, so what it generates can be asserted on directly; main.cpp writes what it returns. Output for string-form dependencies is byte-identical in both API styles, with and without interface dependencies. The listing mode (`--metadata` with no `--module-dir`) went the same way — it was the last reader still deciding on its own. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Dario Gabriel Lipicar <dario@status.im> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
46 lines
1.5 KiB
C
46 lines
1.5 KiB
C
#ifndef METADATA_DEPENDENCIES_H
|
|
#define METADATA_DEPENDENCIES_H
|
|
|
|
#include <QJsonArray>
|
|
#include <QJsonObject>
|
|
#include <QJsonValue>
|
|
#include <QString>
|
|
#include <QStringList>
|
|
|
|
/// The module named by one `metadata.json` `dependencies[]` element.
|
|
///
|
|
/// An element is either a bare name or an object holding that name alongside
|
|
/// the constraints an installer resolves it by (version range, signer DID);
|
|
/// generation needs the name only. Empty for an element that names nothing.
|
|
inline QString dependencyName(const QJsonValue& entry)
|
|
{
|
|
if (entry.isString()) {
|
|
return entry.toString();
|
|
}
|
|
if (entry.isObject()) {
|
|
return entry.toObject().value("name").toString();
|
|
}
|
|
return QString();
|
|
}
|
|
|
|
/// Every module named by a `metadata.json` `dependencies[]` array, in order.
|
|
///
|
|
/// Read the array through this rather than iterating it: an emitter that walks
|
|
/// `deps` itself decides on its own what an element names, and one that decides
|
|
/// differently from its neighbours emits an aggregate whose members and includes
|
|
/// disagree — which does not fail until the generated code is compiled.
|
|
/// Elements that name nothing are dropped.
|
|
inline QStringList dependencyNames(const QJsonArray& entries)
|
|
{
|
|
QStringList names;
|
|
for (const QJsonValue& entry : entries) {
|
|
const QString name = dependencyName(entry);
|
|
if (!name.isEmpty()) {
|
|
names.append(name);
|
|
}
|
|
}
|
|
return names;
|
|
}
|
|
|
|
#endif // METADATA_DEPENDENCIES_H
|