diff --git a/bssl-compat/prefixer/prefixer.cpp b/bssl-compat/prefixer/prefixer.cpp index 24a17dadfe..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); @@ -561,7 +565,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"; @@ -637,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 @@ -683,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; }