[build] Remove make framework-assemblies target (#9269)

I'm often running `make leeroy` to test changes while building on macOS,
and I noticed that an extra handful of Mono.Android.csproj builds were
running each time. The `framework-assemblies` target that is declared
in the generated `rules.mk` file includes some additional project builds
that don't seem to be necessary in a .NET only world.

The build has been updated to stop generating `rules.mk` entirely, and
the make targets in `BuildEverything.mk` have been simplified.
This commit is contained in:
Peter Collins 2024-09-03 10:12:53 -04:00 коммит произвёл GitHub
Родитель 284e38a6b3
Коммит e4a75a816a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
7 изменённых файлов: 2 добавлений и 260 удалений

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

@ -24,7 +24,6 @@ all:
$(call DOTNET_BINLOG,all) $(MSBUILD_FLAGS) $(SOLUTION)
$(call DOTNET_BINLOG,setup-workload) -t:ConfigureLocalWorkload build-tools/create-packs/Microsoft.Android.Sdk.proj
-include bin/Build$(CONFIGURATION)/rules.mk
ifeq ($(OS_NAME),)
export OS_NAME := $(shell uname)

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

@ -1,16 +1,5 @@
.PHONY: leeroy jenkins leeroy-all
#
# framework-assemblies lives in bin/Build$(CONFIGURATION)/rules.mk generated by `make prepare`
#
# It has to be invoked with $(MAKE) because otherwise rules.mk would not be included and we'd
# get a build failure.
#
# The other targets depended upon by leeroy also require rules.mk to be present and thus they
# are invoked in the same way framework-assemblies is
#
# Local `make jenkins` invocations should build everything by default. We need to ensure `-a` is passed to xaprepare when no CI flags are set.
#
jenkins:
ifeq ($(PREPARE_CI_PR)$(PREPARE_CI),00)
$(MAKE) PREPARE_ARGS=-a prepare
@ -23,8 +12,6 @@ ifneq ("$(wildcard $(topdir)/external/monodroid/Makefile)","")
endif
$(MAKE) leeroy
leeroy: leeroy-all framework-assemblies
leeroy-all:
$(call DOTNET_BINLOG,leeroy-all) $(SOLUTION) $(_MSBUILD_ARGS)
leeroy:
$(call DOTNET_BINLOG,leeroy) $(SOLUTION) $(_MSBUILD_ARGS)
$(call DOTNET_BINLOG,setup-workload) -t:ConfigureLocalWorkload build-tools/create-packs/Microsoft.Android.Sdk.proj

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

@ -42,7 +42,6 @@ namespace Xamarin.Android.Prepare
bool? useColor;
bool? dullMode;
Scenario? defaultScenario;
List<RuleGenerator>? ruleGenerators;
string? debugFileExtension;
CompressionFormat? compressionFormat;
Dictionary<KnownConditions, bool> conditions = new Dictionary<KnownConditions, bool> ();
@ -262,18 +261,6 @@ namespace Xamarin.Android.Prepare
}
}
/// <summary>
/// A collection of delegates which can add rules to the `rules.mk` file generated at the end of
/// bootstrapper's run
/// </summary>
public List<RuleGenerator> RuleGenerators {
get {
if (ruleGenerators == null)
ruleGenerators = new List<RuleGenerator> ();
return ruleGenerators;
}
}
/// <summary>
/// Extensions of files with debug information
/// </summary>

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

