Skip to content

Commit db90b8f

Browse files
committed
refactor: use canonical vix3 runtime capabilities
1 parent fdd9f1d commit db90b8f

41 files changed

Lines changed: 201 additions & 177 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CMakeLists.txt‎

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ if (VIX_CLI_BUILD_TESTS)
5050
set(TEMPLATE_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
5151
set(TEMPLATE_BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE)
5252

53-
set(VIX_UTILS_BUILD_TESTS OFF CACHE BOOL "" FORCE)
5453
set(VIX_JSON_BUILD_TESTS OFF CACHE BOOL "" FORCE)
5554
set(VIX_CORE_BUILD_TESTS OFF CACHE BOOL "" FORCE)
5655
set(VIX_NET_BUILD_TESTS OFF CACHE BOOL "" FORCE)
@@ -221,7 +220,6 @@ else()
221220
get_filename_component(_VIX_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE)
222221

223222
set(_VIX_CORE_DIR "${_VIX_MODULES_DIR}/core")
224-
set(_VIX_UTILS_DIR "${_VIX_MODULES_DIR}/utils")
225223
set(_VIX_ASYNC_DIR "${_VIX_MODULES_DIR}/async")
226224
set(_VIX_JSON_DIR "${_VIX_MODULES_DIR}/json")
227225
set(_VIX_TEMPLATE_DIR "${_VIX_MODULES_DIR}/template")
@@ -239,17 +237,13 @@ else()
239237
set(_VIX_ENGINE_DIR "${_VIX_MODULES_DIR}/engine")
240238

241239
set(_LOCAL_LAYOUT_OK FALSE)
242-
if (EXISTS "${_VIX_CORE_DIR}/CMakeLists.txt" AND EXISTS "${_VIX_UTILS_DIR}/CMakeLists.txt")
240+
if (EXISTS "${_VIX_CORE_DIR}/CMakeLists.txt")
243241
set(_LOCAL_LAYOUT_OK TRUE)
244242
endif()
245243

246244
if (_LOCAL_LAYOUT_OK)
247245
message(STATUS "[cli] Building inside Vix repo -> resolving local sibling modules")
248246

249-
if (EXISTS "${_VIX_UTILS_DIR}/CMakeLists.txt" AND NOT TARGET vix::utils)
250-
add_subdirectory("${_VIX_UTILS_DIR}" "${CMAKE_BINARY_DIR}/_vix_utils")
251-
endif()
252-
253247
if (EXISTS "${_VIX_ASYNC_DIR}/CMakeLists.txt" AND NOT TARGET vix::async)
254248
add_subdirectory("${_VIX_ASYNC_DIR}" "${CMAKE_BINARY_DIR}/_vix_async")
255249
endif()
@@ -334,10 +328,6 @@ else()
334328
list(APPEND _VIX_LOCAL_LINK_TARGETS vix::core)
335329
endif()
336330

337-
if (TARGET vix::utils)
338-
list(APPEND _VIX_LOCAL_LINK_TARGETS vix::utils)
339-
endif()
340-
341331
if (TARGET vix::async)
342332
list(APPEND _VIX_LOCAL_LINK_TARGETS vix::async)
343333
endif()
@@ -404,7 +394,6 @@ else()
404394

405395
# Fallback header visibility for modules that expose headers but not imported targets
406396
vix_append_if_exists(_VIX_LOCAL_INCLUDE_DIRS "${_VIX_CORE_DIR}/include")
407-
vix_append_if_exists(_VIX_LOCAL_INCLUDE_DIRS "${_VIX_UTILS_DIR}/include")
408397
vix_append_if_exists(_VIX_LOCAL_INCLUDE_DIRS "${_VIX_ASYNC_DIR}/include")
409398
vix_append_if_exists(_VIX_LOCAL_INCLUDE_DIRS "${_VIX_JSON_DIR}/include")
410399
vix_append_if_exists(_VIX_LOCAL_INCLUDE_DIRS "${_VIX_REPLY_DIR}/include")
@@ -470,13 +459,51 @@ else()
470459
"Missing dependencies for vix_cli.\n"
471460
"Expected one of:\n"
472461
" - umbrella targets vix::vix or vix::core\n"
473-
" - local sibling modules in ../core, ../utils, ../p2p, ../crypto, etc.\n"
462+
" - local sibling modules in ../core, ../p2p, ../crypto, etc.\n"
474463
" - installed packages providing vix::vix or vix::core"
475464
)
476465
endif()
477466
endif()
478467
endif()
479468

