Skip to content

Commit

Permalink
[build] Generate WorkloadDependencies.json (#9613)
Browse files Browse the repository at this point in the history
Context: [`Releases.json` loop][0]
Context: xamarin/xamarin-macios#21779 (comment)
Context: 51151d7
Context: 60bb447
Context: f9b2c97

The `GetAndroidDependencies` target (f9b2c97) and the
`InstallAndroidDependencies` target (60bb447) are used to determine
and install the Android SDK dependencies required to build a project.

Unfortunately, in order to run these targets, a project must exist!

There is a desire to have the .NET Workloads contain machine readable
descriptions of what dependencies they require in order to run, in
order to facilitate tooling that would check for these dependencies
*without* requiring that a project exist.

Add `tools/workload-dependencies`, a new tool which parses a
"Xamarin Manifest" to generate `WorkloadDependencies.json`,
with versions controlled by `Xamarin.Installer.Common.props`
(51151d7).  The "canonical" location for the "Xamarin Manifest" is
`external/android-platform-support/Feeds/AndroidManifestFeed_d17.12.xml`;
failing that, <https://aka.ms/AndroidManifestFeed/d17-12> can be used.

Output of the tool is a JSON document specifying ther required JDK
and Android SDK packages which the .NET for Android workload requires.
This document is `data/WorkloadDependencies.json` within the
`Microsoft.NET.Sdk.Android.Manifest*.nupkg` NuGet package.

	{
	  "microsoft.net.sdk.android": {
	    "workload": {
	      "alias": [
	        "android"
	      ],
	      "version": "35.99.0-ci.pr.gh9613.79"
	    },
	    "jdk": {
	      "version": "[17.0,18.0)",
	      "recommendedVersion": "17.0.12"
	    },
	    "androidsdk": {
	      "packages": [
	        {
	          "desc": "Android SDK Build-Tools 35",
	          "sdkPackage": {
	            "id": "build-tools;35.0.0"
	          },
	          "optional": "false"
	        },
	        {
	          "desc": "Android SDK Command-line Tools",
	          "sdkPackage": {
	            "id": "cmdline-tools;12.0"
	          },
	          "optional": "false"
	        },
	        {
	          "desc": "Android Emulator",
	          "sdkPackage": {
	            "id": "emulator",
	            "recommendedVersion": "35.1.20"
	          },
	          "optional": "true"
	        },
	        {
	          "desc": "NDK (Side by side) 26.1.10909125",
	          "sdkPackage": {
	            "id": "ndk;26.1.10909125"
	          },
	          "optional": "true"
	        },
	        {
	          "desc": "Android SDK Platform 35",
	          "sdkPackage": {
	            "id": "platforms;android-35"
	          },
	          "optional": "false"
	        },
	        {
	          "desc": "Android SDK Platform Baklava (Preview)",
	          "sdkPackage": {
	            "id": "platforms;android-Baklava"
	          },
	          "optional": "true"
	        },
	        {
	          "desc": "Android SDK Platform-Tools",
	          "sdkPackage": {
	            "id": "platform-tools",
	            "recommendedVersion": "34.0.5"
	          },
	          "optional": "false"
	        },
	        {
	          "desc": "Google APIs ARM 64 v8a System Image",
	          "sdkPackage": {
	            "id": {
	              "win-x64": "system-images;android-35;google_apis;x86_64",
	              "mac-x64": "system-images;android-35;google_apis;x86_64",
	              "linux-x64": "system-images;android-35;google_apis;x86_64",
	              "mac-arm64": "system-images;android-35;google_apis;arm64-v8a",
	              "linux-arm64": "system-images;android-35;google_apis;arm64-v8a"
	            }
	          },
	          "optional": "true"
	        }
	      ]
	    }
	  }
	}

[0]: https://loop.cloud.microsoft/p/eyJ1IjoiaHR0cHM6Ly9taWNyb3NvZnQuc2hhcmVwb2ludC1kZi5jb20vc2l0ZXMvYzIyZmVjMDMtN2I4OS00OTJhLTgzNzQtZmZjMTI4YjMwMWRhP25hdj1jejBsTWtaemFYUmxjeVV5Um1NeU1tWmxZekF6TFRkaU9Ea3RORGt5WVMwNE16YzBMV1ptWXpFeU9HSXpNREZrWVNaa1BXSWxNakZXTUhSeU9XY3dRbk5WYlhVdFJWUjNRVEZNY0dOSmQwdG1VVEZUZFVFeFRuRk5XbVZ3TUhVd1dUaEhkVVpKVlRSUGIxWnlVMWxoZFRaT2RFODRTamhISm1ZOU1ERlhSelkwU0RNMU56TlZRbEpITWs1TU1rSkdTemRZV1ZCWFJqSlNTRVJQVENaalBTVXlSaVpoUFV4dmIzQkJjSEFtY0QwbE5EQm1iSFZwWkhnbE1rWnNiMjl3TFhCaFoyVXRZMjl1ZEdGcGJtVnlKbmc5SlRkQ0pUSXlkeVV5TWlVelFTVXlNbFF3VWxSVlNIaDBZVmRPZVdJelRuWmFibEYxWXpKb2FHTnRWbmRpTW14MVpFTXhhMXBwTldwaU1qRTRXV2xHVjAxSVVubFBWMk4zVVc1T1ZtSllWWFJTVmxJelVWUkdUV05IVGtwa01IUnRWVlJHVkdSVlJYaFVia1pPVjIxV2QwMUlWWGRYVkdoSVpGVmFTbFpVVWxCaU1WcDVWVEZzYUdSVVdrOWtSVGcwVTJwb1NHWkVRWGhXTUdNeVRrVm5lazU2VGtwVU1WRXdWMnQwUmxGNldrdFRSbXhaVlRCYVVWUlZhRlJXUlVaRFYyeEZKVE5FSlRJeUpUSkRKVEl5YVNVeU1pVXpRU1V5TWprNE5HUXhZMlpoTFRnMVpXUXROR1kyWXkxaU9EWmlMVFJtTXpZMU1EQXlaak5tTnlVeU1pVTNSQT09In0%3D?ct=1728330820992&
  • Loading branch information
jonpryor committed Dec 18, 2024
1 parent bda1f4f commit b716173
Show file tree
Hide file tree
Showing 5 changed files with 498 additions and 0 deletions.
19 changes: 19 additions & 0 deletions build-tools/create-packs/Microsoft.NET.Sdk.Android.proj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ about the various Microsoft.Android workloads.
<Target Name="_GenerateXAWorkloadContent"
DependsOnTargets="_GetDefaultPackageVersion;_GetLicense">
<PropertyGroup>
<WorkloadDependenciesPath Condition="'$(WorkloadDependenciesPath)' == ''">$(OutputPath)workload-manifest\WorkloadDependencies.json</WorkloadDependenciesPath>
<WorkloadManifestJsonPath Condition="'$(WorkloadManifestJsonPath)' == ''">$(OutputPath)workload-manifest\WorkloadManifest.json</WorkloadManifestJsonPath>
<WorkloadManifestTargetsPath Condition="'$(WorkloadManifestTargetsPath)' == ''">$(OutputPath)workload-manifest\WorkloadManifest.targets</WorkloadManifestTargetsPath>
<WorkloadVersion Condition="'$(WorkloadVersion)' == ''">$(AndroidPackVersionLong)</WorkloadVersion>
Expand All @@ -43,9 +44,27 @@ about the various Microsoft.Android workloads.
Replacements="@NET_PREVIOUS_VERSION@=$(AndroidNetPreviousVersion)">
</ReplaceFileContents>

<ItemGroup>
<_WorkloadDepProp Include="AndroidLatestStablePlatformId=$(AndroidLatestStablePlatformId)" />
<_WorkloadDepProp Include="AndroidLatestUnstablePlatformId=$(AndroidLatestUnstablePlatformId)" />
<_WorkloadDepProp Include="DotNetStableTargetFramework=$(DotNetStableTargetFramework)" />
<_WorkloadDepProp Include="MicrosoftAndroidSdkOutDir=$(MicrosoftAndroidSdkOutDir)" />
<_WorkloadDepProp Include="MonoOptionsVersion=$(MonoOptionsVersion)" />
<_WorkloadDepProp Include="NewtonsoftJsonPackageVersion=$(NewtonsoftJsonPackageVersion)" />
<_WorkloadDepProp Include="WorkloadDependenciesPath=$(WorkloadDependenciesPath)" />
<_WorkloadDepProp Include="WorkloadVersion=$(WorkloadVersion)" />
</ItemGroup>

<MSBuild
Projects="$(MSBuildThisFileDirectory)/../../tools/workload-dependencies/WorkloadDependencies.proj"
Properties="@(_WorkloadDepProp)"
Targets="GenerateWorkloadDependencies"
/>

<ItemGroup>
<_PackageFiles Include="$(WorkloadManifestJsonPath)" PackagePath="data" />
<_PackageFiles Include="$(WorkloadManifestTargetsPath)" PackagePath="data" />
<_PackageFiles Include="$(WorkloadDependenciesPath)" PackagePath="data" />
</ItemGroup>
</Target>

Expand Down
8 changes: 8 additions & 0 deletions tools/workload-dependencies/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<!--
This file exists so that we do NOT import top-level Configuration.props/etc.
This is so that we can cleanly import Xamarin.Installer.Common.props and
Xamarin.Android.Common.props from WorkloadDependencies.proj.
-->
</Project>
Loading

0 comments on commit b716173

Please sign in to comment.