Example #1
0
        FilePath GetOutputFileName(DotNetProjectConfiguration configuration)
        {
            FilePath outputDirectory = GetOutputDirectory(configuration);
            string   assemblyName    = Project.Name;

            return(outputDirectory.Combine(configuration.OutputAssembly + ".dll"));
        }
        public void Load(DotNetProjectConfiguration configuration)
        {
            this.configuration = configuration;
            compilerParameters = (CSharpCompilerParameters)configuration.CompilationParameters;

            symbolsEntry.Text = compilerParameters.DefineSymbols;
            generateXmlOutputCheckButton.Active      = compilerParameters.GenerateXmlDocumentation;
            enableOptimizationCheckButton.Active     = compilerParameters.Optimize;
            generateOverflowChecksCheckButton.Active = compilerParameters.GenerateOverflowChecks;
            warningsAsErrorsCheckButton.Active       = compilerParameters.TreatWarningsAsErrors;
            warningLevelSpinButton.Value             = compilerParameters.WarningLevel;
            additionalArgsEntry.Text = compilerParameters.AdditionalArguments;
            ignoreWarningsEntry.Text = compilerParameters.NoWarnings;

            int i = CSharpLanguageBinding.SupportedPlatforms.IndexOf(compilerParameters.PlatformTarget);

            comboPlatforms.Active = i != -1 ? i : 0;

            if (!configuration.DebugMode || string.Equals("none", compilerParameters.DebugType, StringComparison.OrdinalIgnoreCase))
            {
                comboDebug.Active = DEBUG_NONE;
            }
            else if (string.Equals("pdbonly", compilerParameters.DebugType, StringComparison.OrdinalIgnoreCase))
            {
                comboDebug.Active = DEBUG_PDB_ONLY;
            }
            else
            {
                comboDebug.Active = DEBUG_FULL;
            }
        }