469+
# ----------------------------------------------------
470+
# Canonical environment dependency
471+
# ----------------------------------------------------
472+
if (NOT TARGET vix::env AND NOT TARGET vix_env)
473+
if (EXISTS "${_VIX_MODULES_DIR}/env/CMakeLists.txt")
474+
add_subdirectory("${_VIX_MODULES_DIR}/env" "${CMAKE_BINARY_DIR}/_vix_env")
475+
else()
476+
find_package(vix_env CONFIG REQUIRED)
477+
endif()
478+
endif()
479+
480+
if (TARGET vix::env)
481+
target_link_libraries(vix_cli PRIVATE vix::env)
482+
elseif (TARGET vix_env)
483+
target_link_libraries(vix_cli PRIVATE vix_env)
484+
else()
485+
message(FATAL_ERROR "[cli] Canonical environment access requires vix::env")
486+
endif()
487+
488+
# ----------------------------------------------------
489+
# Canonical logging dependency
490+
# ----------------------------------------------------
491+
if (NOT TARGET vix::log AND NOT TARGET vix_log)
492+
if (EXISTS "${_VIX_MODULES_DIR}/log/CMakeLists.txt")
493+
add_subdirectory("${_VIX_MODULES_DIR}/log" "${CMAKE_BINARY_DIR}/_vix_log")
494+
else()
495+
find_package(vix_log CONFIG REQUIRED)
496+
endif()
497+
endif()
498+
499+
if (TARGET vix::log)
500+
target_link_libraries(vix_cli PRIVATE vix::log)
501+
elseif (TARGET vix_log)
502+
target_link_libraries(vix_cli PRIVATE vix_log)
503+
else()
504+
message(FATAL_ERROR "[cli] Canonical logging requires vix::log")
505+
endif()
506+
480507
# ----------------------------------------------------
481508
# Cloud command support
482509
# ----------------------------------------------------

‎include/vix/cli/util/Shell.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
#include <cstdlib>
55
#include <string>
6-
#include <vix/utils/Env.hpp>
6+
#include <vix/env/Legacy.hpp>
77

