public void UpdateFilelist() { foreach (var p in PhysicalDependencyPaths) { DubReferences.RawIncludes.Add(p); } foreach (var settings in GetBuildSettings(null)) { List <DubBuildSetting> l; if (settings.TryGetValue(DubBuildSettings.ImportPathsProperty, out l)) { for (int i = l.Count - 1; i >= 0; i--) // Ignore architecture/os/compiler restrictions for now { for (int j = l[i].Flags.Length - 1; j >= 0; j--) { DubReferences.RawIncludes.Add(l[i].Flags[j]); } } } } DCompilerConfiguration.UpdateParseCacheAsync(LocalIncludes, false, LocalIncludeCache_FinishedParsing); Items.Clear(); foreach (var f in GetItemFiles(true)) { Items.Add(new ProjectFile(f)); } }
public void UpdateLocalIncludeCache() { analysisFinished_LocalIncludes = false; LocalIncludeCache.SolutionPath = ParentSolution == null ? "" : ParentSolution.BaseDirectory.ToString(); LocalIncludeCache.FallbackPath = BaseDirectory; DCompilerConfiguration.UpdateParseCacheAsync(LocalIncludeCache); }
public void Load(DCompilerConfiguration compiler) { configuration = compiler; if (compiler == null) { txtBinPath.Text = txtCompiler.Text = txtConsoleAppLinker.Text = txtSharedLibLinker.Text = txtStaticLibLinker.Text = null; text_DefaultLibraries.Buffer.Clear(); text_Includes.Buffer.Clear(); releaseArgumentsDialog.Load(null, false); debugArgumentsDialog.Load(null, true); btnMakeDefault.Sensitive = false; return; } //for now, using Executable target compiler command for all targets source compiling LinkTargetConfiguration targetConfig; targetConfig = compiler.GetOrCreateTargetConfiguration(DCompileTarget.Executable); txtBinPath.Text = compiler.BinPath; txtCompiler.Text = compiler.SourceCompilerCommand; check_enableLibPrefixing.Active = compiler.EnableGDCLibPrefixing; //linker targets targetConfig = compiler.GetOrCreateTargetConfiguration(DCompileTarget.Executable); txtConsoleAppLinker.Text = targetConfig.Linker; targetConfig = compiler.GetOrCreateTargetConfiguration(DCompileTarget.SharedLibrary); txtSharedLibLinker.Text = targetConfig.Linker; targetConfig = compiler.GetOrCreateTargetConfiguration(DCompileTarget.StaticLibrary); txtStaticLibLinker.Text = targetConfig.Linker; releaseArgumentsDialog.Load(compiler, false); debugArgumentsDialog.Load(compiler, true); text_DefaultLibraries.Buffer.Text = string.Join(Environment.NewLine, compiler.DefaultLibraries); text_Includes.Buffer.Text = string.Join(Environment.NewLine, compiler.IncludePaths); btnMakeDefault.Active = configuration.Vendor == defaultCompilerVendor; btnMakeDefault.Sensitive = true; using (var buf = new StringWriter()) using (var xml = new System.Xml.XmlTextWriter(buf)) { xml.Formatting = System.Xml.Formatting.Indented; xml.WriteStartDocument(); xml.WriteStartElement("patterns"); compiler.ArgumentPatterns.SaveTo(xml); xml.WriteEndDocument(); tb_ArgPatterns.Buffer.Text = buf.ToString(); } }
public static bool TryLoadPresets(DCompilerConfiguration compiler) { if (compiler != null) { foreach (var kv in presetFileContents) { if (kv.Key == compiler.Vendor) { var x = new XmlTextReader(new StringReader(kv.Value)); x.Read(); compiler.DefaultLibraries.Clear(); compiler.IncludePaths.Clear(); compiler.ReadFrom(x); x.Close(); FitFileExtensions(compiler); return(true); } } } return(false); }
public void Load(DCompilerConfiguration config, bool isDebug) { Configuration = config; IsDebug = isDebug; if (config == null) { Load(null); return; } //compiler targets argsStore [DCompileTarget.ConsolelessExecutable] = config .GetOrCreateTargetConfiguration(DCompileTarget.ConsolelessExecutable) .GetArguments(isDebug) .Clone(); argsStore [DCompileTarget.Executable] = config .GetOrCreateTargetConfiguration(DCompileTarget.Executable) .GetArguments(isDebug) .Clone(); argsStore [DCompileTarget.SharedLibrary] = config .GetOrCreateTargetConfiguration(DCompileTarget.SharedLibrary) .GetArguments(isDebug) .Clone(); argsStore [DCompileTarget.StaticLibrary] = config .GetOrCreateTargetConfiguration(DCompileTarget.StaticLibrary) .GetArguments(isDebug) .Clone(); SelectedCompileTarget = DCompileTarget.ConsolelessExecutable; }
public bool ApplyToVirtConfiguration() { if (configuration == null) { return(false); } configuration.BinPath = txtBinPath.Text; //for now, using Executable target compiler command for all targets source compiling LinkTargetConfiguration targetConfig; targetConfig = configuration.GetOrCreateTargetConfiguration(DCompileTarget.Executable); targetConfig.Compiler = txtCompiler.Text; //linker targets targetConfig = configuration.GetOrCreateTargetConfiguration(DCompileTarget.Executable); targetConfig.Linker = txtConsoleAppLinker.Text; targetConfig = configuration.GetOrCreateTargetConfiguration(DCompileTarget.ConsolelessExecutable); targetConfig.Linker = txtGUIAppLinker.Text; targetConfig = configuration.GetOrCreateTargetConfiguration(DCompileTarget.SharedLibrary); targetConfig.Linker = txtSharedLibLinker.Text; targetConfig = configuration.GetOrCreateTargetConfiguration(DCompileTarget.StaticLibrary); targetConfig.Linker = txtStaticLibLinker.Text; releaseArgumentsDialog.Store(); debugArgumentsDialog.Store(); configuration.DefaultLibraries.Clear(); configuration.DefaultLibraries.AddRange(text_DefaultLibraries.Buffer.Text.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)); #region Store new include paths var paths = text_Includes.Buffer.Text.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); // Remove trailing / and \ for (int i = 0; i < paths.Length; i++) { paths[i] = paths[i].TrimEnd('\\', '/'); } if (configuration.ParseCache.UpdateRequired(paths)) { configuration.ParseCache.ParsedDirectories.Clear(); configuration.ParseCache.ParsedDirectories.AddRange(paths); try { // Update parse cache immediately DCompilerConfiguration.UpdateParseCacheAsync(configuration.ParseCache); } catch (Exception ex) { LoggingService.LogError("Include path analysis error", ex); } } #endregion return(true); }
public void UpdateLocalIncludeCache() { DCompilerConfiguration.UpdateParseCacheAsync(LocalIncludes, BaseDirectory, ParentSolution == null ? BaseDirectory.ToString() : ParentSolution.BaseDirectory.ToString(), true, LocalIncludeCache_FinishedParsing); }
public void Load(DCompilerConfiguration config) { configuration = config; if (config == null) { txtBinPath.Text = txtCompiler.Text = txtConsoleAppLinker.Text = txtGUIAppLinker.Text = txtSharedLibLinker.Text = txtStaticLibLinker.Text = null; text_DefaultLibraries.Buffer.Clear(); text_Includes.Buffer.Clear(); releaseArgumentsDialog.Load(null, false); debugArgumentsDialog.Load(null, true); btnMakeDefault.Sensitive = false; return; } //for now, using Executable target compiler command for all targets source compiling LinkTargetConfiguration targetConfig; targetConfig = config.GetOrCreateTargetConfiguration(DCompileTarget.Executable); txtBinPath.Text = config.BinPath; txtCompiler.Text = targetConfig.Compiler; //linker targets targetConfig = config.GetOrCreateTargetConfiguration(DCompileTarget.Executable); txtConsoleAppLinker.Text = targetConfig.Linker; targetConfig = config.GetOrCreateTargetConfiguration(DCompileTarget.ConsolelessExecutable); txtGUIAppLinker.Text = targetConfig.Linker; targetConfig = config.GetOrCreateTargetConfiguration(DCompileTarget.SharedLibrary); txtSharedLibLinker.Text = targetConfig.Linker; targetConfig = config.GetOrCreateTargetConfiguration(DCompileTarget.StaticLibrary); txtStaticLibLinker.Text = targetConfig.Linker; releaseArgumentsDialog.Load(config, false); debugArgumentsDialog.Load(config, true); text_DefaultLibraries.Buffer.Text = string.Join("\n", config.DefaultLibraries); text_Includes.Buffer.Text = string.Join("\n", config.ParseCache.ParsedDirectories); btnMakeDefault.Active = configuration.Vendor == defaultCompilerVendor; btnMakeDefault.Sensitive = true; }
public void Deserialize(ITypeSerializer handler, DataCollection data) { handler.Deserialize(this, data); foreach (var p in tempIncludes) { LocalIncludeCache.Add(p); } // Parse local includes DCompilerConfiguration.UpdateParseCacheAsync(LocalIncludeCache); }
/// <summary> /// Call this method to make all file paths etc. existing in a compiler /// config (like phobos.lib or dmd.exe) fit to the target OS properly. /// </summary> public static void FitFileExtensions(DCompilerConfiguration cfg) { for (int i = 0; i < cfg.DefaultLibraries.Count; i++) { cfg.DefaultLibraries[i] = Path.ChangeExtension(cfg.DefaultLibraries[i], DCompilerService.StaticLibraryExtension); } cfg.SourceCompilerCommand = Path.ChangeExtension(cfg.SourceCompilerCommand, DCompilerService.ExecutableExtension); foreach (var kv in cfg.LinkTargetConfigurations) { var lt = kv.Value; lt.Linker = Path.ChangeExtension(lt.Linker, DCompilerService.ExecutableExtension); } }
public void Load(DCompilerConfiguration compiler) { configuration = compiler; if (compiler == null) { txtBinPath.Text = txtCompiler.Text = txtConsoleAppLinker.Text = txtSharedLibLinker.Text = txtStaticLibLinker.Text = null; text_DefaultLibraries.Buffer.Clear(); text_Includes.Buffer.Clear(); releaseArgumentsDialog.Load(null, false); debugArgumentsDialog.Load(null, true); btnMakeDefault.Sensitive = false; return; } //for now, using Executable target compiler command for all targets source compiling LinkTargetConfiguration targetConfig; targetConfig = compiler.GetOrCreateTargetConfiguration(DCompileTarget.Executable); txtBinPath.Text = compiler.BinPath; txtCompiler.Text = compiler.SourceCompilerCommand; check_enableLibPrefixing.Active = compiler.EnableGDCLibPrefixing; //linker targets targetConfig = compiler.GetOrCreateTargetConfiguration(DCompileTarget.Executable); txtConsoleAppLinker.Text = targetConfig.Linker; targetConfig = compiler.GetOrCreateTargetConfiguration(DCompileTarget.SharedLibrary); txtSharedLibLinker.Text = targetConfig.Linker; targetConfig = compiler.GetOrCreateTargetConfiguration(DCompileTarget.StaticLibrary); txtStaticLibLinker.Text = targetConfig.Linker; releaseArgumentsDialog.Load(compiler, false); debugArgumentsDialog.Load(compiler, true); text_DefaultLibraries.Buffer.Text = string.Join("\n", compiler.DefaultLibraries); text_Includes.Buffer.Text = string.Join("\n", compiler.IncludePaths); btnMakeDefault.Active = configuration.Vendor == defaultCompilerVendor; btnMakeDefault.Sensitive = true; }
/// <summary> /// Updates the project's parse cache and reparses all of its D sources /// </summary> public void UpdateParseCache() { analysisFinished_LocalCache = analysisFinished_FileLinks = false; var hasFileLinks = new List <ProjectFile>(); foreach (var f in Files) { if ((f.IsLink || f.IsExternalToProject) && File.Exists(f.ToString())) { hasFileLinks.Add(f); } } // To prevent race condition bugs, test if links exist _before_ the actual local file parse procedure starts. if (hasFileLinks.Count == 0) { analysisFinished_FileLinks = true; } DCompilerConfiguration.UpdateParseCacheAsync(GetSourcePaths(), true, LocalFileCache_FinishedParsing); //EDIT: What if those file links refer to other project's files? Or what if more than one project reference the same files? //Furthermore, what if those files become edited and reparsed? Will their reference in the projects be updated either? // -> make a root for every file link in the global parse cache and build up a virtual root containing all file links right before a cache view is requested? /* * Since we don't want to include all link files' directories for performance reasons, * parse them separately and let the entire reparsing procedure wait for them to be successfully parsed. * Ufcs completion preparation will be done afterwards in the TryBuildUfcsCache() method. */ if (hasFileLinks.Count != 0) { new System.Threading.Thread(() => { var r = new MutableRootPackage(); foreach (var f in hasFileLinks) { r.AddModule(DParser.ParseFile(f.FilePath) as DModule); } fileLinkModulesRoot = r; analysisFinished_FileLinks = true; TryBuildUfcsCache(); }) { IsBackground = true } }
public void ReloadCompilerList() { compilerStore.Clear(); defaultCompilerVendor = DCompilerService.Instance.DefaultCompiler; foreach (var cmp in DCompilerService.Instance.Compilers) { var virtCopy = new DCompilerConfiguration(); virtCopy.AssignFrom(cmp); var iter = compilerStore.AppendValues(cmp.Vendor, virtCopy); if (cmp.Vendor == defaultCompilerVendor) { cmbCompilers.SetActiveIter(iter); } } }
private void CreateNewPreset(string name) { if (!CanUseNewName(name)) { return; } ApplyToVirtConfiguration(); configuration = new DCompilerConfiguration { Vendor = name }; ApplyToVirtConfiguration(); Gtk.TreeIter iter; iter = compilerStore.AppendValues(configuration.Vendor, configuration); cmbCompilers.SetActiveIter(iter); }
public void Load(DCompilerConfiguration config, bool isDebug) { Configuration = config; this.isDebug = isDebug; LinkTargetConfiguration targetConfig; BuildConfiguration arguments; //compiler targets targetConfig = config.GetTargetConfiguration(DCompileTarget.ConsolelessExecutable); arguments = targetConfig.GetArguments(isDebug); guiCompiler = arguments.CompilerArguments; targetConfig = config.GetTargetConfiguration(DCompileTarget.Executable); arguments = targetConfig.GetArguments(isDebug); consoleCompiler = arguments.CompilerArguments; targetConfig = config.GetTargetConfiguration(DCompileTarget.SharedLibrary); arguments = targetConfig.GetArguments(isDebug); sharedlibCompiler = arguments.CompilerArguments; targetConfig = config.GetTargetConfiguration(DCompileTarget.StaticLibrary); arguments = targetConfig.GetArguments(isDebug); staticlibCompiler = arguments.CompilerArguments; //linker targets targetConfig = config.GetTargetConfiguration(DCompileTarget.ConsolelessExecutable); arguments = targetConfig.GetArguments(isDebug); guiLinker = arguments.LinkerArguments; targetConfig = config.GetTargetConfiguration(DCompileTarget.Executable); arguments = targetConfig.GetArguments(isDebug); consoleLinker = arguments.LinkerArguments; targetConfig = config.GetTargetConfiguration(DCompileTarget.SharedLibrary); arguments = targetConfig.GetArguments(isDebug); sharedlibLinker = arguments.LinkerArguments; targetConfig = config.GetTargetConfiguration(DCompileTarget.StaticLibrary); arguments = targetConfig.GetArguments(isDebug); staticlibLinker = arguments.LinkerArguments; }
protected void btnDefaults_Clicked(object sender, System.EventArgs e) { //need new object, because the user can still hit canel at the config screen //so we don't want to update the real object yet DCompilerConfiguration realConfig = configuration; try { DCompilerConfiguration tempConfig = new DCompilerConfiguration { Vendor = configuration.Vendor }; DCompilerConfiguration.ResetToDefaults(tempConfig, configuration.Vendor); Load(tempConfig); }finally{ configuration = realConfig; releaseArgumentsDialog.Configuration = realConfig; debugArgumentsDialog.Configuration = realConfig; } }
/// <summary> /// Call this method to make all file paths etc. existing in a compiler /// config (like phobos.lib or dmd.exe) fit to the target OS properly. /// </summary> public static void FitFileExtensions(DCompilerConfiguration cfg) { for (int i = 0; i < cfg.DefaultLibraries.Count; i++) { cfg.DefaultLibraries[i] = Path.ChangeExtension(cfg.DefaultLibraries[i], DCompilerService.StaticLibraryExtension); } foreach (var kv in cfg.LinkTargetConfigurations) { var lt = kv.Value; lt.Compiler = Path.ChangeExtension(lt.Compiler, DCompilerService.ExecutableExtension); lt.Linker = Path.ChangeExtension(lt.Linker, DCompilerService.ExecutableExtension); //HACK: On windows systems, add subsystem flag to the linker to hide console window if (kv.Key == DCompileTarget.ConsolelessExecutable && OS.IsWindows) { const string subsystemExt = " -L/su:windows -L/exet:nt"; lt.DebugArguments.LinkerArguments += subsystemExt; lt.ReleaseArguments.LinkerArguments += subsystemExt; } } }
public static DCompilerConfiguration LoadFromString(string xmlCode) { var cmp = new DCompilerConfiguration(); var x = new XmlTextReader(new StringReader(xmlCode)); if (x.ReadToFollowing("Compiler")) { if (x.MoveToAttribute("Name")) { cmp.Vendor = x.ReadContentAsString(); x.MoveToElement(); } cmp.ReadFrom(x); } x.Close(); FitFileExtensions(cmp); return(cmp); }
public void Load(DCompilerConfiguration config) { configuration = config; //for now, using Executable target compiler command for all targets source compiling LinkTargetConfiguration targetConfig; targetConfig = config.GetTargetConfiguration(DCompileTarget.Executable); txtCompiler.Text = targetConfig.Compiler; //linker targets targetConfig = config.GetTargetConfiguration(DCompileTarget.Executable); txtConsoleAppLinker.Text = targetConfig.Linker; targetConfig = config.GetTargetConfiguration(DCompileTarget.ConsolelessExecutable); txtGUIAppLinker.Text = targetConfig.Linker; targetConfig = config.GetTargetConfiguration(DCompileTarget.SharedLibrary); txtSharedLibLinker.Text = targetConfig.Linker; targetConfig = config.GetTargetConfiguration(DCompileTarget.StaticLibrary); txtStaticLibLinker.Text = targetConfig.Linker; releaseArgumentsDialog.Load(config, false); debugArgumentsDialog.Load(config, true); defaultLibStore.Clear(); foreach (string lib in config.DefaultLibraries) { defaultLibStore.AppendValues(lib); } includePathStore.Clear(); foreach (var p in config.GlobalParseCache.DirectoryPaths) { includePathStore.AppendValues(p); } }
public static bool HasPresetsAvailable(DCompilerConfiguration compiler) { return(HasPresetsAvailable(compiler.Vendor)); }
public void UpdateLocalIncludeCache() { analysisFinished_LocalIncludes = false; LocalIncludeCache.FallbackPath = BaseDirectory; DCompilerConfiguration.UpdateParseCacheAsync(LocalIncludeCache); }
public bool Store() { if (configuration == null) { return(false); } // Store used compiler vendor project.UseDefaultCompilerVendor = cbUseDefaultCompiler.Active; project.PreferOneStepBuild = cbPreferOneStepCompilation.Active; Gtk.TreeIter iter; if (cmbCompiler.GetActiveIter(out iter)) { project.UsedCompilerVendor = cmbCompiler.Model.GetValue(iter, 0) as string; } // Store args configuration.ExtraCompilerArguments = extraCompilerTextView.Buffer.Text; configuration.ExtraLinkerArguments = extraLinkerTextView.Buffer.Text; configuration.OutputDirectory = text_BinDirectory.Text; configuration.Output = text_TargetFile.Text; configuration.ObjectDirectory = text_ObjectsDirectory.Text; configuration.DDocDirectory = text_DDocDir.Text; if (combo_ProjectType.GetActiveIter(out iter)) { configuration.CompileTarget = (DCompileTarget)model_compileTarget.GetValue(iter, 1); } configuration.CustomDebugIdentifiers = text_debugConstants.Text.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); configuration.CustomVersionIdentifiers = text_versionConstants.Text.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); configuration.UpdateGlobalVersionIdentifiers(project); // Store libs configuration.ExtraLibraries.Clear(); configuration.ExtraLibraries.AddRange(text_Libraries.Buffer.Text.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)); // Store includes #region Store new include paths var paths = text_Includes.Buffer.Text.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); // Remove trailing / and \ for (int i = 0; i < paths.Length; i++) { paths[i] = paths[i].TrimEnd('\\', '/'); } if (project.LocalIncludeCache.UpdateRequired(paths)) { project.LocalIncludeCache.ParsedDirectories.Clear(); project.LocalIncludeCache.ParsedDirectories.AddRange(paths); try { // Update parse cache immediately DCompilerConfiguration.UpdateParseCacheAsync(project.LocalIncludeCache); } catch (Exception ex) { LoggingService.LogError("Include path analysis error", ex); } } #endregion // Store project deps project.ProjectDependencies.Clear(); foreach (var i in vbox_ProjectDeps) { var cb = i as CheckButton; if (cb == null || !cb.Active) { continue; } var prj = cb.Data["prj"] as Project; if (prj != null) { project.ProjectDependencies.Add(prj.ItemId); } } return(true); }