コード例 #1
0
        public override IVerbWorker getWorker()
        {
            if (false)
            {
#pragma warning disable 162
                File.WriteAllText(getOutputFile().getFilesystemPath(), "Verification disabled temporarily for debugging");
                return new VerbSyncWorker(new Fresh());
#pragma warning restore 162
            }

            SourcePath boogieExecutable = new SourcePath("tools/Dafny/Boogie.exe", SourcePath.SourceType.sourceTypeTools);

            List<string> args = new List<string>();
            args.Add("/noinfer");
            args.Add("/typeEncoding:m");
            args.Add("/z3opt:ARITH_RANDOM_SEED=1");
            args.Add("/timeLimit:"+timeLimit);
            args.AddRange(getFlags());
            args.Add(bplInput.getRelativePath());

            return new ProcessInvokeAsyncWorker(this,
                    boogieExecutable.getRelativePath(),
                    args.ToArray(),
                    ProcessInvoker.RcHandling.NONZERO_RC_IS_OKAY,
                    getDiagnosticsBase());
        }
コード例 #2
0
        public override IVerbWorker getWorker(WorkingDirectory workingDirectory)
        {
            if (false)
            {
#pragma warning disable 162
                File.WriteAllText(workingDirectory.PathTo(getOutputFile()), "Verification disabled temporarily for debugging");
                return(new VerbSyncWorker(workingDirectory, new Fresh()));

#pragma warning restore 162
            }

            List <string> args = new List <string>();
            args.Add("/noinfer");
            args.Add("/typeEncoding:m");
            args.Add("/z3opt:ARITH_RANDOM_SEED=1");
            args.Add("/timeLimit:" + timeLimit);
            args.AddRange(getFlags());
            args.Add(bplInput.getRelativePath());

            return(new ProcessInvokeAsyncWorker(
                       workingDirectory,
                       this,
                       getBoogieExecutable().getRelativePath(),
                       args.ToArray(),
                       ProcessExitCodeHandling.NonzeroIsOkay,
                       getDiagnosticsBase(),
                       allowCloudExecution: true,
                       returnStandardOut: true,
                       returnStandardError: true));
        }
コード例 #3
0
ファイル: BeatVerb.cs プロジェクト: Paul1nh0/Singularity
        public override IVerbWorker getWorker()
        {
            //-        "beat $BUILD_DEFS -out $out.tmp -in $in $incls"
            List <string> args = new List <string>();

            args.Add("-in");
            args.Add(beatobj.getRelativePath());

            IEnumerable <BuildObject> beatImports =
                BeatExtensions.getBeatFlavoredShallowIncludes(contextVerb, beatobj, BeatIncludes.ImportFilter.ForBeatOrBasm);

            foreach (BuildObject ifcObj in beatImports.Where(obj => !obj.Equals(beatobj)))
            {
                Util.Assert(!ifcObj.getRelativePath().Contains(".imp"));   //- Erk, don't feed imp files as includes!
                args.Add("-i");
                args.Add(ifcObj.getRelativePath());
            }
            args.AddRange(contextVerb.getPoundDefines().ToDefArgs());

            string dbgText = String.Format("rem verb {0}{1}",
                                           this, System.Environment.NewLine);

            return(new ProcessInvokeAsyncWorker(this,
                                                getBeatExecutable().getRelativePath(),
                                                args.ToArray(),
                                                ProcessInvoker.RcHandling.NONZERO_RC_IS_FAILURE,
                                                finalStdoutPath: outputFile().getFilesystemPath(),
                                                failureBase: getDiagnosticsBase(),
                                                dbgText: dbgText));
        }
コード例 #4
0
ファイル: ResultCache.cs プロジェクト: Paul1nh0/Singularity
 //- Fetch an object from the cache and store it in the local
 //- nuobj tree.
 //-
 //- NB BuildObjectValuePointers get stored in untrusted places, so we never
 //- actually use their RelativePath values in filesystem calls.
 //- Instead, we require the caller to supply a local BuildObject where
 //- he expects the ptr to point, and we test for equality, and then
 //- use the obj value for filesystem operations.
 void fetchObject(BuildObjectValuePointer ptr, BuildObject obj)
 {
     //-Console.WriteLine("ResultCache.fetchObject " + obj);
     Util.Assert(obj.getRelativePath().Equals(ptr.relativePath));
     File.Delete(obj.getFilesystemPath());
     this.itemCache.FetchItemToFile(ItemCacheContainer.Objects, ptr.objectHash, obj.getFilesystemPath());
     this.knownObjectHash[obj] = ptr.objectHash;
 }
