Example #1
0
        /// <summary>
        /// Cleans up intermediate files
        /// </summary>
        /// <param name="projectFiles">
        /// The project's files
        /// <see cref="ProjectFileCollection"/>
        /// </param>
        /// <param name="configuration">
        /// Project configuration
        /// <see cref="ValaProjectConfiguration"/>
        /// </param>
        /// <param name="monitor">
        /// The progress monitor to be used
        /// <see cref="IProgressMonitor"/>
        /// </param>
        public void Clean(ProjectFileCollection projectFiles, ValaProjectConfiguration configuration, IProgressMonitor monitor)
        {
            /// Clean up intermediate files
            /// These should only be generated for libraries, but we'll check for them in all cases
            foreach (ProjectFile file in projectFiles)
            {
                if (file.BuildAction == BuildAction.Compile)
                {
                    string cFile = Path.Combine(configuration.OutputDirectory, Path.GetFileNameWithoutExtension(file.Name) + ".c");
                    if (File.Exists(cFile))
                    {
                        File.Delete(cFile);
                    }

                    string hFile = Path.Combine(configuration.OutputDirectory, Path.GetFileNameWithoutExtension(file.Name) + ".h");
                    if (File.Exists(hFile))
                    {
                        File.Delete(hFile);
                    }
                }
            }

            string vapiFile = Path.Combine(configuration.OutputDirectory, configuration.Output + ".vapi");

            if (File.Exists(vapiFile))
            {
                File.Delete(vapiFile);
            }
        }
        /// <summary>
        /// This is the pkg-config package that gets deployed.
        /// <returns>The pkg-config package's filename</returns>
        /// </summary>
        private string WriteDeployablePkgPackage(ConfigurationSelector configuration)
        {
            // FIXME: This should probably be grabed from somewhere.
            string prefix  = "/usr/local";
            string pkgfile = Path.Combine(BaseDirectory, Name + ".pc");
            ValaProjectConfiguration config = (ValaProjectConfiguration)GetConfiguration(configuration);

            using (StreamWriter writer = new StreamWriter(pkgfile)) {
                writer.WriteLine("prefix={0}", prefix);
                writer.WriteLine("exec_prefix=${prefix}");
                writer.WriteLine("libdir=${exec_prefix}/lib");
                writer.WriteLine("includedir=${prefix}/include");
                writer.WriteLine();
                writer.WriteLine("Name: {0}", Name);
                writer.WriteLine("Description: {0}", Description);
                writer.WriteLine("Version: {0}", Version);
                writer.WriteLine("Requires: {0}", string.Join(" ", Packages.ToStringArray()));
                // TODO: How should I get this?
                writer.WriteLine("Conflicts: {0}", string.Empty);
                writer.Write("Libs: -L${libdir} ");
                writer.WriteLine("-l{0}", config.Output);
                writer.Write("Cflags: -I${includedir}/");
                writer.WriteLine("{0} {1}", Name, Regex.Replace(((ValaCompilationParameters)config.CompilationParameters).DefineSymbols, @"(^|\s+)(\w+)", "-D$2 ", RegexOptions.Compiled));
            }

            return(pkgfile);
        }
        /// <summary>
        /// Ths pkg-config package is for internal MonoDevelop use only, it is not deployed.
        /// </summary>
        public void WriteMDPkgPackage(ConfigurationSelector configuration)
        {
            string pkgfile = Path.Combine(BaseDirectory, Name + ".md.pc");

            ValaProjectConfiguration config = (ValaProjectConfiguration)GetConfiguration(configuration);

            using (StreamWriter writer = new StreamWriter(pkgfile)) {
                writer.WriteLine("Name: {0}", Name);
                writer.WriteLine("Description: {0}", Description);
                writer.WriteLine("Version: {0}", Version);
                writer.WriteLine("Libs: -L{0} -l{1}", config.OutputDirectory, config.Output);
//				writer.WriteLine ("Cflags: -I{0}", BaseDirectory);
            }

            // If this project compiles into a shared object we need to
            // export the output path to the LD_LIBRARY_PATH
            string literal         = "LD_LIBRARY_PATH";
            string ld_library_path = Environment.GetEnvironmentVariable(literal);

            if (string.IsNullOrEmpty(ld_library_path))
            {
                Environment.SetEnvironmentVariable(literal, config.OutputDirectory);
            }
            else if (!ld_library_path.Contains(config.OutputDirectory))
            {
                ld_library_path = string.Format("{0}:{1}", config.OutputDirectory, ld_library_path);
                Environment.SetEnvironmentVariable(literal, ld_library_path);
            }
        }
        protected override bool OnGetCanExecute(MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector solutionConfiguration)
        {
            ValaProjectConfiguration conf = (ValaProjectConfiguration)GetConfiguration(solutionConfiguration);
            ExecutionCommand         cmd  = CreateExecutionCommand(conf);

            return((conf.CompileTarget == ValaBinding.CompileTarget.Bin) &&
                   context.ExecutionHandler.CanExecute(cmd));
        }
        public ProjectPackage(ValaProject project) : this()
        {
            name = project.Name;
            ValaProjectConfiguration vpc = (ValaProjectConfiguration)(project.DefaultConfiguration);

            file       = Path.Combine(vpc.OutputDirectory, name + ".vapi");
            is_project = true;
        }
        /// <summary>
        /// Add dependencies of project packages to current project,
        /// and add cflags for project package and LD_LIBRARY_PATH
        /// </summary>
        private void AddDependencies(object obj, ProjectPackageEventArgs args)
        {
            ProjectPackage package = args.Package;

            if (!package.IsProject)
            {
                return;
            }

            string depsfile = Path.ChangeExtension(package.File, ".deps");

            try {
                if (File.Exists(depsfile))
                {
                    string[] lines             = File.ReadAllLines(depsfile);
                    List <ProjectPackage> deps = new List <ProjectPackage>();
                    foreach (string line in lines)
                    {
                        deps.Add(new ProjectPackage(Path.Combine(vapidir, line) + ".vapi"));
                    }                    // add package for each dep
                    packages.AddRange(deps);
                }

                // Currently, we need to add include directory and linker flags - this should be obsoleted
                string ccargs      = string.Format(" --Xcc=\\\\\\\"-I{0}\\\\\\\" --Xcc=\\\\\\\"-L{0}\\\\\\\" --Xcc=\\\\\\\"-l{1}\\\\\\\" ", Path.GetDirectoryName(depsfile), package.Name);
                string ldpath      = string.Empty;
                string packagePath = Path.GetDirectoryName(package.File);

                foreach (ItemConfiguration pc in Configurations)
                {
                    ValaProjectConfiguration valapc = pc as ValaProjectConfiguration;
                    if (null == valapc)
                    {
                        continue;
                    }

                    ValaCompilationParameters vcp = (ValaCompilationParameters)valapc.CompilationParameters;
                    if (!vcp.ExtraCompilerArguments.Contains(ccargs))
                    {
                        vcp.ExtraCompilerArguments += ccargs;
                    }

                    if (valapc.EnvironmentVariables.TryGetValue("LD_LIBRARY_PATH", out ldpath))
                    {
                        if (!ldpath.Contains(packagePath))
                        {
                            ldpath += Path.PathSeparator + packagePath;
                        }
                    }
                    else
                    {
                        ldpath = packagePath;
                    }

                    valapc.EnvironmentVariables["LD_LIBRARY_PATH"] = ldpath;
                } // add compilation parameters and LD_LIBRARY_PATH
            } catch { /* Do anything here? */ }
        }         // AddDependencies
        ExecutionCommand CreateExecutionCommand(ValaProjectConfiguration conf)
        {
            NativeExecutionCommand cmd = new NativeExecutionCommand();

            cmd.Command          = Path.Combine(conf.OutputDirectory, conf.Output);
            cmd.Arguments        = conf.CommandLineParameters;
            cmd.WorkingDirectory = Path.GetFullPath(conf.OutputDirectory);
            return(cmd);
        }
        public override SolutionItemConfiguration CreateConfiguration(string name)
        {
            ValaProjectConfiguration conf = new ValaProjectConfiguration();

            conf.Name = name;
            conf.CompilationParameters = new ValaCompilationParameters();

            return(conf);
        }
        /// <summary>
        /// Deploys a makefile to build the default configuration.
        /// </summary>
        /// <remarks>
        /// TODO: Make configuration-based targets as advertised.
        /// </remarks>
        public Makefile Deploy(AutotoolsContext ctx, MonoDevelop.Projects.SolutionItem entry, MonoDevelop.Core.IProgressMonitor monitor)
        {
            Makefile    mkfile            = new Makefile();
            ValaProject project           = (ValaProject)entry;
            ValaProjectConfiguration conf = (ValaProjectConfiguration)project.DefaultConfiguration;

            StringBuilder files = new StringBuilder();

            foreach (ProjectFile t in project.Files)
            {
                if (BuildAction.Compile == t.BuildAction)
                {
                    files.Append("\\\n\t" + FileService.AbsoluteToRelativePath(project.BaseDirectory, t.FilePath));
                }
            }

            string dir = ctx.DeployContext.GetResolvedPath(TargetDirectory.ProgramFiles, FileService.AbsoluteToRelativePath(conf.OutputDirectory, ctx.TargetSolution.BaseDirectory));

            dir = dir.Replace("@prefix@", "$(prefix)");
            dir = dir.Replace("@PACKAGE@", "$(PACKAGE)");

            TemplateEngine templateEngine = new TemplateEngine();

            templateEngine.Variables ["TOP_SRCDIR"]  = FileService.AbsoluteToRelativePath(project.BaseDirectory, ctx.TargetSolution.BaseDirectory);
            templateEngine.Variables ["FILES"]       = files.ToString();
            templateEngine.Variables ["BUILD_DIR"]   = ".";
            templateEngine.Variables ["INSTALL_DIR"] = "$(DESTDIR)" + dir;
            templateEngine.Variables ["ALL_TARGET"]  = string.Format("all-{0}", conf.Name);
            templateEngine.Variables ["VFLAGS"]      = string.Format("{0} {1}", ValaCompiler.GetCompilerFlags(conf), ValaCompiler.GeneratePkgCompilerArgs(project.Packages));
            templateEngine.Variables ["VTARGET"]     = conf.CompiledOutputName;

            StringWriter sw = new StringWriter();

            string mt;

            if (ctx.MakefileType == MakefileType.AutotoolsMakefile)
            {
                mt = "Makefile.am.template";
            }
            else
            {
                mt = "Makefile.template";
            }

            using (Stream stream = GetType().Assembly.GetManifestResourceStream(mt)) {
                StreamReader reader = new StreamReader(stream);

                templateEngine.Process(reader, sw);
                reader.Close();
            }

            mkfile.Append(sw.ToString());

            return(mkfile);
        }
