From 1d8ad225cd330ac12b9dc516e66f4f895935e395 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Tue, 2 May 2017 12:32:55 -0400 Subject: [PATCH] [build] Build Mono.Android.Export.dll for the *minimum* API level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build-time assembly resolution is...complicated, but to summarize greatly, when `` is resolved, the following locations are checked: $(TargetFrameworkRootPath)\$(TargetFrameworkVersion)\Mono.Android.Export.dll ...included framework versions... $(TargetFrameworkRootPath)\v1.0\Mono.Android.Export.dll The `...included framework versions...` list is controlled by the `RedistList/FrameworkList.xml` files and their `/FileList/@IncludeFramework` attribute value. For example, `bin/Debug/lib/xbuild-frameworks/MonoAndroid/v7.1/RedistList/FrameworkList.xml` may have a value of `v7.0` for the `IncludeFramework` attribute. Checking `/FileList/@IncludeFramework` is done "recursively", and if you have a build environment created by `make jenkins`, this will "chain" through every supported framework version. Thus, if `$(TargetFrameworkVersion)` is `v6.0`, then the following directories may be checked to resolve `Mono.Android.Export.dll`: …/MonoAndroid/v6.0/Mono.Android.Export.dll …/MonoAndroid/v5.1/Mono.Android.Export.dll …/MonoAndroid/v5.0/Mono.Android.Export.dll …/MonoAndroid/v4.4.87/Mono.Android.Export.dll …/MonoAndroid/v4.4/Mono.Android.Export.dll …/MonoAndroid/v4.3/Mono.Android.Export.dll …/MonoAndroid/v4.2/Mono.Android.Export.dll …/MonoAndroid/v4.1/Mono.Android.Export.dll …/MonoAndroid/v4.0.3/Mono.Android.Export.dll …/MonoAndroid/v2.3/Mono.Android.Export.dll …/MonoAndroid/v1.0/Mono.Android.Export.dll The first match is used. Which presents a bit of a problem for e.g. [Build #373's `oss-xamarin.android*.zip`][0] file, which is a build tree prior to this change: It places `Mono.Android.Export.dll` into the `$(AndroidLatestFrameworkVersion)` directory: $ unzip -l oss-xamarin.android_v7.3.99.35_Darwin-x86_64_master_767caad.zip | grep Mono.Android.Export.dll 77824 05-01-2017 21:30 oss-xamarin.android_v7.3.99.35_Darwin-x86_64_master_767caad/bin/Debug/lib/xbuild-frameworks/MonoAndroid/v7.1/Mono.Android.Export.dll 69632 05-01-2017 21:26 oss-xamarin.android_v7.3.99.35_Darwin-x86_64_master_767caad/bin/Release/lib/xbuild-frameworks/MonoAndroid/v7.1/Mono.Android.Export.dll This is problematic because if the app's `$(TargetFrameworkVersion)` value is *lower* than `v7.1`, then `Mono.Android.Export.dll` *cannot be resolved*: $ xbuild /t:SignAndroidPackage /p:TargetFrameworkVersion=v5.0 ExampleUsingExport.csproj ... error XA4210: You need to add a reference to Mono.Android.Export.dll when you use ExportAttribute or ExportFieldAttribute ...ouch. :-( The correct fix is to update the `make framework-assemblies` target to build `Mono.Android.Export.csproj` into the lowest supported API-level, `$(firstword $(API_LEVELS))`. This would change the contents of the above `oss-xamarin.android*.zip` file to instead contain: …/bin/Debug/lib/xbuild-frameworks/MonoAndroid/v2.3/Mono.Android.Export.dll …/bin/Release/lib/xbuild-frameworks/MonoAndroid/v2.3/Mono.Android.Export.dll Since API-10 (v2.3) is the lowest supported API level, this allows `Mono.Android.Export.dll` to be used in all supported framework versions. "While we're at it," remove the `make task-assemblies` and `make runtime-libraries` targets, as these were redundent with -- and ran the same commands as -- the `make leeroy-all` target. [0]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/373/Azure/processDownloadRequest/xamarin-android/oss-xamarin.android_v7.3.99.35_Darwin-x86_64_master_767caad.zip --- build-tools/scripts/BuildEverything.mk | 22 ++++++++++------------ build-tools/scripts/Info.targets | 6 ++++++ src/OpenTK-1.0/OpenTK.csproj | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/build-tools/scripts/BuildEverything.mk b/build-tools/scripts/BuildEverything.mk index a18353bf550..19418c65dc1 100644 --- a/build-tools/scripts/BuildEverything.mk +++ b/build-tools/scripts/BuildEverything.mk @@ -80,20 +80,16 @@ _MSBUILD_ARGS = \ CONFIGURATIONS ?= Debug Release -.PHONY: leeroy jenkins leeroy-all opentk-jcw framework-assemblies runtime-libraries task-assemblies +.PHONY: leeroy jenkins leeroy-all opentk-jcw framework-assemblies .PHONY: create-vsix jenkins: prepare leeroy $(ZIP_OUTPUT) -leeroy: leeroy-all runtime-libraries task-assemblies framework-assemblies opentk-jcw +leeroy: leeroy-all framework-assemblies opentk-jcw leeroy-all: $(foreach conf, $(CONFIGURATIONS), \ - $(MSBUILD) $(MSBUILD_FLAGS) Xamarin.Android.sln /p:Configuration=$(conf) $(_MSBUILD_ARGS) ; ) - -task-assemblies: - $(foreach conf, $(CONFIGURATIONS), \ - $(MSBUILD) $(MSBUILD_FLAGS) /p:Configuration=$(conf) $(_MSBUILD_ARGS) $(SOLUTION); ) + $(MSBUILD) $(MSBUILD_FLAGS) $(SOLUTION) /p:Configuration=$(conf) $(_MSBUILD_ARGS) ; ) framework-assemblies: PREV_VERSION="v1.0"; \ @@ -108,21 +104,23 @@ framework-assemblies: $(MSBUILD) $(MSBUILD_FLAGS) src/Mono.Android/Mono.Android.csproj /p:Configuration=$(conf) $(_MSBUILD_ARGS) \ /p:AndroidApiLevel=$(a) /p:AndroidPlatformId=$(word $(a), $(ALL_PLATFORM_IDS)) /p:AndroidFrameworkVersion=$${CUR_VERSION} \ /p:AndroidPreviousFrameworkVersion=$${PREV_VERSION}; ) \ - PREV_VERSION=$${CUR_VERSION}; ) \ + PREV_VERSION=$${CUR_VERSION}; ) $(foreach conf, $(CONFIGURATIONS), \ rm -f bin/$(conf)/lib/xbuild-frameworks/MonoAndroid/v1.0/Xamarin.Android.NUnitLite.dll; \ $(MSBUILD) $(MSBUILD_FLAGS) src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj /p:Configuration=$(conf) $(_MSBUILD_ARGS) \ /p:AndroidApiLevel=$(firstword $(API_LEVELS)) /p:AndroidPlatformId=$(word $(firstword $(API_LEVELS)), $(ALL_PLATFORM_IDS)) /p:AndroidFrameworkVersion=$(firstword $(FRAMEWORKS)); ) - -runtime-libraries: + _latest_framework=$$($(MSBUILD) /p:DoNotLoadOSProperties=True /nologo /v:minimal /t:GetAndroidLatestFrameworkVersion build-tools/scripts/Info.targets | tr -d '[[:space:]]') ; \ $(foreach conf, $(CONFIGURATIONS), \ - $(MSBUILD) $(MSBUILD_FLAGS) /p:Configuration=$(conf) $(_MSBUILD_ARGS) $(SOLUTION); ) + rm -f "bin/$(conf)/lib/xbuild-frameworks/MonoAndroid/$$_latest_framework"/OpenTK-1.0.* ; \ + $(MSBUILD) $(MSBUILD_FLAGS) src/OpenTK-1.0/OpenTK.csproj /p:Configuration=$(conf) $(_MSBUILD_ARGS) \ + /p:AndroidApiLevel=$(firstword $(API_LEVELS)) /p:AndroidPlatformId=$(word $(firstword $(API_LEVELS)), $(ALL_PLATFORM_IDS)) /p:AndroidFrameworkVersion=$(firstword $(FRAMEWORKS)); ) opentk-jcw: $(foreach a, $(API_LEVELS), \ $(foreach conf, $(CONFIGURATIONS), \ touch bin/$(conf)/lib/xbuild-frameworks/MonoAndroid/*/OpenTK-1.0.dll; \ - $(MSBUILD) $(MSBUILD_FLAGS) src/OpenTK-1.0/OpenTK.csproj /t:GenerateJavaCallableWrappers /p:Configuration=$(conf) $(_MSBUILD_ARGS) /p:AndroidApiLevel=$(a) /p:AndroidPlatformId=$(word $(a), $(ALL_PLATFORM_IDS)) /p:AndroidFrameworkVersion=$(word $(a), $(ALL_FRAMEWORKS)); )) + $(MSBUILD) $(MSBUILD_FLAGS) src/OpenTK-1.0/OpenTK.csproj /t:GenerateJavaCallableWrappers /p:Configuration=$(conf) $(_MSBUILD_ARGS) \ + /p:AndroidApiLevel=$(a) /p:AndroidPlatformId=$(word $(a), $(ALL_PLATFORM_IDS)) /p:AndroidFrameworkVersion=$(word $(a), $(ALL_FRAMEWORKS)); )) _BUNDLE_ZIPS_INCLUDE = \ $(ZIP_OUTPUT_BASENAME)/bin/Debug \ diff --git a/build-tools/scripts/Info.targets b/build-tools/scripts/Info.targets index 45b9ace6662..d99dac7038a 100644 --- a/build-tools/scripts/Info.targets +++ b/build-tools/scripts/Info.targets @@ -7,4 +7,10 @@ Importance="High" /> + + + diff --git a/src/OpenTK-1.0/OpenTK.csproj b/src/OpenTK-1.0/OpenTK.csproj index b147cd3c66d..c4b33c22d82 100644 --- a/src/OpenTK-1.0/OpenTK.csproj +++ b/src/OpenTK-1.0/OpenTK.csproj @@ -600,7 +600,7 @@ 1.8 1.6 $(JavaCallableWrapperOutputPathAbs)$(AssemblyName).dll - $(MSBuildProjectDirectory)\..\..\bin\$(Configuration)\lib\xbuild-frameworks\MonoAndroid\$(AndroidLatestFrameworkVersion)\$(AssemblyName).dll + $(MSBuildProjectDirectory)\$(IntermediateOutputPath)\$(AssemblyName).dll