コード例 #5
0
ファイル: ResultCache.cs プロジェクト: Paul1nh0/Singularity
        //- Read an output object from the nuobj tree and store it in the cache.
        public BuildObjectValuePointer storeObject(BuildObject obj)
        {
            string contentHash = hasher.hash(obj.getFilesystemPath());

            this.itemCache.StoreItemFromFile(ItemCacheContainer.Objects, contentHash, obj.getFilesystemPath());
            this.knownObjectHash[obj] = contentHash;

            return(new BuildObjectValuePointer(contentHash, obj.getRelativePath()));
        }
コード例 #6
0
        protected override List <string> getArgs()
        {
            List <string> args = new List <string>();

            args.Add("-merge");
            args.Add(mutualSummary.getRelativePath());
            args.Add(combiner.getOutputFile().getRelativePath());
            return(args);
        }
コード例 #7
0
        protected override List <string> getArgs()
        {
            List <string> args = new List <string>();

            args.Add("-config");
            args.Add(mutualSummary.getRelativePath());
            args.Add(inferredConfig.getRelativePath());
            return(args);
        }
コード例 #8
0
        /// <summary>
        /// Reads a build object from the local filesystem and stores it in the
        /// cache.
        /// </summary>
        /// <param name="workingDirectory">
        /// Private directory for verb execution.
        /// </param>
        /// <param name="obj">The build object to store in the cache.</param>
        /// <param name="disposition">
        /// Disposition of verb which created this object (if known).
        /// </param>
        /// <returns>A BuildObjectValuePointer describing the object.</returns>
        public BuildObjectValuePointer Store(WorkingDirectory workingDirectory, BuildObject obj, Disposition disposition)
        {
            string contentHash = Util.hashFilesystemPath(workingDirectory.PathTo(obj));

            this.itemCache.StoreItemFromFile(ItemCacheContainer.Objects, contentHash, workingDirectory.PathTo(obj));
            this.Add(obj, disposition, contentHash, null);

            return(new BuildObjectValuePointer(contentHash, obj.getRelativePath()));
        }
コード例 #9
0
        protected override List <string> getArgs()
        {
            List <string> args = new List <string>();

            args.Add("-extractLoops");
            args.Add(basmIn.getRelativePath());
            args.Add(getOutputFile().getRelativePath());

            return(args);
        }
コード例 #10
0
        public override IVerbWorker getWorker()
        {
            List <string> args = new List <string>()
            {
                "/LARGEADDRESSAWARE", "/driver", "/fixed", "/subsystem:native", "/nodefaultlib"
            };

            args.Add(objFile.getRelativePath());
            args.Add("/out:" + outputObject.getRelativePath());
            args.Add("/entry:" + entryPoint);
            args.Add("/base:" + baseAddr);

            return(new ProcessInvokeAsyncWorker(this,
                                                getLinkerExe().getRelativePath(), args.ToArray(), ProcessInvoker.RcHandling.NONZERO_RC_IS_FAILURE, getDiagnosticsBase()));
        }
コード例 #11
0
        public override IVerbWorker getWorker()
        {
            List <string> args = new List <string>()
            {
                pythonScript.getRelativePath(), asmFileIn.getRelativePath()
            };
            string python_exe = @"C:\Python27\pythonw.exe";

            if (!File.Exists(python_exe))
            {
                throw new FileNotFoundException("Missing python executable: " + python_exe + ".  Try installing from: https://-www.python.org/");
            }

            return(new ProcessInvokeAsyncWorker(this,
                                                python_exe, args.ToArray(), ProcessInvoker.RcHandling.NONZERO_RC_IS_FAILURE, getDiagnosticsBase(), allowAbsoluteExe: true));
        }