@ -1,207 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Xamarin.Android.Prepare
{
partial class GeneratedMakeRulesFile : GeneratedFile
{
public GeneratedMakeRulesFile (string outputPath)
: base (outputPath)
{}
public override void Generate (Context context)
{
Log.Todo ("Generate some help for `make help`");
if (context == null)
throw new ArgumentNullException (nameof (context));
using (StreamWriter sw = Utilities.OpenStreamWriter (OutputPath)) {
Generate (context, sw);
sw.Flush ();
}
}
string GetOutputFileName (Context context, string namePrefix)
{
return $"{namePrefix}-v{BuildInfo.XAVersion}.$(-num-commits-since-version-change)_{context.OS.Type}-{context.OS.Architecture}_$(GIT_BRANCH)_$(GIT_COMMIT)-$(CONFIGURATION)";
}
void Generate (Context context, StreamWriter sw)
{
string myPath = Path.Combine (BuildPaths.XAPrepareSourceDir, "Application", "GeneratedMakeRulesFile.cs");
sw.WriteLine ( "#");
sw.WriteLine ($"# Generated by {myPath}");
sw.WriteLine ( "#");
sw.WriteLine ();
WriteVariable ("export OS_NAME", context.OS.Type);
WriteVariable ("export OS_ARCH", context.OS.Architecture);
WriteVariable ("export OS_ARCH_TRANSLATED", context.OS.ProcessIsTranslated ? "true" : "false");
WriteVariable ("PRODUCT_VERSION", context.ProductVersion);
// These must remain dynamic since the developer may change branches without re-running `prepare`
string getGitBranchScript = Utilities.GetRelativePath (BuildPaths.XamarinAndroidSourceRoot, Path.Combine (Configurables.Paths.BuildToolsScriptsDir, "get-git-branch.sh"));
WriteVariable ("GIT_BRANCH", $"$(shell LANG=C \"{getGitBranchScript}\" | tr -d '[[:space:]]' | tr -C a-zA-Z0-9- _)");
WriteVariable ("GIT_COMMIT", $"$(shell LANG=C git log --no-color --first-parent -n1 --pretty=format:%h)");
WriteVariable ("-num-commits-since-version-change", $"$(shell LANG=C git log {context.BuildInfo.CommitOfLastVersionChange}..HEAD --oneline 2>/dev/null | wc -l | sed 's/ //g')");
WriteVariable ("ZIP_EXTENSION", context.OS.ZipExtension);
WriteVariable ("ZIP_OUTPUT_BASENAME", GetOutputFileName (context, "xamarin.android-oss"));
WriteVariable ("ZIP_OUTPUT", "$(ZIP_OUTPUT_BASENAME).$(ZIP_EXTENSION)");
var allApiLevels = new List <string> ();
var allPlatformIDs = new List <string> ();
var allFrameworks = new List <string> ();
var apiLevels = new List <string> ();
var stableApiLevels = new List <string> ();
var frameworks = new List <string> ();
var stableFrameworks = new List <string> ();
var platformIds = new List <string> ();
foreach (AndroidPlatform ap in BuildAndroidPlatforms.AllPlatforms) {
string api = ap.ApiLevel.ToString ();
allApiLevels.Add (api);
allPlatformIDs.Add (ap.PlatformID);
if (!String.IsNullOrEmpty (ap.Framework)) {
allFrameworks.Add (ap.Framework);
frameworks.Add (ap.Framework);
if (ap.Stable)
stableFrameworks.Add (ap.Framework);
} else
allFrameworks.Add ("-");
if (!ap.Supported)
continue;
apiLevels.Add (api);
platformIds.Add (ap.PlatformID);
if (ap.Stable)
stableApiLevels.Add (api);
}
WriteVariable ("ALL_API_LEVELS", ToValue (allApiLevels));
WriteVariable ("ALL_PLATFORM_IDS", ToValue (allPlatformIDs));
WriteVariable ("ALL_FRAMEWORKS", ToValue (allFrameworks));
WriteVariable ("API_LEVELS", ToValue (apiLevels));
WriteVariable ("STABLE_API_LEVELS", ToValue (stableApiLevels));
WriteVariable ("FRAMEWORKS", ToValue (frameworks));
WriteVariable ("STABLE_FRAMEWORKS", ToValue (stableFrameworks));
WriteVariable ("ANDROID_TOOLCHAIN_DIR", context.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory));
if (context.MonoOptions != null && context.MonoOptions.Count > 0) {
WriteVariable ("MONO_OPTIONS", ToValue (context.MonoOptions));
sw.WriteLine ("export MONO_OPTIONS");
}
sw.WriteLine ("_MSBUILD_ARGS = \\");
sw.WriteLine ($"\t/p:{KnownProperties.AndroidSupportedTargetJitAbis}={context.Properties.GetRequiredValue (KnownProperties.AndroidSupportedTargetJitAbis)} \\");
sw.WriteLine ($"\t/p:{KnownProperties.AndroidSupportedTargetAotAbis}={context.Properties.GetRequiredValue (KnownProperties.AndroidSupportedTargetAotAbis)}");
OutputOSVariables (context, sw);
WriteListVariable ("_BUNDLE_ZIPS_INCLUDE", Configurables.Defaults.BundleZipsInclude);
WriteListVariable ("_BUNDLE_ZIPS_EXCLUDE", Configurables.Defaults.BundleZipsExclude);
sw.WriteLine ();
sw.WriteLine (".PHONY: framework-assemblies");
sw.WriteLine ("framework-assemblies:");
string prevVersion = "v1.0";
string monoFrameworksRoot = Path.Combine ("bin", "$(CONFIGURATION)", context.Properties.GetRequiredValue (KnownProperties.XABinRelativeInstallPrefix), Configurables.Paths.MonoAndroidFrameworksSubDir);
for (int i = 0; i < apiLevels.Count; i++) {
string curVersion = frameworks [i];
string apiLevel = apiLevels [i];
string platformId = platformIds [i];
string redistFile = Path.Combine (monoFrameworksRoot, curVersion, "RedistList", "FrameworkList.xml");
WriteRuleLine ($"grep -q {prevVersion} {redistFile}; \\");
WriteRuleLine ( "if [ $$? -ne 0 ] ; then \\");
WriteRuleLine ($"\trm -f {redistFile}; \\");
WriteRuleLine ( "fi; \\");
WriteRuleLine ( "$(call DOTNET_BINLOG,Mono.Android) src/Mono.Android/Mono.Android.csproj \\");
WriteRuleLine ( "\t$(_MSBUILD_ARGS) \\");
WriteRuleLine ($"\t/p:AndroidApiLevel={apiLevel} /p:AndroidPlatformId={platformId} /p:AndroidFrameworkVersion={curVersion} \\");
WriteRuleLine ($"\t/p:AndroidPreviousFrameworkVersion={prevVersion} || exit 1;");
prevVersion = curVersion;
}
string firstApiLevel = apiLevels [0];
string firstPlatformId = platformIds [0];
string firstFramework = frameworks [0];
string latestStableFramework = stableFrameworks [stableFrameworks.Count - 1];
WriteMSBuildCall (
fileToRemovePath: $"{monoFrameworksRoot}/{latestStableFramework}/Mono.Android.Export.*",
projectPath: "src/Mono.Android.Export/Mono.Android.Export.csproj"
);
sw.WriteLine ();
if (context.RuleGenerators == null || context.RuleGenerators.Count == 0)
return;
foreach (RuleGenerator rg in context.RuleGenerators) {
if (rg == null)
continue;
rg (this, sw);
}
void WriteMSBuildCall (string fileToRemovePath, string projectPath)
{
WriteRuleLine ($"rm -f {fileToRemovePath}");
WriteRuleLine ($"$(call DOTNET_BINLOG,NUnitLite) $(MSBUILD_FLAGS) {projectPath} \\");
WriteRuleLine ( "\t$(_MSBUILD_ARGS) \\");
WriteRuleLine ($"\t/p:AndroidApiLevel={firstApiLevel} /p:AndroidPlatformId={firstPlatformId} \\");
WriteRuleLine ($"\t/p:AndroidFrameworkVersion={firstFramework} || exit 1;");
}
string ToValue (ICollection<string> list, string? separator = null)
{
return String.Join (separator ?? " ", list);
}
void WriteRuleLine (string line)
{
sw.Write ('\t');
sw.WriteLine (line);
}
void WriteVariable (string name, string value)
{
sw.WriteLine ($"{name} = {value}");
}
void WriteListVariable (string name, ICollection <string> list, bool conditional = false)
{
if (list.Count == 0)
return;
if (!conditional)
sw.Write ($"{name} =");
foreach (string i in list) {
string item = i.Trim ();
if (String.IsNullOrEmpty (item))
continue;
if (conditional) {
sw.WriteLine ($"ifneq ($(wildcard {item}),)");
sw.WriteLine ($"{name} += {item}");
sw.WriteLine ("endif");
continue;
}
sw.WriteLine (" \\");
sw.Write ($"\t{item}");
}
if (!conditional)
sw.WriteLine ();
}
}
partial void OutputOSVariables (Context context, StreamWriter sw);
}
}

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

