Пример #1
0
        /// <summary>
        /// Initializes a new instance of the ProcessInvokeAsyncWorker class.
        /// </summary>
        /// <param name="workingDirectory">The private working directory for this worker to work in.</param>
        /// <param name="verb">The verb whose worker this is.</param>
        /// <param name="executable">The executable to run.</param>
        /// <param name="args">The command line arguments to provide to the executable.</param>
        /// <param name="exitCodeHandling">How to handle the return code from running the executable.</param>
        /// <param name="failureBase">Not sure what this is -- some debugging/diagnostic thing.</param>
        /// <param name="captureStdout">Where to capture standard out (I think).</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>
        /// <param name="returnStandardOut">Whether to return the standard output of the process.</param>
        /// <param name="returnStandardError">Whether to return the standard error output of the process.</param>
        /// <param name="allowCloudExecution">Whether to allow this worker to run the executable in the cloud.</param>
        /// <remarks>
        /// TODO: executable should be a BuildObject, like every other dependency.
        /// </remarks>
        public ProcessInvokeAsyncWorker(
            WorkingDirectory workingDirectory,
            IProcessInvokeAsyncVerb verb,
            string executable,
            string[] args,
            ProcessExitCodeHandling exitCodeHandling,
            BuildObject failureBase,
            BuildObject captureStdout = null,
            string dbgText            = null,
            bool allowAbsoluteExe     = false,
            bool allowAbsoluteArgs    = false,
            string workingDirOverride = null,
            bool returnStandardOut    = false,
            bool returnStandardError  = false,
            bool allowCloudExecution  = false)
        {
            this.workingDirectory    = workingDirectory;
            this.verb                = verb;
            this.executable          = executable;
            this.args                = args;
            this.exitCodeHandling    = exitCodeHandling;
            this.failureBase         = failureBase;
            this.captureStdout       = captureStdout;
            this.dbgText             = dbgText;
            this.allowAbsoluteExe    = allowAbsoluteExe;
            this.allowAbsoluteArgs   = allowAbsoluteArgs;
            this.workingDirOverride  = workingDirOverride;
            this.returnStandardOut   = returnStandardOut;
            this.returnStandardError = returnStandardError;

            // if (allowCloudExecution)
            // {
            //     // Verbs cannot allow cloud execution if they allow absolute paths to exes or args.
            //     Util.Assert(!this.allowAbsoluteExe);
            //     Util.Assert(!this.allowAbsoluteArgs);
            //     Util.Assert(this.workingDirOverride == null);
            //
            //     if (BuildEngine.theEngine.CloudExecutionQueue != null)
            //     {
            //         // We're good to go for cloud execution.
            //         this.useCloudExecution = true;
            //
            //         // REVIEW: If there are other things we should do on the main thread prior to CloudSubmitter invocation, we should do them here.
            //         this.inputFiles = this.GetInputFiles();
            //         this.outputFiles = new List<BuildObject>(this.verb.getOutputs());
            //         this.outputFiles.AddRange(this.verb.getFailureOutputs());
            //     }
            // }
        }
        /// <summary>
        /// Initializes a new instance of the ProcessInvokeAsyncWorker class.
        /// </summary>
        /// <param name="workingDirectory">The private working directory for this worker to work in.</param>
        /// <param name="verb">The verb whose worker this is.</param>
        /// <param name="executable">The executable to run.</param>
        /// <param name="args">The command line arguments to provide to the executable.</param>
        /// <param name="exitCodeHandling">How to handle the return code from running the executable.</param>
        /// <param name="failureBase">Not sure what this is -- some debugging/diagnostic thing.</param>
        /// <param name="captureStdout">Where to capture standard out (I think).</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>
        /// <param name="returnStandardOut">Whether to return the standard output of the process.</param>
        /// <param name="returnStandardError">Whether to return the standard error output of the process.</param>
        /// <param name="allowCloudExecution">Whether to allow this worker to run the executable in the cloud.</param>
        /// <remarks>
        /// TODO: executable should be a BuildObject, like every other dependency.
        /// </remarks>
        public ProcessInvokeAsyncWorker(
            WorkingDirectory workingDirectory,
            IProcessInvokeAsyncVerb verb,
            string executable,
            string[] args,
            ProcessExitCodeHandling exitCodeHandling,
            BuildObject failureBase,
            BuildObject captureStdout = null,
            string dbgText = null,
            bool allowAbsoluteExe = false,
            bool allowAbsoluteArgs = false,
            string workingDirOverride = null,
            bool returnStandardOut = false,
            bool returnStandardError = false,
            bool allowCloudExecution = false)
        {
            this.workingDirectory = workingDirectory;
            this.verb = verb;
            this.executable = executable;
            this.args = args;
            this.exitCodeHandling = exitCodeHandling;
            this.failureBase = failureBase;
            this.captureStdout = captureStdout;
            this.dbgText = dbgText;
            this.allowAbsoluteExe = allowAbsoluteExe;
            this.allowAbsoluteArgs = allowAbsoluteArgs;
            this.workingDirOverride = workingDirOverride;
            this.returnStandardOut = returnStandardOut;
            this.returnStandardError = returnStandardError;

            if (allowCloudExecution)
            {
                // Verbs cannot allow cloud execution if they allow absolute paths to exes or args.
                Util.Assert(!this.allowAbsoluteExe);
                Util.Assert(!this.allowAbsoluteArgs);
                Util.Assert(this.workingDirOverride == null);

                if (BuildEngine.theEngine.CloudExecutionQueue != null)
                {
                    // We're good to go for cloud execution.
                    this.useCloudExecution = true;

                    // REVIEW: If there are other things we should do on the main thread prior to CloudSubmitter invocation, we should do them here.
                    this.inputFiles = this.GetInputFiles();
                    this.outputFiles = new List<BuildObject>(this.verb.getOutputs());
                    this.outputFiles.AddRange(this.verb.getFailureOutputs());
                }
            }
        }