/// <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
Beispiel #2
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);
            }
        }
		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);
		}
Beispiel #4
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()));
        }
        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);
                    }
                }
            }
        }