Skip to content

Commit 58b1389

Browse files
committed
Move index in build/rules_index
1 parent a3013c5 commit 58b1389

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ endforeach()
230230
set(cpp_rules_ir_outputs)
231231
set(cpp_rules_index_outputs)
232232
set(cpp_rules_index_inputs)
233-
set(_index_clean_stamp ${RULES_IR_DIR}/index/clean.stamp)
233+
set(_index_clean_stamp ${CMAKE_BINARY_DIR}/rules_index/clean.stamp)
234234
set(rust_rules_ir_outputs)
235235
foreach(_rule_dir IN LISTS rule_subdirs)
236236
file(GLOB _cpp_srcs ${_rule_dir}/src.c ${_rule_dir}/src.cpp)
@@ -263,7 +263,7 @@ foreach(_rule_dir IN LISTS rule_subdirs)
263263
add_custom_command(
264264
OUTPUT ${_index_stamp}
265265
COMMAND ${CMAKE_COMMAND} -E make_directory ${_out_dir}
266-
COMMAND $<TARGET_FILE:cpp-rule-indexer> --dir ${_rule_dir} --path ${_rule_name} --index ${RULES_IR_DIR}/index ${_cxxflags} ${_common_headers}
266+
COMMAND $<TARGET_FILE:cpp-rule-indexer> --dir ${_rule_dir} --path ${_rule_name} --index ${CMAKE_BINARY_DIR}/rules_index ${_cxxflags} ${_common_headers}
267267
COMMAND ${CMAKE_COMMAND} -E touch ${_index_stamp}
268268
DEPENDS ${_index_clean_stamp}
269269
VERBATIM
@@ -304,8 +304,8 @@ add_custom_target("preprocess-cpp-rules" ALL DEPENDS ${cpp_rules_ir_outputs})
304304

305305
add_custom_command(
306306
OUTPUT ${_index_clean_stamp}
307-
COMMAND ${CMAKE_COMMAND} -E rm -rf ${RULES_IR_DIR}/index
308-
COMMAND ${CMAKE_COMMAND} -E make_directory ${RULES_IR_DIR}/index
307+
COMMAND ${CMAKE_COMMAND} -E rm -rf ${CMAKE_BINARY_DIR}/rules_index
308+
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/rules_index
309309
COMMAND ${CMAKE_COMMAND} -E touch ${_index_clean_stamp}
310310
DEPENDS ${cpp_rules_index_inputs} ${rule_common_headers} ${rule_indexer_sources}
311311
VERBATIM

‎cpp2rust/converter/rules/registry.cpp‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#include "converter/converter_lib.h"
1414
#include "converter/printer.h"
15-
#include "converter/rules/rules_loader.h"
1615

1716
namespace cpp2rust::RuleRegistry {
1817

@@ -34,9 +33,6 @@ void addRulesFromDirectory(const std::filesystem::path &dir, Model model) {
3433
namespace fs = std::filesystem;
3534
for (const auto &entry : fs::directory_iterator(dir)) {
3635
const auto &path = entry.path();
37-
if (path.filename() == RulesLoader::kIndexDirName) {
38-
continue;
39-
}
4036
assert(fs::exists(path / "ir_src.json") &&
4137
(fs::exists(path / "ir_unsafe.json") ||
4238
fs::exists(path / "ir_refcount.json")));

‎cpp2rust/converter/rules/rules_loader.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,10 @@ void PragmaHandler::HandlePragma(clang::Preprocessor &PP,
424424
}
425425
ctx.setTraversalScope({ctx.getTranslationUnitDecl()});
426426

427-
auto text = BuildRulesBuffer(fs::path(rules_dir_) / kIndexDirName, selected,
428-
ctx.getLangOpts().CPlusPlus);
427+
auto index_dir =
428+
fs::weakly_canonical(rules_dir_).parent_path() / kIndexDirName;
429+
auto text =
430+
BuildRulesBuffer(index_dir, selected, ctx.getLangOpts().CPlusPlus);
429431
log() << "rules loaded for this translation unit:\n" << text;
430432
auto rules_file = src_mgr.createFileID(
431433
llvm::MemoryBuffer::getMemBufferCopy(text, "<cpp2rust-rules>"),

‎cpp2rust/converter/rules/rules_loader.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace cpp2rust::RulesLoader {
1818

1919
inline constexpr const char *kPragmaName = "cpp2rust_rules";
2020

21-
inline constexpr const char *kIndexDirName = "index";
21+
inline constexpr const char *kIndexDirName = "rules_index";
2222

2323
std::filesystem::path ClassKey(const clang::NamedDecl *decl);
2424

0 commit comments

Comments
 (0)