Skip to content

Commit 53f2e10

Browse files
committed
Improve direct script cache fingerprint
1 parent cb73efd commit 53f2e10

3 files changed

Lines changed: 341 additions & 67 deletions

File tree

include/vix/cli/commands/run/RunDetail.hpp

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,6 @@ namespace vix::commands::RunCommand::detail
277277
std::vector<fs::path> headerOnlyDepIncludeDirs;
278278
};
279279

280-
/**
281-
* @brief Cache metadata for a directly compiled script artifact.
282-
*/
283280
struct DirectScriptCacheState
284281
{
285282
fs::path rootDir;
@@ -293,6 +290,42 @@ namespace vix::commands::RunCommand::detail
293290
bool needsRebuild = true;
294291
};
295292

293+
/**
294+
* @brief Full deterministic fingerprint used to identify a direct script build.
295+
*
296+
* This describes everything that can affect the produced binary. The direct
297+
* script cache key should be derived from this structure instead of only the
298+
* script path or source timestamp.
299+
*/
300+
struct DirectBuildFingerprint
301+
{
302+
std::string formatVersion{"1"};
303+
std::string vixVersion;
304+
305+
std::string compilerPath;
306+
std::string compilerVersion;
307+
std::string targetTriple;
308+
309+
std::string cppStandard;
310+
std::string buildMode;
311+
312+
std::string scriptPath;
313+
std::string scriptContentHash;
314+
std::uint64_t scriptMtimeNs = 0;
315+
316+
std::vector<std::string> includeDirs;
317+
std::vector<std::string> systemIncludeDirs;
318+
std::vector<std::string> defines;
319+
std::vector<std::string> compileOpts;
320+
321+
std::vector<std::string> libDirs;
322+
std::vector<std::string> libs;
323+
std::vector<std::string> linkOpts;
324+
325+
std::vector<std::string> depFingerprints;
326+
std::vector<std::string> headerFingerprints;
327+
};
328+
296329
/**
297330
* @brief Concrete plan for the fast direct-compile script path.
298331
*/
@@ -313,9 +346,9 @@ namespace vix::commands::RunCommand::detail
313346
bool passthroughRuntime = false;
314347
int effectiveTimeoutSec = 0;
315348

349+
DirectBuildFingerprint fingerprint;
316350
ScriptProbeResult probe;
317351
};
318-
319352
/**
320353
* @brief Concrete plan for the generated CMake fallback path.
321354
*/

src/commands/NewCommand.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,29 +1820,29 @@ int main()
18201820
const fs::path srcDir = projectDir / "src";
18211821
const fs::path testsDir = projectDir / "tests";
18221822
static const char *kEnvExample = R"(# ----------------------------------
1823-
# Server
1824-
# ----------------------------------
1825-
SERVER_PORT=8080
1826-
1827-
# ----------------------------------
1828-
# Database
1829-
# ----------------------------------
1830-
DATABASE_ENGINE=mysql
1831-
DATABASE_DEFAULT_HOST=127.0.0.1
1832-
DATABASE_DEFAULT_PORT=3306
1833-
DATABASE_DEFAULT_USER=root
1834-
DATABASE_DEFAULT_PASSWORD=
1835-
DATABASE_DEFAULT_NAME=appdb
1836-
1837-
# ----------------------------------
1838-
# Logging
1839-
# ----------------------------------
1840-
LOGGING_ASYNC=true
1841-
1842-
# ----------------------------------
1843-
# Security / WAF
1844-
# ----------------------------------
1845-
WAF_MODE=basic
1823+
# Server
1824+
# ----------------------------------
1825+
SERVER_PORT=8080
1826+
1827+
# ----------------------------------
1828+
# Database
1829+
# ----------------------------------
1830+
DATABASE_ENGINE=mysql
1831+
DATABASE_DEFAULT_HOST=127.0.0.1
1832+
DATABASE_DEFAULT_PORT=3306
1833+
DATABASE_DEFAULT_USER=root
1834+
DATABASE_DEFAULT_PASSWORD=
1835+
DATABASE_DEFAULT_NAME=appdb
1836+
1837+
# ----------------------------------
1838+
# Logging
1839+
# ----------------------------------
1840+
LOGGING_ASYNC=true
1841+
1842+
# ----------------------------------
1843+
# Security / WAF
1844+
# ----------------------------------
1845+
WAF_MODE=basic
18461846
)";
18471847

18481848
if (!ensure_dir(srcDir, err))

0 commit comments

Comments
 (0)