Example #10
0
        public void Load(ValaProjectConfiguration config)
        {
            configuration         = config;
            compilationParameters = (ValaCompilationParameters)configuration.CompilationParameters;

            switch (compilationParameters.WarningLevel)
            {
            case WarningLevel.None:
                noWarningRadio.Active = true;
                break;

            case WarningLevel.Normal:
                normalWarningRadio.Active = true;
                break;

            case WarningLevel.All:
                allWarningRadio.Active = true;
                break;
            }

            warningsAsErrorsCheckBox.Active = compilationParameters.WarningsAsErrors;
            threadingCheckbox.Sensitive     = (config.CompileTarget == CompileTarget.Bin);
            threadingCheckbox.Active        = (threadingCheckbox.Sensitive && compilationParameters.EnableMultithreading);

            optimizationSpinButton.Value = compilationParameters.OptimizationLevel;

            switch (configuration.CompileTarget)
            {
            case ValaBinding.CompileTarget.Bin:
                targetComboBox.Active = 0;
                break;

            case ValaBinding.CompileTarget.StaticLibrary:
                targetComboBox.Active = 1;
                break;

            case ValaBinding.CompileTarget.SharedLibrary:
                targetComboBox.Active = 2;
                break;
            }

            extraCompilerTextView.Buffer.Text = compilationParameters.ExtraCompilerArguments;

            defineSymbolsTextEntry.Text = compilationParameters.DefineSymbols;

            foreach (string lib in configuration.Libs)
            {
                libStore.AppendValues(lib);
            }

            foreach (string includePath in configuration.Includes)
            {
                includePathStore.AppendValues(includePath);
            }
        }
