public override string GetCompilerFlags(CProjectConfiguration configuration) { StringBuilder args = new StringBuilder(); string precdir = Path.Combine(configuration.SourceDirectory, ".prec"); CCompilationParameters cp = (CCompilationParameters)configuration.CompilationParameters; if (configuration.DebugMode) { args.Append("-g "); } if (configuration.CompileTarget == CBinding.CompileTarget.SharedLibrary) { args.Append("-fPIC "); } switch (cp.WarningLevel) { case WarningLevel.None: args.Append("-w "); break; case WarningLevel.Normal: // nothing break; case WarningLevel.All: args.Append("-Wall "); break; } args.Append("-O" + cp.OptimizationLevel + " "); if (cp.ExtraCompilerArguments != null && cp.ExtraCompilerArguments.Length > 0) { string extraCompilerArgs = cp.ExtraCompilerArguments.Replace('\n', ' '); args.Append(extraCompilerArgs + " "); } if (cp.DefineSymbols != null && cp.DefineSymbols.Length > 0) { args.Append(ProcessDefineSymbols(cp.DefineSymbols) + " "); } if (configuration.Includes != null) { foreach (string inc in configuration.Includes) { args.Append("-I" + inc + " "); } } args.Append("-I" + precdir); return(args.ToString()); }
public CProject(ProjectCreateInformation info, XmlElement projectOptions, string language) { Init(); string binPath = "."; if (info != null) { Name = info.ProjectName; binPath = info.BinPath; } switch (language) { case "C": this.language = Language.C; break; case "CPP": this.language = Language.CPP; break; } Compiler = null; // use default compiler depending on language CProjectConfiguration configuration = (CProjectConfiguration)CreateConfiguration("Debug"); ((CCompilationParameters)configuration.CompilationParameters).DefineSymbols = "DEBUG MONODEVELOP"; Configurations.Add(configuration); configuration = (CProjectConfiguration)CreateConfiguration("Release"); configuration.DebugMode = false; ((CCompilationParameters)configuration.CompilationParameters).OptimizationLevel = 3; ((CCompilationParameters)configuration.CompilationParameters).DefineSymbols = "MONODEVELOP"; Configurations.Add(configuration); foreach (CProjectConfiguration c in Configurations) { c.OutputDirectory = Path.Combine(binPath, c.Name); c.SourceDirectory = BaseDirectory; c.Output = Name; CCompilationParameters parameters = c.CompilationParameters as CCompilationParameters; if (projectOptions != null) { if (projectOptions.Attributes["Target"] != null) { c.CompileTarget = (CBinding.CompileTarget)Enum.Parse( typeof(CBinding.CompileTarget), projectOptions.Attributes["Target"].InnerText); } if (projectOptions.Attributes["PauseConsoleOutput"] != null) { c.PauseConsoleOutput = bool.Parse( projectOptions.Attributes["PauseConsoleOutput"].InnerText); } if (projectOptions.Attributes["CompilerArgs"].InnerText != null) { if (parameters != null) { parameters.ExtraCompilerArguments = projectOptions.Attributes["CompilerArgs"].InnerText; } } if (projectOptions.Attributes["LinkerArgs"].InnerText != null) { if (parameters != null) { parameters.ExtraLinkerArguments = projectOptions.Attributes["LinkerArgs"].InnerText; } } } } }
private void MakeSharedLibrary(ProjectFileCollection projectFiles, ProjectPackageCollection packages, CProjectConfiguration configuration, CompilerResults cr, IProgressMonitor monitor, string outputName) { if (!NeedsUpdate(projectFiles, outputName)) { return; } string objectFiles = StringArrayToSingleString(ObjectFiles(projectFiles)); string pkgargs = GeneratePkgLinkerArgs(packages); StringBuilder args = new StringBuilder(); CCompilationParameters cp = (CCompilationParameters)configuration.CompilationParameters; if (cp.ExtraLinkerArguments != null && cp.ExtraLinkerArguments.Length > 0) { string extraLinkerArgs = cp.ExtraLinkerArguments.Replace('\n', ' '); args.Append(extraLinkerArgs + " "); } if (configuration.LibPaths != null) { foreach (string libpath in configuration.LibPaths) { args.Append("-L" + libpath + " "); } } if (configuration.Libs != null) { foreach (string lib in configuration.Libs) { args.Append("-l" + lib + " "); } } monitor.Log.WriteLine("Generating shared object..."); string linker_args = string.Format("-shared -o {0} {1} {2} {3}", outputName, objectFiles, args.ToString(), pkgargs); monitor.Log.WriteLine("using: " + linkerCommand + " " + linker_args); ProcessWrapper p = Runtime.ProcessService.StartProcess(linkerCommand, linker_args, null, null); p.WaitForExit(); string line; StringWriter error = new StringWriter(); while ((line = p.StandardError.ReadLine()) != null) { error.WriteLine(line); } monitor.Log.WriteLine(error.ToString()); ParseCompilerOutput(error.ToString(), cr); error.Close(); p.Close(); ParseLinkerOutput(error.ToString(), cr); }
public CodeGenerationPanel (Properties customizationObject) { this.Build (); configuration = customizationObject.Get<CProjectConfiguration> ("Config"); compilationParameters = (CCompilationParameters)configuration.CompilationParameters; Gtk.CellRendererText textRenderer = new Gtk.CellRendererText (); libTreeView.Model = libStore; libTreeView.HeadersVisible = false; libTreeView.AppendColumn ("Library", textRenderer, "text", 0); libPathTreeView.Model = libPathStore; libPathTreeView.HeadersVisible = false; libPathTreeView.AppendColumn ("Library", textRenderer, "text", 0); includePathTreeView.Model = includePathStore; includePathTreeView.HeadersVisible = false; includePathTreeView.AppendColumn ("Include", textRenderer, "text", 0); switch (compilationParameters.WarningLevel) { case WarningLevel.None: noWarningRadio.Active = true; break; case WarningLevel.Normal: normalWarningRadio.Active = true; break; case WarningLevel.All: allWarningRadio.Active = true; break; } optimizationSpinButton.Value = compilationParameters.OptimizationLevel; switch (configuration.CompileTarget) { case CBinding.CompileTarget.Bin: targetComboBox.Active = 0; break; case CBinding.CompileTarget.StaticLibrary: targetComboBox.Active = 1; break; case CBinding.CompileTarget.SharedLibrary: targetComboBox.Active = 2; break; } extraCompilerTextView.Buffer.Text = compilationParameters.ExtraCompilerArguments; extraLinkerTextView.Buffer.Text = compilationParameters.ExtraLinkerArguments; defineSymbolsTextEntry.Text = compilationParameters.DefineSymbols; foreach (string lib in configuration.Libs) libStore.AppendValues (lib); foreach (string libPath in configuration.LibPaths) libPathStore.AppendValues (libPath); foreach (string includePath in configuration.Includes) includePathStore.AppendValues (includePath); }
public CodeGenerationPanel(Properties customizationObject) { this.Build(); configuration = customizationObject.Get <CProjectConfiguration> ("Config"); compilationParameters = (CCompilationParameters)configuration.CompilationParameters; Gtk.CellRendererText textRenderer = new Gtk.CellRendererText(); libTreeView.Model = libStore; libTreeView.HeadersVisible = false; libTreeView.AppendColumn("Library", textRenderer, "text", 0); libPathTreeView.Model = libPathStore; libPathTreeView.HeadersVisible = false; libPathTreeView.AppendColumn("Library", textRenderer, "text", 0); includePathTreeView.Model = includePathStore; includePathTreeView.HeadersVisible = false; includePathTreeView.AppendColumn("Include", textRenderer, "text", 0); switch (compilationParameters.WarningLevel) { case WarningLevel.None: noWarningRadio.Active = true; break; case WarningLevel.Normal: normalWarningRadio.Active = true; break; case WarningLevel.All: allWarningRadio.Active = true; break; } optimizationSpinButton.Value = compilationParameters.OptimizationLevel; switch (configuration.CompileTarget) { case CBinding.CompileTarget.Bin: targetComboBox.Active = 0; break; case CBinding.CompileTarget.StaticLibrary: targetComboBox.Active = 1; break; case CBinding.CompileTarget.SharedLibrary: targetComboBox.Active = 2; break; } extraCompilerTextView.Buffer.Text = compilationParameters.ExtraCompilerArguments; extraLinkerTextView.Buffer.Text = compilationParameters.ExtraLinkerArguments; defineSymbolsTextEntry.Text = compilationParameters.DefineSymbols; foreach (string lib in configuration.Libs) { libStore.AppendValues(lib); } foreach (string libPath in configuration.LibPaths) { libPathStore.AppendValues(libPath); } foreach (string includePath in configuration.Includes) { includePathStore.AppendValues(includePath); } }