MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / resolve_dynamic_module_path

Function resolve_dynamic_module_path

src/builtin/module_jit.cpp:1332–1355  ·  view source on GitHub ↗

Pure resolution: pick the path to load, in priority order: 1. / — daspkg release bundle layout (modules sit next to the exe) 2. / — SDK install layout AND local dev build 3. — baked-at-codegen absolute path (legacy / paths without /modules/ segment) Tiers 1+2 are skipped when rel_path is empty/null. Returns the chosen path; tier 3 i

Source from the content-addressed store, hash-verified

1330// Tiers 1+2 are skipped when rel_path is empty/null. Returns the chosen path;
1331// tier 3 is unconditional, so the result is never empty when fallback is set.
1332static das::string resolve_dynamic_module_path ( const char * rel_path, const char * fallback_abs_path ) {
1333 namespace fs = std::filesystem;
1334 // tier 1 — exe_dir (parent_path correctly preserves filesystem root: "/myapp""/", "C:\myapp.exe""C:\")
1335 das::string exeFile;
1336 if ( g_jit_exe_file_for_test ) {
1337 const char * s = g_jit_exe_file_for_test();
1338 if ( s ) exeFile = s;
1339 } else {
1340 exeFile = das::getExecutableFileName();
1341 }
1342 if ( !exeFile.empty() ) {
1343 fs::path exeDir = fs::path(exeFile.c_str()).parent_path();
1344 if ( exeDir.empty() ) exeDir = "."; // exe is a bare filename relative to cwd
1345 das::string p = pick_at_dir(exeDir, rel_path);
1346 if ( !p.empty() ) return p;
1347 }
1348 // tier 2 — das_root
1349 {
1350 das::string p = pick_at_dir(fs::path(das::getDasRoot().c_str()), rel_path);
1351 if ( !p.empty() ) return p;
1352 }
1353 // tier 3 — baked absolute (legacy fallback)
1354 return fallback_abs_path ? fallback_abs_path : "";
1355}
1356#else
1357// No file IO (DAS_NO_FILEIO): there is no filesystem to resolve a dynamic
1358// module against, and a build with no fio can't dlopen one anyway. Calling

Calls 5

getExecutableFileNameFunction · 0.85
pick_at_dirFunction · 0.85
getDasRootFunction · 0.85
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected