/// <summary> /// Run CodeGenerator /// </summary> public void Run() { Logger.Progress(0, "Starting code generation..."); try { // Run the parser var parser = new Parser.CppParser { IsGeneratingDoc = IsGeneratingDoc, DocProviderAssembly = DocProviderAssemblyPath, // @"..\..\..\DocProviderFromMsdn\bin\debug\DocProviderFromMsdn.exe", ForceParsing = _isAssemblyNew, CastXmlExecutablePath = CastXmlExecutablePath }; // Init the parser parser.Init(Config); if (Logger.HasErrors) { Logger.Fatal("Initializing parser failed"); } // Run the parser var group = parser.Run(); if (Logger.HasErrors) { Logger.Fatal("C++ compiler failed to parse header files"); } // Run the main mapping process var transformer = new TransformManager { GeneratedPath = _generatedPath, ForceGenerator = _isAssemblyNew, AppType = AppType }; transformer.Init(group, Config); if (Logger.HasErrors) { Logger.Fatal("Mapping rules initialization failed"); } transformer.Generate(); if (Logger.HasErrors) { Logger.Fatal("Code generation failed"); } // Print statistics parser.PrintStatistics(); transformer.PrintStatistics(); // Output all elements var fileWriter = new StreamWriter("SharpGen_rename.log"); transformer.NamingRules.DumpRenames(fileWriter); fileWriter.Close(); // Update Checkfile for assembly File.WriteAllText(_assemblyCheckFile, ""); File.SetLastWriteTime(_assemblyCheckFile, _assemblyDatetime); // Update Checkfile for all config files File.WriteAllText(_allConfigCheck, ""); File.SetLastWriteTime(_allConfigCheck, DateTime.Now); } finally { Logger.Progress(100, "Finished"); } }
/// <summary> /// Run CodeGenerator /// </summary> public void Run() { Logger.Progress(0, "Starting code generation..."); try { var consumerConfig = new ConfigFile { Id = ConsumerBindMappingConfigId }; // Run the parser var parser = new Parser.CppParser(GlobalNamespace, Logger) { IsGeneratingDoc = IsGeneratingDoc, DocProviderAssembly = DocProviderAssemblyPath, ForceParsing = _isAssemblyNew, CastXmlExecutablePath = CastXmlExecutablePath, OutputPath = IntermediateOutputPath }; // Init the parser (consumerConfig.IncludeProlog, consumerConfig.IncludeDirs, consumerConfig.Includes) = parser.Init(Config); if (Logger.HasErrors) { Logger.Fatal("Initializing parser failed"); } // Run the parser var group = parser.Run(); if (Logger.HasErrors) { Logger.Fatal("C++ compiler failed to parse header files"); } // Run the main mapping process var transformer = new TransformManager(GlobalNamespace, Logger) { GeneratedPath = _generatedPath, IncludeAssemblyNameFolder = IncludeAssemblyNameFolder, GeneratedCodeFolder = GeneratedCodeFolder, ForceGenerator = _isAssemblyNew, AppType = AppType }; consumerConfig.Extension = transformer.Init(group, Config, IntermediateOutputPath); if (Logger.HasErrors) { Logger.Fatal("Mapping rules initialization failed"); } transformer.Generate(IntermediateOutputPath); if (Logger.HasErrors) { Logger.Fatal("Code generation failed"); } // Print statistics parser.PrintStatistics(); transformer.PrintStatistics(); // Output all elements using (var renameLog = File.Open(Path.Combine(IntermediateOutputPath, "SharpGen_rename.log"), FileMode.OpenOrCreate, FileAccess.Write)) using (var fileWriter = new StreamWriter(renameLog)) { transformer.NamingRules.DumpRenames(fileWriter); } var(bindings, defines) = transformer.GenerateTypeBindingsForConsumers(); consumerConfig.Bindings.AddRange(bindings); consumerConfig.Extension.AddRange(defines); // TODO: Include include-prolog's and include rules w/ pre or post text (no attaches). GenerateConfigForConsumers(consumerConfig); // Update Checkfile for assembly File.WriteAllText(_assemblyCheckFile, ""); File.SetLastWriteTime(_assemblyCheckFile, _assemblyDatetime); // Update Checkfile for all config files File.WriteAllText(_allConfigCheck, ""); File.SetLastWriteTime(_allConfigCheck, DateTime.Now); } finally { Logger.Progress(100, "Finished"); } }