コード例 #12
0
ファイル: MasmVerb.cs プロジェクト: Paul1nh0/Singularity
        public override IVerbWorker getWorker()
        {
            List <string> args = new List <string>()
            {
                "/Cp", "/c", "/Zd", "/Zf", "/Zi"
            };

            args.Add("/Fo" + getObj().getRelativePath());
            args.Add("/Fl" + getLis().getRelativePath());
            //-args.Add("/Fm" + getMap().getRelativePath());
            //- TODO: "/I$SPEC_INCLUDE_DIR"
            args.Add(asmFile.getRelativePath());

            return(new ProcessInvokeAsyncWorker(this,
                                                getMasmExe().getRelativePath(), args.ToArray(), ProcessInvoker.RcHandling.NONZERO_RC_IS_FAILURE, getDiagnosticsBase()));
        }
コード例 #13
0
        //- Look for 0 or 1 instance of a single-valued annotation.
        public string getTheAnnotation(string label, string defaultValue)
        {
            IEnumerable <string[]> anns = getAnnotations(label);

            if (anns.Count() == 0)
            {
                return(defaultValue);
            }
            string[] ann = anns.First();
            if (ann.Length != 2)
            {
                throw new SourceConfigurationError(
                          String.Format("Annotation {0} in file {1} should have exactly one argument",
                                        ann[0], inputObject.getRelativePath()));
            }
            return(ann[1]);
        }
コード例 #14
0
 /// <summary>
 /// Gets the absolute path to the given build object under IronRoot.
 /// </summary>
 /// <param name="obj">A build object.</param>
 /// <returns>The absolute path to the build object.</returns>
 public static string PathTo(BuildObject obj)
 {
     return Path.Combine(BuildEngine.theEngine.getIronRoot(), obj.getRelativePath());
 }
コード例 #15
0
 /// <summary>
 /// Gets the absolute path to the given build object in this working directory.
 /// </summary>
 /// <param name="obj">A build object.</param>
 /// <returns>The absolute path to the build object.</returns>
 public string PathTo(BuildObject obj)
 {
     return Path.Combine(this.path, obj.getRelativePath());
 }
コード例 #16
0
 public override AbstractId getAbstractIdentifier()
 {
     return(new AbstractId(this.GetType().Name, version, obj.getRelativePath()));
 }
コード例 #17
0
 /// <summary>
 /// Gets the absolute path to the given build object under IronRoot.
 /// </summary>
 /// <param name="obj">A build object.</param>
 /// <returns>The absolute path to the build object.</returns>
 public static string PathTo(BuildObject obj)
 {
     return(Path.Combine(BuildEngine.theEngine.getIronRoot(), obj.getRelativePath()));
 }
コード例 #18
0
ファイル: Repository.cs プロジェクト: jango2015/Ironclad
        /// <summary>
        /// Gets information about an object in this repository.
        /// Will add missing source objects to the repository as needed.
        /// </summary>
        /// <param name="obj">The object to look up.</param>
        /// <returns>Information about the object.</returns>
        /// <remarks>
        /// Returns null if obj isn't in this run's cache.
        /// Cannot return value.disposition==Stale, I guess?
        /// </remarks>
        private RepositoryEntry GetValue(BuildObject obj)
        {
            if (this.entries.ContainsKey(obj))
            {
                return this.entries[obj];
            }
            else
            {
                SourcePath src = obj as SourcePath;
                if (src != null)
            {
                // Special case to get local source files into the
                // repository (and the item cache).
                // REVIEW: Should we require that source files are explicitly added?
                try
                {
                        // Complain if someone uses tabs or non-CRLF line endings in a source file.
                        // Visual Studio is pretty insistent on using tabs in solution (.sln) files, so we let it.
                        if ((src.Type == SourcePath.SourceType.Src) && (src.getExtension() != ".sln"))
                        {
                            if (!Util.CheckSourceFileForBadCharacters(IronRootDirectory.PathTo(obj)))
                            {
                                throw new SourceConfigurationError("Bad characters (tabs?) or non-CRLF line endings in source file " + obj.getRelativePath());
                            }
                        }

                    string hash = Util.hashFilesystemPath(IronRootDirectory.PathTo(obj));
                    this.itemCache.StoreItemFromFile(ItemCacheContainer.Sources, hash, IronRootDirectory.PathTo(obj));
                    this.Add(obj, new Fresh(), hash, null);
                }
                catch (IOException)
                {
                    throw new SourceConfigurationError("Cannot find source path " + obj.getRelativePath());
                }

                return this.entries[obj];
            }
            else
            {
                return null;
            }
        }
        }
