From d93828deae8f64e51645c9e37f44333f1585731b Mon Sep 17 00:00:00 2001 From: Zuzana Miklankova Date: Thu, 10 Oct 2024 15:57:17 +0200 Subject: [PATCH 1/2] fix prefixer to work also with relative paths for outdir Signed-off-by: Zuzana Miklankova --- bssl-compat/prefixer/prefixer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bssl-compat/prefixer/prefixer.cpp b/bssl-compat/prefixer/prefixer.cpp index 24a17dadfe..f767a28678 100644 --- a/bssl-compat/prefixer/prefixer.cpp +++ b/bssl-compat/prefixer/prefixer.cpp @@ -561,7 +561,12 @@ void MyFrontendAction::EndSourceFileAction() { std::regex regex("[a-zA-Z_][a-zA-Z0-9_]*", std::regex::basic | std::regex::optimize); opt::vstr() << "Processing " << files.size() << " files...\n"; for (auto [header, incl] : files) { - auto path = opt::incdir() / opt::prefix / header; + std::filesystem::path path; + if (header == opt::hfile() || header == opt::cfile()) { + path = header; + } else { + path = opt::incdir() / opt::prefix / header; + } std::string buffer; opt::vstr() << " - " << path << "\n"; From 93d927b25230d0788460d108ed3861e6c13546e8 Mon Sep 17 00:00:00 2001 From: Zuzana Miklankova Date: Tue, 22 Oct 2024 15:29:55 +0200 Subject: [PATCH 2/2] add relative-incl option to prefixer Signed-off-by: Zuzana Miklankova --- bssl-compat/prefixer/prefixer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bssl-compat/prefixer/prefixer.cpp b/bssl-compat/prefixer/prefixer.cpp index f767a28678..0303881e35 100644 --- a/bssl-compat/prefixer/prefixer.cpp +++ b/bssl-compat/prefixer/prefixer.cpp @@ -25,6 +25,7 @@ namespace opt { static std::set srcskip; static std::filesystem::path output = std::filesystem::current_path(); static std::string prefix = "ossl"; + static bool relative_incl = false; static bool verbose = false; static std::vector extraIdentifiers = { @@ -442,6 +443,9 @@ void MyFrontendAction::EndSourceFileAction() { for(const auto &f : m_functions) { std::string header = f.getHeader(srcmgr); if(funcmap.find(header) == funcmap.end()) { + if (opt::relative_incl) { + header = header.substr(header.find(opt::prefix), header.length()); + } hstr << "#include \"" << header <<"\"" << std::endl; } funcmap[header].push_back(f); @@ -642,6 +646,7 @@ static bool usage(int exitcode) { << " --prefix The prefix to be applied to functions, types & macros" << std::endl << " --output Output directory for generated files" << std::endl << " --verbose Print more info about what's being done" << std::endl + << " --relative-incl Include headers in .h with relative paths, starting with /." << std::endl << std::endl << "All files will be generated under the output directory as follows:" << std::endl << std::endl @@ -688,6 +693,9 @@ int main(int argc, const char **argv) { else if ((arg == "--output") && ((++i < argc) || usage(-1))) { opt::output = argv[i]; } + else if (arg == "--relative-incl") { + opt::relative_incl = true; + } else if (arg == "--verbose") { opt::verbose = true; }