Ejemplo n.º 1
0
        /// <summary>
        /// Routine which checks if the resource compiler is present.
        /// </summary>
        /// <returns>
        /// <see langword="true" /> if the resource compiler is present;
        /// otherwise, <see langword="false" />.
        /// </returns>
        private static bool CheckResourceCompilerPresent()
        {
            PathScanner scanner = new PathScanner();

            scanner.Add("rc.exe");
            return(scanner.Scan("PATH").Count > 0);
        }
Ejemplo n.º 2
0
        private static StringCollection GetCompilersOnPath()
        {
            PathScanner scanner = new PathScanner();

            scanner.Add("cl.exe");
            return(scanner.Scan("PATH"));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Routine which checks if the header files are present.
 /// </summary>
 /// <returns>
 /// <see langword="true" /> if the header files are present; otherwise,
 /// <see langword="false" />.
 /// </returns>
 private static bool CheckHeaderFilesPresent()
 {
     foreach (string headerFile in ExpectedHeaderFiles)
     {
         PathScanner scanner = new PathScanner();
         scanner.Add(headerFile);
         if (scanner.Scan("INCLUDE").Count == 0)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Routine which checks if the libs are present.
 /// </summary>
 /// <returns>
 /// <see langword="true" /> if the libs are present; otherwise,
 /// <see langword="false" />.
 /// </returns>
 private static bool CheckLibsPresent()
 {
     foreach (string lib in ExpectedLibs)
     {
         PathScanner scanner = new PathScanner();
         scanner.Add(lib);
         if (scanner.Scan("LIB").Count == 0)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 5
0
        protected string MKSExecute(string command)
        {
            // locate Source Integrity client on PATH
            PathScanner pathScanner = new PathScanner();

            pathScanner.Add("si.exe");
            StringCollection files = pathScanner.Scan();

            if (files.Count == 0)
            {
                throw new BuildException("Could not find MKS Integrity Client on the system path.",
                                         Location);
            }

            // set up process
            Process proc = new Process();

            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.CreateNoWindow         = true;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.RedirectStandardError  = true;
            proc.StartInfo.FileName  = files[0];
            proc.StartInfo.Arguments = command;
            proc.Start();
            proc.WaitForExit();

            if (proc.ExitCode != 0)
            {
                throw new BuildException(proc.ExitCode.ToString(), Location,
                                         new Exception(proc.StandardError.ReadToEnd()));
            }
            else
            {
                return(proc.StandardOutput.ReadToEnd());
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Determines whether any file that are includes in the specified
        /// source file has been updated after the obj was compiled.
        /// </summary>
        /// <param name="srcFileName">The source file to check.</param>
        /// <param name="objLastWriteTime">The last write time of the compiled obj.</param>
        /// <returns>
        /// The full path to the include file that was modified after the obj
        /// was compiled, or <see langword="null" /> if no include files were
        /// modified since the obj was compiled.
        /// </returns>
        /// <remarks>
        ///   <para>
        ///   To determine what includes are defined in a source file, conditional
        ///   directives are not honored.
        ///   </para>
        ///   <para>
        ///   If a given include cannot be resolved to an existing file, then
        ///   it will be considered stable.
        ///   </para>
        /// </remarks>
        private string FindUpdatedInclude(string srcFileName, DateTime objLastWriteTime) {
            // quick and dirty code to check whether includes have been modified
            // after the source was last modified

            // TODO: recursively check includes

            Log(Level.Debug, "Checking whether includes of \"{0}\" have been"
                + " updated.", srcFileName);

            // holds the line we're parsing
            string line;

            // locate include directives in source file
            using (StreamReader sr = new StreamReader(srcFileName, true)) {
                while ((line = sr.ReadLine()) != null) {
                    Match match = _includeRegex.Match(line);
                    if (match.Groups.Count != 2) {
                        continue;
                    }

                    string includeFile = match.Groups["includefile"].Value;

                    Log(Level.Debug, "Checking include \"{0}\"...", includeFile);

                    string resolvedInclude = _resolvedIncludes[includeFile] as string;
                    if (resolvedInclude == null) {
                        foreach (string includeDir in IncludeDirs.DirectoryNames) {
                            string foundIncludeFile = FileUtils.CombinePaths(includeDir, includeFile);
                            if (File.Exists(foundIncludeFile)) {
                                Log(Level.Debug, "Found include \"{0}\" in"
                                    + " includedirs.", includeFile);
                                resolvedInclude = foundIncludeFile;
                                break;
                            }
                        }

                        // if we could not locate include in include dirs and
                        // source dir, then try to locate include in INCLUDE 
                        // env var
                        if (resolvedInclude == null) {
                            PathScanner pathScanner = new PathScanner();
                            pathScanner.Add(includeFile);
                            StringCollection includes = pathScanner.Scan("INCLUDE");
                            if (includes.Count > 0) {
                                Log(Level.Debug, "Found include \"{0}\" in"
                                    + " INCLUDE.", includeFile);
                                resolvedInclude = includes[0];
                            }
                        }

                        // if we could not locate include in include dirs
                        // and INCLUDE env var then check for include in base
                        // directory (which is used as working dir)
                        if (resolvedInclude == null) {
                            string foundIncludeFile = FileUtils.CombinePaths(
                                BaseDirectory.FullName, includeFile);
                            if (File.Exists(foundIncludeFile)) {
                                Log(Level.Debug, "Found include \"{0}\" in"
                                    + " working directory.", includeFile);
                                resolvedInclude = foundIncludeFile;
                            }
                        }

                        if (resolvedInclude != null) {
                            _resolvedIncludes.Add(includeFile, resolvedInclude);
                        }
                    }

                    if (resolvedInclude != null) {
                        if (File.GetLastWriteTime(resolvedInclude) > objLastWriteTime) {
                            return resolvedInclude;
                        }
                    } else {
                        // TODO: what do we do if the include cannot be located ?
                        //
                        // for now we'll consider the obj file to be up-to-date
                        Log(Level.Debug, "Include \"{0}\" could not be located.", 
                            includeFile);
                    }
                }
            }

            return null;
        }