/// <summary>Initialises a new instance of the <see cref="ConfigurationViewModel"/> class.</summary> /// <param name="eventAggregator">An event aggregator instance used to publish application wide messages.</param> /// <param name="configuration">The configuration to be used with this ViewModel.</param> public ConfigurationViewModel(IEventAggregator eventAggregator, CompileConfiguration configuration) { this.eventAggregator = eventAggregator; // Set sensible defaults, if the configuration is null if (configuration == null) { this.All = true; this.Debug = false; this.Optimize = false; this.Quiet = true; this.FlagsFile = "TESV_Papyrus_Flags.flg"; this.SelectedAssemblyOption = AssemblyOption.AssembleAndDelete; // Since we want to keep the defaults, we return here. return; } this.All = configuration.All; this.Debug = configuration.Debug; this.Optimize = configuration.Optimize; this.Quiet = configuration.Quiet; this.FlagsFile = configuration.FlagFile; this.SelectedAssemblyOption = configuration.AssemblyOption; }
bool ProcessModel(CompileConfiguration cc) { String modelName = Path.GetFileNameWithoutExtension(cc.modelFilename); String modelExtension = Path.GetExtension(cc.modelFilename); CSharpCodeProvider compiler; CompilerParameters compParams; SetupCompiler(null, out compiler, out compParams); compParams.ReferencedAssemblies.AddRange(cc.externalAssemblies); compParams.CompilerOptions = (flags & ProcessSpecFlags.CompileWithDebug) != 0 ? "/debug" : "/optimize"; compParams.OutputAssembly = cc.destDir + "lgsp-" + modelName + ".dll"; CompilerResults compResults; try { if(File.Exists(cc.destDir + modelName + "ExternalFunctions.cs")) { String externalFunctionsFile = cc.destDir + modelName + "ExternalFunctions.cs"; String externalFunctionsImplFile = cc.destDir + modelName + "ExternalFunctionsImpl.cs"; if(cc.modelStubFilename != null) compResults = compiler.CompileAssemblyFromFile(compParams, cc.modelFilename, cc.modelStubFilename, externalFunctionsFile, externalFunctionsImplFile); else compResults = compiler.CompileAssemblyFromFile(compParams, cc.modelFilename, externalFunctionsFile, externalFunctionsImplFile); } else { if(cc.modelStubFilename != null) compResults = compiler.CompileAssemblyFromFile(compParams, cc.modelFilename, cc.modelStubFilename); else compResults = compiler.CompileAssemblyFromFile(compParams, cc.modelFilename); } if(compResults.Errors.HasErrors) { Console.Error.WriteLine("Illegal model C# source code: " + compResults.Errors.Count + " Errors:"); foreach(CompilerError error in compResults.Errors) Console.Error.WriteLine("Line: " + error.Line + " - " + error.ErrorText + " @ " + error.FileName); return false; } } catch(Exception ex) { Console.Error.WriteLine("Unable to compile model: {0}", ex.Message); return false; } cc.modelAssembly = compResults.CompiledAssembly; cc.modelAssemblyName = compParams.OutputAssembly; AddAssembly(cc.modelAssembly); Console.WriteLine(" - Model assembly \"{0}\" generated.", cc.modelAssemblyName); return true; }
public static void Rescan() { CompileConfiguration.ClearScripts(); ReloadDirectory("Assets/Resources"); CompileConfiguration.Save(); var content = "Found scripts:\n\n" + string.Join("\n", CompileConfiguration.Content.Scripts.Keys.Take(20)); if (CompileConfiguration.Content.Scripts.Count > 20) { content += "\n...more"; } EditorUtility.DisplayDialog("Rescan finished", content, "Close"); }
/// <summary> /// 设置通用的配置 /// </summary> /// <param name="compile"></param> public static void SetCommonConfiguration(this CompileConfiguration compile) { // 属性等于属性的写法作用是用来在配置文件里面写入默认配置 // 如果配置不存在,那么将被写入默认配置 // 作用:先在项目根路径调用命令,此时写入了默认配置,默认配置的路径将是对的相对路径 // 第二个命令在项目其他路径调用,此时尝试获取配置,拿到的配置是第一个任务写入的绝对路径 // 如果没有此方法,那么第二个命令将不知道哪个是项目的根路径,无法解决我在仓库里面给某个子项目打包。如有仓库是 `lindexi` 里面包含三个不同的项目 `shi` `dou` `bi` 此时如果想要打包 `shi` 和 `dou` 两个项目,每个项目打包都是独立的,那么将无法找对项目 compile.BuildConfigurationDirectory = compile.BuildConfigurationDirectory; compile.ObfuscationConfigurationSaprojDirectory = compile.ObfuscationConfigurationSaprojDirectory; compile.SetupConfigurationDirectory = compile.SetupConfigurationDirectory; compile.InstallerWorkingDirectory = compile.InstallerWorkingDirectory; compile.InstallerCompilingDirectory = compile.InstallerCompilingDirectory; compile.InstallerPackingDirectory = compile.InstallerPackingDirectory; }
/// <summary>Saves the selected solution to the solution repository.</summary> public void SaveSolution() { // Create a solution object with the information attainable from this view model. Solution sln = new Solution { Path = this.SolutionPath, Name = this.SolutionName, Version = this.Version }; // Get the configurations the solution currently has IList <CompileConfiguration> compileConfigs = new List <CompileConfiguration>(this.Configurations.Where(config => !Equals(config, Constants.EditCompileConfiguration))); sln.CompileConfigurations = compileConfigs; // Refresh the information on the currently selected configuration and set the name. CompileConfiguration selectedConfig = this.GenerateConfigurationDetails(); selectedConfig.Name = this.SelectedConfiguration; sln.SelectedConfiguration = this.SelectedConfiguration; // Now we need to pass the solution to the repository. Since it only accepts DictionaryRanges // we need to wrap the solution. IDictionaryRange <string, Solution> solutions = new DictionaryRange <string, Solution>(); solutions.Add(this.SolutionName, sln); // We also need to check if the solution name changed and handle it properly. if (this.oldSolutionName != this.SolutionName) { this.solutionRepository.Delete(new List <string> { this.oldSolutionName }); this.solutionRepository.Create(solutions); this.oldSolutionName = sln.Name; } else { this.solutionRepository.Update(solutions); } // Refresh the view models properties this.Configurations = new ObservableCollection <CompileConfiguration>(sln.CompileConfigurations) { Constants.EditCompileConfiguration }; // Reset the selected configuration this.SelectedConfiguration = sln.SelectedConfiguration; }
private static void RemoveTranslation(string language) { if (!EditorUtility.DisplayDialog($"Delete translation {language}", "This action cannot be reversed", "Remove", "Cancel")) { return; } foreach (var(_, info) in CompileConfiguration.Content.Scripts.Where(e => e.Value.Translations.ContainsKey(language))) { info.Translations.Remove(language); info.RemoveTranslationFile(language); } CompileConfiguration.Save(); AssetDatabase.Refresh(); }
/// <summary> /// 寻找本机安装的 MSBuild 文件路径,填充到 <paramref name="compileConfiguration"/> 里 /// </summary> /// <param name="compileConfiguration"></param> public static void FindInstalledMSBuildFilePath(CompileConfiguration compileConfiguration) { var vs2019Community = @"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"; if (File.Exists(vs2019Community)) { compileConfiguration.VS2019CommunityMSBuild = vs2019Community; } var vs2019Enterprise = @"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe"; if (File.Exists(vs2019Enterprise)) { compileConfiguration.VS2019EnterpriseMSBuild = vs2019Enterprise; } var vs2019Professional = @"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe"; if (File.Exists(vs2019Professional)) { compileConfiguration.VS2019ProfessionalMSBuild = vs2019Professional; } var vs2022EnterpriseMSBuild = @"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Msbuild\Current\Bin\MSBuild.exe"; if (File.Exists(vs2022EnterpriseMSBuild)) { compileConfiguration.VS2022EnterpriseMSBuild = vs2022EnterpriseMSBuild; } var vs2022ProfessionalMSBuild = @"C:\Program Files\Microsoft Visual Studio\2022\Professional\Msbuild\Current\Bin\MSBuild.exe"; if (File.Exists(vs2022ProfessionalMSBuild)) { compileConfiguration.VS2022ProfessionalMSBuild = vs2022ProfessionalMSBuild; } var vs2022CommunityMSBuild = @"C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\MSBuild.exe"; if (File.Exists(vs2022CommunityMSBuild)) { compileConfiguration.VS2022CommunityMSBuild = vs2022CommunityMSBuild; } }
/// <summary>Changes the compile configuration for the current solution.</summary> /// <param name="sender">The <see cref="ComboBox"/> that holds the selected item.</param> public void ChangeConfiguration(ComboBox sender) { // If the selected item is null, we do nothing. if (sender.SelectedItem == null) { return; } // Get the name of the selected compile configuration CompileConfiguration configurationName = (CompileConfiguration)sender.SelectedValue; // If then name is equal to <edit...> then we open the configuration manager if (configurationName.Equals(Constants.EditCompileConfiguration)) { // Create a new ViewModel ConfigurationManagerViewModel viewModel = new ConfigurationManagerViewModel(this.windowManager, this.Configurations); // Get how the window was closed bool?answer = this.windowManager.ShowDialog(viewModel); // If the window was closed with "true" we want to handle the data coming back if (answer.HasValue && answer.Value) { this.Configurations = viewModel.GetConfigurations(); } // After adding a new configuration to the solution we need to save it. this.SaveSolution(); // We don't want to do anything more, so we return. return; } // If the user didn't select the <edit...> item, we simply set the new selected configuration this.SelectedConfiguration = configurationName.Name; // After that we want to show the user the configuration view this.ConfigurationView = new ConfigurationViewModel(this.eventAggregator, this.Configurations.Single(c => c.Name == this.SelectedConfiguration)); // Again, we want to save the changes in the solution. this.SaveSolution(); }
private void CreateTranslation(ICollection <string> existedLanguageName) { if (!TranslationManager.CheckLanguageName(_newLanguage)) { EditorUtility.DisplayDialog("Unable to add translation", $"Translation name can only contains A-Z, a-z, 0-9, _", "Close"); } else if (existedLanguageName.Contains(_newLanguage)) { EditorUtility.DisplayDialog("Unable to add translation", $"Translation {_newLanguage} already existed", "Close"); } else { foreach (var(_, info) in CompileConfiguration.Content.Scripts) { info.Translations.Add(_newLanguage, null); info.CreateTranslationFile(_newLanguage); } _newLanguage = ""; CompileConfiguration.Save(); AssetDatabase.Refresh(); } }
/// <summary> /// 编译文件 /// </summary> /// <param name="path">脚本ID</param> /// <param name="forceCompile">是否强制重新编译</param> /// <returns>发生变化的文件列表</returns> public static IEnumerable <string> CompileAsset(string path, bool forceCompile = false) { if (!Application.isEditor) { throw new NotSupportedException($"Cannot compile {path}: static file compiler can only run in editor mode"); } if (!path.EndsWith(".vns")) { throw new NotSupportedException($"Cannot compile {path}: file name extension must be .vns"); } var option = ScriptInformation.CreateInformationFromAsset(path); if (option == null) { throw new NullReferenceException($"Cannot compile {path}: target outside of source folder or target is not acceptable script/binary"); } var changedFiles = new List <string>(); var source = File.ReadAllText(path, Encoding.UTF8).UnifyLineBreak(); if (!option.hash.HasValue) { option.hash = Hasher.Crc32(Encoding.UTF8.GetBytes(source)); } var identifier = new CodeIdentifier { Id = option.id, Hash = option.hash.Value }; // 编译文件 if (!forceCompile) { if (option.recordedHash.HasValue && option.recordedHash.Value == identifier.Hash) { return(new string[] { }); // 如果源代码内容没有变化则直接跳过编译 } } var(content, defaultTranslation) = CompileCode(source, identifier); var binaryFile = option.BinaryAssetPath(); File.WriteAllBytes(binaryFile, content); option.recordedHash = option.hash = identifier.Hash; changedFiles.Add(binaryFile); // 处理其他翻译 foreach (var(language, _) in option.Translations) { var languageFile = option.LanguageAssetPath(language); if (File.Exists(languageFile)) { var existedTranslation = new ScriptTranslation(File.ReadAllText(languageFile)); if (!existedTranslation.MergeWith(defaultTranslation)) { continue; } existedTranslation.SaveToAsset(languageFile); changedFiles.Add(languageFile); } else { // 如果翻译不存在,以默认翻译为蓝本新建翻译文件 defaultTranslation.SaveToAsset(languageFile); changedFiles.Add(languageFile); } } CompileConfiguration.Save(); return(changedFiles); }
/// <summary> /// 重新扫描项目并更新目标脚本的信息 /// </summary> /// <param name="option">目标脚本信息</param> /// <param name="save">是否扫描完成后自动保存</param> public static void RescanScriptInformation(ScriptInformation option, bool save = true) { var source = option.SourceAssetPath(); if (!string.IsNullOrEmpty(source)) { if (File.Exists(source)) { option.hash = Hasher.Crc32(Encoding.UTF8.GetBytes(File.ReadAllText(source, Encoding.UTF8).UnifyLineBreak())); } else { option.hash = null; } } var binary = option.BinaryAssetPath(); if (!string.IsNullOrEmpty(binary)) { if (File.Exists(source)) { var stream = new FileStream(binary, FileMode.Open); var hash = ScriptInformation.ReadBinaryHash(stream); stream.Close(); option.recordedHash = hash; } else { option.recordedHash = null; } } var detectedLanguage = new List <string>(); foreach (var language in Directory.GetDirectories($"Assets/{CompileConfiguration.Content.TranslationFolder}").Select(Path.GetFileName)) { if (File.Exists($"Assets/{CompileConfiguration.Content.TranslationFolder}/{language}/{option.id}.txt")) { if (!option.Translations.ContainsKey(language)) { option.Translations.Add(language, null); } detectedLanguage.Add(language); } else { if (option.Translations.ContainsKey(language)) { option.Translations.Remove(language); } } } var needRemove = new List <string>(); foreach (var(key, _) in option.Translations) { if (!detectedLanguage.Contains(key)) { needRemove.Add(key); } } foreach (var key in needRemove) { option.Translations.Remove(key); } if (!option.HasSource() && !option.HasBinary()) { CompileConfiguration.Content.Scripts.Remove(option.id); } if (save) { CompileConfiguration.Save(); } }
private ErrorType CompileActions(CompileConfiguration cc, String actionsOutputSource) { CSharpCodeProvider compiler; CompilerParameters compParams; SetupCompiler(cc.modelAssemblyName, out compiler, out compParams); compParams.ReferencedAssemblies.AddRange(cc.externalAssemblies); compParams.GenerateInMemory = false; compParams.IncludeDebugInformation = (flags & ProcessSpecFlags.CompileWithDebug) != 0; compParams.CompilerOptions = (flags & ProcessSpecFlags.CompileWithDebug) != 0 ? "/debug" : "/optimize"; compParams.TreatWarningsAsErrors = false; compParams.OutputAssembly = cc.destDir + "lgsp-" + cc.actionsName + ".dll"; CompilerResults compResults; if((flags & ProcessSpecFlags.KeepGeneratedFiles) != 0) { if(cc.externalActionsExtensionOutputFilename != null) { if(cc.externalActionsExtensionFilename != null) compResults = compiler.CompileAssemblyFromFile(compParams, cc.actionsOutputFilename, cc.externalActionsExtensionOutputFilename, cc.externalActionsExtensionFilename); else compResults = compiler.CompileAssemblyFromFile(compParams, cc.actionsOutputFilename, cc.externalActionsExtensionOutputFilename); } else compResults = compiler.CompileAssemblyFromFile(compParams, cc.actionsOutputFilename); } else { if(cc.externalActionsExtensionOutputFilename != null) { String externalActionsExtensionOutputSource; String externalActionsExtensionSource; ErrorType result = ReadExternalActionExtensionSources(cc.externalActionsExtensionOutputFilename, cc.externalActionsExtensionFilename, out externalActionsExtensionOutputSource, out externalActionsExtensionSource); if(result != ErrorType.NoError) return result; if(cc.externalActionsExtensionFilename != null) compResults = compiler.CompileAssemblyFromSource(compParams, actionsOutputSource, externalActionsExtensionOutputSource, externalActionsExtensionSource); else compResults = compiler.CompileAssemblyFromSource(compParams, actionsOutputSource, externalActionsExtensionOutputSource); } else compResults = compiler.CompileAssemblyFromSource(compParams, actionsOutputSource); } if(compResults.Errors.HasErrors) { String errorMsg = compResults.Errors.Count + " Errors:"; foreach(CompilerError error in compResults.Errors) errorMsg += String.Format("\r\n{0} at line {1} of {2}: {3}", error.IsWarning ? "Warning" : "ERROR", error.Line, error.FileName, error.ErrorText); Console.Error.WriteLine("Illegal generated actions C# source code (or erroneous programmed extension), " + errorMsg); return ErrorType.GrGenNetError; } Console.WriteLine(" - Actions assembly \"{0}\" generated.", compParams.OutputAssembly); return ErrorType.NoError; }
private ErrorType GenerateActionsSourceCode(CompileConfiguration cc, IGraphModel model, String statisticsPath, out String actionsOutputSource) { /////////////////////////////////////////////// // compile the intermediate action files generated by the java frontend // to gain access via reflection to their content needed for matcher code generation // and collect that content actionsOutputSource = null; Assembly initialAssembly; ErrorType result = CompileIntermediateActions(cc.modelAssemblyName, cc.actionsFilename, out initialAssembly); if(result != ErrorType.NoError) return result; Dictionary<String, Type> actionTypes; Dictionary<String, Type> proceduresTypes; LGSPRuleAndMatchingPatterns ruleAndMatchingPatterns; CollectActionTypes(initialAssembly, out actionTypes, out proceduresTypes, out ruleAndMatchingPatterns); Dictionary<String, List<IFilter>> rulesToFilters; Dictionary<String, List<String>> filterFunctionsToInputTypes; Dictionary<String, List<String>> rulesToInputTypes; Dictionary<String, List<String>> rulesToOutputTypes; Dictionary<String, List<String>> sequencesToInputTypes; Dictionary<String, List<String>> sequencesToOutputTypes; Dictionary<String, List<String>> proceduresToInputTypes; Dictionary<String, List<String>> proceduresToOutputTypes; Dictionary<String, bool> proceduresToIsExternal; Dictionary<String, List<String>> functionsToInputTypes; Dictionary<String, String> functionsToOutputType; Dictionary<String, bool> functionsToIsExternal; Dictionary<String, List<String>> rulesToTopLevelEntities; Dictionary<String, List<String>> rulesToTopLevelEntityTypes; CollectActionParameterTypes(ruleAndMatchingPatterns, model, out rulesToFilters, out filterFunctionsToInputTypes, out rulesToInputTypes, out rulesToOutputTypes, out rulesToTopLevelEntities, out rulesToTopLevelEntityTypes, out sequencesToInputTypes, out sequencesToOutputTypes, out proceduresToInputTypes, out proceduresToOutputTypes, out proceduresToIsExternal, out functionsToInputTypes, out functionsToOutputType, out functionsToIsExternal); LGSPSequenceGenerator seqGen = new LGSPSequenceGenerator(this, model, rulesToFilters, filterFunctionsToInputTypes, rulesToInputTypes, rulesToOutputTypes, rulesToTopLevelEntities, rulesToTopLevelEntityTypes, sequencesToInputTypes, sequencesToOutputTypes, proceduresToInputTypes, proceduresToOutputTypes, proceduresToIsExternal, functionsToInputTypes, functionsToOutputType, functionsToIsExternal); /////////////////////////////////////////////// // generate external extension source if needed (cause there are external action extension) bool isAutoGeneratedFilterExisting; bool isExternalFilterFunctionExisting; bool isExternalSequenceExisting; DetermineWhetherExternalActionsFileIsNeeded(ruleAndMatchingPatterns, out isAutoGeneratedFilterExisting, out isExternalFilterFunctionExisting, out isExternalSequenceExisting); SourceBuilder externalSource = null; if(isAutoGeneratedFilterExisting || isExternalFilterFunctionExisting || isExternalSequenceExisting) { EmitExternalActionsFileHeader(cc, model, isExternalFilterFunctionExisting || isExternalSequenceExisting, ref externalSource); } /////////////////////////////////////////////// // take action intermediate file until action insertion point as base for action file SourceBuilder source = new SourceBuilder((flags & ProcessSpecFlags.KeepGeneratedFiles) != 0); source.Indent(); source.Indent(); bool actionPointFound; String actionsNamespace; result = CopyIntermediateCodeInsertingSequencesCode(cc.actionsFilename, actionTypes, proceduresTypes, seqGen, source, out actionPointFound, out actionsNamespace); if(result != ErrorType.NoError) return result; if(!actionPointFound) { Console.Error.WriteLine("Illegal actions C# input source code: Actions insertion point not found!"); return ErrorType.GrGenJavaError; } source.Unindent(); source.Append("\n"); /////////////////////////////////////////////// // generate and insert the matcher source code into the action file // already filled with the content of the action intermediate file until the action insertion point String unitName; int lastDot = actionsNamespace.LastIndexOf("."); if(lastDot == -1) unitName = ""; else unitName = actionsNamespace.Substring(lastDot + 8); // skip ".Action_" LGSPGraphStatistics graphStatistics = null; if(statisticsPath != null) { Console.WriteLine("Reading graph statistics from {0}", statisticsPath); graphStatistics = new LGSPGraphStatistics(model); graphStatistics.Parse(statisticsPath); } GenerateAndInsertMatcherSourceCode(model, cc.actionsName, unitName, cc.externalActionsExtensionFilename, ruleAndMatchingPatterns, seqGen, isAutoGeneratedFilterExisting, isExternalFilterFunctionExisting, graphStatistics, statisticsPath, externalSource, source); actionsOutputSource = WriteSourceAndExternalSource(externalSource, source, cc.actionsOutputFilename, cc.externalActionsExtensionOutputFilename); return ErrorType.NoError; }
private ErrorType GenerateModelAndIntermediateActions(CompileConfiguration cc) { if((flags & ProcessSpecFlags.UseExistingMask) == ProcessSpecFlags.UseNoExistingFiles) { List<String> genModelFiles, genModelStubFiles, genActionsFiles; if(!ExecuteGrGenJava(cc.tmpDir, flags, out genModelFiles, out genModelStubFiles, out genActionsFiles, cc.specFile)) { return ErrorType.GrGenJavaError; } if(genModelFiles.Count == 1) cc.modelFilename = genModelFiles[0]; else if(genModelFiles.Count > 1) { Console.Error.WriteLine("Multiple models are not supported by ProcessSpecification, yet!"); return ErrorType.GrGenNetError; } if(genModelStubFiles.Count == 1) cc.modelStubFilename = genModelStubFiles[0]; else if(genModelStubFiles.Count > 1) { Console.Error.WriteLine("Multiple model stubs are not supported by ProcessSpecification, yet!"); return ErrorType.GrGenNetError; } if(genActionsFiles.Count == 1) cc.actionsFilename = genActionsFiles[0]; else if(genActionsFiles.Count > 1) { Console.Error.WriteLine("Multiple action sets are not supported by ProcessSpecification, yet!"); return ErrorType.GrGenNetError; } } else { String[] producedFiles = Directory.GetFiles(cc.tmpDir); foreach(String file in producedFiles) { if(file.EndsWith("Model.cs")) { if(cc.modelFilename == null || File.GetLastWriteTime(file) > File.GetLastWriteTime(cc.modelFilename)) cc.modelFilename = file; } else if(file.EndsWith("Actions_intermediate.cs")) { if(cc.actionsFilename == null || File.GetLastWriteTime(file) > File.GetLastWriteTime(cc.actionsFilename)) cc.actionsFilename = file; } else if(file.EndsWith("ModelStub.cs")) { if(cc.modelStubFilename == null || File.GetLastWriteTime(file) > File.GetLastWriteTime(cc.modelStubFilename)) cc.modelStubFilename = file; } } } if(cc.modelFilename == null || cc.actionsFilename == null) { Console.Error.WriteLine("Not all required files have been generated!"); return ErrorType.GrGenJavaError; } return ErrorType.NoError; }
private ErrorType GetActionsSourceCode(CompileConfiguration cc, IGraphModel model, String statisticsPath, out String actionsOutputSource) { ErrorType res; if((flags & ProcessSpecFlags.UseExistingMask) == ProcessSpecFlags.UseAllGeneratedFiles) res = ReuseExistingActionsSourceCode(cc.actionsOutputFilename, out actionsOutputSource); else res = GenerateActionsSourceCode(cc, model, statisticsPath, out actionsOutputSource); return res; }
ErrorType ProcessSpecificationImpl(String specFile, String destDir, String tmpDir, String statisticsPath, String[] externalAssemblies) { Console.WriteLine("Building libraries..."); CompileConfiguration cc = new CompileConfiguration(specFile, destDir, tmpDir, externalAssemblies); /////////////////////////////////////////////// // use java frontend to build the model and intermediate action source files ErrorType res = GenerateModelAndIntermediateActions(cc); if(res != ErrorType.NoError) return res; /////////////////////////////////////////////// // compile the model if(!ProcessModel(cc)) return ErrorType.GrGenNetError; IGraphModel model = GetGraphModel(cc.modelAssembly); if(model == null) return ErrorType.GrGenNetError; if((flags & ProcessSpecFlags.NoProcessActions) != 0) return ErrorType.NoError; /////////////////////////////////////////////// // get the actions source code String actionsOutputSource; res = GetActionsSourceCode(cc, model, statisticsPath, out actionsOutputSource); if(res != ErrorType.NoError) return res; if((flags & ProcessSpecFlags.NoCreateActionsAssembly) != 0) return ErrorType.NoError; /////////////////////////////////////////////// // finally compile the actions source file into an action assembly res = CompileActions(cc, actionsOutputSource); if(res != ErrorType.NoError) return res; return ErrorType.NoError; }
private void EmitExternalActionsFileHeader(CompileConfiguration cc, IGraphModel model, bool implementationNeeded, ref SourceBuilder externalSource) { cc.externalActionsExtensionOutputFilename = cc.destDir + cc.actionsName + "ExternalFunctions.cs"; externalSource = new SourceBuilder((flags & ProcessSpecFlags.KeepGeneratedFiles) != 0); // generate external action extension file header externalSource.AppendFront("// This file has been generated automatically by GrGen (www.grgen.net)\n"); externalSource.AppendFront("// Do not modify this file! Any changes will be lost!\n"); externalSource.AppendFrontFormat("// Generated from \"{0}.grg\" on {1} {2}\n", cc.baseName, DateTime.Now.ToString(), System.TimeZone.CurrentTimeZone.StandardName); externalSource.AppendFront("using System;\n"); externalSource.AppendFront("using System.Collections.Generic;\n"); externalSource.AppendFront("using GRGEN_LIBGR = de.unika.ipd.grGen.libGr;\n"); externalSource.AppendFront("using GRGEN_LGSP = de.unika.ipd.grGen.lgsp;\n"); externalSource.AppendFrontFormat("using GRGEN_MODEL = de.unika.ipd.grGen.Model_" + model.ModelName + ";\n"); externalSource.AppendFrontFormat("using GRGEN_ACTIONS = de.unika.ipd.grGen.Action_" + cc.baseName + ";\n"); externalSource.AppendFront("\nnamespace de.unika.ipd.grGen.Action_" + cc.baseName + "\n"); externalSource.AppendFront("{"); externalSource.Indent(); if(implementationNeeded) // not needed if only generated filters exist, then the generated file is sufficient cc.externalActionsExtensionFilename = cc.destDir + cc.actionsName + "ExternalFunctionsImpl.cs"; }