Example #11
0
        public void Load(ValaProjectConfiguration config)
        {
            configuration = config;

            outputNameTextEntry.Text = configuration.Output;
            outputPathTextEntry.Text = configuration.OutputDirectory;
            parametersTextEntry.Text = configuration.CommandLineParameters;

            externalConsoleCheckbox.Active = configuration.ExternalConsole;
            pauseCheckbox.Active           = configuration.PauseConsoleOutput;
        }
Example #12
0
        protected override BuildResult DoBuild(IProgressMonitor monitor, ConfigurationSelector configuration)
        {
            ValaProjectConfiguration pc = (ValaProjectConfiguration)GetConfiguration(configuration);

            pc.SourceDirectory = BaseDirectory;

            return(compiler_manager.Compile(
                       Files, packages,
                       pc,
                       monitor));
        }
Example #13
0
		public void Load (ValaProjectConfiguration config)
		{
			configuration = config;
			
			outputNameTextEntry.Text = configuration.Output;
			outputPathTextEntry.Text = configuration.OutputDirectory;
			parametersTextEntry.Text = configuration.CommandLineParameters;
			
			externalConsoleCheckbox.Active = configuration.ExternalConsole;
			pauseCheckbox.Active = configuration.PauseConsoleOutput;
		}
 protected override void InsertItem(int index, ProjectPackage value)
 {
     if (value.IsProject && null != project)
     {
         ValaProjectConfiguration vpc = (ValaProjectConfiguration)project.DefaultConfiguration;
         value.File = ProjectPackage.ToRelativePath(value.File, Path.Combine(vpc.OutputDirectory, vpc.CompiledOutputName));
     }
     base.InsertItem(index, value);
     if (project != null)
     {
         project.NotifyPackageAddedToProject(value);
     }
 }
