Merged PR 711302: Allow MsBuild pips to consume global dependencies

Allow MsBuild pips to consume global dependencies
This commit is contained in:
Iman Narasamdya 2023-04-06 19:45:00 +00:00
Родитель ed9e86f168
Коммит 4ede5719dc
2 изменённых файлов: 9 добавлений и 8 удалений

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

@ -556,6 +556,9 @@ namespace BuildXL.FrontEnd.MsBuild
// to avoid a large number of path sets
processBuilder.Options |= Process.Options.EnforceWeakFingerprintAugmentation;
// Allow the pip to consume global dependencies like passthrough environment variables and untracked scopes.
processBuilder.Options |= Process.Options.RequireGlobalDependencies;
// By default the double write policy is to allow same content double writes and safe rewrites.
// Otherwise we honor the double write policy specified in the resolver configuration
processBuilder.RewritePolicy |= m_resolverSettings.DoubleWritePolicy.HasValue

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

@ -64,6 +64,9 @@ namespace BuildXL.Utilities.Configuration
/// </remarks>
public static void ComputeEnvironment(this IProjectGraphResolverSettings resolverSettings, PathTable pathTable, out IDictionary<string, string> trackedEnv, out ICollection<string> passthroughEnv, out bool processEnvironmentUsed)
{
// Do not use CollectionUtilities.EmptyArray<string>() because the caller can modify the collection.
passthroughEnv = new List<string>();
if (resolverSettings.Environment == null)
{
var allEnvironmentVariables = Environment.GetEnvironmentVariables();
@ -75,13 +78,11 @@ namespace BuildXL.Utilities.Configuration
trackedEnv[envVar.ToString()] = value.ToString();
}
passthroughEnv = CollectionUtilities.EmptyArray<string>();
return;
}
processEnvironmentUsed = false;
var trackedList = new Dictionary<string, string>(OperatingSystemHelper.EnvVarComparer);
var passthroughList = new List<string>();
trackedEnv = new Dictionary<string, string>(OperatingSystemHelper.EnvVarComparer);
var builder = new StringBuilder();
foreach (var kvp in resolverSettings.Environment)
@ -90,16 +91,13 @@ namespace BuildXL.Utilities.Configuration
var valueOrPassthrough = kvp.Value?.GetValue();
if (valueOrPassthrough == null || valueOrPassthrough is not UnitValue)
{
trackedList.Add(kvp.Key, ProcessEnvironmentData(kvp.Value, pathTable, builder));
trackedEnv.Add(kvp.Key, ProcessEnvironmentData(kvp.Value, pathTable, builder));
}
else
{
passthroughList.Add(kvp.Key);
passthroughEnv.Add(kvp.Key);
}
}
trackedEnv = trackedList;
passthroughEnv = passthroughList;
}
private static string ProcessEnvironmentData([MaybeNull] EnvironmentData environmentData, PathTable pathTable, StringBuilder s)