Skip to content

Commit 2965353

Browse files
committed
fix(hash): remove duplicate project fingerprint definition
2 parents 484e18b + aae9498 commit 2965353

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

include/vix/cli/util/Hash.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace vix::cli::util
3434
std::optional<std::string> sha256_file(const fs::path &p);
3535
std::optional<std::string> sha256_directory(const fs::path &dir);
3636

37-
std::string compute_project_files_fingerprint(const fs::path &projectDir);
37+
std::string compute_cmake_config_fingerprint(const fs::path &projectDir);
3838
bool signature_matches(const fs::path &sigFile, const std::string &sig);
3939
std::string signature_join(const std::vector<std::pair<std::string, std::string>> &kvs);
4040

src/commands/BuildCommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ namespace vix::commands::BuildCommand
626626

627627
plan.launcher = detect_launcher(opt);
628628
plan.fastLinkerFlag = detect_fast_linker_flag(opt);
629-
plan.projectFingerprint = util::compute_project_files_fingerprint(plan.projectDir);
629+
plan.projectFingerprint = util::compute_cmake_config_fingerprint(plan.projectDir);
630630

631631
if (!opt.targetTriple.empty())
632632
plan.buildDir = plan.projectDir / (plan.preset.buildDirName + "-" + opt.targetTriple);

src/util/Hash.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,27 +132,44 @@ namespace vix::cli::util
132132
return vix::crypto::hex_lower(out);
133133
}
134134

135-
std::string compute_project_files_fingerprint(const fs::path &projectDir)
135+
std::string compute_cmake_config_fingerprint(const fs::path &projectDir)
136136
{
137137
std::vector<fs::path> files;
138138
files.reserve(256);
139139

140-
files.push_back(projectDir / "CMakeLists.txt");
140+
const fs::path rootCMake = projectDir / "CMakeLists.txt";
141+
if (file_exists(rootCMake))
142+
files.push_back(rootCMake);
143+
141144
collect_files_recursive(projectDir / "cmake", ".cmake", files);
142145

143146
const fs::path presets = projectDir / "CMakePresets.json";
144147
if (file_exists(presets))
145148
files.push_back(presets);
146149

150+
const fs::path userPresets = projectDir / "CMakeUserPresets.json";
151+
if (file_exists(userPresets))
152+
files.push_back(userPresets);
153+
154+
const fs::path vixJson = projectDir / "vix.json";
155+
if (file_exists(vixJson))
156+
files.push_back(vixJson);
157+
158+
const fs::path vixLock = projectDir / "vix.lock";
159+
if (file_exists(vixLock))
160+
files.push_back(vixLock);
161+
147162
std::sort(files.begin(), files.end());
163+
files.erase(std::unique(files.begin(), files.end()), files.end());
148164

149165
std::uint64_t h = FNV_OFFSET;
150166

151167
for (const auto &p : files)
152168
{
153169
std::error_code ec{};
154170
const fs::path rp = fs::weakly_canonical(p, ec);
155-
const std::string pathStr = ec ? p.string() : rp.string();
171+
const std::string pathStr = ec ? p.lexically_relative(projectDir).string()
172+
: rp.lexically_relative(projectDir).string();
156173

157174
const auto hashOpt = read_file_hash_hex(p);
158175
const std::string line = pathStr + "=" + (hashOpt ? *hashOpt : "<missing>");

0 commit comments

Comments
 (0)