Example #15
0
        protected override void DoExecute(IProgressMonitor monitor,
                                          ExecutionContext context,
                                          ConfigurationSelector configuration)
        {
            ValaProjectConfiguration conf = (ValaProjectConfiguration)GetConfiguration(configuration);
            bool     pause = conf.PauseConsoleOutput;
            IConsole console;

            if (conf.CompileTarget != ValaBinding.CompileTarget.Bin)
            {
                MessageService.ShowMessage("Compile target is not an executable!");
                return;
            }

            ExecutionCommand cmd = CreateExecutionCommand(conf);

            monitor.Log.WriteLine("Running project...");

            if (conf.ExternalConsole)
            {
                console = context.ExternalConsoleFactory.CreateConsole(!pause);
            }
            else
            {
                console = context.ConsoleFactory.CreateConsole(!pause);
            }

            AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor(monitor);

            try {
                if (!context.ExecutionHandler.CanExecute(cmd))
                {
                    monitor.ReportError("Cannot execute \"" + conf.Output + "\". The selected execution mode is not supported for Vala projects.", null);
                    return;
                }

                IProcessAsyncOperation op = context.ExecutionHandler.Execute(cmd, console);

                operationMonitor.AddOperation(op);
                op.WaitForCompleted();

                monitor.Log.WriteLine("The operation exited with code: {0}", op.ExitCode);
            } catch (Exception ex) {
                monitor.ReportError("Cannot execute \"" + conf.Output + "\"", ex);
            } finally {
                operationMonitor.Dispose();
                console.Dispose();
            }
        }
        protected override void SetItem(int index, ProjectPackage item)
        {
            ProjectPackage oldValue = Items [index];

            if (item.IsProject && null != project)
            {
                ValaProjectConfiguration vpc = (ValaProjectConfiguration)project.DefaultConfiguration;
                item.File = ProjectPackage.ToRelativePath(item.File, Path.Combine(vpc.OutputDirectory, vpc.CompiledOutputName));
            }
            base.SetItem(index, item);
            if (project != null)
            {
                project.NotifyPackageRemovedFromProject(oldValue);
                project.NotifyPackageAddedToProject(item);
            }
        }
Example #17
0
        public void GenerateDepfile(ValaProjectConfiguration configuration, ProjectPackageCollection packages)
        {
            try {
                if (configuration.CompileTarget != CompileTarget.SharedLibrary)
                {
                    return;
                }

                using (StreamWriter writer = new StreamWriter(Path.Combine(configuration.OutputDirectory, Path.ChangeExtension(configuration.Output, ".deps")))) {
                    foreach (ProjectPackage package in packages)
                    {
                        writer.WriteLine(package.Name);
                    }
                }
            } catch { /* Don't care */ }
        }
Example #18
0
		public void Load (ValaProjectConfiguration config)
		{
			configuration = config;
			compilationParameters = (ValaCompilationParameters)configuration.CompilationParameters;
			
			switch (compilationParameters.WarningLevel)
			{
			case WarningLevel.None:
				noWarningRadio.Active = true;
				break;
			case WarningLevel.Normal:
				normalWarningRadio.Active = true;
				break;
			case WarningLevel.All:
				allWarningRadio.Active = true;
				break;
			}
			
			warningsAsErrorsCheckBox.Active = compilationParameters.WarningsAsErrors;
			threadingCheckbox.Sensitive = (config.CompileTarget == CompileTarget.Bin);
			threadingCheckbox.Active = (threadingCheckbox.Sensitive && compilationParameters.EnableMultithreading);
			
			optimizationSpinButton.Value = compilationParameters.OptimizationLevel;
			
			switch (configuration.CompileTarget)
			{
			case ValaBinding.CompileTarget.Bin:
				targetComboBox.Active = 0;
				break;
			case ValaBinding.CompileTarget.StaticLibrary:
				targetComboBox.Active = 1;
				break;
			case ValaBinding.CompileTarget.SharedLibrary:
				targetComboBox.Active = 2;
				break;
			}
			
			extraCompilerTextView.Buffer.Text = compilationParameters.ExtraCompilerArguments;
			
			defineSymbolsTextEntry.Text = compilationParameters.DefineSymbols;
			
			foreach (string lib in configuration.Libs)
				libStore.AppendValues (lib);
			
			foreach (string includePath in configuration.Includes)
				includePathStore.AppendValues (includePath);
		}
