mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
oilgen: add an --exit-code option to fail on noop
This commit is contained in:
parent
9cb8fd7a97
commit
72f31639b7
@ -16,7 +16,7 @@ oilgen:
|
|||||||
ln -s ../../build/oilgen oilgen
|
ln -s ../../build/oilgen oilgen
|
||||||
|
|
||||||
JitCompiled.o: oilgen OilVectorOfStrings.o
|
JitCompiled.o: oilgen OilVectorOfStrings.o
|
||||||
DRGN_ENABLE_TYPE_ITERATOR=1 ./oilgen -o JitCompiled.o -c ../../build/sample.oid.toml -d OilVectorOfStrings.o
|
./oilgen --exit-code -o JitCompiled.o -c ../../build/sample.oid.toml -d OilVectorOfStrings.o
|
||||||
|
|
||||||
OilVectorOfStrings: OilVectorOfStrings.o JitCompiled.o
|
OilVectorOfStrings: OilVectorOfStrings.o JitCompiled.o
|
||||||
${CXX} ${CXXFLAGS} OilVectorOfStrings.o JitCompiled.o -o OilVectorOfStrings
|
${CXX} ${CXXFLAGS} OilVectorOfStrings.o JitCompiled.o -o OilVectorOfStrings
|
||||||
|
@ -199,7 +199,11 @@ int OIGenerator::generate(fs::path& primaryObject, SymbolService& symbols) {
|
|||||||
size_t successes = oilTypes.size() - failures;
|
size_t successes = oilTypes.size() - failures;
|
||||||
LOG(INFO) << "object introspection generation complete. " << successes
|
LOG(INFO) << "object introspection generation complete. " << successes
|
||||||
<< " successes and " << failures << " failures.";
|
<< " successes and " << failures << " failures.";
|
||||||
return (failures > 0) ? -1 : 0;
|
|
||||||
|
if (failures > 0 || (failIfNothingGenerated && successes == 0)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ObjectIntrospection
|
} // namespace ObjectIntrospection
|
||||||
|
@ -39,11 +39,15 @@ class OIGenerator {
|
|||||||
void setSourceFileDumpPath(fs::path _sourceFileDumpPath) {
|
void setSourceFileDumpPath(fs::path _sourceFileDumpPath) {
|
||||||
sourceFileDumpPath = std::move(_sourceFileDumpPath);
|
sourceFileDumpPath = std::move(_sourceFileDumpPath);
|
||||||
}
|
}
|
||||||
|
void setFailIfNothingGenerated(bool fail) {
|
||||||
|
failIfNothingGenerated = fail;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
fs::path outputPath;
|
fs::path outputPath;
|
||||||
fs::path configFilePath;
|
fs::path configFilePath;
|
||||||
fs::path sourceFileDumpPath;
|
fs::path sourceFileDumpPath;
|
||||||
|
bool failIfNothingGenerated;
|
||||||
|
|
||||||
std::unordered_map<std::string, std::string> oilStrongToWeakSymbolsMap(
|
std::unordered_map<std::string, std::string> oilStrongToWeakSymbolsMap(
|
||||||
drgnplusplus::program& prog);
|
drgnplusplus::program& prog);
|
||||||
|
@ -34,6 +34,8 @@ constexpr static OIOpts opts{
|
|||||||
"Path to OI configuration file."},
|
"Path to OI configuration file."},
|
||||||
OIOpt{'d', "dump-jit", optional_argument, "<jit.cpp>",
|
OIOpt{'d', "dump-jit", optional_argument, "<jit.cpp>",
|
||||||
"Write generated code to a file (for debugging)."},
|
"Write generated code to a file (for debugging)."},
|
||||||
|
OIOpt{'e', "exit-code", no_argument, nullptr,
|
||||||
|
"Return a bad exit code if nothing is generated."},
|
||||||
};
|
};
|
||||||
|
|
||||||
void usage() {
|
void usage() {
|
||||||
@ -55,6 +57,7 @@ int main(int argc, char* argv[]) {
|
|||||||
fs::path outputPath = "a.o";
|
fs::path outputPath = "a.o";
|
||||||
fs::path configFilePath = "/usr/local/share/oi/base.oid.toml";
|
fs::path configFilePath = "/usr/local/share/oi/base.oid.toml";
|
||||||
fs::path sourceFileDumpPath = "";
|
fs::path sourceFileDumpPath = "";
|
||||||
|
bool exitCode = false;
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt_long(argc, argv, opts.shortOpts(), opts.longOpts(),
|
while ((c = getopt_long(argc, argv, opts.shortOpts(), opts.longOpts(),
|
||||||
@ -69,6 +72,9 @@ int main(int argc, char* argv[]) {
|
|||||||
case 'd':
|
case 'd':
|
||||||
sourceFileDumpPath = optarg != nullptr ? optarg : "jit.cpp";
|
sourceFileDumpPath = optarg != nullptr ? optarg : "jit.cpp";
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
exitCode = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +95,7 @@ int main(int argc, char* argv[]) {
|
|||||||
oigen.setOutputPath(std::move(outputPath));
|
oigen.setOutputPath(std::move(outputPath));
|
||||||
oigen.setConfigFilePath(std::move(configFilePath));
|
oigen.setConfigFilePath(std::move(configFilePath));
|
||||||
oigen.setSourceFileDumpPath(sourceFileDumpPath);
|
oigen.setSourceFileDumpPath(sourceFileDumpPath);
|
||||||
|
oigen.setFailIfNothingGenerated(exitCode);
|
||||||
|
|
||||||
SymbolService symbols(primaryObject);
|
SymbolService symbols(primaryObject);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user