88
namespace vix::cli::util
99
{
1010
inline bool debug_enabled()
1111
{
12-
const char *v = vix::utils::vix_getenv("VIX_DEBUG");
12+
const char *v = vix::env::legacy::getenv("VIX_DEBUG");
1313
if (!v)
1414
return false;
1515

‎src/CLI.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
#include <vix/cli/commands/AgentCommand.hpp>
6666
#include <vix/cli/commands/GameExportCommand.hpp>
6767
#include <vix/cli/commands/CloudCommand.hpp>
68-
#include <vix/utils/Env.hpp>
68+
#include <vix/env/Legacy.hpp>
6969
#include <vix/cli/Style.hpp>
70-
#include <vix/utils/Logger.hpp>
70+
#include <vix/log/Logger.hpp>
7171
#include <vix/cli/util/Ui.hpp>
7272

7373
#include <iostream>
@@ -84,7 +84,7 @@
8484

8585
namespace vix
8686
{
87-
using Logger = vix::utils::Logger;
87+
using Logger = vix::log::Logger;
8888
using namespace vix::cli::style;
8989

9090
namespace
@@ -223,7 +223,7 @@ namespace vix
223223

224224
void apply_log_level_from_env(Logger &logger)
225225
{
226-
if (const char *env = vix::utils::vix_getenv("VIX_LOG_LEVEL"))
226+
if (const char *env = vix::env::legacy::getenv("VIX_LOG_LEVEL"))
227227
{
228228
std::string value(env);
229229

‎src/cmake/CMakeBuild.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include <vix/engine/Process.hpp>
2727
#include <vix/engine/BuildParallelism.hpp>
28-
#include <vix/utils/Env.hpp>
28+
#include <vix/env/Legacy.hpp>
2929

3030
#ifdef _WIN32
3131
#include <io.h>
@@ -344,7 +344,7 @@ namespace vix::cli::build
344344
* downloads dependencies. Keep a heartbeat enabled by default for
345345
* configure, while still allowing explicit control through the env var.
346346
*/
347-
const char *v = vix::utils::vix_getenv("VIX_BUILD_HEARTBEAT");
347+
const char *v = vix::env::legacy::getenv("VIX_BUILD_HEARTBEAT");
348348
if (!v || !*v)
349349
return isConfigure;
350350

‎src/cmake/GlobalPackages.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Vix.cpp
1212
*/
1313
#include <vix/cli/cmake/GlobalPackages.hpp>
14-
#include <vix/utils/Env.hpp>
14+
#include <vix/env/Legacy.hpp>
1515

1616
#include <algorithm>
1717
#include <cstdlib>
@@ -30,9 +30,9 @@ namespace vix::cli::build
3030
static std::optional<std::string> home_dir()
3131
{
3232
#ifdef _WIN32
33-
const char *home = vix::utils::vix_getenv("USERPROFILE");
33+
const char *home = vix::env::legacy::getenv("USERPROFILE");
3434
#else
35-
const char *home = vix::utils::vix_getenv("HOME");
35+
const char *home = vix::env::legacy::getenv("HOME");
3636
#endif
3737
if (!home || std::string(home).empty())
3838
return std::nullopt;

‎src/commands/AddCommand.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <vix/cli/util/Semver.hpp>
2121
#include <vix/cli/util/Ui.hpp>
2222
#include <vix/cli/util/ProjectMutation.hpp>
23-
#include <vix/utils/Env.hpp>
23+
#include <vix/env/Legacy.hpp>
2424

2525
#include <nlohmann/json.hpp>
2626

@@ -65,9 +65,9 @@ namespace vix::commands
6565
std::string home_dir()
6666
{
6767
#ifdef _WIN32
68-
const char *home = vix::utils::vix_getenv("USERPROFILE");
68+
const char *home = vix::env::legacy::getenv("USERPROFILE");
6969
#else
70-
const char *home = vix::utils::vix_getenv("HOME");
70+
const char *home = vix::env::legacy::getenv("HOME");
7171
#endif
7272
return home ? std::string(home) : std::string();
7373
}

‎src/commands/CacheCommand.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
#include <vix/cli/commands/CacheCommand.hpp>
4040
#include <vix/cli/Style.hpp>
41-
#include <vix/utils/Env.hpp>
41+
#include <vix/env/Legacy.hpp>
4242
#include <nlohmann/json.hpp>
4343

4444
#include <filesystem>
@@ -145,7 +145,7 @@ namespace
145145

146146
std::string env_or_empty(const char *name)
147147
{
148-
const char *v = vix::utils::vix_getenv(name);
148+
const char *v = vix::env::legacy::getenv(name);
149149
if (v && *v)
150150
return std::string(v);
151151
return {};
@@ -639,7 +639,7 @@ namespace
639639

640640
if (!sopt.pubkey.has_value())
641641
{
642-
const char *home = vix::utils::vix_getenv("HOME");
642+
const char *home = vix::env::legacy::getenv("HOME");
643643
if (home && *home)
644644
{
645645
const fs::path p1 = fs::path(home) / ".config" / "vix" / "keys" / "vix-pack.pub";

‎src/commands/CloudCommand.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <vix/cli/cmake/CMakeBuild.hpp>
1515
#include <vix/cli/util/Hash.hpp>
1616
#include <vix/requests/requests.hpp>
17-
#include <vix/utils/Env.hpp>
17+
#include <vix/env/Legacy.hpp>
1818

1919
#include <nlohmann/json.hpp>
2020

@@ -207,11 +207,11 @@ namespace vix::commands
207207

208208
bool color_enabled(std::ostream &stream)
209209
{
210-
const char *no_color = vix::utils::vix_getenv("NO_COLOR");
210+
const char *no_color = vix::env::legacy::getenv("NO_COLOR");
211211
if (no_color && *no_color)
212212
return false;
213213

214-
const char *term = vix::utils::vix_getenv("TERM");
214+
const char *term = vix::env::legacy::getenv("TERM");
215215
if (term && std::string(term) == "dumb")
216216
return false;
217217

@@ -414,9 +414,9 @@ namespace vix::commands
414414
fs::path home_dir()
415415
{
416416
#ifdef _WIN32
417-
const char *home = vix::utils::vix_getenv("USERPROFILE");
417+
const char *home = vix::env::legacy::getenv("USERPROFILE");
418418
#else
419-
const char *home = vix::utils::vix_getenv("HOME");
419+
const char *home = vix::env::legacy::getenv("HOME");
420420
#endif
421421
return home && *home ? fs::path(home) : fs::current_path();
422422
}
@@ -1271,7 +1271,7 @@ namespace vix::commands
12711271
#elif defined(__APPLE__)
12721272
const auto result = vix::cli::build::run_process_capture({"open", url}, {}, output);
12731273
#else
1274-
const char *browser = vix::utils::vix_getenv("BROWSER");
1274+
const char *browser = vix::env::legacy::getenv("BROWSER");
12751275
if (browser && *browser)
12761276
{
12771277
const auto custom = vix::cli::build::run_process_capture({browser, url}, {}, output);

‎src/commands/DoctorCommand.cpp‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <vix/cli/commands/DoctorCommand.hpp>
1515
#include <vix/cli/util/Ui.hpp>
1616
#include <vix/cli/Style.hpp>
17-
#include <vix/utils/Env.hpp>
17+
#include <vix/env/Legacy.hpp>
1818
#include <vix/requests/Client.hpp>
1919
#include <nlohmann/json.hpp>
2020

@@ -56,12 +56,12 @@ namespace vix::commands
5656
fs::path stats_file()
5757
{
5858
#ifdef _WIN32
59-
if (const char *p = vix::utils::vix_getenv("LOCALAPPDATA"))
59+
if (const char *p = vix::env::legacy::getenv("LOCALAPPDATA"))
6060
if (*p)
6161
return fs::path(p) / "Vix" / "install.json";
6262
return fs::current_path() / "install.json";
6363
#else
64-
if (const char *home = vix::utils::vix_getenv("HOME"))
64+
if (const char *home = vix::env::legacy::getenv("HOME"))
6565
if (*home)
6666
return fs::path(home) / ".local" / "share" / "vix" / "install.json";
6767
return fs::current_path() / "install.json";
@@ -70,7 +70,7 @@ namespace vix::commands
7070

7171
fs::path current_exe_path()
7272
{
73-
if (const char *p = vix::utils::vix_getenv("VIX_CLI_PATH"))
73+
if (const char *p = vix::env::legacy::getenv("VIX_CLI_PATH"))
7474
if (*p)
7575
return fs::path(p);
7676
#ifdef _WIN32
@@ -268,7 +268,7 @@ namespace vix::commands
268268

269269
bool path_contains_dir(const std::string &dir)
270270
{
271-
const char *p = vix::utils::vix_getenv("PATH");
271+
const char *p = vix::env::legacy::getenv("PATH");
272272
if (!p)
273273
return false;
274274

@@ -348,7 +348,7 @@ namespace vix::commands
348348

349349
std::optional<fs::path> env_path(const char *name)
350350
{
351-
if (const char *value = vix::utils::vix_getenv(name))
351+
if (const char *value = vix::env::legacy::getenv(name))
352352
{
353353
if (*value)
354354
return fs::path(value);
@@ -359,7 +359,7 @@ namespace vix::commands
359359

360360
std::optional<fs::path> first_cmake_prefix_path()
361361
{
362-
if (const char *value = vix::utils::vix_getenv("CMAKE_PREFIX_PATH"))
362+
if (const char *value = vix::env::legacy::getenv("CMAKE_PREFIX_PATH"))
363363
{
364364
if (!*value)
365365
return std::nullopt;
@@ -1709,7 +1709,7 @@ namespace vix::commands
17091709
vix::cli::util::warn_line(std::cerr, "minisign: missing (optional; sha256 still secures upgrades)");
17101710
#endif
17111711

1712-
if (const char *lvl = vix::utils::vix_getenv("VIX_LOG_LEVEL"))
1712+
if (const char *lvl = vix::env::legacy::getenv("VIX_LOG_LEVEL"))
17131713
vix::cli::util::kv(std::cout, "VIX_LOG_LEVEL", std::string(lvl));
17141714

17151715
// Online check

‎src/commands/InfoCommand.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <vix/cli/commands/InfoCommand.hpp>
1515
#include <vix/cli/util/Ui.hpp>
1616
#include <vix/cli/Style.hpp>
17-
#include <vix/utils/Env.hpp>
17+
#include <vix/env/Legacy.hpp>
1818

1919
#include <nlohmann/json.hpp>
2020

@@ -40,9 +40,9 @@ namespace vix::commands
4040
static std::string home_dir()
4141
{
4242
#ifdef _WIN32
43-
const char *home = vix::utils::vix_getenv("USERPROFILE");
43+
const char *home = vix::env::legacy::getenv("USERPROFILE");
4444
#else
45-
const char *home = vix::utils::vix_getenv("HOME");
45+
const char *home = vix::env::legacy::getenv("HOME");
4646
#endif
4747
return home ? std::string(home) : std::string();
4848
}

0 commit comments

Comments
 (0)