@ -1,6 +0,0 @@
using System.IO;
namespace Xamarin.Android.Prepare
{
delegate void RuleGenerator (GeneratedMakeRulesFile file, StreamWriter rulesWriter);
}

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

@ -146,23 +146,6 @@ namespace Xamarin.Android.Prepare
{ "x86_64", "x86_64-linux-android" },
};
/// <summary>
/// Used in rules.mk generator. Files to include in the XA bundle archives.
/// </summary>
public static readonly List <string> BundleZipsInclude = new List <string> {
"$(ZIP_OUTPUT_BASENAME)/THIRD-PARTY-NOTICES.TXT",
"$(ZIP_OUTPUT_BASENAME)/bin/Debug",
"$(ZIP_OUTPUT_BASENAME)/bin/Release",
};
/// <summary>
/// Used in rules.mk generator. Files to exclude from the XA bundle archives. Must be syntactically
/// correct for GNU Make.
/// </summary>
public static readonly List <string> BundleZipsExclude = new List <string> {
"$(ZIP_OUTPUT_BASENAME)/bin/*/bundle-*.zip"
};
public static readonly List <NDKTool> NDKTools = new List<NDKTool> {
// Tools prefixed with architecture triple
new NDKTool (name: "as", prefixed: true),

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

@ -27,7 +27,6 @@ namespace Xamarin.Android.Prepare
partial void AddUnixPostBuildSteps (Context context, List<GeneratedFile> steps)
{
steps.Add (new GeneratedMakeRulesFile (Path.Combine (Configurables.Paths.BuildBinDir, "rules.mk")));
steps.Add (new GeneratedConfigurationFile (Path.Combine (Configurables.Paths.BinDirRoot, "configuration.mk")));
}
}