Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 36 additions & 19 deletions .github/workflows/reusable/cached-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,43 @@ description: "install dependencies, build and cache result, or restore from cach
runs:
using: "composite"
steps:
- name: cache homedir
# The cache keys must distinguish the TARGET platform, not just the
# runner: the macOS host build, the iOS build and the Android build
# all run on the same macos runner image, and GitHub's cache is
# write-once per key — with a shared key the first job to save owns
# the cache forever and the other platforms' saves fail ("Cache save
# failed."), so their dependencies were rebuilt from source on every
# run (~30 min Android, ~35 min iOS). ARCHFLAGS is the workflow-level
# platform selector (empty = host, --ios, --android). The vcpkg
# submodule commit is part of the key because the tool version
# changes what it builds; the restore-keys prefix fallback reuses the
# newest previous cache on any key miss — vcpkg's own per-package ABI
# hashing makes stale archive entries harmless (they are ignored) and
# `vcpkg install` reconciles a stale installed tree.
- name: compute cache keys
id: keys
run: |
echo "platform=${ARCHFLAGS:-host}" >> "$GITHUB_OUTPUT"
echo "vcpkg_sha=$(git rev-parse HEAD:vcpkg)" >> "$GITHUB_OUTPUT"
shell: bash
- name: cache vcpkg binary archives
id: cache-homedir
uses: actions/cache/restore@v4
with:
key: ${{ runner.arch }}-${{ runner.os }}-cache-homedir2-${{ hashFiles('./vcpkg.json', './overlaytriplets/**', './overlayports/**') }}
key: ${{ runner.arch }}-${{ runner.os }}-${{ steps.keys.outputs.platform }}-archives-${{ steps.keys.outputs.vcpkg_sha }}-${{ hashFiles('./vcpkg.json', './overlaytriplets/**', './overlayports/**') }}
restore-keys: |
${{ runner.arch }}-${{ runner.os }}-${{ steps.keys.outputs.platform }}-archives-${{ steps.keys.outputs.vcpkg_sha }}-
${{ runner.arch }}-${{ runner.os }}-${{ steps.keys.outputs.platform }}-archives-
path: |
~/.cache/vcpkg/archives
- name: cache vcpkg installed
id: cache-vcpkg-installed
uses: actions/cache/restore@v4
with:
key: ${{ runner.arch }}-${{ runner.os }}-cache-vcpkg-installed2-${{ hashFiles('./vcpkg.json', './overlaytriplets/**', './overlayports/**') }}
key: ${{ runner.arch }}-${{ runner.os }}-${{ steps.keys.outputs.platform }}-installed-${{ steps.keys.outputs.vcpkg_sha }}-${{ hashFiles('./vcpkg.json', './overlaytriplets/**', './overlayports/**') }}
restore-keys: |
${{ runner.arch }}-${{ runner.os }}-${{ steps.keys.outputs.platform }}-installed-${{ steps.keys.outputs.vcpkg_sha }}-
${{ runner.arch }}-${{ runner.os }}-${{ steps.keys.outputs.platform }}-installed-
path: |
./build/vcpkg_installed
- name: install-prerequisities
Expand Down Expand Up @@ -45,30 +70,22 @@ runs:
exit "$EXITCODE"
fi
shell: bash
- name: cache homedir save
# Save even on failure (if: always()) so a partially built dependency
# set is reused by the retry. Saving is skipped when the exact key was
# already restored (nothing new to store).
- name: cache vcpkg binary archives save
id: cache-homedir-save
if: always()
if: always() && steps.cache-homedir.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.arch }}-${{ runner.os }}-cache-homedir2-${{ hashFiles('./vcpkg.json', './overlaytriplets/**', './overlayports/**') }}
key: ${{ runner.arch }}-${{ runner.os }}-${{ steps.keys.outputs.platform }}-archives-${{ steps.keys.outputs.vcpkg_sha }}-${{ hashFiles('./vcpkg.json', './overlaytriplets/**', './overlayports/**') }}
path: |
~/.cache/vcpkg/archives
- name: cache vcpkg installed save
id: cache-vcpkg-installed-save
if: always()
if: always() && steps.cache-vcpkg-installed.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.arch }}-${{ runner.os }}-cache-vcpkg-installed2-${{ hashFiles('./vcpkg.json', './overlaytriplets/**', './overlayports/**') }}
key: ${{ runner.arch }}-${{ runner.os }}-${{ steps.keys.outputs.platform }}-installed-${{ steps.keys.outputs.vcpkg_sha }}-${{ hashFiles('./vcpkg.json', './overlaytriplets/**', './overlayports/**') }}
path: |
./build/vcpkg_installed
#- name: Commit compiled binaries
# run: |
# git config --global user.name 'github-actions[bot]'
# git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# git add packages/streamr-libstreamrproxyclient/dist
# git add packages/streamr-libstreamrproxyclient/wrappers/go
# git commit -m "Automatically compiled binaries"
# git pull --rebase --no-edit
# git push --no-verify
# shell: bash

