Merged PR 687518: Resolve the BuildXL executable location in AdoBuildRunner instead of taking it as an argument

Resolve the BuildXL executable location in AdoBuildRunner instead of taking it as an argument
This commit is contained in:
Marcelo Lynch 🧉 2022-11-08 00:27:49 +00:00
Родитель a4f3447663
Коммит 259aa69989
3 изменённых файлов: 18 добавлений и 15 удалений

Просмотреть файл

@ -198,9 +198,9 @@ function build {
if [[ -n "$arg_useAdoBuildRunner" ]]; then
local adoBuildRunnerExe="$arg_BuildXLBin/AdoBuildRunner"
chmod u=rx "$adoBuildRunnerExe" || true
print_info "${tputBold}Running AdoBuildRunner:${tputReset} '$adoBuildRunnerExe' '$bxlExe' ${g_bxlCmdArgs[@]}"
print_info "${tputBold}Running AdoBuildRunner:${tputReset} '$adoBuildRunnerExe' ${g_bxlCmdArgs[@]}"
"$adoBuildRunnerExe" "$bxlExe" "${g_bxlCmdArgs[@]}"
"$adoBuildRunnerExe" "${g_bxlCmdArgs[@]}"
else
print_info "${tputBold}Running bxl:${tputReset} '$bxlExe' ${g_bxlCmdArgs[@]}"

Просмотреть файл

@ -4,7 +4,10 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using BuildXL.AdoBuildRunner.Vsts;
namespace BuildXL.AdoBuildRunner.Build
@ -14,16 +17,23 @@ namespace BuildXL.AdoBuildRunner.Build
/// </summary>
public class BuildExecutor : BuildExecutorBase, IBuildExecutor
{
/// <nodoc />
public BuildExecutor(ILogger logger) : base(logger) { }
private readonly string m_bxlExeLocation;
private int ExecuteBuild(string executableName, string arguments, string buildSourcesDirectory)
/// <nodoc />
public BuildExecutor(ILogger logger) : base(logger)
{
// Resolve the bxl executable location
var exeName = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "bxl" : "bxl.exe";
m_bxlExeLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), exeName);
}
private int ExecuteBuild(string arguments, string buildSourcesDirectory)
{
var process = new Process()
{
StartInfo =
{
FileName = executableName,
FileName = m_bxlExeLocation,
Arguments = arguments,
RedirectStandardOutput = true,
RedirectStandardError = true
@ -63,11 +73,7 @@ namespace BuildXL.AdoBuildRunner.Build
// Extend this eventually, with the context needed for the builds
}
private static string ExtractAndEscapeCommandLineArguments(string[] exec)
{
var args = exec.Skip(1);
return string.Join(" ", args);
}
private static string ExtractAndEscapeCommandLineArguments(string[] args) => string.Join(" ", args);
/// <inherit />
public void PrepareBuildEnvironment(BuildContext buildContext)
@ -84,7 +90,7 @@ namespace BuildXL.AdoBuildRunner.Build
public int ExecuteSingleMachineBuild(BuildContext buildContext, string[] buildArguments)
{
Logger.Info($@"Launching single machine build!");
return ExecuteBuild(buildArguments[0], ExtractAndEscapeCommandLineArguments(buildArguments), buildContext.SourcesDirectory);
return ExecuteBuild(ExtractAndEscapeCommandLineArguments(buildArguments), buildContext.SourcesDirectory);
}
/// <inherit />
@ -96,7 +102,6 @@ namespace BuildXL.AdoBuildRunner.Build
var workerFlags = string.Join(" ", workers);
return ExecuteBuild(
buildArguments[0],
ExtractAndEscapeCommandLineArguments(buildArguments) +
$" /distributedBuildRole:master /distributedBuildServicePort:{Constants.MachineGrpcPort} /relatedActivityId:{buildContext.SessionId} " +
workerFlags,
@ -110,7 +115,6 @@ namespace BuildXL.AdoBuildRunner.Build
Logger.Info($@"Launching distributed build as worker!");
return ExecuteBuild(
buildArguments[0],
"/p:BuildXLWorkerAttachTimeoutMin=10 " + // By default, set the timeout to 10min in the workers to avoid unnecessary waiting upon connection failures
ExtractAndEscapeCommandLineArguments(buildArguments) +
$" /distributedBuildRole:worker /distributedBuildServicePort:{Constants.MachineGrpcPort} /relatedActivityId:{buildContext.SessionId} ",

Просмотреть файл

@ -801,7 +801,6 @@ if ($NoSubst) {
if ($UseAdoBuildRunner) {
# Wrap the invocation with the AdoBuildRunner
$arguments = @($executable) + $arguments
$arguments = $arguments.Replace("""", "\""")
$executable = $useDeployment.adoBuildRunner
}