Skip to content

Commit

Permalink
oilgen: accept multiple config files (#379)
Browse files Browse the repository at this point in the history
Summary:

Extend the multiple config files system to OILGen, the piece it was originally designed for. This allows for specifying additional configs which say which keys of maps to capture.

Reviewed By: ajor

Differential Revision: D50105138
  • Loading branch information
JakeHillion authored and facebook-github-bot committed Oct 11, 2023
1 parent 4c6f232 commit 217f675
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 2 additions & 3 deletions oi/OIGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ int OIGenerator::generate(fs::path& primaryObject, SymbolService& symbols) {
OICompiler::Config compilerConfig{};
compilerConfig.usePIC = pic;

auto features =
config::processConfigFiles(std::vector<fs::path>{configFilePath},
featuresMap, compilerConfig, generatorConfig);
auto features = config::processConfigFiles(configFilePaths, featuresMap,
compilerConfig, generatorConfig);
if (!features) {
LOG(ERROR) << "failed to process config file";
return -1;
Expand Down
7 changes: 4 additions & 3 deletions oi/OIGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma once

#include <filesystem>
#include <vector>

#include "oi/DrgnUtils.h"
#include "oi/OICodeGen.h"
Expand All @@ -31,8 +32,8 @@ class OIGenerator {
void setOutputPath(fs::path _outputPath) {
outputPath = std::move(_outputPath);
}
void setConfigFilePath(fs::path _configFilePath) {
configFilePath = std::move(_configFilePath);
void setConfigFilePaths(std::vector<fs::path> _configFilePaths) {
configFilePaths = std::move(_configFilePaths);
}
void setSourceFileDumpPath(fs::path _sourceFileDumpPath) {
sourceFileDumpPath = std::move(_sourceFileDumpPath);
Expand All @@ -46,7 +47,7 @@ class OIGenerator {

private:
std::filesystem::path outputPath;
std::filesystem::path configFilePath;
std::vector<std::filesystem::path> configFilePaths;
std::filesystem::path sourceFileDumpPath;
bool failIfNothingGenerated = false;
bool pic = false;
Expand Down
7 changes: 4 additions & 3 deletions tools/OILGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <cstdlib>
#include <filesystem>
#include <iostream>
#include <vector>

#include "oi/OICodeGen.h"
#include "oi/OIGenerator.h"
Expand Down Expand Up @@ -61,7 +62,7 @@ int main(int argc, char* argv[]) {
FLAGS_stderrthreshold = 0;

fs::path outputPath = "a.o";
fs::path configFilePath = "/usr/local/share/oi/base.oid.toml";
std::vector<fs::path> configFilePaths;
fs::path sourceFileDumpPath = "";
bool exitCode = false;
bool pic = false;
Expand All @@ -77,7 +78,7 @@ int main(int argc, char* argv[]) {
outputPath = optarg;
break;
case 'c':
configFilePath = optarg;
configFilePaths.emplace_back(optarg);
break;
case 'd':
google::LogToStderr();
Expand Down Expand Up @@ -114,7 +115,7 @@ int main(int argc, char* argv[]) {
OIGenerator oigen;

oigen.setOutputPath(std::move(outputPath));
oigen.setConfigFilePath(std::move(configFilePath));
oigen.setConfigFilePaths(std::move(configFilePaths));
oigen.setSourceFileDumpPath(sourceFileDumpPath);
oigen.setFailIfNothingGenerated(exitCode);
oigen.setUsePIC(pic);
Expand Down

0 comments on commit 217f675

Please sign in to comment.