26 changes: 25 additions & 1 deletion MODERNIZATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,31 @@ exactly that. So consolidation walks the dependency chain from the top:
version accepts it — owner-approved selective disabling, compiler
coverage unaffected (fourth exclusion overall; revisit each clangd
release).
7. C-7 streamr-json
7. **C-7 streamr-json** ✅ — the 3 headers (jsonConcepts, toJson,
toString) became named sub-modules (`streamr.json.X`); façade and
include/ tree deleted; the 4 importers (json's own tests + example)
flipped to narrow imports, and the logger units' temporary TEXTUAL
`streamr-json/toJson.hpp` include from C-6 flipped to
`import streamr.json.toJson;`. First conversion with zero compile
errors on the first whole-tree build — the accumulated rules
(std-include pass, curated-name consumer flip, minimal imports,
inline-constexpr, GMF-only C declarations) now cover the whole
failure surface.
**The same PR repairs the CI dependency caching** (owner asked for it
to be folded in): the C-2 consolidation commit had accidentally
REVERTED PR #41's per-platform cache keys in
`.github/workflows/reusable/cached-install/action.yml` (a rebase
mishap — #41 and C-2 were in flight simultaneously). Since C-2 the
Android/iOS jobs shared one `ARM64-macOS-…` key with the host macOS
leg; the host job saved first and owned the write-once key, so the
cross builds restored a useless host cache and rebuilt every vcpkg
dependency from source — degrading as the old per-platform entries
were LRU-evicted (repo cache 11.7 GB > 10 GB cap): Android leg C-3
48 min → C-6 139/123 min. The #41 scheme (`${ARCHFLAGS:-host}`
platform component + vcpkg submodule SHA + restore-keys fallbacks +
skip-save-on-exact-hit) is restored verbatim; the first post-merge
run per platform repopulates the caches (slow once), after which
Android returns to ~10 min and iOS to ~5 min.
8. C-8 streamr-eventemitter (+ final bench.sh metrics and memo closure)

One package per PR, `bench.sh` measured at the dht step and at the end
Expand Down
17 changes: 7 additions & 10 deletions packages/streamr-json/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,16 @@ endif()
# project() because it inspects the compiler id.
include(${CMAKE_CURRENT_SOURCE_DIR}/StreamrModules.cmake)

# Module façade (MODERNIZATION.md Part 2): the package is now a STATIC
# library whose module interface units re-export the public headers.
# #include consumers are unaffected; import consumers get the BMIs.
# CONSOLIDATED (MODERNIZATION.md Phase 2.6): one named sub-module per
# former public header (settled architecture: no umbrella). The include/
# tree is gone; the module interface units are the source of truth, so
# the package no longer exports any include directory.
file(GLOB_RECURSE STREAMR_JSON_MODULE_UNITS CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/modules/*.cppm)
streamr_add_module_library(streamr-json
FILES
modules/streamr.json.cppm
modules/streamr.json-all.cppm)
FILES ${STREAMR_JSON_MODULE_UNITS})
add_library(streamr::streamr-json ALIAS streamr-json)

target_include_directories(
streamr-json PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

# PUBLIC (was INTERFACE): the module interface units themselves compile
# against boost-pfr/nlohmann in their global module fragments.
target_link_libraries(streamr-json PUBLIC Boost::pfr)
Expand Down
9 changes: 6 additions & 3 deletions packages/streamr-json/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ clangd-tidy -p ./build $FILES
echo "Running clang-format --dry-run on $FILES"
../../run-clang-format.py $FILES

# Module interface units: format check only. clangd-tidy is not run on
# .cppm files (headers remain the fully linted source of truth during the
# façade migration; clangd modules support is still experimental).
# CONSOLIDATED (MODERNIZATION.md Phase 2.6): the include/ tree is gone —
# the code lives in the module interface units, which are linted with
# clangd-tidy as the source of truth.
MODULE_FILES=$(find ./modules -type f -name "*.cppm" 2>/dev/null | xargs echo)
if [ -n "$MODULE_FILES" ]; then
echo "Running clangd-tidy on $MODULE_FILES"
clangd-tidy -p ./build $MODULE_FILES

echo "Running clang-format --dry-run on $MODULE_FILES"
../../run-clang-format.py $MODULE_FILES
fi
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
#ifndef STREAMR_JSON_JSONCONCEPTS_HPP
#define STREAMR_JSON_JSONCONCEPTS_HPP

// Module streamr.json.jsonConcepts
// CONSOLIDATED from the former header
// streamr-json/jsonConcepts.hpp (MODERNIZATION.md Phase 2.6):
// this file is now the source of truth.
module;

#include <initializer_list>
#include <string>
#include <string_view>
#include <type_traits>
#include <boost/pfr/traits.hpp>
#include <nlohmann/json.hpp>

namespace streamr::json {
export module streamr.json.jsonConcepts;

export namespace streamr::json {
namespace suppresslint { // linter does not support concepts, and thinks this
// file is unused
using SuppressLint = void;
Expand Down Expand Up @@ -88,6 +97,4 @@ std::initializer_list<noaland::i_dont_care>>);
};
*/

} // namespace streamr::json

#endif // STREAMR_JSON_JSONCONCEPTS_HPP
} // namespace streamr::json
48 changes: 0 additions & 48 deletions packages/streamr-json/modules/streamr.json-all.cppm

