private bool TrySetBuildToolExecutor( PipConstructionHelper pipConstructionHelper, ProcessBuilder processBuilder, ProjectWithPredictions project) { // If we should use the dotnet core version of msbuild, the executable for the pip is dotnet.exe instead of msbuild.exe, and // the first argument is msbuild.dll FileArtifact cmdExeArtifact; if (m_resolverSettings.ShouldRunDotNetCoreMSBuild()) { cmdExeArtifact = FileArtifact.CreateSourceFile(m_dotnetExePath); processBuilder.ArgumentsBuilder.Add(PipDataAtom.FromAbsolutePath(m_msBuildPath)); } else { cmdExeArtifact = FileArtifact.CreateSourceFile(m_msBuildPath); } processBuilder.Executable = cmdExeArtifact; processBuilder.AddInputFile(cmdExeArtifact); processBuilder.AddCurrentHostOSDirectories(); processBuilder.AddUntrackedAppDataDirectories(); processBuilder.AddUntrackedProgramDataDirectories(); // Temp directory setup including setting TMP and TEMP env vars. The path to // the temp dir is generated in a consistent fashion between BuildXL runs to // ensure environment value (and hence pip hash) consistency. processBuilder.EnableTempDirectory(); processBuilder.ToolDescription = StringId.Create(m_context.StringTable, I($"{m_moduleDefinition.Descriptor.Name} - {project.FullPath.ToString(PathTable)}")); return(true); }
private void SetCmdTool( ProcessBuilder processBuilder, RushProject project) { var cmdExeArtifact = FileArtifact.CreateSourceFile(AbsolutePath.Create(PathTable, Environment.GetEnvironmentVariable("COMSPEC"))); processBuilder.Executable = cmdExeArtifact; processBuilder.AddInputFile(cmdExeArtifact); processBuilder.AddCurrentHostOSDirectories(); processBuilder.AddUntrackedAppDataDirectories(); processBuilder.AddUntrackedProgramDataDirectories(); // Temp directory setup including setting TMP and TEMP env vars. The path to // the temp dir is generated in a consistent fashion between BuildXL runs to // ensure environment value (and hence pip hash) consistency. processBuilder.EnableTempDirectory(); processBuilder.ToolDescription = StringId.Create(m_context.StringTable, I($"{m_moduleDefinition.Descriptor.Name} - {project.Name}")); }
protected void AddUntrackedWindowsDirectories(ProcessBuilder processBuilder) { if (OperatingSystemHelper.IsUnixOS) { processBuilder.EnableTempDirectory(); foreach (var dir in new[] { Private, SystemLibrary, Usr, Dev, Var, AppleInternal, Bin, Etc, Proc, TmpDir }) { processBuilder.AddUntrackedDirectoryScope(DirectoryArtifact.CreateWithZeroPartialSealId(Context.PathTable, dir)); } string userTextEncodingFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".CFUserTextEncoding"); processBuilder.AddUntrackedFile(AbsolutePath.Create(Context.PathTable, userTextEncodingFile)); } else { processBuilder.AddUntrackedWindowsDirectories(); } }
private bool TrySetBuildToolExecutor( PipConstructionHelper pipConstructionHelper, ProcessBuilder processBuilder, ProjectWithPredictions project) { FileArtifact cmdExeArtifact = FileArtifact.CreateSourceFile(m_msBuildExePath); processBuilder.Executable = cmdExeArtifact; processBuilder.AddInputFile(cmdExeArtifact); processBuilder.AddCurrentHostOSDirectories(); processBuilder.AddUntrackedAppDataDirectories(); processBuilder.AddUntrackedProgramDataDirectories(); // Temp directory setup including setting TMP and TEMP env vars. The path to // the temp dir is generated in a consistent fashion between BuildXL runs to // ensure environment value (and hence pip hash) consistency. processBuilder.EnableTempDirectory(); AbsolutePath toolDir = m_msBuildExePath.GetParent(PathTable); processBuilder.ToolDescription = StringId.Create(m_context.StringTable, I($"{m_moduleDefinition.Descriptor.Name} - {project.FullPath.ToString(PathTable)}")); return(true); }
private bool TryConfigureProcessBuilder(ProcessBuilder processBuilder, NinjaNode node, QualifierId qualifierId) { SeparateExecutableFromCommands(node.Command, out string executable, out string args); if (!TryFindExecutablePath(executable, out AbsolutePath exePath)) { Tracing.Logger.Log.InvalidExecutablePath(m_context.LoggingContext, Location.FromFile(m_specPath.ToString(m_context.PathTable)), node.Command); return(false); } FileArtifact prExeArtifact = FileArtifact.CreateSourceFile(exePath); processBuilder.Executable = prExeArtifact; processBuilder.AddInputFile(prExeArtifact); using (var pipDataBuilderWrapper = m_context.GetPipDataBuilder()) { var pipDataBuilder = pipDataBuilderWrapper.Instance; pipDataBuilder.Add(args); processBuilder.ArgumentsBuilder.Add(pipDataBuilder.ToPipData(string.Empty, PipDataFragmentEscaping.NoEscaping)); } if (node.ResponseFile.HasValue) { using (var pipDataBuilderWrapper = m_context.GetPipDataBuilder()) { var pipDataBuilder = pipDataBuilderWrapper.Instance; pipDataBuilder.Add(node.ResponseFile?.Content); PipData responseFileData = pipDataBuilder.ToPipData(string.Empty, PipDataFragmentEscaping.NoEscaping); // We tell the process builder to write the response file but to not add any arguments to the process (requiresExplicitArgument = false) // because that information is already in node.Command var rspFileSpec = ResponseFileSpecification.Builder() .ExplicitData(responseFileData) .RequiresArgument(false) .ExplicitPath((AbsolutePath)node.ResponseFile?.Path) .Build(); processBuilder.SetResponseFileSpecification(rspFileSpec); } } // TODO: Maybe a better description. Add ninja description or change command for input/outputs processBuilder.ToolDescription = StringId.Create(m_context.StringTable, I($"{m_moduleDefinition.Descriptor.Name} - {node.Rule} - {executable} :: [{node.Command}]")); processBuilder.Options |= Process.Options.AllowUndeclaredSourceReads | Process.Options.OutputsMustRemainWritable | Process.Options.OutputsMustRemainWritable; processBuilder.EnableTempDirectory(); // Working directory - the directory containing the ninja spec file // Ninja generators may express paths relative to this processBuilder.WorkingDirectory = DirectoryArtifact.CreateWithZeroPartialSealId(m_specPath.GetParent(m_context.PathTable)); // Untrack directories UntrackFilesAndDirectories(processBuilder); // Allow some surviving child process AddRequiredSurvivingChildren(processBuilder); // Environment variables SetEnvironmentVariables(processBuilder, node); return(true); }