コード例 #19
0
ファイル: Repository.cs プロジェクト: jango2015/Ironclad
 /// <summary>
 /// Add information about an object to the Repository.
 /// The object path must be under the object root.
 /// </summary>
 /// <param name="obj">The object in question.</param>
 /// <param name="disposition">
 /// Disposition of the verb which created this object.
 /// </param>
 /// <param name="hash">Hash of the object's contents.</param>
 public void AddObject(BuildObject obj, Disposition disposition, string hash)
 {
     Util.Assert(obj.getRelativePath().StartsWith(BuildEngine.theEngine.getObjRoot(), StringComparison.Ordinal));
     this.Add(obj, disposition, hash, null);
 }
コード例 #20
0
        /// <summary>
        /// Initializes a new instance of the ProcessInvoker class.
        /// </summary>
        /// <param name="workingDirectory">The working directory the process is started in.</param>
        /// <param name="executable">The executable to run.</param>
        /// <param name="args">The command line arguments to provide to the executable.</param>
        /// <param name="failureBase">Not sure what this is -- some debugging/diagnostic thing.</param>
        /// <param name="captureStdout">Where to (optionally) capture standard out.</param>
        /// <param name="dbgText">Debugging text for something or another.</param>
        /// <param name="allowAbsoluteExe">Whether to allow an absolute (rather than relative) file path to the executable.</param>
        /// <param name="allowAbsoluteArgs">Whether to allow absolute (rather than relative) file paths as arguments.</param>
        /// <param name="workingDirOverride">The working directory to use.</param>
        public ProcessInvoker(
            WorkingDirectory workingDirectory,
            string executable,
            string[] args,
            BuildObject failureBase,
            BuildObject captureStdout = null,
            string dbgText            = null,
            bool allowAbsoluteExe     = false,
            bool allowAbsoluteArgs    = false,
            string workingDirOverride = null)
        {
            // Catch bad verb authors before they hurt themselves.
            Util.Assert(allowAbsoluteExe || !executable.Contains(":"));  // Hey, this looks like an absolute path! Use .getRelativePath(); it makes your output more stable.
            foreach (string arg in args)
            {
                // Pardon my distasteful heuristic to avoid flagging /flag:value args.
                Util.Assert(allowAbsoluteArgs || arg.Length < 2 || arg[1] != ':');  // Hey, this looks like an absolute path! Use .getRelativePath() to tolerate crossing machine boundaries.
            }

            this.workingDirectory = workingDirectory;
            this.stdout           = new StringBuilder();
            this.stderr           = new StringBuilder();

            using (Job job = new Job())
            {
                using (Process proc = new Process())
                {
                    if (allowAbsoluteExe)
                    {
                        proc.StartInfo.FileName = executable;
                    }
                    else
                    {
                        // TODO: *All* async verbs need to list their executable (and all the libs it depends upon) as dependencies.
                        proc.StartInfo.FileName = workingDirectory.PathTo(executable);
                    }

                    // TODO Is there a better way to escape the args to avoid problems with spaces?
                    proc.StartInfo.Arguments              = string.Join(" ", args);
                    proc.StartInfo.WorkingDirectory       = workingDirOverride == null ? workingDirectory.Root : workingDirOverride;
                    proc.StartInfo.RedirectStandardOutput = true;

                    // REVIEW: Maybe we should always capture stdout in a StringBuilder and just write it out to a file afterwards if requested?
                    if (captureStdout != null)
                    {
                        this.tmpStdout           = new BuildObject(captureStdout.getRelativePath() + ".tmp");
                        this.stdoutFile          = new StreamWriter(workingDirectory.PathTo(this.tmpStdout));
                        proc.OutputDataReceived += new DataReceivedEventHandler(this.StdoutRedirectHandler);
                    }
                    else
                    {
                        // Collect stdout here for diagnostics.
                        proc.OutputDataReceived += new DataReceivedEventHandler(this.StdoutHandler);
                    }

                    proc.StartInfo.RedirectStandardError = true;
                    proc.ErrorDataReceived        += new DataReceivedEventHandler(this.StderrHandler);
                    proc.StartInfo.UseShellExecute = false;

                    string commandLine = proc.StartInfo.FileName + " " + proc.StartInfo.Arguments;
                    if (failureBase != null && AlwaysEmitDiagnostics)
                    {
                        // In diagnostic mode, we emit the command line twice, once ahead in case Boogie decides
                        // to run away and never come back.
                        BuildObject failureBatObj = failureBase.makeOutputObject(".bat");
                        workingDirectory.CreateDirectoryFor(failureBatObj);
                        File.WriteAllText(workingDirectory.PathTo(failureBatObj), commandLine);
                    }

                    proc.Start();
                    job.AddProcess(proc);
                    proc.BeginOutputReadLine();
                    proc.BeginErrorReadLine();
                    proc.WaitForExit();

                    this.cpuTime = job.GetCpuTime().TotalSeconds;

                    this.exitCode = proc.ExitCode;
                    if (this.stdoutFile != null)
                    {
                        this.stdoutFile.Close();
                    }

                    if (failureBase != null && AlwaysEmitDiagnostics)
                    {
                        workingDirectory.CreateDirectoryFor(failureBase);
                        File.WriteAllText(workingDirectory.PathTo(failureBase.makeOutputObject(".bat")), commandLine);
                        File.WriteAllText(workingDirectory.PathTo(failureBase.makeOutputObject(".txt")), dbgText);
                        File.WriteAllText(workingDirectory.PathTo(failureBase.makeOutputObject(".stdout")), this.GetStdoutString());
                        File.WriteAllText(workingDirectory.PathTo(failureBase.makeOutputObject(".stderr")), this.GetStderr());
                    }
                }
            }

            // REVIEW: Add Delete, Exists and Move methods to WorkingDirectory class?
            if (this.tmpStdout != null && File.Exists(workingDirectory.PathTo(this.tmpStdout)))
            {
                // REVIEW: Nothing should be here.  Bother with the delete?
                File.Delete(workingDirectory.PathTo(captureStdout));
                File.Move(workingDirectory.PathTo(this.tmpStdout), workingDirectory.PathTo(captureStdout));
                this.tmpStdout = null;
            }
        }
