Skip to content

Commit 23fae62

Browse files
committed
fix(run): detect Vix runtime scripts correctly in CMake fallback
- fix script feature detection for `using namespace vix` and related patterns - make generated fallback CMakeLists use the Vix runtime branch when needed - ensure Vix runtime scripts link against the umbrella `vix::vix` target - keep `--local-cache` behavior working for generated script projects Result: - `vix run file.cpp` works for Vix runtime scripts - `vix run file.cpp --local-cache` works too - generated fallback projects now enter the correct Vix linking path
1 parent 07cb8d7 commit 23fae62

3 files changed

Lines changed: 23 additions & 12 deletions

File tree

src/commands/run/RunScript.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,13 +982,20 @@ namespace vix::commands::RunCommand::detail
982982
plan.configureLogPath = plan.projectDir / "configure.log";
983983
plan.buildLogPath = plan.projectDir / "build.log";
984984
plan.targetName = plan.exeName;
985-
plan.useVixRuntime = probe.usesVixRuntime;
985+
986+
plan.useVixRuntime = probe.usesVixRuntime || script_uses_vix(plan.scriptPath);
986987

987988
plan.exePath = plan.buildDir / plan.exeName;
988989
#ifdef _WIN32
989990
plan.exePath += ".exe";
990991
#endif
991992

993+
plan.configSignature = make_script_config_signature(
994+
plan.useVixRuntime,
995+
opt.enableSanitizers,
996+
opt.enableUbsanOnly,
997+
opt.scriptFlags);
998+
992999
plan.shouldConfigure = true;
9931000
plan.shouldBuild = true;
9941001
plan.shouldRun = true;

src/commands/run/detail/ScriptCMake.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,23 +1027,16 @@ namespace vix::commands::RunCommand::detail
10271027
if (withSqlite || withMySql)
10281028
append_line(s);
10291029

1030-
append_line(s, "find_package(vix QUIET CONFIG)");
1031-
append_line(s, "if (NOT vix_FOUND)");
1032-
append_line(s, " find_package(Vix CONFIG REQUIRED)");
1033-
append_line(s, "endif()");
1030+
append_line(s, "find_package(Vix CONFIG REQUIRED)");
10341031
append_line(s);
10351032

10361033
append_line(s, "set(VIX_MAIN_TARGET \"\")");
10371034
append_line(s, "if (TARGET vix::vix)");
10381035
append_line(s, " set(VIX_MAIN_TARGET vix::vix)");
10391036
append_line(s, "elseif (TARGET Vix::vix)");
10401037
append_line(s, " set(VIX_MAIN_TARGET Vix::vix)");
1041-
append_line(s, "elseif (TARGET vix::core)");
1042-
append_line(s, " set(VIX_MAIN_TARGET vix::core)");
1043-
append_line(s, "elseif (TARGET Vix::core)");
1044-
append_line(s, " set(VIX_MAIN_TARGET Vix::core)");
10451038
append_line(s, "else()");
1046-
append_line(s, " message(FATAL_ERROR \"No Vix target found (vix::vix/Vix::vix/vix::core/Vix::core)\")");
1039+
append_line(s, " message(FATAL_ERROR \"No umbrella Vix target found (vix::vix or Vix::vix). Runtime scripts require the full Vix package.\")");
10471040
append_line(s, "endif()");
10481041
append_line(s);
10491042

@@ -1147,6 +1140,8 @@ namespace vix::commands::RunCommand::detail
11471140
append_global_cmake_defaults(s);
11481141

11491142
const ScriptFeatures feat = detect_script_features(cppPath);
1143+
const bool effectiveUseVixRuntime = useVixRuntime || feat.usesVix;
1144+
11501145
ScriptLinkFlags lf = parse_link_flags(scriptFlags);
11511146
ScriptCompileFlags cf = parse_compile_flags(scriptFlags);
11521147

@@ -1169,7 +1164,7 @@ namespace vix::commands::RunCommand::detail
11691164
append_target_link_options(s, targetName, lf.linkOpts);
11701165
append_base_warning_and_platform_flags(s, targetName);
11711166

1172-
if (!useVixRuntime)
1167+
if (!effectiveUseVixRuntime)
11731168
{
11741169
append_non_vix_runtime_links(s, targetName);
11751170
}

src/commands/run/detail/ScriptProbe.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,17 @@ namespace vix::commands::RunCommand::detail
345345
auto has = [&](const char *s)
346346
{ return line.find(s) != std::string::npos; };
347347

348-
if (has("vix::") || has("Vix::") || has("#include <vix/") || has("#include \"vix/"))
348+
if (has("vix::") ||
349+
has("Vix::") ||
350+
has("using namespace vix") ||
351+
has("using namespace Vix") ||
352+
has("using vix::") ||
353+
has("using Vix::") ||
354+
has("#include <vix/") ||
355+
has("#include \"vix/"))
356+
{
349357
f.usesVix = true;
358+
}
350359

351360
if (has("#include <vix/orm/") || has("#include \"vix/orm/") ||
352361
has("vix::orm") || has("using namespace vix::orm"))

0 commit comments

Comments
 (0)