MCPcopy Create free account
hub / github.com/GPUOpen-Tools/GPU-Reshape / main

Function main

Source/Test/Device/Generator/Source/main.cpp:43–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41#include "Assembler.h"
42
43int main(int argc, char *const argv[]) {
44 argparse::ArgumentParser argParser("GPUOpen GRS - TestSuite Backend generator");
45
46 // Setup parameters
47 argParser.add_argument("-shaderType").help("Shader type file").default_value(std::string(""));
48 argParser.add_argument("-test").help("Test file").default_value(std::string(""));
49 argParser.add_argument("-name").help("Shader name").default_value(std::string(""));
50 argParser.add_argument("-templates").help("Path to the templates").default_value(std::string(""));
51 argParser.add_argument("-shader").help("Path of the generated shader header").default_value(std::string(""));
52 argParser.add_argument("-feature").help("Name of the feature").default_value(std::string(""));
53 argParser.add_argument("-o").help("Output of the generated file").default_value(std::string(""));
54
55 // Attempt to parse the input
56 try {
57 argParser.parse_args(argc, argv);
58 } catch (const std::runtime_error &err) {
59 std::cerr << err.what() << std::endl;
60 std::cerr << argParser;
61 return 1;
62 }
63
64 // Arguments
65 auto &&shaderType = argParser.get<std::string>("-shaderType");
66 auto &&test = argParser.get<std::string>("-test");
67 auto &&name = argParser.get<std::string>("-name");
68 auto &&templates = argParser.get<std::string>("-templates");
69 auto &&shader = argParser.get<std::string>("-shader");
70 auto &&feature = argParser.get<std::string>("-feature");
71 auto &&out = argParser.get<std::string>("-o");
72
73 // Mode
74 if (!shaderType.empty()) {
75 TemplateEngine shaderTypeTemplate;
76
77 // Load template
78 if (!shaderTypeTemplate.Load((std::filesystem::path(templates) / "ShaderType.cppt").string().c_str())) {
79 std::cerr << "Failed to load template" << std::endl;
80 return 1;
81 }
82
83 // Names
84 shaderTypeTemplate.SubstituteAll("$PATH", shaderType.c_str());
85 shaderTypeTemplate.SubstituteAll("$NAME", name.c_str());
86
87 // Attempt to open the output
88 std::ofstream outFile(out);
89 if (!outFile.good()) {
90 std::cerr << "Failed to open file '" << out << "'" << std::endl;
91 return 1;
92 }
93
94 // Write contents
95 outFile << shaderTypeTemplate.GetString();
96 } else if (!test.empty()) {
97 // Attempt to load the test
98 std::ifstream testFile(test);
99 if (!testFile.good()) {
100 std::cerr << "Failed to open file '" << test << "'" << std::endl;

Callers

nothing calls this directly

Calls 6

SubstituteAllMethod · 0.80
emptyMethod · 0.45
LoadMethod · 0.45
GetStringMethod · 0.45
ParseMethod · 0.45
AssembleMethod · 0.45

Tested by

no test coverage detected