This file was deleted.

4 changes: 0 additions & 4 deletions packages/streamr-json/modules/streamr.json.cppm

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
#ifndef STREAMR_JSON_TOJSON_HPP
#define STREAMR_JSON_TOJSON_HPP
// Module streamr.json.toJson
// CONSOLIDATED from the former header
// streamr-json/toJson.hpp (MODERNIZATION.md Phase 2.6):
// this file is now the source of truth.
module;

#include <cstddef>
#include <initializer_list>
#include <map>
#include <string>
#include <string_view>
#include <type_traits>
#include <vector>
#include <boost/pfr.hpp>
#include <boost/pfr/core.hpp>
#include <boost/pfr/core_name.hpp>
#include <boost/pfr/traits.hpp>
#include <boost/pfr/tuple_size.hpp>
#include <nlohmann/json.hpp>

#include "streamr-json/jsonConcepts.hpp"
namespace streamr::json {
export module streamr.json.toJson;

import streamr.json.jsonConcepts;

export namespace streamr::json {
using suppresslint::SuppressLint; // otherwise linter thinks jsonConcepts.hpp
// is unused
using json = nlohmann::json;
Expand Down Expand Up @@ -253,6 +263,4 @@ json toJson(const T& value) {

using StreamrJsonInitializerList = std::initializer_list<JsonBuilder>;

} // namespace streamr::json

#endif
} // namespace streamr::json
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
#ifndef STREAMR_JSON_TOSTRING_HPP
#define STREAMR_JSON_TOSTRING_HPP
// Module streamr.json.toString
// CONSOLIDATED from the former header
// streamr-json/toString.hpp (MODERNIZATION.md Phase 2.6):
// this file is now the source of truth.
module;

#include <initializer_list>
#include <string>

export module streamr.json.toString;

import streamr.json.jsonConcepts;
import streamr.json.toJson;

/**
* Convert (almost) any struct to string in C++20.
**/

#include "streamr-json/jsonConcepts.hpp"
#include "streamr-json/toJson.hpp"

namespace streamr::json {
export namespace streamr::json {

using suppresslint::SuppressLint; // otherwise linter thinks jsonConcepts.hpp
// is unused
Expand Down Expand Up @@ -42,6 +50,4 @@ std::string toString(const T& value) {
return value.toString();
}

} // namespace streamr::json

#endif
} // namespace streamr::json
3 changes: 2 additions & 1 deletion packages/streamr-json/src/examples/JsonExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <utility>
#include <nlohmann/json.hpp>

import streamr.json;
import streamr.json.toJson;
import streamr.json.toString;

using streamr::json::StreamrJsonInitializerList;
using streamr::json::toJson;
Expand Down
2 changes: 1 addition & 1 deletion packages/streamr-json/test/unit/TestJsonConcepts.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <gtest/gtest.h>

import streamr.json;
import streamr.json.toJson;

using streamr::json::toJson; // NOLINT

Expand Down
2 changes: 1 addition & 1 deletion packages/streamr-json/test/unit/toJsonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "TestClass.hpp"
#include "WeatherData.hpp"
import streamr.json;
import streamr.json.toJson;

using streamr::json::toJson;

Expand Down
2 changes: 1 addition & 1 deletion packages/streamr-json/test/unit/toStringTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "TestClass.hpp"
#include "WeatherData.hpp"

import streamr.json;
import streamr.json.toString;

using streamr::json::toString;

Expand Down
2 changes: 1 addition & 1 deletion packages/streamr-logger/modules/Logger.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ module;
#include <string_view>
#include <utility>
#include <nlohmann/json.hpp>
#include "streamr-json/toJson.hpp"

export module streamr.logger.Logger;

import streamr.json.toJson;
import streamr.logger.FollyLoggerImpl;
import streamr.logger.LoggerImpl;
import streamr.logger.StreamrLogLevel;
Expand Down
2 changes: 1 addition & 1 deletion packages/streamr-logger/modules/SLogger.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ module;
#include <string>
#include <string_view>
#include <nlohmann/json.hpp>
#include "streamr-json/toJson.hpp"

export module streamr.logger.SLogger;

import streamr.json.toJson;
import streamr.logger.Logger;

export namespace streamr::logger {
Expand Down
Loading