Example #19
0
        /// <summary>
        /// Compile the project
        /// </summary>
        /// <param name="projectFiles">
        /// Collection of project files
        /// <see cref="ProjectFileCollection"/>
        /// </param>
        /// <param name="packages">
        /// Collection of depended packages
        /// <see cref="ProjectPackageCollection"/>
        /// </param>
        /// <param name="configuration">
        /// Project configuration
        /// <see cref="ValaProjectConfiguration"/>
        /// </param>
        /// <param name="monitor">
        /// Progress monitor to be used
        /// <see cref="IProgressMonitor"/>
        /// </param>
        /// <returns>
        /// Result of the compilation
        /// <see cref="ICompilerResult"/>
        /// </returns>
        public BuildResult Compile(
            ProjectFileCollection projectFiles,
            ProjectPackageCollection packages,
            ValaProjectConfiguration configuration,
            IProgressMonitor monitor)
        {
            if (!appsChecked)
            {
                appsChecked   = true;
                compilerFound = CheckApp(compilerCommand);
            }            /// Check for compiler


            if (!compilerFound)
            {
                BuildResult cres = new BuildResult();
                cres.AddError("Compiler not found: " + compilerCommand);
                return(cres);
            }            /// No compiler!

            CompilerResults cr      = new CompilerResults(new TempFileCollection());
            bool            success = true;

            /// Build compiler params string
            string compilerArgs = GetCompilerFlags(configuration) + " " + GeneratePkgCompilerArgs(packages);

            /// Build executable name
            string outputName = Path.Combine(configuration.OutputDirectory,
                                             configuration.CompiledOutputName);

            monitor.BeginTask(GettextCatalog.GetString("Compiling source"), 1);

            success = DoCompilation(projectFiles, compilerArgs, outputName, monitor, cr);

            GenerateDepfile(configuration, packages);

            if (success)
            {
                monitor.Step(1);
            }
            monitor.EndTask();

            return(new BuildResult(cr, ""));
        }
Example #20
0
        public override void CopyFrom(ItemConfiguration configuration)
        {
            base.CopyFrom(configuration);
            ValaProjectConfiguration conf = (ValaProjectConfiguration)configuration;

            output   = conf.output;
            target   = conf.target;
            includes = conf.includes;
            libs     = conf.libs;
            source_directory_path = conf.source_directory_path;

            if (conf.CompilationParameters == null)
            {
                compilationParameters = null;
            }
            else
            {
                compilationParameters = (ICloneable)conf.compilationParameters.Clone();
            }
        }
Example #21
0
        private List <ProjectPackage> GetPackagesOfProjects(Project project)
        {
            List <ProjectPackage> packages = new List <ProjectPackage>();
            ProjectPackage        package;

            foreach (Project c in IdeApp.Workspace.GetAllProjects())
            {
                if (c is ValaProject)
                {
                    ValaProject proj = c as ValaProject;
                    ValaProjectConfiguration conf = proj.GetConfiguration(IdeApp.Workspace.ActiveConfiguration) as ValaProjectConfiguration;
                    if (conf.CompileTarget != CompileTarget.Bin)
                    {
                        proj.WriteMDPkgPackage(conf.Selector);
                        package = new ProjectPackage(proj);
                        packages.Add(package);
                    }
                }
            }

            return(packages);
        }
