| 50 | #include <Language.h> |
| 51 | |
| 52 | int main(int argc, char *const argv[]) { |
| 53 | argparse::ArgumentParser program("GPUOpen GRS - Message Generator"); |
| 54 | |
| 55 | // Setup parameters |
| 56 | program.add_argument("-libs").help("Path of a library for extensions").default_value(std::string("")); |
| 57 | program.add_argument("-templates").help("Path of the templates").required(); |
| 58 | program.add_argument("-schemaxml").help("Path of the schema xml file").required(); |
| 59 | program.add_argument("-lang").help("Languages to generator for, limited to [cpp, cs]").default_value(std::string("")); |
| 60 | program.add_argument("-opath").help("Output directory of the generated files").required(); |
| 61 | |
| 62 | // Attempt to parse the input |
| 63 | try { |
| 64 | program.parse_args(argc, argv); |
| 65 | } catch (const std::runtime_error &err) { |
| 66 | std::cerr << err.what() << std::endl; |
| 67 | std::cerr << program; |
| 68 | return 1; |
| 69 | } |
| 70 | |
| 71 | // Arguments |
| 72 | auto &&libs = program.get<std::string>("-libs"); |
| 73 | auto &&templates = program.get<std::string>("-templates"); |
| 74 | auto &&schemaxml = program.get<std::string>("-schemaxml"); |
| 75 | auto &&outputpath = program.get<std::string>("-opath"); |
| 76 | auto &&langs = program.get<std::string>("-lang"); |
| 77 | |
| 78 | // Libraries to import |
| 79 | std::vector<Library> libraries; |
| 80 | |
| 81 | // Parse libraries |
| 82 | std::stringstream libStream(libs); |
| 83 | while( libStream.good() && !libs.empty() ) { |
| 84 | std::string libraryPath; |
| 85 | getline(libStream, libraryPath, ','); |
| 86 | |
| 87 | // Try to load the library |
| 88 | Library& library = libraries.emplace_back(); |
| 89 | if (!library.Load(libraryPath.c_str())) { |
| 90 | std::cerr << "Failed to load library: '" << libraryPath << "'" << std::endl; |
| 91 | return 1; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | // Shared registry |
| 96 | Registry registry; |
| 97 | |
| 98 | // Install the message generator |
| 99 | auto messageGenerator = registry.AddNew<MessageGenerator>(); |
| 100 | |
| 101 | // Setup the host |
| 102 | GeneratorHost host; |
| 103 | host.AddMessage("struct", messageGenerator); |
| 104 | host.AddMessage("message", messageGenerator); |
| 105 | |
| 106 | // Install all libraries |
| 107 | for (Library& lib : libraries) { |
| 108 | auto* install = lib.GetProcAddr<PluginInstall>("Install"); |
| 109 | if (!install) { |
nothing calls this directly
no test coverage detected