/// <summary> /// Outputs a message to the console or the form /// </summary> /// <param name="strMsg">The message to output</param> public static void Output(string strMsg) { if (isConsoleApp) { Console.WriteLine(strMsg); } else { Form1.Instance().Output(strMsg); } }
/// <summary> /// Gets a value indicating whether invalid counters should be considered errors, or if they should be ignored. /// </summary> /// <returns>True to ignore the invalid counters; false if they should be considered errors.</returns> public static bool IgnoreInvalidCounters() { if (isConsoleApp) { // by default, running from the console will ignore invalid counters return(true); } else { return(Form1.Instance().IgnoreInvalidCounters()); } }
public static void Main(string[] args) { if (args.Length == 0) { isConsoleApp = false; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(Form1.Instance()); return; } if (args.Length != 2 && args.Length != 5) { Console.WriteLine("Usage: PublicCounterCompiler.exe"); Console.WriteLine(" - using no parameters will open the user interface"); Console.WriteLine("Usage: PublicCounterCompiler [API] [HW generation]"); Console.WriteLine(" opens the user interface and propulates the input fileds with the following parameters:"); Console.WriteLine(" [API] - the API to compile counters for (ex: GL, CL, HSA, DX11, etc)"); Console.WriteLine(" [HW generation] - the generation to compile counters for (ex: R10xx, R11xx, R12xx, etc)"); Console.WriteLine("Usage: PublicCounterCompiler [counter names file] [Public counter definition file] [output dir] [active section label]"); Console.WriteLine(" [counter names file] - text file containing hardware counter names and type (CounterNames[API][GEN].txt)"); Console.WriteLine(" [Public counter definition file] - text file defining how the public counters are calculated (PublicCounterDefinitions*.txt)"); Console.WriteLine(" [Output Dir] - the directory to generate the output in (Ex: the path to the Src/GPUPerfAPICounterGenerator directory)"); Console.WriteLine(" [Counter List Output Dir] - the directory to generate the counter list text files in (Ex: the path to the Output/CounterListFiles directory)"); Console.WriteLine(" [Test output Dir] - the directory to generate the test output in (Ex: the path to the Src/GPUPerfAPIUnitTests/counters directory)"); Console.WriteLine(" [Active section label] - the label to take the counter names from (ex: dx11r10xx)"); return; } if (args.Length == 2) { isConsoleApp = false; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form1.Instance().apiName.Text = args[0]; Form1.Instance().GPUFamily.Text = args[1]; Application.Run(Form1.Instance()); return; } else if (args.Length == 5) { string strError; if (LoadFilesAndGenerateOutput(args[0], args[1], args[2], args[3], args[4], args[5], out strError) == false) { Output(strError); } } }
public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // set output paths const string compilerOutputFolder = "output\\"; int endPath = Application.StartupPath.IndexOf(compilerOutputFolder) + compilerOutputFolder.Length; if (compilerOutputFolder.Length == endPath) { MessageBox.Show(Application.ProductName + " was started out of unexpected folder.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string gpaPath = GpaTools.Gpa.GetGpuPerfApiPath(); // Derived counter definition input var counterCompiler = new CounterCompiler(); CounterCompiler.DerivedCounterFileInput counterPath = new CounterCompiler.DerivedCounterFileInput { rootFilename = GpaTools.Gpa.publicFilePrefix, compiler_type_str = GpaTools.Gpa.publicStr, compilerInputPath = gpaPath + GpaTools.Gpa.counterDefDir, autoGenCompilerInputFilePath = gpaPath + GpaTools.Gpa.autoGenPublicCounterInputDir, outputDirectory = gpaPath + GpaTools.Gpa.autoGenCounterGeneratorOutDir, counterListOutputDirectory = gpaPath + GpaTools.Gpa.counterListOutDir, testOutputDirectory = gpaPath + GpaTools.Gpa.autoGenTestOutDir }; counterCompiler.derivedCounterFileInput = counterPath; var form = Form1.Instance(counterCompiler); // handle operational mode if (args.Length == 0) { counterCompiler.isConsoleApp = false; Application.Run(form); GpaTools.CMakeGenerator.Init = GpaTools.CounterDefCMakeGenerator.Init; GpaTools.CMakeGenerator.ProcessFile = GpaTools.CounterDefCMakeGenerator.ProcessFiles; GpaTools.CMakeGenerator.CMakeWriter = GpaTools.CounterDefCMakeGenerator.CMakeWriter; GpaTools.CMakeGenerator.AddDirectory(GpaTools.Gpa.GetGpuPerfApiPath() + "GPA\\source\\auto_generated"); GpaTools.CMakeGenerator.GenerateCMakeFiles(); return; } if (args.Length == 2 || args.Length == 7 || args.Length == 8) { // We can do this! } else { Console.WriteLine("Usage: PublicCounterCompiler.exe"); Console.WriteLine(" - using no parameters will open the user interface"); Console.WriteLine("Usage: PublicCounterCompiler [API] [HW generation]"); Console.WriteLine( " opens the user interface and populates the input fields with the following parameters:"); Console.WriteLine(" [API] - the API to compile counters for (ex: GL, CL, DX11, etc)"); Console.WriteLine( " [HW generation] - the generation to compile counters for (ex: R10xx, R11xx, R12xx, etc)"); Console.WriteLine( "Usage: PublicCounterCompiler [counter names file] [Public counter definition file] [output dir] [API] [GPU]"); Console.WriteLine( " [counter names file] - text file containing hardware counter names and type (CounterNames[API][GEN].txt)"); Console.WriteLine( " [Public counter definition file] - text file defining how the public counters are calculated (PublicCounterDefinitions*.txt)"); Console.WriteLine( " [Output Dir] - the directory to generate the output in (Ex: the path to the Src/GPUPerfAPICounterGenerator directory)"); Console.WriteLine( " [Counter List Output Dir] - the directory to generate the counter list text files in (Ex: the path to the Output/CounterListFiles directory)"); Console.WriteLine( " [Test output Dir] - the directory to generate the test output in (Ex: the path to the Src/GPUPerfAPIUnitTests/counters directory)"); Console.WriteLine( " [API] - the API to compile counters for (ex: GL, CL, DX11, etc)"); Console.WriteLine( " [HW generation] - the generation to compile counters for (ex: R10xx, R11xx, R12xx, etc)"); Console.WriteLine( " {ASIC} - name of the ASIC (ex: baffin)"); return; } if (args.Length == 2) { counterCompiler.isConsoleApp = false; counterCompiler.isConsoleApp = false; form.apiName.Text = args[0]; form.GPUFamily.Text = args[1]; Application.Run(form); GpaTools.CMakeGenerator.Init = GpaTools.CounterDefCMakeGenerator.Init; GpaTools.CMakeGenerator.ProcessFile = GpaTools.CounterDefCMakeGenerator.ProcessFiles; GpaTools.CMakeGenerator.CMakeWriter = GpaTools.CounterDefCMakeGenerator.CMakeWriter; GpaTools.CMakeGenerator.AddDirectory(GpaTools.Gpa.GetGpuPerfApiPath() + "GPA\\source\\auto_generated"); GpaTools.CMakeGenerator.GenerateCMakeFiles(); } else if (args.Length == 7) { counterCompiler.LoadFilesAndGenerateOutput("Public", args[0], args[1], args[2], args[3], args[4], args[5], args[6], string.Empty, form.DisplayMessageHandler, form.ErrorHandler); } else if (args.Length == 8) { counterCompiler.LoadFilesAndGenerateOutput("Public", args[0], args[1], args[2], args[3], args[4], args[5], args[6], "_" + args[7], form.DisplayMessageHandler, form.ErrorHandler); } }