Example #22
0
        protected override BuildResult Build(IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
        {
            ValaProject project = entry as ValaProject;

            if (project == null)
            {
                return(base.Build(monitor, entry, configuration));
            }

            foreach (ValaProject p in project.DependedOnProjects())
            {
                p.Build(monitor, configuration, true);
            }

            ValaProjectConfiguration conf = (ValaProjectConfiguration)project.GetConfiguration(configuration);

            if (conf.CompileTarget != CompileTarget.Bin)
            {
                project.WriteMDPkgPackage(configuration);
            }

            return(base.Build(monitor, entry, configuration));
        }
Example #23
0
		/// <summary>
		/// Generates compiler args for the current settings
		/// </summary>
		/// <param name="configuration">
		/// Project configuration
		/// <see cref="ValaProjectConfiguration"/>
		/// </param>
		/// <returns>
		/// A compiler-interpretable string
		/// <see cref="System.String"/>
		/// </returns>
		public static string GetCompilerFlags (ValaProjectConfiguration configuration)
		{
			List<string> args = new List<string> ();
			
			
			ValaCompilationParameters cp =
				(ValaCompilationParameters)configuration.CompilationParameters;

			args.Add (string.Format ("-d '{0}'", configuration.OutputDirectory));
			
			if (configuration.DebugMode)
				args.Add ("-g");

			switch (configuration.CompileTarget) {
			case ValaBinding.CompileTarget.Bin:
				if (cp.EnableMultithreading) {
					args.Add ("--thread");
				}
				break;
			case ValaBinding.CompileTarget.SharedLibrary:
				args.Add (string.Format ("--Xcc=\"-shared\" --Xcc=\"-fPIC\" --Xcc=\"-I'{0}'\" -H \"{1}.h\" --library \"{1}\"", configuration.OutputDirectory, configuration.Output));
				break;
			}

// Valac will get these sooner or later			
//			switch (cp.WarningLevel)
//			{
//			case WarningLevel.None:
//				args.Append ("-w ");
//				break;
//			case WarningLevel.Normal:
//				// nothing
//				break;
//			case WarningLevel.All:
//				args.Append ("-Wall ");
//				break;
//			}
//			
//			if (cp.WarningsAsErrors)
//				args.Append ("-Werror ");
//			
			if (0 < cp.OptimizationLevel) { 
				args.Add ("--Xcc=\"-O" + cp.OptimizationLevel + "\"");
			}
			
			if (cp.ExtraCompilerArguments != null && cp.ExtraCompilerArguments.Length > 0) {
				args.Add (ExpandBacktickedParameters (cp.ExtraCompilerArguments.Replace (Environment.NewLine, " ")));
			}
			
			if (cp.DefineSymbols != null && cp.DefineSymbols.Length > 0) {
				args.Add (ProcessDefineSymbols (cp.DefineSymbols));
			}
			
			if (configuration.Includes != null)
				foreach (string inc in configuration.Includes)
					args.Add ("--vapidir \"" + inc + "\"");

			if (configuration.Libs != null)
				foreach (string lib in configuration.Libs)
					args.Add ("--pkg \"" + lib + "\"");
			
			return string.Join (" ", args.ToArray ());
		}
Example #24
0
        public ValaProject(ProjectCreateInformation info,
                           XmlElement projectOptions, string language)
        {
            Init();
            string binPath = ".";

            if (info != null)
            {
                Name    = info.ProjectName;
                binPath = info.BinPath;
            }

            Compiler = null;

            ValaProjectConfiguration configuration =
                (ValaProjectConfiguration)CreateConfiguration("Debug");

            configuration.DebugMode = true;
            ((ValaCompilationParameters)configuration.CompilationParameters).DefineSymbols = "DEBUG MONODEVELOP";

            Configurations.Add(configuration);

            configuration =
                (ValaProjectConfiguration)CreateConfiguration("Release");

            configuration.DebugMode = false;
            ((ValaCompilationParameters)configuration.CompilationParameters).OptimizationLevel = 3;
            ((ValaCompilationParameters)configuration.CompilationParameters).DefineSymbols     = "MONODEVELOP";
            Configurations.Add(configuration);

            foreach (ValaProjectConfiguration c in Configurations)
            {
                c.OutputDirectory = Path.Combine(binPath, c.Name);
                c.SourceDirectory = info.ProjectBasePath;
                c.Output          = Name;
                ValaCompilationParameters parameters = c.CompilationParameters as ValaCompilationParameters;

                if (projectOptions != null)
                {
                    if (projectOptions.Attributes["Target"] != null)
                    {
                        c.CompileTarget = (ValaBinding.CompileTarget)Enum.Parse(
                            typeof(ValaBinding.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["Packages"].InnerText != null)
                    {
                        List <ProjectPackage> packs = new List <ProjectPackage>();
                        foreach (string pack in projectOptions.Attributes["Packages"].InnerText.Split('|'))
                        {
                            packs.Add(new ProjectPackage(
                                          string.Format("{0}{1}{2}.vapi",
                                                        vapidir,
                                                        Path.DirectorySeparatorChar,
                                                        pack)));
                        }
                        packages.AddRange(packs);
                    }
                }
            }
        }
Example #25
0
		public override SolutionItemConfiguration CreateConfiguration (string name)
		{
			ValaProjectConfiguration conf = new ValaProjectConfiguration ();
			
			conf.Name = name;
			conf.CompilationParameters = new ValaCompilationParameters ();
			
			return conf;
		}
Example #26
0
		/// <summary>
		/// Compile the project
		/// </summary>
		/// <param name="projectFiles">
		/// Collection of project files
		/// <see cref="ProjectFileCollection"/>
		/// </param>
		/// <param name="packages">
		/// Collection of depended packages
		/// <see cref="ProjectPackageCollection"/>
		/// </param>
		/// <param name="configuration">
		/// Project configuration
		/// <see cref="ValaProjectConfiguration"/>
		/// </param>
		/// <param name="monitor">
		/// Progress monitor to be used
		/// <see cref="IProgressMonitor"/>
		/// </param>
		/// <returns>
		/// Result of the compilation
		/// <see cref="ICompilerResult"/>
		/// </returns>
		public BuildResult Compile (
			ProjectFileCollection projectFiles,
			ProjectPackageCollection packages,
			ValaProjectConfiguration configuration,
			IProgressMonitor monitor)
		{
			
			if (!appsChecked) {
				appsChecked = true;
				compilerFound = CheckApp (compilerCommand);
			}/// Check for compiler
				
			
			if (!compilerFound) {
				BuildResult cres = new BuildResult ();
				cres.AddError ("Compiler not found: " + compilerCommand);
				return cres;
			}/// No compiler!
			
			CompilerResults cr = new CompilerResults (new TempFileCollection ());
			bool success = true;
			
			/// Build compiler params string
			string compilerArgs = GetCompilerFlags (configuration) + " " + GeneratePkgCompilerArgs (packages);
			
			/// Build executable name
			string outputName = Path.Combine (configuration.OutputDirectory,
											  configuration.CompiledOutputName);
			
			monitor.BeginTask (GettextCatalog.GetString ("Compiling source"), 1);
			
			success = DoCompilation (projectFiles, compilerArgs, outputName, monitor, cr);

			GenerateDepfile (configuration, packages);

			if (success)
				monitor.Step (1);
			monitor.EndTask ();
			
			return new BuildResult (cr, "");
		}
Example #27
0
        /// <summary>
        /// Generates compilers flags for selected defines
        /// </summary>
        /// <param name="configuration">
        /// Project configuration
        /// <see cref="ValaProjectConfiguration"/>
        /// </param>
        /// <returns>
        /// A compiler-interpretable string
        /// <see cref="System.String"/>
        /// </returns>
        public string GetDefineFlags(ValaProjectConfiguration configuration)
        {
            string defines = ((ValaCompilationParameters)configuration.CompilationParameters).DefineSymbols;

            return(ProcessDefineSymbols(defines));
        }
Example #28
0
		string ICompiler.GetCompilerFlags (ValaProjectConfiguration configuration)
		{
			return ValaCompiler.GetCompilerFlags (configuration);
		}
Example #29
0
 string ICompiler.GetCompilerFlags(ValaProjectConfiguration configuration)
 {
     return(ValaCompiler.GetCompilerFlags(configuration));
 }
Example #30
0
        /// <summary>
        /// Generates compiler args for the current settings
        /// </summary>
        /// <param name="configuration">
        /// Project configuration
        /// <see cref="ValaProjectConfiguration"/>
        /// </param>
        /// <returns>
        /// A compiler-interpretable string
        /// <see cref="System.String"/>
        /// </returns>
        public static string GetCompilerFlags(ValaProjectConfiguration configuration)
        {
            List <string> args = new List <string> ();


            ValaCompilationParameters cp =
                (ValaCompilationParameters)configuration.CompilationParameters;

            args.Add(string.Format("-d '{0}'", configuration.OutputDirectory));

            if (configuration.DebugMode)
            {
                args.Add("-g");
            }

            switch (configuration.CompileTarget)
            {
            case ValaBinding.CompileTarget.Bin:
                if (cp.EnableMultithreading)
                {
                    args.Add("--thread");
                }
                break;

            case ValaBinding.CompileTarget.SharedLibrary:
                args.Add(string.Format("--Xcc=\"-shared\" --Xcc=\"-fPIC\" --Xcc=\"-I'{0}'\" -H \"{1}.h\" --library \"{1}\"", configuration.OutputDirectory, configuration.Output));
                break;
            }

// Valac will get these sooner or later
//			switch (cp.WarningLevel)
//			{
//			case WarningLevel.None:
//				args.Append ("-w ");
//				break;
//			case WarningLevel.Normal:
//				// nothing
//				break;
//			case WarningLevel.All:
//				args.Append ("-Wall ");
//				break;
//			}
//
//			if (cp.WarningsAsErrors)
//				args.Append ("-Werror ");
//
            if (0 < cp.OptimizationLevel)
            {
                args.Add("--Xcc=\"-O" + cp.OptimizationLevel + "\"");
            }

            if (cp.ExtraCompilerArguments != null && cp.ExtraCompilerArguments.Length > 0)
            {
                args.Add(ExpandBacktickedParameters(cp.ExtraCompilerArguments.Replace(Environment.NewLine, " ")));
            }

            if (cp.DefineSymbols != null && cp.DefineSymbols.Length > 0)
            {
                args.Add(ProcessDefineSymbols(cp.DefineSymbols));
            }

            if (configuration.Includes != null)
            {
                foreach (string inc in configuration.Includes)
                {
                    args.Add("--vapidir \"" + inc + "\"");
                }
            }

            if (configuration.Libs != null)
            {
                foreach (string lib in configuration.Libs)
                {
                    args.Add("--pkg \"" + lib + "\"");
                }
            }

            return(string.Join(" ", args.ToArray()));
        }
Example #31
0
		ExecutionCommand CreateExecutionCommand (ValaProjectConfiguration conf)
		{
			NativeExecutionCommand cmd = new NativeExecutionCommand ();
			cmd.Command = Path.Combine (conf.OutputDirectory, conf.Output);
			cmd.Arguments = conf.CommandLineParameters;
			cmd.WorkingDirectory = Path.GetFullPath (conf.OutputDirectory);
			return cmd;
		}
Example #32
0
		public void GenerateDepfile (ValaProjectConfiguration configuration, ProjectPackageCollection packages)
		{
			try {
				if (configuration.CompileTarget != CompileTarget.SharedLibrary){ return; }
				
				using (StreamWriter writer = new StreamWriter (Path.Combine (configuration.OutputDirectory, Path.ChangeExtension (configuration.Output, ".deps")))) {
					foreach (ProjectPackage package in packages) {
						writer.WriteLine (package.Name);
					}
				}
			} catch { /* Don't care */ }
		}
Example #33
0
		/// <summary>
		/// Generates compilers flags for selected defines
		/// </summary>
		/// <param name="configuration">
		/// Project configuration
		/// <see cref="ValaProjectConfiguration"/>
		/// </param>
		/// <returns>
		/// A compiler-interpretable string
		/// <see cref="System.String"/>
		/// </returns>
		public string GetDefineFlags (ValaProjectConfiguration configuration)
		{
			string defines = ((ValaCompilationParameters)configuration.CompilationParameters).DefineSymbols;
			return ProcessDefineSymbols (defines);
		}
Example #34
0
        public override FilePath GetOutputFileName(ConfigurationSelector configuration)
        {
            ValaProjectConfiguration conf = (ValaProjectConfiguration)GetConfiguration(configuration);

            return(conf.OutputDirectory.Combine(conf.CompiledOutputName));
        }
Example #35
0
		/// <summary>
		/// Cleans up intermediate files
		/// </summary>
		/// <param name="projectFiles">
		/// The project's files
		/// <see cref="ProjectFileCollection"/>
		/// </param>
		/// <param name="configuration">
		/// Project configuration
		/// <see cref="ValaProjectConfiguration"/>
		/// </param>
		/// <param name="monitor">
		/// The progress monitor to be used
		/// <see cref="IProgressMonitor"/>
		/// </param>
		public void Clean (ProjectFileCollection projectFiles, ValaProjectConfiguration configuration, IProgressMonitor monitor)
		{
			/// Clean up intermediate files
			/// These should only be generated for libraries, but we'll check for them in all cases
			foreach (ProjectFile file in projectFiles) {
				if (file.BuildAction == BuildAction.Compile) {
					string cFile = Path.Combine (configuration.OutputDirectory, Path.GetFileNameWithoutExtension (file.Name) + ".c");
					if (File.Exists (cFile)){ File.Delete (cFile); }
						
					string hFile = Path.Combine (configuration.OutputDirectory, Path.GetFileNameWithoutExtension (file.Name) + ".h");
					if (File.Exists (hFile)){ File.Delete (hFile); }
				}
			}
			
			string vapiFile = Path.Combine (configuration.OutputDirectory, configuration.Output + ".vapi");
			if (File.Exists (vapiFile)){ File.Delete (vapiFile); }
		}