container: root: change base path, related refactor

The base path is now *outside* of the macro directory; allowing for a
more integrated view of `dfi`'s entire `root` system. This is more
apparent once running an interactive session where the expectation is
(more intuitively) that any path should be relative to 'src/root' and
not 'src/root/macro'.

The rationale for why this was in 'src/root/macro' to begin with stems
from how `root` (by default) will automatically load rootlogon.C in the
directory that `root` is started. This is causing more confusion than
not because `dfi`'s usage of `root` is not limited to macros.

These changes skirt the line between needing a major API bump and not
but, so far, appears to be on the side of *not*. However, the TODOs
noted for macro loading should be addressed prior to any API changes.
This commit is contained in:
2025-11-21 12:32:32 -08:00
parent 273f2cef49
commit 9fec1b427c
6 changed files with 61 additions and 41 deletions

View File

@@ -189,11 +189,11 @@ void rootlogon()
gSystem->AddLinkedLibs("-lsodium"); // libsodium
// Load default `dfi` public consumables
gInterpreter->ProcessLine(".L ../plugin/common/utility.hh");
gInterpreter->ProcessLine(".L ../macro/common/utility.hh");
gInterpreter->ProcessLine(".L ../src/hash.hh");
gInterpreter->ProcessLine(".L ../src/random.hh");
gInterpreter->ProcessLine(".L ../src/utility.hh");
gInterpreter->ProcessLine(".L plugin/common/utility.hh");
gInterpreter->ProcessLine(".L macro/common/utility.hh");
gInterpreter->ProcessLine(".L src/hash.hh");
gInterpreter->ProcessLine(".L src/random.hh");
gInterpreter->ProcessLine(".L src/utility.hh");
}
#endif // CONTAINER_SRC_ROOT_MACRO_ROOTLOGON_C_

View File

@@ -66,9 +66,9 @@ class Benchmark
{
static bool loaded{false};
static const std::initializer_list<std::string> paths{
{"../test/benchmark/hash.hh"},
{"../test/benchmark/random.hh"},
{"../test/benchmark/utility.hh"}};
{"test/benchmark/hash.hh"},
{"test/benchmark/random.hh"},
{"test/benchmark/utility.hh"}};
if (!loaded)
{

View File

@@ -66,10 +66,10 @@ class Unit
{
static bool loaded{false};
static const std::initializer_list<std::string> paths{
{"../test/unit/hash.hh"},
{"../test/unit/random.hh"},
{"../test/unit/type.hh"},
{"../test/unit/utility.hh"}};
{"test/unit/hash.hh"},
{"test/unit/random.hh"},
{"test/unit/type.hh"},
{"test/unit/utility.hh"}};
if (!loaded)
{

View File

@@ -60,16 +60,16 @@ class Server final
//! \details Registers internal macros
static void register_commands()
{
namespace common = ::dfi::macro::common;
namespace macro = ::dfi::macro;
common::Command::load({"web/internal/crypto.C"});
common::g_HTTPServer->RegisterCommand(
macro::load("macro/web/internal/crypto.C");
macro::common::g_HTTPServer->RegisterCommand(
"/rng_sample",
"::dfi::macro::web::internal::Random::rng_sample(\"%arg1%"
"\")");
common::Command::load({"web/internal/meta.C"});
common::g_HTTPServer->RegisterCommand(
macro::load("macro/web/internal/meta.C");
macro::common::g_HTTPServer->RegisterCommand(
"/meta_sample",
"::dfi::macro::web::internal::Meta::meta_sample(\"%arg1%"
"\")");

View File

@@ -373,7 +373,9 @@ TEST_F(CommonRepoFiles, MacroLoad)
ASSERT_NE(ecode, nullptr);
EXPECT_NE(*ecode, EErrorCode::kNoError);
ASSERT_NO_THROW(::dfi::macro::load("crypto/hash.C"));
// TODO(afiore): macro loading should not need to be prepended with "macro/"
// (see TODO in common impl regarding plugins-like functionality)
ASSERT_NO_THROW(::dfi::macro::load("macro/crypto/hash.C"));
gInterpreter->ProcessLine(
"dfi::macro::common::crypto::botan::Hash h;", ecode.get());
ASSERT_NE(ecode, nullptr);