mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
This replaces usages of `llvm::fs` and string manipulation with `std::filesystem`, also replacing `std::string` with `std::filesystem::path` where it made sense. Moreover MD5 hashing used in macOS file remapping was replaced by SHA256 hashing using a small header-only SHA256 C++ library with an MIT license, https://github.com/okdshin/PicoSHA2. File contents hashing was relocated to the newly created `file` library for later planned reuse.
22 lines
883 B
C++
22 lines
883 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include "swift/extractor/infra/file/PathHash.h"
|
|
|
|
namespace codeql {
|
|
|
|
using PathRemapping = std::unordered_map<std::filesystem::path, std::filesystem::path>;
|
|
// Rewrites all the output CLI args to point to a scratch dir instead of the actual locations.
|
|
// This is needed to ensure that the artifacts produced by the extractor do not collide with the
|
|
// artifacts produced by the actual Swift compiler.
|
|
// Returns the map containing remapping oldpath -> newPath.
|
|
PathRemapping rewriteOutputsInPlace(const std::filesystem::path& scratchDir,
|
|
std::vector<std::string>& CLIArgs);
|
|
|
|
// Create directories for all the redirected new paths as the Swift compiler expects them to exist.
|
|
void ensureDirectoriesForNewPathsExist(const PathRemapping& remapping);
|
|
|
|
} // namespace codeql
|