コード例 #21
0
ファイル: Repository.cs プロジェクト: jango2015/Ironclad
        /// <summary>
        /// Reads a build object from the local filesystem and stores it in the
        /// cache.
        /// </summary>
        /// <param name="workingDirectory">
        /// Private directory for verb execution.
        /// </param>
        /// <param name="obj">The build object to store in the cache.</param>
        /// <param name="disposition">
        /// Disposition of verb which created this object (if known).
        /// </param>
        /// <returns>A BuildObjectValuePointer describing the object.</returns>
        public BuildObjectValuePointer Store(WorkingDirectory workingDirectory, BuildObject obj, Disposition disposition)
        {
            string contentHash = Util.hashFilesystemPath(workingDirectory.PathTo(obj));
            this.itemCache.StoreItemFromFile(ItemCacheContainer.Objects, contentHash, workingDirectory.PathTo(obj));
            this.Add(obj, disposition, contentHash, null);

            return new BuildObjectValuePointer(contentHash, obj.getRelativePath());
        }
コード例 #22
0
ファイル: ProcessInvoker.cs プロジェクト: jango2015/Ironclad
        /// <summary>
        /// Initializes a new instance of the ProcessInvoker class.
        /// </summary>
        /// <param name="workingDirectory">The working directory the process is started in.</param>
        /// <param name="executable">The executable to run.</param>
        /// <param name="args">The command line arguments to provide to the executable.</param>
        /// <param name="failureBase">Not sure what this is -- some debugging/diagnostic thing.</param>
        /// <param name="captureStdout">Where to (optionally) capture standard out.</param>
        /// <param name="dbgText">Debugging text for something or another.</param>
        /// <param name="allowAbsoluteExe">Whether to allow an absolute (rather than relative) file path to the executable.</param>
        /// <param name="allowAbsoluteArgs">Whether to allow absolute (rather than relative) file paths as arguments.</param>
        /// <param name="workingDirOverride">The working directory to use.</param>
        public ProcessInvoker(
            WorkingDirectory workingDirectory,
            string executable,
            string[] args,
            BuildObject failureBase,
            BuildObject captureStdout = null,
            string dbgText = null,
            bool allowAbsoluteExe = false,
            bool allowAbsoluteArgs = false,
            string workingDirOverride = null)
        {
            // Catch bad verb authors before they hurt themselves.
            Util.Assert(allowAbsoluteExe || !executable.Contains(":"));  // Hey, this looks like an absolute path! Use .getRelativePath(); it makes your output more stable.
            foreach (string arg in args)
            {
                // Pardon my distasteful heuristic to avoid flagging /flag:value args.
                Util.Assert(allowAbsoluteArgs || arg.Length < 2 || arg[1] != ':');  // Hey, this looks like an absolute path! Use .getRelativePath() to tolerate crossing machine boundaries.
            }

            this.workingDirectory = workingDirectory;
            this.stdout = new StringBuilder();
            this.stderr = new StringBuilder();

            using (Job job = new Job())
            {
                using (Process proc = new Process())
                {
                    if (allowAbsoluteExe)
                    {
                        proc.StartInfo.FileName = executable;
                    }
                    else
                    {
                        // TODO: *All* async verbs need to list their executable (and all the libs it depends upon) as dependencies.
                        proc.StartInfo.FileName = workingDirectory.PathTo(executable);
                    }

                    // TODO Is there a better way to escape the args to avoid problems with spaces?
                    proc.StartInfo.Arguments = string.Join(" ", args);
                    proc.StartInfo.WorkingDirectory = workingDirOverride == null ? workingDirectory.Root : workingDirOverride;
                    proc.StartInfo.RedirectStandardOutput = true;

                    // REVIEW: Maybe we should always capture stdout in a StringBuilder and just write it out to a file afterwards if requested?
                    if (captureStdout != null)
                    {
                        this.tmpStdout = new BuildObject(captureStdout.getRelativePath() + ".tmp");
                        this.stdoutFile = new StreamWriter(workingDirectory.PathTo(this.tmpStdout));
                        proc.OutputDataReceived += new DataReceivedEventHandler(this.StdoutRedirectHandler);
                    }
                    else
                    {
                        // Collect stdout here for diagnostics.
                        proc.OutputDataReceived += new DataReceivedEventHandler(this.StdoutHandler);
                    }

                    proc.StartInfo.RedirectStandardError = true;
                    proc.ErrorDataReceived += new DataReceivedEventHandler(this.StderrHandler);
                    proc.StartInfo.UseShellExecute = false;

                    string commandLine = proc.StartInfo.FileName + " " + proc.StartInfo.Arguments;
                    if (failureBase != null && AlwaysEmitDiagnostics)
                    {
                        // In diagnostic mode, we emit the command line twice, once ahead in case Boogie decides
                        // to run away and never come back.
                        BuildObject failureBatObj = failureBase.makeOutputObject(".bat");
                        workingDirectory.CreateDirectoryFor(failureBatObj);
                        File.WriteAllText(workingDirectory.PathTo(failureBatObj), commandLine);
                    }

                    proc.Start();
                    job.AddProcess(proc);
                    proc.BeginOutputReadLine();
                    proc.BeginErrorReadLine();
                    proc.WaitForExit();

                    this.cpuTime = job.GetCpuTime().TotalSeconds;

                    this.exitCode = proc.ExitCode;
                    if (this.stdoutFile != null)
                    {
                        this.stdoutFile.Close();
                    }

                    if (failureBase != null && AlwaysEmitDiagnostics)
                    {
                        workingDirectory.CreateDirectoryFor(failureBase);
                        File.WriteAllText(workingDirectory.PathTo(failureBase.makeOutputObject(".bat")), commandLine);
                        File.WriteAllText(workingDirectory.PathTo(failureBase.makeOutputObject(".txt")), dbgText);
                        File.WriteAllText(workingDirectory.PathTo(failureBase.makeOutputObject(".stdout")), this.GetStdoutString());
                        File.WriteAllText(workingDirectory.PathTo(failureBase.makeOutputObject(".stderr")), this.GetStderr());
                    }
                }
            }

            // REVIEW: Add Delete, Exists and Move methods to WorkingDirectory class?
            if (this.tmpStdout != null && File.Exists(workingDirectory.PathTo(this.tmpStdout)))
            {
                // REVIEW: Nothing should be here.  Bother with the delete?
                File.Delete(workingDirectory.PathTo(captureStdout));
                File.Move(workingDirectory.PathTo(this.tmpStdout), workingDirectory.PathTo(captureStdout));
                this.tmpStdout = null;
            }
        }
