예제 #1
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 */ }
        }
예제 #2
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, ""));
        }
예제 #3
0
        /// <summary>
        /// Generates compiler args for depended packages
        /// </summary>
        /// <param name="packages">
        /// The collection of packages for this project
        /// <see cref="ProjectPackageCollection"/>
        /// </param>
        /// <returns>
        /// The string needed by the compiler to reference the necessary packages
        /// <see cref="System.String"/>
        /// </returns>
        public static string GeneratePkgCompilerArgs(ProjectPackageCollection packages)
        {
            if (packages == null || packages.Count < 1)
            {
                return(string.Empty);
            }

            StringBuilder libs = new StringBuilder();

            foreach (ProjectPackage p in packages)
            {
                if (p.IsProject)
                {
                    libs.AppendFormat(" \"{0}\" ", p.File);
                }
                else
                {
                    libs.AppendFormat(" --pkg \"{0}\" ", p.Name);
                }
            }

            return(libs.ToString());
        }