-I and -D command line options (specify include paths/defines)

This commit is contained in:
Wolfgang Thaller 2014-10-16 02:26:41 +02:00
parent 30abda2087
commit 8b723e5685
3 changed files with 24 additions and 0 deletions

View File

@ -28,6 +28,8 @@ int main(int argc, const char *argv[])
("output,o", po::value<std::string>()->default_value("rez.output.rsrc"), "output file")
("type,t", po::value<std::string>()->default_value("rsrc"), "output file finder type code")
("creator,c", po::value<std::string>()->default_value("RSED"), "output file finder creator code")
("define,D", po::value<std::vector<std::string>>(), "predefine preprocessor symbol")
("include,I", po::value<std::vector<std::string>>(), "add include file path")
("debug,d", "debug logging")
;
po::options_description hidden, alldesc;
@ -71,6 +73,13 @@ int main(int argc, const char *argv[])
for(std::string fn : options["input"].as<std::vector<std::string>>())
{
RezLexer lexer(fn);
for(std::string define : options["define"].as<std::vector<std::string>>())
lexer.addDefine(define);
for(std::string path : options["include"].as<std::vector<std::string>>())
lexer.addIncludePath(path);
RezParser parser(lexer, world);
parser.parse();
}

View File

@ -101,6 +101,18 @@ RezLexer::~RezLexer()
}
void RezLexer::addDefine(std::string str)
{
pImpl->ctx.add_macro_definition(str);
}
void RezLexer::addIncludePath(std::string path)
{
pImpl->ctx.add_include_path(path.c_str());
}
bool RezLexer::atEnd()
{
return pImpl->iter == pImpl->ctx.end();

View File

@ -23,6 +23,9 @@ public:
~RezLexer();
RezSymbol nextToken();
void addDefine(std::string str);
void addIncludePath(std::string path);
};
#endif // REZLEXER_H