Skip to content
Open
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
15 changes: 14 additions & 1 deletion bssl-compat/prefixer/prefixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace opt {
static std::set<std::string> 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<std::regex> extraIdentifiers = {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -637,6 +646,7 @@ static bool usage(int exitcode) {
<< " --prefix <string> The prefix to be applied to functions, types & macros" << std::endl
<< " --output <path> Output directory for generated files" << std::endl
<< " --verbose Print more info about what's being done" << std::endl
<< " --relative-incl Include headers in <prefix>.h with relative paths, starting with <prefix>/." << std::endl
<< std::endl
<< "All files will be generated under the output directory as follows:" << std::endl
<< std::endl
Expand Down Expand Up @@ -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;
}
Expand Down