Skip to content

Add temporary flag to fix rules_swift remapping #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion index-import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ static cl::opt<bool>
Incremental("incremental",
cl::desc("Only transfer units if they are newer"));

static cl::opt<bool> UndoRulesSwiftRenames(
"undo-rules_swift-renames",
cl::desc(
"Until Bazel 6.0, rules_swift replaces spaces in object files with "
"'__SPACE__'. Using this flag undoes that replacement, changing "
"'__SPACE__' into ' '. This flag will be removed in the future."));

struct Remapper {
public:
std::string remap(const llvm::StringRef input) const {
Expand Down Expand Up @@ -215,7 +222,18 @@ importUnit(StringRef outputUnitsPath, StringRef inputUnitPath,
ModuleNameScope &moduleNames) {
// The set of remapped paths.
auto workingDir = remapper.remap(reader->getWorkingDirectory());
auto outputFile = remapper.remap(reader->getOutputFile());

auto originalOutputFilePath = std::string(reader->getOutputFile());
if (UndoRulesSwiftRenames) {
// Replace all instances of "__SPACE__" iwith " "
std::string::size_type start = 0;
while ((start = originalOutputFilePath.find("__SPACE__", start)) !=
std::string::npos) {
originalOutputFilePath.replace(start, 9, " ");
start += 1;
}
}
auto outputFile = remapper.remap(originalOutputFilePath);

// Cloning records when we've got an output records path
const auto cloneDepRecords = !outputRecordsPath.empty();
Expand Down