Example #3
0
        protected override ExecutionCommand CreateExecutionCommand(ConfigurationSelector configSel,
                                                                   DotNetProjectConfiguration configuration)
        {
            var conf = (IPhoneProjectConfiguration)configuration;

            IPhoneSimulatorTarget simTarget = null;

            var minOS = string.IsNullOrEmpty(conf.MtouchMinimumOSVersion)?
                        IPhoneSdkVersion.GetDefault() : IPhoneSdkVersion.Parse(conf.MtouchMinimumOSVersion);

            if (conf.Platform != PLAT_IPHONE)
            {
                simTarget = GetSimulatorTarget(conf);
                if (simTarget == null)
                {
                    var defaultDevice = ((IPhoneProject)conf.ParentItem).SupportedDevices == TargetDevice.IPad?
                                        TargetDevice.IPad : TargetDevice.IPhone;
                    simTarget = new IPhoneSimulatorTarget(defaultDevice, conf.MtouchSdkVersion.ResolveIfDefault());
                }
            }

            return(new IPhoneExecutionCommand(TargetRuntime, TargetFramework, conf.AppDirectory, conf.OutputDirectory,
                                              conf.DebugMode && conf.MtouchDebug, simTarget, minOS, SupportedDevices)
            {
                UserAssemblyPaths = GetUserAssemblyPaths(configSel)
            });
        }
        public void LoadConfigData(ProjectConfigurationPropertyPanel dlg)
        {
            configuration      = (DotNetProjectConfiguration)dlg.CurrentConfiguration;
            project            = (DotNetProject)dlg.ConfiguredProject;
            compilerParameters = (JavaCompilerParameters)configuration.CompilationParameters;

            compileTargetCombo.Active = (int)configuration.CompileTarget;

            if (compilerParameters.Compiler == JavaCompiler.Javac)
            {
                compilerJavacButton.Active = true;
            }
            else
            {
                compilerGcjButton.Active = true;
            }

            enableOptimizationCheckButton.Active       = compilerParameters.Optimize;
            generateDebugInformationCheckButton.Active = configuration.DebugMode;
            deprecationCheckButton.Active      = compilerParameters.Deprecation;
            generateWarningsCheckButton.Active = compilerParameters.GenWarnings;
            warningsAsErrorsCheckButton.Active = !configuration.RunWithWarnings;

            compilerEntry.Text  = compilerParameters.CompilerPath;
            classPathEntry.Text = compilerParameters.ClassPath;
            mainClassEntry.Text = compilerParameters.MainClass;
            symbolsEntry.Text   = compilerParameters.DefineSymbols;
            OnCompilerToggled(null, null);
        }
		public void Load (DotNetProject project, DotNetProjectConfiguration configuration)
		{
			this.project       = project;
			this.configuration = configuration;
			compileTargetCombo.Active          = configuration.CompileTarget == CompileTarget.Exe ? 0 : 1;
			checkbuttonIncludeDebugInfo.Active = configuration.DebugSymbols;
		}
        protected override bool ConfigurationsAreEqual(IEnumerable <ItemConfiguration> configs)
        {
            DotNetProjectConfiguration cref = null;

            foreach (DotNetProjectConfiguration c in configs)
            {
                if (cref == null)
                {
                    cref = c;
                }
                else
                {
                    if (c.SignAssembly != cref.SignAssembly)
                    {
                        return(false);
                    }
                    if (c.DelaySign != cref.DelaySign)
                    {
                        return(false);
                    }
                    if (c.AssemblyKeyFile != cref.AssemblyKeyFile)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
		public void Load (DotNetProjectConfiguration configuration)
		{
			this.configuration = configuration;
			compilerParameters = (CSharpCompilerParameters) configuration.CompilationParameters;
			
			symbolsEntry.Text                          = compilerParameters.DefineSymbols;
			generateXmlOutputCheckButton.Active        = !string.IsNullOrEmpty (compilerParameters.DocumentationFile);
			enableOptimizationCheckButton.Active       = compilerParameters.Optimize;
			generateOverflowChecksCheckButton.Active   = compilerParameters.GenerateOverflowChecks;
			warningsAsErrorsCheckButton.Active         = compilerParameters.TreatWarningsAsErrors;
			warningLevelSpinButton.Value               = compilerParameters.WarningLevel;
			ignoreWarningsEntry.Text                   = compilerParameters.NoWarnings;
			
			int i = CSharpLanguageBinding.SupportedPlatforms.IndexOf (compilerParameters.PlatformTarget);
			comboPlatforms.Active = i != -1 ? i : 0;

			if (!configuration.DebugMode || string.Equals ("none", compilerParameters.DebugType, StringComparison.OrdinalIgnoreCase)) {
				comboDebug.Active = DEBUG_NONE;
			} else if (string.Equals ("pdbonly", compilerParameters.DebugType, StringComparison.OrdinalIgnoreCase)) {
				comboDebug.Active = DEBUG_PDB_ONLY;
			} else {
				comboDebug.Active = DEBUG_FULL;
			}

			xmlDocsEntry.DefaultPath = configuration.OutputDirectory;

			xmlDocsEntry.Path = string.IsNullOrEmpty (compilerParameters.DocumentationFile)
				? configuration.CompiledOutputName.ChangeExtension (".xml")
				: compilerParameters.DocumentationFile;
		}
		public void LoadConfigData (ProjectConfigurationPropertyPanel dlg)
		{	
			configuration = (DotNetProjectConfiguration) dlg.CurrentConfiguration;
			project = (DotNetProject) dlg.ConfiguredProject;
			compilerParameters = (JavaCompilerParameters) configuration.CompilationParameters;

			compileTargetCombo.Active = (int) configuration.CompileTarget;

			if (compilerParameters.Compiler == JavaCompiler.Javac)
				compilerJavacButton.Active = true;
			else
				compilerGcjButton.Active = true;

			enableOptimizationCheckButton.Active = compilerParameters.Optimize;
			generateDebugInformationCheckButton.Active = configuration.DebugMode;
			deprecationCheckButton.Active = compilerParameters.Deprecation;
			generateWarningsCheckButton.Active = compilerParameters.GenWarnings;
			warningsAsErrorsCheckButton.Active = !configuration.RunWithWarnings;
			
			compilerEntry.Text = compilerParameters.CompilerPath;
			classPathEntry.Text = compilerParameters.ClassPath;				
			mainClassEntry.Text = compilerParameters.MainClass;				
			symbolsEntry.Text = compilerParameters.DefineSymbols;	
			OnCompilerToggled (null, null);
		}
 public void Load(DotNetProject project, DotNetProjectConfiguration configuration)
 {
     this.project                       = project;
     this.configuration                 = configuration;
     compileTargetCombo.Active          = configuration.CompileTarget == CompileTarget.Exe ? 0 : 1;
     checkbuttonIncludeDebugInfo.Active = configuration.DebugMode;
 }
        protected SolutionItemConfiguration CreateConfigurationBlock(MonoDevelop.Projects.DotNetProject project, Config ConfigBlock, string AssemblyName, string OuputType, IProgressMonitor monitor)
        {
            DotNetProjectConfiguration confObj = project.CreateConfiguration(ConfigBlock.Name) as DotNetProjectConfiguration;

            confObj.RunWithWarnings = false;
            confObj.DebugMode       = ConfigBlock.DebugSymbols;
            project.CompileTarget   = (CompileTarget)Enum.Parse(typeof(CompileTarget), OuputType, true);

            string dir = MapPath(project.BaseDirectory, ConfigBlock.OutputPath);

            if (dir == null)
            {
                dir = Path.Combine("bin", ConfigBlock.Name);
                monitor.ReportWarning(string.Format(GettextCatalog.GetString("Output directory '{0}' can't be mapped to a local directory. The directory '{1}' will be used instead"), ConfigBlock.OutputPath, dir));
            }
            confObj.OutputDirectory = dir;
            confObj.OutputAssembly  = AssemblyName;

            CSharpCompilerParameters compilerParams = new CSharpCompilerParameters();

            compilerParams.WarningLevel           = ConfigBlock.WarningLevel;
            compilerParams.NoWarnings             = "";
            compilerParams.Optimize               = ConfigBlock.Optimize;
            compilerParams.DefineSymbols          = ConfigBlock.DefineConstants;
            compilerParams.UnsafeCode             = ConfigBlock.AllowUnsafeBlocks;
            compilerParams.GenerateOverflowChecks = ConfigBlock.CheckForOverflowUnderflow;

            return(confObj);
        }
Example #11
0
        public string GetTypeAssemblyQualifiedName(object type)
        {
            IType         t = (IType)type;
            DotNetProject p = (DotNetProject)t.SourceProjectDom.Project;
            DotNetProjectConfiguration conf = (DotNetProjectConfiguration)p.GetConfiguration(ConfigurationSelector.Default);

            return(t.FullName + ", " + conf.CompiledOutputName.FileNameWithoutExtension);
        }
 protected override ExecutionCommand OnCreateExecutionCommand(
     ConfigurationSelector configSel,
     DotNetProjectConfiguration configuration,
     TargetFrameworkMoniker framework,
     ProjectRunConfiguration runConfiguration)
 {
     return(CreateDotNetCoreExecutionCommand(configSel, configuration, runConfiguration));
 }
 OperationConsole CreateConsole(DotNetProjectConfiguration config, ExecutionContext context, ProgressMonitor monitor)
 {
     if (config.ExternalConsole)
     {
         return(context.ExternalConsoleFactory.CreateConsole(!config.PauseConsoleOutput, monitor.CancellationToken));
     }
     return(context.ConsoleFactory.CreateConsole(monitor.CancellationToken));
 }
Example #14
0
 IConsole CreateConsole(DotNetProjectConfiguration config, ExecutionContext context)
 {
     if (config.ExternalConsole)
     {
         return(context.ExternalConsoleFactory.CreateConsole(!config.PauseConsoleOutput));
     }
     return(context.ConsoleFactory.CreateConsole(!config.PauseConsoleOutput));
 }
Example #15
0
		protected override ExecutionCommand CreateExecutionCommand (ConfigurationSelector configSel,
		                                                            DotNetProjectConfiguration configuration)
		{
			var conf = (MeeGoProjectConfiguration) configuration;
			return new MeeGoExecutionCommand (conf) {
				UserAssemblyPaths = GetUserAssemblyPaths (configSel),
			};
		}
Example #16
0
		public static BuildResult Compile (ProjectItemCollection projectItems, DotNetProjectConfiguration configuration, ConfigurationSelector configurationSelector, IProgressMonitor monitor)
		{
			JavaCompilerParameters parameters = (configuration.CompilationParameters as JavaCompilerParameters) ?? new JavaCompilerParameters ();
			string outdir   = configuration.OutputDirectory;
			string options  = GenerateOptionString (configuration);
			string compiler = parameters.CompilerPath;
			if (String.IsNullOrEmpty (compiler))
				compiler = "javac";
			
			StringBuilder files = new StringBuilder ();
			foreach (ProjectFile finfo in projectItems.GetAll<ProjectFile> ()) {
				if (finfo.Subtype != Subtype.Directory && finfo.BuildAction == BuildAction.Compile) {
					files.Append (" \"");
					files.Append (finfo.Name);
					files.Append ("\"");
				}
			}

			StringBuilder classpath = new StringBuilder (parameters.ClassPath);
			AppendClasspath (classpath, GenerateReferenceStubs (monitor, configurationSelector, configuration, parameters, projectItems));
			AppendClasspath (classpath, GenerateReferenceStub (monitor, configurationSelector, configuration, new ProjectReference(ReferenceType.Gac, "mscorlib")));
			
			StringBuilder args = new StringBuilder ();
			args.Append (options.ToString ());
			if (parameters.Compiler == JavaCompiler.Gcj)
				args.Append ("-C ");
			if (classpath.Length != 0) {
				args.Append (" -classpath ");
				args.Append (classpath.ToString ());
			}
			args.Append (files.ToString ());
			args.Append (" -d ");
			args.Append (outdir);
			
			CompilerResults results = new CompilerResults (new TempFileCollection ());
			StringWriter output = new StringWriter ();
			StringWriter error = new StringWriter ();

			bool success;
			try {
				success = Compile (monitor, compiler, args.ToString (), configuration, parameters, output, error);
				ParseJavaOutput (parameters.Compiler, error.ToString(), results);
			} catch (Exception ex) {
				string errorMsg = AddinManager.CurrentLocalizer.GetString ("Execution on '{0}' failed. Make sure the Java compiler is properly installed", compiler);
				monitor.ReportError (errorMsg, ex);
				success = false;
				results.Errors.Add (new CompilerError ("", 0, 0, "", errorMsg));
			}
			
			if (success) {
				output = new StringWriter ();
				error = new StringWriter ();
				CompileToAssembly (monitor, configuration, parameters, projectItems, output, error);
				ParseIkvmOutput (parameters.Compiler, error.ToString(), results);
			}
			
			return new BuildResult (results, "");
		}
Example #17
0
        public override DeployFileCollection GetProjectDeployFiles(DeployContext ctx, Project project, ConfigurationSelector configuration)
        {
            DeployFileCollection deployFiles = new DeployFileCollection();

            base.GetProjectDeployFiles(ctx, project, configuration);
            // Add the compiled output file

            string outputFile = project.GetOutputFileName(configuration);

            if (!string.IsNullOrEmpty(outputFile))
            {
                deployFiles.Add(new DeployFile(project, outputFile, Path.GetFileName(outputFile), TargetDirectory.ProgramFiles));
            }

            // Collect deployable files
            foreach (ProjectFile file in project.Files)
            {
                // skip CopyToOutputDirectory files when it's just a project build, because
                // MonoDevelop.Project.Projects already copies these files using more subtle overwriting
                // semantics
                if (file.CopyToOutputDirectory != FileCopyMode.None)
                {
                    continue;
                }

                DeployProperties props = new DeployProperties(file);
                if (props.ShouldDeploy)
                {
                    DeployFile dp = new DeployFile(file);
                    deployFiles.Add(dp);

                    if (string.Compare(Path.GetFileName(dp.SourcePath), "app.config", true) == 0 && string.Compare(Path.GetFileName(dp.RelativeTargetPath), "app.config", true) == 0)
                    {
                        string newName = Path.GetFileName(outputFile) + ".config";
                        dp.RelativeTargetPath = Path.Combine(Path.GetDirectoryName(dp.RelativeTargetPath), newName);
                    }
                }
            }

            foreach (FileCopySet.Item item in project.GetSupportFileList(configuration))
            {
                deployFiles.Add(new DeployFile(project, item.Src, item.Target, TargetDirectory.ProgramFiles));
            }

            DotNetProject netProject = project as DotNetProject;

            if (netProject != null)
            {
                DotNetProjectConfiguration conf = (DotNetProjectConfiguration)project.GetConfiguration(configuration);
                if (conf.DebugMode)
                {
                    string mdbFile = netProject.TargetRuntime.GetAssemblyDebugInfoFile(conf.CompiledOutputName);
                    deployFiles.Add(new DeployFile(project, mdbFile, Path.GetFileName(mdbFile), TargetDirectory.ProgramFiles));
                }
            }

            return(deployFiles);
        }
		protected override ExecutionCommand CreateExecutionCommand (ConfigurationSelector configSel, DotNetProjectConfiguration configuration)
		{
			var cmd = (DotNetExecutionCommand) base.CreateExecutionCommand (configSel, configuration);
			cmd.Command = Assembly.GetEntryAssembly ().Location;
			cmd.Arguments = "--no-redirect";
			cmd.EnvironmentVariables["MONODEVELOP_DEV_ADDINS"] = GetOutputFileName (configSel).ParentDirectory;
			cmd.EnvironmentVariables ["MONODEVELOP_CONSOLE_LOG_LEVEL"] = "All";
			return cmd;
		}
Example #19
0
        protected override ExecutionCommand CreateExecutionCommand(ConfigurationSelector configSel,
                                                                   DotNetProjectConfiguration configuration)
        {
            var conf = (MeeGoProjectConfiguration)configuration;

            return(new MeeGoExecutionCommand(conf)
            {
                UserAssemblyPaths = GetUserAssemblyPaths(configSel),
            });
        }
Example #20
0
        FilePath GetXapName(MoonlightProject proj, DotNetProjectConfiguration conf)
        {
            string xapName = proj.XapFilename;

            if (String.IsNullOrEmpty(xapName))
            {
                xapName = proj.Name + ".xap";
            }
            return(conf.OutputDirectory.Combine(xapName));
        }
Example #21
0
        FilePath GetTestPageFileName(MoonlightProject proj, DotNetProjectConfiguration conf)
        {
            string testPage = proj.TestPageFileName;

            if (String.IsNullOrEmpty(testPage))
            {
                testPage = "TestPage.html";
            }
            return(conf.OutputDirectory.Combine(testPage));
        }
		public void TestSetup()
		{
			_project = new DotNetAssemblyProject ("C#");
			var p = new CSharpCompilerParameters ();
			var config = new DotNetProjectConfiguration () { CompilationParameters = p };
			_project.DefaultConfiguration = config;

			_update = new MonoIsland ();
			_update.BaseDirectory = "/mybase";
		}
Example #23
0
        protected override ExecutionCommand CreateExecutionCommand(ConfigurationSelector configSel,
                                                                   DotNetProjectConfiguration configuration)
        {
            var conf = (MonoMacProjectConfiguration)configuration;

            return(new MonoMacExecutionCommand(TargetRuntime, TargetFramework, conf.AppDirectory,
                                               conf.LaunchScript, conf.DebugMode)
            {
                UserAssemblyPaths = GetUserAssemblyPaths(configSel)
            });
        }
Example #24
0
        protected override ExecutionCommand CreateExecutionCommand(ConfigurationSelector configSel,
                                                                   DotNetProjectConfiguration configuration)
        {
            var conf = (MonoDroidProjectConfiguration)configuration;

            return(new MonoDroidExecutionCommand(conf.PackageName,
                                                 conf.ApkSignedPath, TargetRuntime, TargetFramework, conf.DebugMode)
            {
                UserAssemblyPaths = GetUserAssemblyPaths(configSel)
            });
        }
Example #25
0
        public void GetAssemblyNameTest()
        {
            var debug   = new DotNetProjectConfiguration("Debug");
            var release = new DotNetProjectConfiguration("Release");

            debug.OutputAssembly   = "assembly_debug";
            release.OutputAssembly = "assembly_release";
            Assert.That(new ItemConfiguration [] { debug, release }.GetAssemblyName(), Is.Empty);

            debug.OutputAssembly = release.OutputAssembly = "assembly";
            Assert.That(new ItemConfiguration [] { debug, release }.GetAssemblyName(), Is.EqualTo("assembly"));
        }
Example #26
0
        public void ResolveOutDirectoryTemplateTest(string template, string id, string expected)
        {
            var dotnetConfig = new DotNetProjectConfiguration(id)
            {
                AppendTargetFrameworkToOutputPath = true,
                TargetFrameworkShortName          = "netcore22"
            };

            var result = dotnetConfig.ResolveOutDirectoryTemplate(template);

            Assert.That(result, Is.EqualTo(expected));
        }
Example #27
0
        public void GetCommonOutDirTemplateTest()
        {
            var debug   = new DotNetProjectConfiguration("Debug");
            var release = new DotNetProjectConfiguration("Release");

            debug.OutputDirectory   = new FilePath("/Users/project/bin/Debug");
            release.OutputDirectory = new FilePath("/Users/project/bin/Release");
            Assert.That(new ItemConfiguration [] { debug, release }.GetCommonOutDirTemplate(), Is.EqualTo("/Users/project/bin/$(Configuration)"));

            debug.OutputDirectory   = new FilePath("/Users/project/build/Debug");
            release.OutputDirectory = new FilePath("/Users/project/bin/Release");
            Assert.That(new ItemConfiguration [] { debug, release }.GetCommonOutDirTemplate(), Is.Empty);
        }
Example #28
0
        protected override BuildResult OnCompileSources(ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, MonoDevelop.Core.ProgressMonitor monitor)
        {
            monitor.Log.WriteLine("Starting...");
            var fileNames = items.OfType <ProjectFile>().Select((ProjectFile arg) => arg.FilePath.ToString()).ToArray();
            var options   = new System.CodeDom.Compiler.CompilerParameters();

            options.OutputAssembly = configuration.CompiledOutputName.ToString();
            var compileResult = OneScriptCompilerService.CompileAssemblyFromFile(options, fileNames);

            monitor.Log.WriteLine("Done!");

            return(new BuildResult(compileResult, null));
        }
Example #29
0
        public void ParseOutDirectoryTemplateTest()
        {
            string expectedOutput = System.IO.Path.Combine("Users", "ProjectFoo", "Foo", "netcore22");
            var    conf           = new DotNetProjectConfiguration("Foo")
            {
                TargetFrameworkShortName = "netcore22"
            };

            string outputTemplate = System.IO.Path.Combine("Users", "ProjectFoo", "$(Configuration)", "$(TargetFramework)");
            var    parsed         = conf.ParseOutDirectoryTemplate(outputTemplate);

            Assert.That(parsed, Is.EqualTo(expectedOutput));
        }
Example #30
0
        public void TestSetup()
        {
            _project = new DotNetAssemblyProject("C#");
            var p      = new CSharpCompilerParameters();
            var config = new DotNetProjectConfiguration()
            {
                CompilationParameters = p
            };

            _project.DefaultConfiguration = config;

            _update = new MonoIsland();
            _update.BaseDirectory = "/mybase";
        }
Example #31
0
		static string GenerateOptionString (DotNetProjectConfiguration configuration)
		{
			JavaCompilerParameters parameters = (configuration.CompilationParameters as JavaCompilerParameters) ?? new JavaCompilerParameters ();
			StringBuilder result = new StringBuilder ();
			result.Append (configuration.DebugMode ? " -g " : " -g:none ");
			if (parameters.Optimize)
				result.Append (" -O ");
			if (parameters.Deprecation)
				result.Append (" -deprecation ");
			if (parameters.GenWarnings)
				result.Append (" -nowarn ");
			result.Append (" -encoding utf8 ");
			return result.ToString ();
		}
Example #32
0
 			public  CodeGenerationPanelWidget(Properties CustomizationObject) : base ("Nemerle.glade", "CodeGenerationPanel")
 			{
				configuration = (DotNetProjectConfiguration) ((Properties)CustomizationObject).Get("Config");
				compilerParameters = (NemerleParameters) configuration.CompilationParameters;
				
				target.Active = (int) configuration.CompileTarget;
				
				nostdmacros.Active = compilerParameters.Nostdmacros;
				nostdlib.Active    = compilerParameters.Nostdlib;
				ignorewarnings.Active = configuration.RunWithWarnings;
				ot.Active          = compilerParameters.Ot;
				greedy.Active      = compilerParameters.Greedy;
				pedantic.Active    = compilerParameters.Pedantic;
 			}
        protected override DotNetCompilerParameters OnCreateCompilationParameters(DotNetProjectConfiguration config, ConfigurationKind kind)
        {
            var pars = new VBCompilerParameters();

            if (kind == ConfigurationKind.Debug)
            {
                pars.AddDefineSymbol("DEBUG");
            }
            else if (kind == ConfigurationKind.Release)
            {
                pars.Optimize = true;
            }
            return(pars);
        }
            public CodeGenerationPanelWidget(Properties CustomizationObject) : base("Nemerle.glade", "CodeGenerationPanel")
            {
                configuration      = (DotNetProjectConfiguration)((Properties)CustomizationObject).Get("Config");
                compilerParameters = (NemerleParameters)configuration.CompilationParameters;

                target.Active = (int)configuration.CompileTarget;

                nostdmacros.Active    = compilerParameters.Nostdmacros;
                nostdlib.Active       = compilerParameters.Nostdlib;
                ignorewarnings.Active = configuration.RunWithWarnings;
                ot.Active             = compilerParameters.Ot;
                greedy.Active         = compilerParameters.Greedy;
                pedantic.Active       = compilerParameters.Pedantic;
            }
Example #35
0
        public void GetTemplateTest()
        {
            string expectedTemplate = System.IO.Path.Combine("Users", "Project", "$(Configuration)", "$(TargetFramework)");
            var    conf             = new DotNetProjectConfiguration("Foo")
            {
                TargetFrameworkShortName          = "netcore22",
                OutputDirectory                   = System.IO.Path.Combine("Users", "Project", "Foo", "netcore22"),
                AppendTargetFrameworkToOutputPath = true
            };

            var template = conf.GetTemplate();

            Assert.That(template, Is.EqualTo(expectedTemplate));
        }
        public override ParseOptions CreateParseOptions(DotNetProjectConfiguration configuration)
        {
            if (parseOptions != null)
            {
                return(parseOptions);
            }

            return(new CSharpParseOptions(
                       LanguageVersion.CSharp6,
                       DocumentationMode.Parse,
                       SourceCodeKind.Regular,
                       ImmutableArray <string> .Empty.AddRange(GetDefineSymbols())
                       ));
        }
Example #37
0
        public override Microsoft.CodeAnalysis.ParseOptions CreateParseOptions(DotNetProjectConfiguration configuration)
        {
            var symbols = GetDefineSymbols();

            if (configuration != null)
            {
                symbols = symbols.Concat(configuration.GetDefineSymbols()).Distinct();
            }
            return(new Microsoft.CodeAnalysis.CSharp.CSharpParseOptions(
                       GetRoslynLanguageVersion(langVersion),
                       Microsoft.CodeAnalysis.DocumentationMode.Parse,
                       Microsoft.CodeAnalysis.SourceCodeKind.Regular,
                       ImmutableArray <string> .Empty.AddRange(symbols)
                       ));
        }
        protected override ExecutionCommand OnCreateExecutionCommand(
            ConfigurationSelector configSel,
            DotNetProjectConfiguration configuration,
            TargetFrameworkMoniker framework,
            ProjectRunConfiguration runConfiguration)
        {
            var result = CreateAspNetCoreExecutionCommand(configSel, configuration, runConfiguration);

            if (result != null)
            {
                return(result);
            }

            return(base.OnCreateExecutionCommand(configSel, configuration, framework, runConfiguration));
        }
        FilePath GetOutputDirectory(DotNetProjectConfiguration configuration)
        {
            string   targetFramework = dotNetCoreMSBuildProject.TargetFrameworks.FirstOrDefault();
            FilePath outputDirectory = configuration.OutputDirectory;

            if (outputDirectory.IsAbsolute)
            {
                return(outputDirectory);
            }
            else if (outputDirectory == "./")
            {
                outputDirectory = Path.Combine("bin", configuration.Name);
            }

            return(Project.BaseDirectory.Combine(outputDirectory.ToString(), targetFramework));
        }
		public void Load (DotNetProjectConfiguration configuration)
		{
			this.configuration = configuration;
			compilerParameters = (CSharpCompilerParameters) configuration.CompilationParameters;
			
			symbolsEntry.Text                          = compilerParameters.DefineSymbols;
			generateDebugInformationCheckButton.Active = configuration.DebugMode;
			generateXmlOutputCheckButton.Active        = compilerParameters.GenerateXmlDocumentation;
			enableOptimizationCheckButton.Active       = compilerParameters.Optimize;
			generateOverflowChecksCheckButton.Active   = compilerParameters.GenerateOverflowChecks;
			warningsAsErrorsCheckButton.Active         = compilerParameters.TreatWarningsAsErrors;
			warningLevelSpinButton.Value               = compilerParameters.WarningLevel;
			additionalArgsEntry.Text                   = compilerParameters.AdditionalArguments;
			ignoreWarningsEntry.Text                   = compilerParameters.NoWarnings;
			
			int i = CSharpLanguageBinding.SupportedPlatforms.IndexOf (compilerParameters.PlatformTarget);
			comboPlatforms.Active = i != -1 ? i : 0;
		}
		DeployFile GenerateLaunchScript (DeployContext ctx, DotNetProject netProject, LinuxDeployData data, DotNetProjectConfiguration conf)
		{
			string file = ctx.CreateTempFile ();
			string exe = "@ProgramFiles@/" + Path.GetFileName (conf.CompiledOutputName);
			
			using (StreamWriter sw = new StreamWriter (file)) {
				sw.WriteLine ("#!/bin/sh");
				sw.WriteLine ();
				sw.WriteLine ("exec mono \"" + exe + "\" \"$@\"");
			}
			string outfile = data.ScriptName;
			if (string.IsNullOrEmpty (outfile))
				outfile = netProject.Name.ToLower ();
			DeployFile df = new DeployFile (netProject, file, outfile, TargetDirectory.Binaries);
			df.ContainsPathReferences = true;
			df.DisplayName = GettextCatalog.GetString ("Launch script for {0}", netProject.Name);
			df.FileAttributes = DeployFileAttributes.Executable;
			return df;
		}
Example #42
0
 public BuildResult Compile(ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, IProgressMonitor monitor)
 {
     try
     {
         var outWriter = new StringWriter();
         var arguments = String.Join(" ", items.GetAll<ProjectFile>().Select(pf => pf.FilePath.ToString()).ToArray());
         using (var processWrapper = processStarter.StartProcess("booc", arguments, configuration.OutputDirectory.ToString(), outWriter, monitor.Log))
         {
             using (var aggregatedOperationMonitor = new AggregatedOperationMonitor(monitor, processWrapper))
             {
                 processWrapper.WaitForExit();
                 if (monitor.IsCancelRequested)
                 {
                     monitor.Log.WriteLine("Build canceled");
                     monitor.ReportError("Build canceled", null);
                 }
                 monitor.EndTask(); // TODO: Do we need this?
                 var output = outWriter.ToString();
                 var compilerResults = new CompilerResults(new TempFileCollection());
                 using (var stringReader = new StringReader(output))
                 {
                     for (var line = stringReader.ReadLine(); line != null; line = stringReader.ReadLine())
                     {
                         var error = ParseOutputLine(line);
                         if (error != null)
                         {
                             compilerResults.Errors.Add(error);
                         }
                     }
                 }
                 return new BuildResult(compilerResults, output);
             }
         }
     }
     catch (Exception ex)
     {
         monitor.Log.WriteLine(ex.ToString());
     }
     return null;
 }
		DeployFile GeneratePcFile (DeployContext ctx, DotNetProject netProject, LinuxDeployData data, DotNetProjectConfiguration conf)
		{
			string libs = "-r:@ProgramFiles@/" + Path.GetFileName (conf.CompiledOutputName);
			string requires = "";
			string version = netProject.Version;
			if (string.IsNullOrEmpty (version) && netProject.ParentSolution != null)
				version = netProject.ParentSolution.Version;
			    
			string file = ctx.CreateTempFile ();
			using (StreamWriter sw = new StreamWriter (file)) {
				sw.WriteLine ("Name: " + netProject.Name);
				sw.WriteLine ("Description: " + (String.IsNullOrEmpty(netProject.Description) ? netProject.Name : netProject.Description));
				sw.WriteLine ("Version: " + version);
				sw.WriteLine ();
				sw.WriteLine ("Requires: " + requires);
				sw.WriteLine ("Libs: " + libs);
			}
			string outfile = netProject.Name.ToLower () + ".pc";
			DeployFile df = new DeployFile (netProject, file, outfile, LinuxTargetDirectory.PkgConfig);
			df.ContainsPathReferences = true;
			df.DisplayName = GettextCatalog.GetString ("pkg-config file for {0}", netProject.Name);
			return df;
		}
		protected override SolutionItemConfiguration OnCreateConfiguration (string name, ConfigurationKind kind)
		{
			DotNetProjectConfiguration conf = new DotNetProjectConfiguration (name);
			string dir;
			if (conf.Platform.Length == 0)
				dir = Path.Combine ("bin", conf.Name);
			else
				dir = Path.Combine (Path.Combine ("bin", conf.Platform), conf.Name);

			conf.OutputDirectory = String.IsNullOrEmpty (BaseDirectory) ? dir : Path.Combine (BaseDirectory, dir);
			conf.OutputAssembly = Name;

			if (kind == ConfigurationKind.Debug) {
				conf.DebugSymbols = true;
				conf.DebugType = "full";
			} else {
				conf.DebugSymbols = false;
			}

			if (LanguageBinding != null)
				conf.CompilationParameters = OnCreateCompilationParameters (conf, kind);

			return conf;
		}
		protected override ExecutionCommand CreateExecutionCommand (ConfigurationSelector configSel,
		                                                            DotNetProjectConfiguration configuration)
		{
			var conf = (MonoDroidProjectConfiguration) configuration;
			
			return new MonoDroidExecutionCommand (conf.PackageName,
				conf.ApkSignedPath, TargetRuntime, TargetFramework, conf.DebugMode) {
				UserAssemblyPaths = GetUserAssemblyPaths (configSel)
			};
		}
		/// <summary>
		///   Creates the execution command.
		/// </summary>
		/// <param name = "configSel">The configuration selector.</param>
		/// <param name = "configuration">The configuration.</param>
		/// <returns>The execution command.</returns>
		protected override ExecutionCommand CreateExecutionCommand (ConfigurationSelector configSel, DotNetProjectConfiguration configuration)
		{
			if (this.CompileTarget != CompileTarget.Exe) {
				return base.CreateExecutionCommand (configSel, configuration);
			}

			if (this.projectType == MonobjcProjectType.None) {
				return base.CreateExecutionCommand (configSel, configuration);
			}

			// Infer application name from configuration
			MonobjcProjectConfiguration conf = (MonobjcProjectConfiguration)configuration;
			String applicationName = this.GetApplicationName (configSel);
			conf.ApplicationName = applicationName;
			
			switch (this.ApplicationType) {
			case MonobjcProjectType.CocoaApplication:
				{
					// Create the bundle maker to get the path to the runtime
					BundleMaker maker = new BundleMaker (applicationName, conf.OutputDirectory);
					conf.Runtime = maker.Runtime;
				}
				break;
			case MonobjcProjectType.ConsoleApplication:
				{
					// Build the command line
					conf.Runtime = FileProvider.GetPath (this.TargetOSVersion, "runtime");
					conf.CommandLineParameters = this.GetOutputFileName (configSel);
				}
				break;
			default:
				throw new NotSupportedException ("Unsupported application type " + this.ApplicationType);
			}

			// Create the command
			MonobjcExecutionCommand command = new MonobjcExecutionCommand (conf);
			command.UserAssemblyPaths = this.GetUserAssemblyPaths (configSel);

			return command;
		}
		public static BuildResult Compile (ProjectItemCollection projectItems, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, IProgressMonitor monitor)
		{
			CSharpCompilerParameters compilerParameters = (CSharpCompilerParameters)configuration.CompilationParameters ?? new CSharpCompilerParameters ();
			CSharpProjectParameters projectParameters = (CSharpProjectParameters)configuration.ProjectParameters ?? new CSharpProjectParameters ();
			
			string outputName       = configuration.CompiledOutputName;
			string responseFileName = Path.GetTempFileName();
			
			if (File.Exists (outputName)) {
				bool isWriteable = false;
				int count = 0;
				do {
					try {
						using (var stream = File.OpenWrite (outputName)) {
							isWriteable = true;
						}
					} catch (Exception) {
						Thread.Sleep (20);
					}
				} while (count++ < 5 && !isWriteable);
				if (!isWriteable) {
					MessageService.ShowError (string.Format (GettextCatalog.GetString ("Can't lock file: {0}."), outputName));
					return null;
				}
			}
			
			TargetRuntime runtime = MonoDevelop.Core.Runtime.SystemAssemblyService.DefaultRuntime;
			DotNetProject project = configuration.ParentItem as DotNetProject;
			if (project != null)
				runtime = project.TargetRuntime;

			StringBuilder sb = new StringBuilder ();
			List<string> gacRoots = new List<string> ();
			sb.AppendFormat ("\"/out:{0}\"", outputName);
			sb.AppendLine ();
			
			HashSet<string> alreadyAddedReference = new HashSet<string> ();
			foreach (ProjectReference lib in projectItems.GetAll <ProjectReference> ()) {
				if (lib.ReferenceType == ReferenceType.Project && !(lib.OwnerProject.ParentSolution.FindProjectByName (lib.Reference) is DotNetProject))
					continue;
				foreach (string fileName in lib.GetReferencedFileNames (configSelector)) {
					switch (lib.ReferenceType) {
					case ReferenceType.Gac:
						SystemPackage pkg = lib.Package;
						if (pkg == null) {
							string msg = string.Format (GettextCatalog.GetString ("{0} could not be found or is invalid."), lib.Reference);
							monitor.ReportWarning (msg);
							continue;
						}

						if (alreadyAddedReference.Add (fileName))
							AppendQuoted (sb, "/r:", fileName);
						
						if (pkg.GacRoot != null && !gacRoots.Contains (pkg.GacRoot))
							gacRoots.Add (pkg.GacRoot);
						if (!string.IsNullOrEmpty (pkg.Requires)) {
							foreach (string requiredPackage in pkg.Requires.Split(' ')) {
								SystemPackage rpkg = runtime.AssemblyContext.GetPackage (requiredPackage);
								if (rpkg == null)
									continue;
								foreach (SystemAssembly assembly in rpkg.Assemblies) {
									if (alreadyAddedReference.Add (assembly.Location))
										AppendQuoted (sb, "/r:", assembly.Location);
								}
							}
						}
						break;
					default:
						if (alreadyAddedReference.Add (fileName))
							AppendQuoted (sb, "/r:", fileName);
						break;
					}
				}
			}
			
			sb.AppendLine ("/nologo");
			sb.Append ("/warn:");sb.Append (compilerParameters.WarningLevel.ToString ());
			sb.AppendLine ();
			
			if (configuration.SignAssembly) {
				if (File.Exists (configuration.AssemblyKeyFile))
					AppendQuoted (sb, "/keyfile:", configuration.AssemblyKeyFile);
			}
			
			if (configuration.DebugMode) {
				sb.AppendLine ("/debug:+");
				sb.AppendLine ("/debug:full");
			}
			
			switch (compilerParameters.LangVersion) {
			case LangVersion.Default:
				break;
			case LangVersion.ISO_1:
				sb.AppendLine ("/langversion:ISO-1");
				break;
			case LangVersion.ISO_2:
				sb.AppendLine ("/langversion:ISO-2");
				break;
			default:
				string message = "Invalid LangVersion enum value '" + compilerParameters.LangVersion.ToString () + "'";
				monitor.ReportError (message, null);
				LoggingService.LogError (message);
				return null;
			}
			
			// mcs default is + but others might not be
			if (compilerParameters.Optimize)
				sb.AppendLine ("/optimize+");
			else
				sb.AppendLine ("/optimize-");
			
			bool hasWin32Res = !string.IsNullOrEmpty (projectParameters.Win32Resource) && File.Exists (projectParameters.Win32Resource);
			if (hasWin32Res) 
				AppendQuoted (sb, "/win32res:", projectParameters.Win32Resource);
			
			if (!string.IsNullOrEmpty (projectParameters.Win32Icon) && File.Exists (projectParameters.Win32Icon)) {
				if (hasWin32Res) {
					monitor.ReportWarning ("Both Win32 icon and Win32 resource cannot be specified. Ignoring the icon.");
				} else {
					AppendQuoted (sb, "/win32icon:", projectParameters.Win32Icon);
				}
			}
			
			if (projectParameters.CodePage != 0)
				sb.AppendLine ("/codepage:" + projectParameters.CodePage);
			else if (runtime is MonoTargetRuntime)
				sb.AppendLine ("/codepage:utf8");
			
			if (compilerParameters.UnsafeCode) 
				sb.AppendLine ("-unsafe");
			if (compilerParameters.NoStdLib) 
				sb.AppendLine ("-nostdlib");
			
			if (!string.IsNullOrEmpty (compilerParameters.PlatformTarget) && compilerParameters.PlatformTarget.ToLower () != "anycpu") {
				//HACK: to ignore the platform flag for Mono <= 2.4, because gmcs didn't support it
				if (runtime.RuntimeId == "Mono" && runtime.AssemblyContext.GetAssemblyLocation ("Mono.Debugger.Soft", null) == null) {
					LoggingService.LogWarning ("Mono runtime '" + runtime.DisplayName + 
					                           "' appears to be too old to support the 'platform' C# compiler flag.");
				} else {
					sb.AppendLine ("/platform:" + compilerParameters.PlatformTarget);
				}
			}

			if (compilerParameters.TreatWarningsAsErrors) {
				sb.AppendLine ("-warnaserror");
				if (!string.IsNullOrEmpty (compilerParameters.WarningsNotAsErrors))
					sb.AppendLine ("-warnaserror-:" + compilerParameters.WarningsNotAsErrors);
			}
			
			if (compilerParameters.DefineSymbols.Length > 0) {
				string define_str = string.Join (";", compilerParameters.DefineSymbols.Split (new char [] {',', ' ', ';'}, StringSplitOptions.RemoveEmptyEntries));
				if (define_str.Length > 0) {
					AppendQuoted (sb, "/define:", define_str);
					sb.AppendLine ();
				}
			}

			CompileTarget ctarget = configuration.CompileTarget;
			
			if (!string.IsNullOrEmpty (projectParameters.MainClass)) {
				sb.AppendLine ("/main:" + projectParameters.MainClass);
				// mcs does not allow providing a Main class when compiling a dll
				// As a workaround, we compile as WinExe (although the output will still
				// have a .dll extension).
				if (ctarget == CompileTarget.Library)
					ctarget = CompileTarget.WinExe;
			}
			
			switch (ctarget) {
				case CompileTarget.Exe:
					sb.AppendLine ("/t:exe");
					break;
				case CompileTarget.WinExe:
					sb.AppendLine ("/t:winexe");
					break;
				case CompileTarget.Library:
					sb.AppendLine ("/t:library");
					break;
			}
			
			foreach (ProjectFile finfo in projectItems.GetAll<ProjectFile> ()) {
				if (finfo.Subtype == Subtype.Directory)
					continue;

				switch (finfo.BuildAction) {
					case "Compile":
						AppendQuoted (sb, "", finfo.Name);
						break;
					case "EmbeddedResource":
						string fname = finfo.Name;
						if (string.Compare (Path.GetExtension (fname), ".resx", true) == 0)
							fname = Path.ChangeExtension (fname, ".resources");
						sb.Append ('"');sb.Append ("/res:");
						sb.Append (fname);sb.Append (',');sb.Append (finfo.ResourceId);
						sb.Append ('"');sb.AppendLine ();
						break;
					default:
						continue;
				}
			}
			if (compilerParameters.GenerateXmlDocumentation) 
				AppendQuoted (sb, "/doc:", Path.ChangeExtension (outputName, ".xml"));
			
			if (!string.IsNullOrEmpty (compilerParameters.AdditionalArguments)) 
				sb.AppendLine (compilerParameters.AdditionalArguments);
			
			if (!string.IsNullOrEmpty (compilerParameters.NoWarnings)) 
				AppendQuoted (sb, "/nowarn:", compilerParameters.NoWarnings);

			if (runtime.RuntimeId == "MS.NET") {
				sb.AppendLine("/fullpaths");
				sb.AppendLine("/utf8output");
			}

			string output = "";
			string error  = "";
			
			File.WriteAllText (responseFileName, sb.ToString ());
			
			string compilerName;
			try {
				compilerName = GetCompilerName (runtime, configuration.TargetFramework);
			} catch (Exception e) {
				string message = "Could not obtain a C# compiler";
				monitor.ReportError (message, e);
				return null;
			}
			
			monitor.Log.WriteLine (compilerName + " /noconfig " + sb.ToString ().Replace ('\n',' '));
			
			string workingDir = ".";
			if (configuration.ParentItem != null) {
				workingDir = configuration.ParentItem.BaseDirectory;
				if (workingDir == null)
					// Dummy projects created for single files have no filename
					// and so no BaseDirectory.
					// This is a workaround for a bug in 
					// ProcessStartInfo.WorkingDirectory - not able to handle null
					workingDir = ".";
			}

			LoggingService.LogInfo (compilerName + " " + sb.ToString ());
			
			ExecutionEnvironment envVars = runtime.GetToolsExecutionEnvironment (project.TargetFramework);
			string cargs = "/noconfig @\"" + responseFileName + "\"";

			int exitCode = DoCompilation (compilerName, cargs, workingDir, envVars, gacRoots, ref output, ref error);
			
			BuildResult result = ParseOutput (output, error);
			if (result.CompilerOutput.Trim ().Length != 0)
				monitor.Log.WriteLine (result.CompilerOutput);
			
			//if compiler crashes, output entire error string
			if (result.ErrorCount == 0 && exitCode != 0) {
				try {
					monitor.Log.Write (File.ReadAllText (error));
				} catch (IOException) {
				}
				result.AddError ("The compiler appears to have crashed. Check the build output pad for details.");
				LoggingService.LogError ("C# compiler crashed. Response file '{0}', stdout file '{1}', stderr file '{2}'",
				                         responseFileName, output, error);
			} else {
				FileService.DeleteFile (responseFileName);
				FileService.DeleteFile (output);
				FileService.DeleteFile (error);
			}
			return result;
		}
Example #48
0
		public override SolutionItemConfiguration CreateConfiguration (string name)
		{
			DotNetProjectConfiguration conf = new DotNetProjectConfiguration (name);
			string dir;
			if (conf.Platform.Length == 0)
				dir = Path.Combine ("bin", conf.Name);
			else
				dir = Path.Combine (Path.Combine ("bin", conf.Platform), conf.Name);

			conf.OutputDirectory = String.IsNullOrEmpty (BaseDirectory) ? dir : Path.Combine (BaseDirectory, dir);
			conf.OutputAssembly = Name;
			if (LanguageBinding != null) {
				XmlElement xconf = null;
				if (!string.IsNullOrEmpty (conf.Platform)) {
					XmlDocument doc = new XmlDocument ();
					xconf = doc.CreateElement ("Options");
					xconf.SetAttribute ("Platform", conf.Platform);
				}
				conf.CompilationParameters = LanguageBinding.CreateCompilationParameters (xconf);
			}
			return conf;
		}
Example #49
0
		protected override ExecutionCommand CreateExecutionCommand (ConfigurationSelector configSel,
		                                                            DotNetProjectConfiguration configuration)
		{
			var conf = (MonoMacProjectConfiguration) configuration;
			
			return new MonoMacExecutionCommand (TargetRuntime, TargetFramework, conf.AppDirectory,
			                                    conf.LaunchScript, conf.DebugMode) {
				UserAssemblyPaths = GetUserAssemblyPaths (configSel)
			};
		}
		protected override BuildResult OnCompileSources (ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, MonoDevelop.Core.ProgressMonitor monitor)
		{
			Debug.Assert(compilerServices != null);
			return compilerServices.Compile (items, configuration, configSelector, monitor);
		}
		protected override DotNetCompilerParameters OnCreateCompilationParameters (DotNetProjectConfiguration config, ConfigurationKind kind)
		{
			var pars = new VBCompilerParameters ();
			if (kind == ConfigurationKind.Debug)
				pars.AddDefineSymbol ("DEBUG");
			else if (kind == ConfigurationKind.Release)
				pars.Optimize = true;
			return pars;
		}
		protected override DotNetCompilerParameters OnCreateCompilationParameters (DotNetProjectConfiguration config, ConfigurationKind kind)
		{
			var pars = new CSharpCompilerParameters ();
			if (SupportedPlatforms.Contains (config.Platform))
				pars.PlatformTarget = config.Platform;
			
			if (kind == ConfigurationKind.Debug)
				pars.AddDefineSymbol ("DEBUG");
			else if (kind == ConfigurationKind.Release)
				pars.Optimize = true;
			return pars;
		}
Example #53
0
		protected override ExecutionCommand CreateExecutionCommand (ConfigurationSelector configSel,
		                                                            DotNetProjectConfiguration configuration)
		{
			var conf = (IPhoneProjectConfiguration) configuration;
			
			IPhoneSimulatorTarget simTarget = null;
			
			var minOS = string.IsNullOrEmpty (conf.MtouchMinimumOSVersion)?
				IPhoneSdkVersion.GetDefault () : IPhoneSdkVersion.Parse (conf.MtouchMinimumOSVersion);
			
			if (conf.Platform != PLAT_IPHONE) {
				simTarget = GetSimulatorTarget (conf);
				if (simTarget == null) {
					var defaultDevice = ((IPhoneProject)conf.ParentItem).SupportedDevices == TargetDevice.IPad?
						TargetDevice.IPad : TargetDevice.IPhone;
					simTarget = new IPhoneSimulatorTarget (defaultDevice, conf.MtouchSdkVersion.ResolveIfDefault ());
				}
			}
			
			return new IPhoneExecutionCommand (TargetRuntime, TargetFramework, conf.AppDirectory, conf.OutputDirectory,
			                                   conf.DebugMode && conf.MtouchDebug, simTarget, minOS, SupportedDevices) {
				UserAssemblyPaths = GetUserAssemblyPaths (configSel)
			};
		}
		public BuildResult Compile (ProjectItemCollection projectItems, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, IProgressMonitor monitor)
		{
			return ILAsmCompilerManager.Compile (projectItems, configuration, configSelector, monitor);
		}
		public BuildResult Compile (ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, ProgressMonitor monitor)
		{
			VBCompilerParameters compilerparameters = (VBCompilerParameters) configuration.CompilationParameters;
			if (compilerparameters == null)
				compilerparameters = new VBCompilerParameters ();
			
			var projectparameters = (VBProject) configuration.ParentItem;

			string exe = configuration.CompiledOutputName;
			string responseFileName = Path.GetTempFileName();
			StreamWriter writer = new StreamWriter (responseFileName);
			
			writer.WriteLine (GenerateOptions (configuration, compilerparameters, projectparameters, exe));

			// Write references
			foreach (ProjectReference lib in items.GetAll<ProjectReference> ()) {
				foreach (string fileName in lib.GetReferencedFileNames (configSelector)) {
					writer.Write ("\"-r:");
					writer.Write (fileName);
					writer.WriteLine ("\"");
				}
			}
			
			// Write source files and embedded resources
			foreach (ProjectFile finfo in items.GetAll<ProjectFile> ()) {
				if (finfo.Subtype != Subtype.Directory) {
					switch (finfo.BuildAction) {
						case "Compile":
							writer.WriteLine("\"" + finfo.Name + "\"");
						break;
						
						case "EmbeddedResource":
							string fname = finfo.Name;
							if (String.Compare (Path.GetExtension (fname), ".resx", true) == 0)
								fname = Path.ChangeExtension (fname, ".resources");

							writer.WriteLine("\"-resource:{0},{1}\"", fname, finfo.ResourceId);
							break;
						
						default:
							continue;
					}
				}
			}
			
			// Write source files and embedded resources
			foreach (Import import in items.GetAll<Import> ()) {
				writer.WriteLine ("-imports:{0}", import.Include);
			}
			
			TempFileCollection tf = new TempFileCollection ();
			writer.Close();
			
			string output = "";
			string compilerName = configuration.TargetRuntime.GetToolPath (configuration.TargetFramework, "vbc");
			if (compilerName == null) {
				BuildResult res = new BuildResult ();
				res.AddError (string.Format ("Visual Basic .NET compiler not found ({0})", configuration.TargetRuntime.DisplayName));
				return res;
			}
			
			string workingDir = ".";
			if (configuration.ParentItem != null)
				workingDir = configuration.ParentItem.BaseDirectory;
			int exitCode;
			
			var envVars = configuration.TargetRuntime.GetToolsExecutionEnvironment (configuration.TargetFramework);
			
			monitor.Log.WriteLine (Path.GetFileName (compilerName) + " " + string.Join (" ", File.ReadAllLines (responseFileName)));
			exitCode = DoCompilation (compilerName, responseFileName, tf, workingDir, envVars, ref output);
			
			monitor.Log.WriteLine (output);			                                                          
			BuildResult result = ParseOutput (tf, output);
			if (result.Errors.Count == 0 && exitCode != 0) {
				// Compilation failed, but no errors?
				// Show everything the compiler said.
				result.AddError (output);
			}
			
			FileService.DeleteFile (responseFileName);
			if (configuration.CompileTarget != CompileTarget.Library) {
				WriteManifestFile (exe);
			}
			return result;
		}
        public static BuildResult Compile(ProjectItemCollection projectItems, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, IProgressMonitor monitor)
        {
            FSharpCompilerParameters compilerParameters = (FSharpCompilerParameters)configuration.CompilationParameters ?? new FSharpCompilerParameters ();
            FSharpProjectParameters projectParameters = (FSharpProjectParameters)configuration.ProjectParameters ?? new FSharpProjectParameters ();

            string outputName       = configuration.CompiledOutputName;

            TargetRuntime runtime = MonoDevelop.Core.Runtime.SystemAssemblyService.DefaultRuntime;
            DotNetProject project = configuration.ParentItem as DotNetProject;
            if (project != null)
                runtime = project.TargetRuntime;

            StringBuilder sb = new StringBuilder ();
            List<string> gacRoots = new List<string> ();
            sb.AppendFormat ("--out:{0}", outputName);
            sb.AppendLine ();

            HashSet<string> alreadyAddedReference = new HashSet<string> ();
            foreach (ProjectReference lib in projectItems.GetAll <ProjectReference> ()) {
                if (lib.ReferenceType == ReferenceType.Project && !(lib.OwnerProject.ParentSolution.FindProjectByName (lib.Reference) is DotNetProject))
                    continue;
                foreach (string fileName in lib.GetReferencedFileNames (configSelector)) {
                    switch (lib.ReferenceType) {
                    case ReferenceType.Gac:
                        SystemPackage pkg = lib.Package;
                        if (pkg == null) {
                            string msg = string.Format (GettextCatalog.GetString ("{0} could not be found or is invalid."), lib.Reference);
                            monitor.ReportWarning (msg);
                            continue;
                        }
                        string referencedName = pkg.IsCorePackage ? Path.GetFileName (fileName) : fileName;
                        if (!alreadyAddedReference.Contains (referencedName)) {
                        alreadyAddedReference.Add (referencedName);
                            AppendQuoted (sb, "--reference:", referencedName);
                        }

                        if (pkg.GacRoot != null && !gacRoots.Contains (pkg.GacRoot))
                            gacRoots.Add (pkg.GacRoot);
                        if (!string.IsNullOrEmpty (pkg.Requires)) {
                            foreach (string requiredPackage in pkg.Requires.Split(' ')) {
                                SystemPackage rpkg = runtime.AssemblyContext.GetPackage (requiredPackage);
                                if (rpkg == null)
                                    continue;
                                foreach (SystemAssembly assembly in rpkg.Assemblies) {
                                    if (alreadyAddedReference.Contains (assembly.Location))
                                        continue;
                                    alreadyAddedReference.Add (assembly.Location);
                                    AppendQuoted (sb, "--reference:", assembly.Location);
                                }
                            }
                        }
                        break;
                    default://
                        AppendQuoted (sb, "--reference:", fileName);
                        break;
                    }
                }
            }

            // THINK!! WNH			sb.Append ("/warn:");sb.Append (compilerParameters.WarningLevel.ToString ());
            //			sb.AppendLine ();

            if (configuration.SignAssembly) {
                if (File.Exists (configuration.AssemblyKeyFile))
                    AppendQuoted (sb, "--keyfile:", configuration.AssemblyKeyFile);
            }

            if (configuration.DebugMode) {
            // WNH REVIEW				sb.AppendLine ("/debug:+");
            //			sb.AppendLine ("/debug:full");
                sb.AppendLine ("-g");
            }

            // mcs default is + but others might not be   <<<<< what about FSC default??? WNH
            if (compilerParameters.Optimize)
                sb.AppendLine ("--optimize+");
            else
                sb.AppendLine ("--optimize-");

            bool hasWin32Res = !string.IsNullOrEmpty (projectParameters.Win32Resource) && File.Exists (projectParameters.Win32Resource);
            if (hasWin32Res)
                AppendQuoted (sb, "--win32res:", projectParameters.Win32Resource);

            if (!string.IsNullOrEmpty (projectParameters.Win32Icon) && File.Exists (projectParameters.Win32Icon)) {
                if (hasWin32Res) {
                    monitor.ReportWarning ("Both Win32 icon and Win32 resource cannot be specified. Ignoring the icon.");
                } else {
                    AppendQuoted (sb, "--win32icon:", projectParameters.Win32Icon);
                }
            }

            if (projectParameters.CodePage != 0)    // WNH RIP OUT???
                sb.AppendLine ("--codepage:" + projectParameters.CodePage);
            else if (runtime is MonoTargetRuntime)
                sb.AppendLine ("--utf8output");

            //			if (compilerParameters.UnsafeCode)    WNH RIP OUT??
            //				sb.AppendLine ("-unsafe");
            //			if (compilerParameters.NoStdLib)
            //				sb.AppendLine ("-nostdlib");

            if (!string.IsNullOrEmpty (compilerParameters.PlatformTarget) && compilerParameters.PlatformTarget.ToLower () != "anycpu") {
                //HACK: to ignore the platform flag for Mono <= 2.4, because gmcs didn't support it
                if (runtime.RuntimeId == "Mono" && runtime.AssemblyContext.GetAssemblyLocation ("Mono.Debugger.Soft", null) == null) {
                    LoggingService.LogWarning ("Mono runtime '" + runtime.DisplayName +
                                               "' appears to be too old to support the 'platform' F# compiler flag.");
                } else {
                    sb.AppendLine ("--platform:" + compilerParameters.PlatformTarget);
                }
            }

            if (compilerParameters.TreatWarningsAsErrors) {
                sb.AppendLine ("--all-warnings-as-errors");
                if (!string.IsNullOrEmpty (compilerParameters.WarningsNotAsErrors))
                    sb.AppendLine ("-warnaserror-:" + compilerParameters.WarningsNotAsErrors);
            }

            if (compilerParameters.DefineSymbols.Length > 0) {
                string define_str = string.Join (";", compilerParameters.DefineSymbols.Split (new char [] {',', ' ', ';'}, StringSplitOptions.RemoveEmptyEntries));
                if (define_str.Length > 0) {
            // WNH					AppendQuoted (sb, "--define:", define_str);  // WNH REVIEW!!!!
            // WNH					AppendQuoted (sb, "--define:", define_str);  // WNH REVIEW!!!!
                    sb.AppendFormat("--define:{0}", define_str);   // WNH
                    sb.AppendLine ();
                }
            }

            CompileTarget ctarget = configuration.CompileTarget;

            switch (ctarget) {
                case CompileTarget.Exe:
                    sb.AppendLine ("--target:exe");
                    break;
                case CompileTarget.WinExe:
                    sb.AppendLine ("--target:winexe");
                    break;
                case CompileTarget.Library:
                    sb.AppendLine ("--target:library");
                    break;
            }

            foreach (ProjectFile finfo in projectItems.GetAll<ProjectFile> ()) {
                if (finfo.Subtype == Subtype.Directory)
                    continue;

                switch (finfo.BuildAction) {
                    case "Compile":
            // WNH 						AppendQuoted (sb, "", finfo.Name);
                        sb.AppendLine (finfo.Name);   // WNH
                        break;
                    case "EmbeddedResource":
                        string fname = finfo.Name;
                        if (string.Compare (Path.GetExtension (fname), ".resx", true) == 0)
                            fname = Path.ChangeExtension (fname, ".resources");
                        sb.Append ('"');sb.Append ("--resource:");
                        sb.Append (fname);sb.Append (',');sb.Append (finfo.ResourceId);
                        sb.Append ('"');sb.AppendLine ();
                        break;
                    default:
                        continue;
                }
            }
            if (compilerParameters.GenerateXmlDocumentation)
                AppendQuoted (sb, "--doc:", Path.ChangeExtension (outputName, ".xml"));

            if (!string.IsNullOrEmpty (compilerParameters.AdditionalArguments))
                sb.AppendLine (compilerParameters.AdditionalArguments);

            if (!string.IsNullOrEmpty (compilerParameters.NoWarnings))
                AppendQuoted (sb, "--no-warn:", compilerParameters.NoWarnings);  // WNH can't be a list on FSC!!!! FIX!!!

            if (runtime.RuntimeId == "MS.NET")
                sb.AppendLine ("--fullpaths");

            string output = "";
            string error  = "";

            string compilerName;
            try {
                compilerName = GetCompilerName (runtime, configuration.TargetFramework);
            } catch (Exception e) {
                string message = "Could not obtain a F# compiler";
                monitor.ReportError (message, e);
                return null;
            }

            monitor.Log.WriteLine (compilerName + sb.ToString ().Replace ('\n',' '));

            string workingDir = ".";
            if (configuration.ParentItem != null) {
                workingDir = configuration.ParentItem.BaseDirectory;
                if (workingDir == null)
                    // Dummy projects created for single files have no filename
                    // and so no BaseDirectory.
                    // This is a workaround for a bug in
                    // ProcessStartInfo.WorkingDirectory - not able to handle null
                    workingDir = ".";
            }

            // Log the fsc command line
            LoggingService.LogInfo (compilerName + " " + sb.ToString ());

            // Compile!
            Dictionary<string,string> envVars = runtime.GetToolsEnvironmentVariables (project.TargetFramework);
            int exitCode = DoCompilation (compilerName, sb.ToString(), workingDir, envVars, gacRoots, ref output, ref error);

            BuildResult result = ParseOutput (output, error);
            if (result.CompilerOutput.Trim ().Length != 0)
                monitor.Log.WriteLine (result.CompilerOutput);

            // If compiler crashes, output entire error string
            if (result.ErrorCount == 0 && exitCode != 0) {
                try {
                    monitor.Log.Write (File.ReadAllText (error));
                } catch (IOException) {
                }
                result.AddError ("The compiler appears to have crashed. Check the build output pad for details.");
            } else {
                FileService.DeleteFile (output);
                FileService.DeleteFile (error);
            }

            return result;
        }
		public BuildResult Compile(ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, IProgressMonitor monitor)
		{
			LoggingService.LogDebug ("NotImplemented");
			return null;
		}
		string GenerateOptions (DotNetProjectConfiguration configuration, VBCompilerParameters compilerparameters, VBProject projectparameters, string outputFileName)
		{
			var project = configuration.ParentItem;
			StringBuilder sb = new StringBuilder ();
			
			sb.AppendFormat ("\"-out:{0}\"", outputFileName);
			sb.AppendLine ();
			
			sb.AppendLine ("-nologo");
			sb.AppendLine ("-utf8output");
			sb.AppendLine ("-quiet");

			sb.AppendFormat ("-debug:{0}", compilerparameters.DebugType);
			sb.AppendLine ();

			if (compilerparameters.Optimize)
				sb.AppendLine ("-optimize+");

			
			if (projectparameters.OptionStrict)
				sb.AppendLine ("-optionstrict+");
			else
				sb.AppendLine ("-optionstrict-");
			
			if (projectparameters.OptionExplicit)
				sb.AppendLine ("-optionexplicit+");
			else
				sb.AppendLine ("-optionexplicit-");

			if (projectparameters.BinaryOptionCompare)
				sb.AppendLine ("-optioncompare:binary");
			else
				sb.AppendLine ("-optioncompare:text");

			if (projectparameters.OptionInfer)
				sb.AppendLine ("-optioninfer+");
			else
				sb.AppendLine ("-optioninfer-");

			string mytype = projectparameters.MyType;
			if (!string.IsNullOrEmpty (mytype)) {
				sb.AppendFormat ("-define:_MYTYPE=\\\"{0}\\\"", mytype);
				sb.AppendLine ();
			}
			
			string win32IconPath = projectparameters.ApplicationIcon;
			if (!string.IsNullOrEmpty (win32IconPath) && File.Exists (win32IconPath)) {
				sb.AppendFormat ("\"-win32icon:{0}\"", win32IconPath);
				sb.AppendLine ();
			}

			if (!string.IsNullOrEmpty (projectparameters.CodePage)) {
				TextEncoding enc = TextEncoding.GetEncoding (projectparameters.CodePage);
				sb.AppendFormat ("-codepage:{0}", enc.CodePage);
				sb.AppendLine ();
			}
			
			if (!string.IsNullOrEmpty (project.DefaultNamespace)) {
				sb.AppendFormat ("-rootnamespace:{0}", project.DefaultNamespace);
				sb.AppendLine ();
			}
			
			if (!string.IsNullOrEmpty (compilerparameters.DefineConstants)) {
				sb.AppendFormat ("\"-define:{0}\"", compilerparameters.DefineConstants);
				sb.AppendLine ();
			}

			if (compilerparameters.DefineDebug)
				sb.AppendLine ("-define:DEBUG=-1");

			if (compilerparameters.DefineTrace)
				sb.AppendLine ("-define:TRACE=-1");

			if (compilerparameters.WarningsDisabled) {
				sb.AppendLine ("-nowarn");
			} else if (!string.IsNullOrEmpty (compilerparameters.NoWarn)) {
				sb.AppendFormat ("-nowarn:{0}", compilerparameters.NoWarn);
				sb.AppendLine ();
			}

			if (!string.IsNullOrEmpty (compilerparameters.WarningsAsErrors)) {
				sb.AppendFormat ("-warnaserror+:{0}", compilerparameters.WarningsAsErrors);
				sb.AppendLine ();
			}
			
			if (configuration.SignAssembly) {
				if (File.Exists (configuration.AssemblyKeyFile)) {
					sb.AppendFormat ("\"-keyfile:{0}\"", configuration.AssemblyKeyFile);
					sb.AppendLine ();
				}
			}
			
			if (configuration.DelaySign)
				sb.AppendLine ("-delaySign");

			if (!string.IsNullOrEmpty (compilerparameters.DocumentationFile)) {
				sb.AppendFormat ("\"-doc:{0}\"", compilerparameters.DocumentationFile);
				sb.AppendLine ();
			}

			if (!string.IsNullOrEmpty (projectparameters.StartupObject) && projectparameters.StartupObject != "Sub Main") {
				sb.Append ("-main:");
				sb.Append (projectparameters.StartupObject);
				sb.AppendLine ();
			}

			if (compilerparameters.RemoveIntegerChecks)
				sb.AppendLine ("-removeintchecks+");
			
			if (!string.IsNullOrEmpty (compilerparameters.AdditionalParameters)) {
				sb.Append (compilerparameters.AdditionalParameters);
				sb.AppendLine ();
			}
						
			switch (configuration.CompileTarget) {
				case CompileTarget.Exe:
					sb.AppendLine ("-target:exe");
					break;
				case CompileTarget.WinExe:
					sb.AppendLine ("-target:winexe");
					break;
				case CompileTarget.Library:
					sb.AppendLine ("-target:library");
					break;
				case CompileTarget.Module:
					sb.AppendLine ("-target:module");
					break;
				default:
					throw new NotSupportedException("unknown compile target:" + configuration.CompileTarget);
			}
			
			return sb.ToString();
		}
Example #59
0
		protected virtual ExecutionCommand CreateExecutionCommand (ConfigurationSelector configSel, DotNetProjectConfiguration configuration)
		{
			DotNetExecutionCommand cmd = new DotNetExecutionCommand (configuration.CompiledOutputName);
			cmd.Arguments = configuration.CommandLineParameters;
			cmd.WorkingDirectory = Path.GetDirectoryName (configuration.CompiledOutputName);
			cmd.EnvironmentVariables = configuration.GetParsedEnvironmentVariables ();
			cmd.TargetRuntime = TargetRuntime;
			cmd.UserAssemblyPaths = GetUserAssemblyPaths (configSel);
			return cmd;
		}
		protected override BuildResult OnCompileSources (ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, ProgressMonitor monitor)
		{
			return CSharpBindingCompilerManager.Compile (items, configuration, configSelector, monitor);
		}