/// <summary>Compiles the source files with the selected configuration.</summary> /// <exception cref="NotImplementedException">Not yet implemented.</exception> public async void Compile() { // Get the list of input folders the user added himself IList <string> inputFolders = new List <string>(this.ImportFolderView.ImportFolders.Select(f => f.FolderPath)); // We always want to add skyrims data folder, if only for the flags file. inputFolders.Add(Path.Combine(this.settingsRepository.Read()["SkyrimPath"].ToString(), @"Data\Scripts\Source")); var filePaths = Directory.GetFiles(Path.Combine(this.SolutionPath, "src"), "*.psc", SearchOption.AllDirectories); var scripts = filePaths.Select(file => new PapyrusScript { Path = file, FlagsFile = this.ConfigurationView.FlagsFile }); ICompiler compiler = Compiler.CreateInstance(this.settingsRepository.Read()["SkyrimPath"].ToString()); foreach (string inputFolder in inputFolders) { compiler.ImportFolders.Add(inputFolder); } foreach (PapyrusScript script in scripts) { compiler.FilesToCompile.Add(script); } compiler.Debug = this.ConfigurationView.Debug; compiler.Optimize = this.ConfigurationView.Optimize; compiler.AssemblyOption = this.ConfigurationView.SelectedAssemblyOption; compiler.Quiet = this.ConfigurationView.Quiet; compiler.OutputFolder = Path.Combine(this.SolutionPath, "bin", this.SelectedConfiguration, "scripts"); compiler.CompilerErrorHandler += this.CompilerErrorHandler; compiler.CompilerNotifyHandler += this.CompilerNotifyHandler; // Increase the build by one per compile int build = Convert.ToInt32(string.IsNullOrEmpty(this.Version.Build) ? "0" : this.Version.Build) + 1; this.Version = this.Version.Change(build: build.ToString()); // Compile and move await compiler.CompileAsync(); this.MoveCompileFiles(); }
/// <summary> /// Compile the module file /// </summary> private async Task CompileModuleAsync( string path, Recipe recipe, BuildState buildState, IList <string> includePaths, string objectDirectory, string binaryDirectory) { Log.Info("Compile Module"); if (string.IsNullOrEmpty(recipe.Public)) { throw new InvalidOperationException("The public file was not set."); } var modules = new List <string>(); var defines = new List <string>(); defines.Add("SOUP_BUILD"); // Set the active version namespace defines.Add(BuildRecipeNamespaceDefine(recipe)); // Add all of the direct dependencies as module references // and set their version defintions // TODO: MSVC requires all trasnsitive modules also bool isRecursive = _compiler.Name == "MSVC"; await BuildDependencyModuleReferences(path, binaryDirectory, recipe, modules, defines, isRecursive); // TODO: Clang wants modules to be cppm var publicFile = recipe.Public; if (_compiler.Name == "Clang") { publicFile = Path.GetFileNameWithoutExtension(publicFile) + ".cppm"; } var args = new CompileArguments() { Standard = Compiler.LanguageStandard.Latest, RootDirectory = path, OutputDirectory = objectDirectory, PreprocessorDefinitions = defines, SourceFiles = new List <string>() { publicFile }, IncludeDirectories = includePaths, Modules = modules, ExportModule = true, GenerateIncludeTree = true, }; // Ensure the object directory exists var objectDirectry = Path.Combine(args.RootDirectory, objectDirectory); if (!Directory.Exists(objectDirectry)) { Directory.CreateDirectory(objectDirectry); } // Compile each file var result = await _compiler.CompileAsync(args); // Save the build state if (result.HeaderIncludeFiles != null) { buildState.UpdateIncludeTree(result.HeaderIncludeFiles); } }