public void Load(DCompilerConfiguration config, bool isDebug) { Configuration = config; IsDebug = isDebug; if (config == null) { Load (null); return; } //compiler targets 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.Executable; }
/// <summary> /// Note: the ParseCache's Root package will NOT be copied but simply assigned to the local root package! /// Changes made to the local root package will affect o's Root package!! /// </summary> /// <param name="o"></param> public void AssignFrom(DCompilerConfiguration o) { Vendor = o.Vendor; BinPath = o.BinPath; SourceCompilerCommand = o.SourceCompilerCommand; ArgumentPatterns.CopyFrom(o.ArgumentPatterns); EnableGDCLibPrefixing = o.EnableGDCLibPrefixing; IncludePaths.Clear(); if (o.IncludePaths != null) { IncludePaths.AddRange(o.IncludePaths); } DefaultLibraries.Clear(); DefaultLibraries.AddRange(o.DefaultLibraries); LinkTargetConfigurations.Clear(); foreach (var kv in o.LinkTargetConfigurations) { var newLt = new LinkTargetConfiguration(); newLt.CopyFrom(kv.Value); LinkTargetConfigurations [kv.Key] = newLt; } FinishedParsing = o.FinishedParsing; HadInitialParse = o.HadInitialParse; }
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); }
static void HandleOverLongArgumentStrings(DCompilerConfiguration cmp, bool isLinking, ref string argstring, out string tempFile) { tempFile = null; if (argstring.Length < 1024) { return; } if (isLinking && !cmp.ArgumentPatterns.CommandFileCanBeUsedForLinking) { return; } var cmdFile = cmp.ArgumentPatterns.CommandFile; if (string.IsNullOrWhiteSpace(cmdFile)) { return; } tempFile = Path.GetTempFileName(); File.WriteAllText(tempFile, argstring); argstring = string.Format(cmdFile, tempFile); }
/// <summary> /// Note: the ParseCache's Root package will NOT be copied but simply assigned to the local root package! /// Changes made to the local root package will affect o's Root package!! /// </summary> /// <param name="o"></param> public void AssignFrom(DCompilerConfiguration o) { Vendor = o.Vendor; BinPath = o.BinPath; SourceCompilerCommand = o.SourceCompilerCommand; ArgumentPatterns.CopyFrom(o.ArgumentPatterns); EnableGDCLibPrefixing = o.EnableGDCLibPrefixing; ParseCache.ParsedDirectories.Clear(); if (o.ParseCache.ParsedDirectories != null) { ParseCache.ParsedDirectories.AddRange(o.ParseCache.ParsedDirectories); } ParseCache.Root = o.ParseCache.Root; DefaultLibraries.Clear(); DefaultLibraries.AddRange(o.DefaultLibraries); LinkTargetConfigurations.Clear(); foreach (var kv in o.LinkTargetConfigurations) { var newLt = new LinkTargetConfiguration(); newLt.CopyFrom(kv.Value); LinkTargetConfigurations [kv.Key] = newLt; } }
public void ReadFrom(DCompilerConfiguration cmpCfg, XmlReader x) { while (x.Read()) { switch (x.LocalName) { case "CompilerArg": CompilerArguments = x.ReadString(); break; case "LinkerArgs": LinkerArguments = x.ReadString(); break; case "OneStepBuildArgs": OneStepBuildArguments = x.ReadString(); break; // Legacy support case "gdcLibPrefixing": cmpCfg.EnableGDCLibPrefixing = x.ReadString() == "true"; break; } } }
/// <summary> /// Initializes all commands and arguments (also debug&release args!) with default values depending on given target compiler type /// </summary> public static DCompilerConfiguration CreateWithDefaults(DCompilerVendor Compiler) { var cfg = new DCompilerConfiguration { Vendor = Compiler }; ResetToDefaults(cfg, Compiler); return(cfg); }
/// <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 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); } }
public bool LoadFrom(DCompilerConfiguration cmpCfg, System.Xml.XmlReader x) { if (x.ReadState == ReadState.Initial) { x.Read(); } if (x.MoveToAttribute("Target") && !Enum.TryParse(x.ReadContentAsString(), true, out TargetType)) { return(false); } while (x.Read()) { switch (x.LocalName) { // For backward compatibility keep on parsing this case "CompilerCommand": cmpCfg.SourceCompilerCommand = x.ReadString(); break; case "LinkerCommand": Linker = x.ReadString(); break; case "Patterns": // ditto var s = x.ReadSubtree(); cmpCfg.ArgumentPatterns.ReadFrom(s); s.Close(); break; case "DebugArgs": s = x.ReadSubtree(); DebugArguments.ReadFrom(cmpCfg, s); s.Close(); break; case "ReleaseArgs": s = x.ReadSubtree(); ReleaseArguments.ReadFrom(cmpCfg, s); s.Close(); break; } } return(true); }
public static void Load() { // Deserialize config data _instance = PropertyService.Get <DCompiler>(GlobalPropertyName); //LoggingService.AddLogger(new MonoDevelop.Core.Logging.FileLogger("A:\\monoDev.log", true)); if (_instance == null) { _instance = new DCompiler { Dmd = DCompilerConfiguration.CreateWithDefaults(DCompilerVendor.DMD), Gdc = DCompilerConfiguration.CreateWithDefaults(DCompilerVendor.GDC), Ldc = DCompilerConfiguration.CreateWithDefaults(DCompilerVendor.LDC) } } ; }
public void ReadFrom(DCompilerConfiguration cmpCfg,XmlReader x) { while (x.Read()) switch (x.LocalName) { case "CompilerArg": CompilerArguments = x.ReadString (); break; case "LinkerArgs": LinkerArguments = x.ReadString (); break; case "OneStepBuildArgs": OneStepBuildArguments = x.ReadString (); break; // Legacy support case "gdcLibPrefixing": cmpCfg.EnableGDCLibPrefixing = x.ReadString() == "true"; break; } }
public static void ResetToDefaults(DCompilerConfiguration cfg, DCompilerVendor Compiler) { CompilerDefaultArgumentProvider cmp = null; switch (Compiler) { case DCompilerVendor.DMD: cmp = new Dmd(cfg); break; case DCompilerVendor.GDC: cmp = new Gdc(cfg); break; case DCompilerVendor.LDC: cmp = new Ldc(cfg); break; } // Reset arguments BEFORE reset compiler commands - only then, the 4 link target config objects will be created. cmp.ResetBuildArguments(); cmp.ResetCompilerConfiguration(); }
/// <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 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; }
/// <summary> /// Note: the ParseCache's Root package will NOT be copied but simply assigned to the local root package! /// Changes made to the local root package will affect o's Root package!! /// </summary> /// <param name="o"></param> public void AssignFrom(DCompilerConfiguration o) { Vendor = o.Vendor; BinPath = o.BinPath; ParseCache.ParsedDirectories.Clear(); if (o.ParseCache.ParsedDirectories != null) { ParseCache.ParsedDirectories.AddRange(o.ParseCache.ParsedDirectories); } ParseCache.Root = o.ParseCache.Root; DefaultLibraries.Clear(); DefaultLibraries.AddRange(o.DefaultLibraries); LinkTargetConfigurations.Clear(); foreach (var kv in o.LinkTargetConfigurations) { var newLt = new LinkTargetConfiguration(); newLt.CopyFrom(kv.Value); LinkTargetConfigurations [kv.Key] = newLt; } }
public static bool ResetToDefaults(DCompilerConfiguration cfg) { return(CompilerPresets.PresetLoader.TryLoadPresets(cfg)); }
public CompilerDefaultArgumentProvider(DCompilerConfiguration Configuration) { this.Configuration = Configuration; }
/// <summary> /// Initializes all commands and arguments (also debug&release args!) with default values depending on given target compiler type /// </summary> public static DCompilerConfiguration CreateWithDefaults(DCompilerVendor Compiler) { var cfg = new DCompilerConfiguration { Vendor=Compiler }; ResetToDefaults(cfg, Compiler); return cfg; }
public Dmd(DCompilerConfiguration cfg) : base(cfg) { }
/// <summary> /// Note: the ParseCache's Root package will NOT be copied but simply assigned to the local root package! /// Changes made to the local root package will affect o's Root package!! /// </summary> /// <param name="o"></param> public void AssignFrom(DCompilerConfiguration o) { Vendor = o.Vendor; BinPath = o.BinPath; ParseCache.ParsedDirectories.Clear (); if (o.ParseCache.ParsedDirectories != null) ParseCache.ParsedDirectories.AddRange (o.ParseCache.ParsedDirectories); ParseCache.Root = o.ParseCache.Root; DefaultLibraries.Clear (); DefaultLibraries.AddRange (o.DefaultLibraries); LinkTargetConfigurations.Clear (); foreach (var kv in o.LinkTargetConfigurations) { var newLt = new LinkTargetConfiguration (); newLt.CopyFrom (kv.Value); LinkTargetConfigurations [kv.Key] = newLt; } }
public static IEnumerable<string> GetLibraries(DProjectConfiguration projCfg, DCompilerConfiguration compiler) { var libraries = (IEnumerable<string>)FillInMacros(projCfg.GetReferencedLibraries(projCfg.Selector), new PrjPathMacroProvider { slnPath = projCfg.Project.ParentSolution.BaseDirectory }); if (compiler.EnableGDCLibPrefixing) libraries = HandleGdcSpecificLibraryReferencing(libraries, projCfg.Project.BaseDirectory); return libraries; }
static void HandleOverLongArgumentStrings(DCompilerConfiguration cmp, bool isLinking,ref string argstring, out string tempFile) { tempFile = null; if (argstring.Length < 1024) return; if (isLinking && !cmp.ArgumentPatterns.CommandFileCanBeUsedForLinking) return; var cmdFile = cmp.ArgumentPatterns.CommandFile; if (string.IsNullOrWhiteSpace (cmdFile)) return; tempFile = Path.GetTempFileName (); File.WriteAllText (tempFile, argstring); argstring = string.Format (cmdFile, tempFile); }
public static IEnumerable <string> GetLibraries(DProjectConfiguration projCfg, DCompilerConfiguration compiler) { var libraries = (IEnumerable <string>)FillInMacros(projCfg.GetReferencedLibraries(projCfg.Selector), new PrjPathMacroProvider { slnPath = projCfg.Project.ParentSolution != null ? projCfg.Project.ParentSolution.BaseDirectory.ToString() : "" }); if (compiler.EnableGDCLibPrefixing) { libraries = HandleGdcSpecificLibraryReferencing(libraries, projCfg.Project.BaseDirectory); } return(libraries); }
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; } }
static void LoadDefaultDmd2Paths(DCompilerConfiguration cmp) { if (cmp == null) return; if (OS.IsWindows) { foreach (var drv in Directory.GetLogicalDrives()) { string dir, p; if (string.IsNullOrEmpty(cmp.BinPath)) { dir = Path.Combine(drv, "D\\dmd2\\windows\\bin"); if (Directory.Exists(dir)) cmp.BinPath = dir; } dir = Path.Combine (drv,"D\\dmd2\\src"); p = Path.Combine (dir, "druntime\\import"); if (Directory.Exists (p)) cmp.IncludePaths.Add (p); p = Path.Combine (dir, "phobos"); if (Directory.Exists(p)) { cmp.IncludePaths.Add(p); break; } } return; } Dictionary<string,string> defaults; if (OS.IsLinux) defaults = new Dictionary<string,string> { { "/usr/local/include/dlang/dmd/",null }, { "/usr/include/dlang/dmd/",null }, { "/usr/include/dmd", null }, { "/usr/local/include/dmd", null }, }; else if (OS.IsMac) defaults = new Dictionary<string,string> { { "/usr/share/dmd/src/druntime/import", "/usr/share/dmd/src/phobos" }, { "/usr/local/opt/dmd/libexec/src/druntime", "/usr/local/opt/dmd/libexec/src/phobos" }, { "/usr/opt/dmd/libexec/src/druntime", "/usr/opt/dmd/libexec/src/phobos" }, { "/opt/dmd/libexec/src/druntime", "/opt/dmd/libexec/src/phobos" }, }; else return; foreach (var kv in defaults) { if (Directory.Exists (kv.Key)) { cmp.IncludePaths.Add (kv.Key); if (kv.Value != null && Directory.Exists (kv.Value)) cmp.IncludePaths.Add (kv.Value); } } }
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 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 (); } }
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 static string GenAdditionalAttributes(DCompilerConfiguration compiler, DProjectConfiguration cfg) { var sb = new StringBuilder(); var p = compiler.ArgumentPatterns; if (cfg.UnittestMode) { sb.Append(p.UnittestFlag + " "); } if (ProfilerModeHandler.IsProfilerMode && compiler.HasProfilerSupport) { sb.Append(p.ProfileFlag + " -v "); } if (cfg.CustomDebugIdentifiers != null && cfg.CustomVersionIdentifiers.Length != 0) { foreach (var id in cfg.CustomDebugIdentifiers) { sb.Append(p.DebugDefinition + "=" + id + " "); } } if (cfg.DebugLevel > 0) { sb.Append(p.DebugDefinition + "=" + cfg.DebugLevel + " "); } if (cfg.DebugMode) { sb.Append(p.DebugDefinition + " "); } if (cfg.CustomVersionIdentifiers != null && cfg.CustomVersionIdentifiers.Length != 0) { foreach (var id in cfg.CustomVersionIdentifiers) { sb.Append(p.VersionDefinition + "=" + id + " "); } } // DDoc handling var ddocFiles = new List <string> (); var files = cfg.Project.GetItemFiles(true); foreach (var f in files) { if (f.Extension.EndsWith(".ddoc", StringComparison.OrdinalIgnoreCase)) { ddocFiles.Add(f); } } if (ddocFiles.Count != 0) { sb.Append(p.EnableDDocFlag + " "); foreach (var ddoc in ddocFiles) { sb.AppendFormat(p.DDocDefinitionFile, ddoc); sb.Append(" "); } sb.AppendFormat(p.DDocExportDirectory, Path.IsPathRooted(cfg.DDocDirectory)? cfg.DDocDirectory : (new FilePath(cfg.DDocDirectory).ToAbsolute(cfg.Project.BaseDirectory)).ToString()); } return(sb.ToString().Trim()); }
public static string GenAdditionalAttributes (DCompilerConfiguration compiler, DProjectConfiguration cfg) { if (compiler == null || cfg == null) return string.Empty; var sb = new StringBuilder (); var p = compiler.ArgumentPatterns; string s = cfg.Platform; if (s != null && s.Contains('|')) s = s.Substring(0, s.IndexOf('|')); if (cfg.Platform != null && compiler.ArgumentPatterns.PlatformDependentOptions.TryGetValue(s, out s)) sb.Append(s).Append(' '); if (cfg.UnittestMode) sb.Append (p.UnittestFlag).Append(' '); if(ProfilerModeHandler.IsProfilerMode && compiler.HasProfilerSupport) sb.Append (p.ProfileFlag).Append(' '); if (cfg.CustomDebugIdentifiers != null && cfg.CustomVersionIdentifiers.Length != 0) foreach (var id in cfg.CustomDebugIdentifiers) sb.Append (p.DebugDefinition + "=" + id + " "); if (cfg.DebugLevel > 0) sb.Append (p.DebugDefinition).Append('=').Append(cfg.DebugLevel).Append(' '); if (cfg.DebugMode) sb.Append (p.DebugDefinition).Append(' '); if (cfg.CustomVersionIdentifiers != null && cfg.CustomVersionIdentifiers.Length != 0) foreach (var id in cfg.CustomVersionIdentifiers) sb.Append (p.VersionDefinition).Append('=').Append(id).Append(' '); // DDoc handling if (cfg.Project == null) return sb.ToString ().Trim (); var ddocFiles = new List<string> (); var files = cfg.Project.GetItemFiles (true); foreach (var f in files) if (f.Extension.EndsWith (".ddoc", StringComparison.OrdinalIgnoreCase)) ddocFiles.Add (f); if (ddocFiles.Count != 0) { sb.Append(p.EnableDDocFlag+" "); foreach(var ddoc in ddocFiles){ sb.AppendFormat(p.DDocDefinitionFile,ddoc); sb.Append(" "); } sb.AppendFormat(p.DDocExportDirectory,Path.IsPathRooted(cfg.DDocDirectory)? cfg.DDocDirectory : (new FilePath(cfg.DDocDirectory).ToAbsolute(cfg.Project.BaseDirectory)).ToString()); } return sb.ToString().Trim(); }
public static bool HasPresetsAvailable(DCompilerConfiguration compiler) { return HasPresetsAvailable(compiler.Vendor); }
/// <summary> /// Note: the ParseCache's Root package will NOT be copied but simply assigned to the local root package! /// Changes made to the local root package will affect o's Root package!! /// </summary> /// <param name="o"></param> public void AssignFrom (DCompilerConfiguration o) { Vendor = o.Vendor; BinPath = o.BinPath; SourceCompilerCommand = o.SourceCompilerCommand; ArgumentPatterns.CopyFrom(o.ArgumentPatterns); EnableGDCLibPrefixing = o.EnableGDCLibPrefixing; IncludePaths.Clear (); if (o.IncludePaths != null) IncludePaths.AddRange (o.IncludePaths); DefaultLibraries.Clear (); DefaultLibraries.AddRange (o.DefaultLibraries); LinkTargetConfigurations.Clear (); foreach (var kv in o.LinkTargetConfigurations) { var newLt = new LinkTargetConfiguration (); newLt.CopyFrom (kv.Value); LinkTargetConfigurations [kv.Key] = newLt; } FinishedParsing = o.FinishedParsing; HadInitialParse = o.HadInitialParse; }
public bool LoadFrom (DCompilerConfiguration cmpCfg,XmlReader x) { if (x.ReadState == ReadState.Initial) x.Read (); if (x.MoveToAttribute ("Target") && !Enum.TryParse(x.ReadContentAsString(), true, out TargetType)) return false; while (x.Read()) switch (x.LocalName) { // For backward compatibility keep on parsing this case "CompilerCommand": cmpCfg.SourceCompilerCommand = x.ReadString (); break; case "LinkerCommand": Linker = x.ReadString (); break; case "Patterns": // ditto var s = x.ReadSubtree (); cmpCfg.ArgumentPatterns.ReadFrom (s); s.Close (); break; case "DebugArgs": s = x.ReadSubtree (); DebugArguments.ReadFrom (cmpCfg, s); s.Close (); break; case "ReleaseArgs": s = x.ReadSubtree (); ReleaseArguments.ReadFrom (cmpCfg,s); s.Close (); break; } return true; }
public static bool ResetToDefaults(DCompilerConfiguration cfg) { return CompilerPresets.PresetLoader.TryLoadPresets(cfg); }
public static string GenAdditionalAttributes(DCompilerConfiguration compiler, DProjectConfiguration cfg) { var sb = new StringBuilder (); var p = compiler.ArgumentPatterns; if (cfg.UnittestMode) sb.Append (p.UnittestFlag + " "); if(ProfilerModeHandler.IsProfilerMode && compiler.HasProfilerSupport) sb.Append (p.ProfileFlag + " -v "); if (cfg.CustomDebugIdentifiers != null && cfg.CustomVersionIdentifiers.Length != 0) foreach (var id in cfg.CustomDebugIdentifiers) sb.Append (p.DebugDefinition + "=" + id + " "); if (cfg.DebugLevel > 0) sb.Append (p.DebugDefinition + "=" + cfg.DebugLevel + " "); if (cfg.DebugMode) sb.Append (p.DebugDefinition + " "); if (cfg.CustomVersionIdentifiers != null && cfg.CustomVersionIdentifiers.Length != 0) foreach (var id in cfg.CustomVersionIdentifiers) sb.Append (p.VersionDefinition + "=" + id + " "); // DDoc handling var ddocFiles = new List<string> (); var files = cfg.Project.GetItemFiles (true); foreach (var f in files) if (f.Extension.EndsWith (".ddoc", StringComparison.OrdinalIgnoreCase)) ddocFiles.Add (f); if (ddocFiles.Count != 0) { sb.Append(p.EnableDDocFlag+" "); foreach(var ddoc in ddocFiles){ sb.AppendFormat(p.DDocDefinitionFile,ddoc); sb.Append(" "); } sb.AppendFormat(p.DDocExportDirectory,Path.IsPathRooted(cfg.DDocDirectory)? cfg.DDocDirectory : (new FilePath(cfg.DDocDirectory).ToAbsolute(cfg.Project.BaseDirectory)).ToString()); } return sb.ToString().Trim(); }
public static IEnumerable <string> GetLibraries(DProjectConfiguration projCfg, DCompilerConfiguration compiler) { var libraries = new List <string>(FillInMacros(projCfg.GetReferencedLibraries(projCfg.Selector), new PrjPathMacroProvider { slnPath = projCfg.Project.ParentSolution != null ? projCfg.Project.ParentSolution.BaseDirectory.ToString() : "" })); // Link in lib files that are ought to be 'Compile'd foreach (var pf in projCfg.Project.Files) { if (pf.BuildAction != BuildAction.Compile) { continue; } var filePath = pf.IsLink ? pf.Link : pf.FilePath; if (OS.IsWindows ? filePath.Extension == ".a" : filePath.Extension == ".lib") { libraries.Add(filePath); } } if (compiler.EnableGDCLibPrefixing) { libraries = new List <string>(HandleGdcSpecificLibraryReferencing(libraries, projCfg.Project.BaseDirectory)); } return(libraries); }
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; }
public static string GenAdditionalAttributes(DCompilerConfiguration compiler, DProjectConfiguration cfg) { if (compiler == null || cfg == null) { return(string.Empty); } var sb = new StringBuilder(); var p = compiler.ArgumentPatterns; string s = cfg.Platform; if (s != null && s.Contains('|')) { s = s.Substring(0, s.IndexOf('|')); } if (cfg.Platform != null && compiler.ArgumentPatterns.PlatformDependentOptions.TryGetValue(s, out s)) { sb.Append(s).Append(' '); } if (cfg.UnittestMode) { sb.Append(p.UnittestFlag).Append(' '); } if (ProfilerModeHandler.IsProfilerMode && compiler.HasProfilerSupport) { sb.Append(p.ProfileFlag).Append(' '); } if (cfg.CustomDebugIdentifiers != null && cfg.CustomDebugIdentifiers.Length != 0) { foreach (var id in cfg.CustomDebugIdentifiers) { sb.Append(p.DebugDefinition + "=" + id + " "); } } if (cfg.DebugLevel > 0) { sb.Append(p.DebugDefinition).Append('=').Append(cfg.DebugLevel).Append(' '); } if (cfg.DebugMode) { sb.Append(p.DebugDefinition).Append(' '); } if (cfg.CustomVersionIdentifiers != null && cfg.CustomVersionIdentifiers.Length != 0) { foreach (var id in cfg.CustomVersionIdentifiers) { sb.Append(p.VersionDefinition).Append('=').Append(id).Append(' '); } } // DDoc handling if (cfg.Project == null) { return(sb.ToString().Trim()); } var ddocFiles = new List <string> (); var files = cfg.Project.GetItemFiles(true); foreach (var f in files) { if (f.Extension.EndsWith(".ddoc", StringComparison.OrdinalIgnoreCase)) { ddocFiles.Add(f); } } if (ddocFiles.Count != 0) { sb.Append(p.EnableDDocFlag + " "); foreach (var ddoc in ddocFiles) { sb.AppendFormat(p.DDocDefinitionFile, ddoc); sb.Append(" "); } sb.AppendFormat(p.DDocExportDirectory, Path.IsPathRooted(cfg.DDocDirectory)? cfg.DDocDirectory : (new FilePath(cfg.DDocDirectory).ToAbsolute(cfg.Project.BaseDirectory)).ToString()); } return(sb.ToString().Trim()); }
/// <summary> /// Note: the ParseCache's Root package will NOT be copied but simply assigned to the local root package! /// Changes made to the local root package will affect o's Root package!! /// </summary> /// <param name="o"></param> public void AssignFrom(DCompilerConfiguration o) { Vendor = o.Vendor; BinPath = o.BinPath; SourceCompilerCommand = o.SourceCompilerCommand; ArgumentPatterns.CopyFrom(o.ArgumentPatterns); EnableGDCLibPrefixing = o.EnableGDCLibPrefixing; ParseCache.ParsedDirectories.Clear (); if (o.ParseCache.ParsedDirectories != null) ParseCache.ParsedDirectories.AddRange (o.ParseCache.ParsedDirectories); ParseCache.Root = o.ParseCache.Root; DefaultLibraries.Clear (); DefaultLibraries.AddRange (o.DefaultLibraries); LinkTargetConfigurations.Clear (); foreach (var kv in o.LinkTargetConfigurations) { var newLt = new LinkTargetConfiguration (); newLt.CopyFrom (kv.Value); LinkTargetConfigurations [kv.Key] = newLt; } }
public Ldc(DCompilerConfiguration cfg) : base(cfg) { }
static void LoadDefaultDmd2Paths(DCompilerConfiguration cmp) { if (cmp == null) { return; } if (OS.IsWindows) { foreach (var drv in Directory.GetLogicalDrives()) { string dir, p; if (string.IsNullOrEmpty(cmp.BinPath)) { dir = Path.Combine(drv, "D\\dmd2\\windows\\bin"); if (Directory.Exists(dir)) { cmp.BinPath = dir; } } dir = Path.Combine(drv, "D\\dmd2\\src"); p = Path.Combine(dir, "druntime\\import"); if (Directory.Exists(p)) { cmp.IncludePaths.Add(p); } p = Path.Combine(dir, "phobos"); if (Directory.Exists(p)) { cmp.IncludePaths.Add(p); break; } } return; } Dictionary <string, string> defaults; if (OS.IsLinux) { defaults = new Dictionary <string, string> { { "/usr/local/include/dlang/dmd/", null }, { "/usr/include/dlang/dmd/", null }, { "/usr/include/dmd", null }, { "/usr/local/include/dmd", null }, } } ; else if (OS.IsMac) { defaults = new Dictionary <string, string> { { "/usr/share/dmd/src/druntime/import", "/usr/share/dmd/src/phobos" }, { "/usr/local/opt/dmd/libexec/src/druntime", "/usr/local/opt/dmd/libexec/src/phobos" }, { "/usr/opt/dmd/libexec/src/druntime", "/usr/opt/dmd/libexec/src/phobos" }, { "/opt/dmd/libexec/src/druntime", "/opt/dmd/libexec/src/phobos" }, } } ; else { return; } foreach (var kv in defaults) { if (Directory.Exists(kv.Key)) { cmp.IncludePaths.Add(kv.Key); if (kv.Value != null && Directory.Exists(kv.Value)) { cmp.IncludePaths.Add(kv.Value); } } } }
public static IEnumerable<string> GetLibraries(DProjectConfiguration projCfg, DCompilerConfiguration compiler) { var libraries = new List<string>(FillInMacros (projCfg.GetReferencedLibraries (projCfg.Selector), new PrjPathMacroProvider { slnPath = projCfg.Project.ParentSolution != null ? projCfg.Project.ParentSolution.BaseDirectory.ToString () : "" })); // Link in lib files that are ought to be 'Compile'd foreach (var pf in projCfg.Project.Files) { if (pf.BuildAction != BuildAction.Compile) continue; var filePath = pf.IsLink ? pf.Link : pf.FilePath; if (OS.IsWindows ? filePath.Extension == ".a" : filePath.Extension == ".lib") libraries.Add(filePath); } if (compiler.EnableGDCLibPrefixing) libraries = new List<string>(HandleGdcSpecificLibraryReferencing(libraries, projCfg.Project.BaseDirectory)); return libraries; }