コード例 #23
0
ファイル: NuObjContents.cs プロジェクト: Paul1nh0/Singularity
 public void bless(BuildObject obj, string hashIfKnown, Disposition disp)
 {
     Util.Assert(obj.getRelativePath().StartsWith(BuildEngine.theEngine.getObjRoot()));
     blessInternal(obj, hashIfKnown, disp, null);
 }
コード例 #24
0
        /// <summary>
        /// Gets information about an object in this repository.
        /// Will add missing source objects to the repository as needed.
        /// </summary>
        /// <param name="obj">The object to look up.</param>
        /// <returns>Information about the object.</returns>
        /// <remarks>
        /// Returns null if obj isn't in this run's cache.
        /// Cannot return value.disposition==Stale, I guess?
        /// </remarks>
        private RepositoryEntry GetValue(BuildObject obj)
        {
            if (this.entries.ContainsKey(obj))
            {
                return(this.entries[obj]);
            }
            else
            {
                SourcePath src = obj as SourcePath;
                if (src != null)
                {
                    // Special case to get local source files into the
                    // repository (and the item cache).
                    // REVIEW: Should we require that source files are explicitly added?
                    try
                    {
                        // Complain if someone uses tabs or non-CRLF line endings in a source file.
                        // Visual Studio is pretty insistent on using tabs in solution (.sln) files, so we let it.
                        if ((src.Type == SourcePath.SourceType.Src) && (src.getExtension() != ".sln"))
                        {
                            if (!Util.CheckSourceFileForBadCharacters(IronRootDirectory.PathTo(obj)))
                            {
                                throw new SourceConfigurationError("Bad characters (tabs?) or non-CRLF line endings in source file " + obj.getRelativePath());
                            }
                        }

                        string hash = Util.hashFilesystemPath(IronRootDirectory.PathTo(obj));
                        this.itemCache.StoreItemFromFile(ItemCacheContainer.Sources, hash, IronRootDirectory.PathTo(obj));
                        this.Add(obj, new Fresh(), hash, null);
                    }
                    catch (IOException)
                    {
                        throw new SourceConfigurationError("Cannot find source path " + obj.getRelativePath());
                    }

                    return(this.entries[obj]);
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #25
0
 /// <summary>
 /// Add information about an object to the Repository.
 /// The object path must be under the object root.
 /// </summary>
 /// <param name="obj">The object in question.</param>
 /// <param name="disposition">
 /// Disposition of the verb which created this object.
 /// </param>
 /// <param name="hash">Hash of the object's contents.</param>
 public void AddObject(BuildObject obj, Disposition disposition, string hash)
 {
     Util.Assert(obj.getRelativePath().StartsWith(BuildEngine.theEngine.getObjRoot(), StringComparison.Ordinal));
     this.Add(obj, disposition, hash, null);
 }
コード例 #26
0
 /// <summary>
 /// Gets the absolute path to the given build object in this working directory.
 /// </summary>
 /// <param name="obj">A build object.</param>
 /// <returns>The absolute path to the build object.</returns>
 public string PathTo(BuildObject obj)
 {
     return(Path.Combine(this.path, obj.getRelativePath()));
 }