From 2cef9a1db0056a25f8185b68c5defbd5edbca496 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Mon, 20 Dec 2021 17:11:44 -0500 Subject: [PATCH 1/3] [WIP] More dotnet build support for unix --- Makefile | 6 ++--- ...amarin.Android.Tools.BootstrapTasks.csproj | 24 +++++++++++++++++++ build-tools/scripts/BuildEverything.mk | 4 ++-- build-tools/scripts/Packaging.mk | 6 +++-- .../Application/GeneratedMakeRulesFile.cs | 8 +++---- external/debugger-libs | 2 +- .../Xamarin.Android.Build.Tasks.targets | 3 +-- .../MSBuildDeviceIntegration.targets | 2 +- 8 files changed, 40 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 27a9f29441b..3908a60f030 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ _PREPARE_CI_MODE_ARGS = $(_PREPARE_CI_MODE_PR_ARGS) -a _PREPARE_ARGS = all: - $(call MSBUILD_BINLOG,all,$(_SLN_BUILD)) /restore $(MSBUILD_FLAGS) $(SOLUTION) + $(call DOTNET_BINLOG,all) $(MSBUILD_FLAGS) $(SOLUTION) -m:1 $(call MSBUILD_BINLOG,all,$(_SLN_BUILD)) /restore $(MSBUILD_FLAGS) tools/xabuild/xabuild.csproj -include bin/Build$(CONFIGURATION)/rules.mk @@ -97,7 +97,7 @@ all-tests:: MSBUILD="$(MSBUILD)" $(call MSBUILD_BINLOG,all-tests,tools/scripts/xabuild) /restore $(MSBUILD_FLAGS) Xamarin.Android-Tests.sln pack-dotnet:: - $(call MSBUILD_BINLOG,pack-dotnet,$(_SLN_BUILD)) $(MSBUILD_FLAGS) Xamarin.Android.sln /t:PackDotNet + $(call DOTNET_BINLOG,pack-dotnet) $(MSBUILD_FLAGS) $(SOLUTION) -m:1 -t:PackDotNet install:: @if [ ! -d "bin/$(CONFIGURATION)" ]; then \ @@ -141,7 +141,7 @@ run-all-tests: exit $$_r clean: - $(call MSBUILD_BINLOG,clean) /t:Clean Xamarin.Android.sln + $(call DOTNET_BINLOG,clean) -t:Clean $(SOLUTION) -m:1 tools/scripts/xabuild $(MSBUILD_FLAGS) /t:Clean Xamarin.Android-Tests.sln distclean: diff --git a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj index f9dbf9a4984..c01ea666449 100644 --- a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj +++ b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj @@ -19,4 +19,28 @@ + + + + <_MonoUnixDylib Include="$(PkgMono_Unix)\runtimes\osx-arm64\native\libMono.Unix.dylib" Condition=" '$(HostOS)' == 'Darwin' " /> + <_MonoUnixDylib Include="$(PkgMono_Unix)\runtimes\osx-x64\native\libMono.Unix.dylib" /> + + + <_MonoUnixOutputDylib>$(OutputPath)$(TargetFrameworkNETStandard)\libMono.Unix.dylib + + + + + + diff --git a/build-tools/scripts/BuildEverything.mk b/build-tools/scripts/BuildEverything.mk index 27c5d96bcb8..6e34f03fdfa 100644 --- a/build-tools/scripts/BuildEverything.mk +++ b/build-tools/scripts/BuildEverything.mk @@ -22,10 +22,10 @@ ifneq ("$(wildcard $(topdir)/external/monodroid/Makefile)","") cd $(topdir)/external/monodroid && ./configure --with-xamarin-android='$(topdir)' cd $(topdir)/external/monodroid && $(MAKE) build-monodroid CONFIGURATION=$(CONFIGURATION) XAMARIN_ANDROID_PATH=$(topdir) endif - $(MAKE) leeroy $(ZIP_OUTPUT) + $(MAKE) leeroy leeroy: leeroy-all framework-assemblies leeroy-all: - $(call MSBUILD_BINLOG,leeroy-all,$(_SLN_BUILD)) /restore $(SOLUTION) /p:Configuration=$(CONFIGURATION) $(_MSBUILD_ARGS) + $(call DOTNET_BINLOG,leeroy-all) $(SOLUTION) -m:1 $(_MSBUILD_ARGS) $(call MSBUILD_BINLOG,leeroy-all,$(_SLN_BUILD)) /restore tools/xabuild/xabuild.csproj /p:Configuration=$(CONFIGURATION) $(_MSBUILD_ARGS) diff --git a/build-tools/scripts/Packaging.mk b/build-tools/scripts/Packaging.mk index 4d199b1761b..f282cee5b09 100644 --- a/build-tools/scripts/Packaging.mk +++ b/build-tools/scripts/Packaging.mk @@ -11,7 +11,7 @@ create-nupkgs: $(call DOTNET_BINLOG,create-all-packs) -t:CreateAllPacks $(topdir)/build-tools/create-packs/Microsoft.Android.Sdk.proj create-pkg: - MONO_IOMAP=all MONO_OPTIONS="$(MONO_OPTIONS)" $(call MSBUILD_BINLOG,create-pkg) /p:Configuration=$(CONFIGURATION) /t:CreatePkg \ + $(call DOTNET_BINLOG,create-pkg) /t:CreatePkg \ build-tools/create-pkg/create-pkg.csproj \ $(if $(PACKAGE_VERSION),/p:ProductVersion="$(PACKAGE_VERSION)") \ $(if $(PACKAGE_VERSION_REV),/p:XAVersionCommitCount="$(PACKAGE_VERSION_REV)") \ @@ -21,10 +21,12 @@ create-pkg: $(if $(_MSBUILD_ARGS),"$(_MSBUILD_ARGS)") create-workload-installers: - MONO_IOMAP=all MONO_OPTIONS="$(MONO_OPTIONS)" $(call MSBUILD_BINLOG,create-workload-installers) /p:Configuration=$(CONFIGURATION) /t:CreateWorkloadInstallers \ + $(call DOTNET_BINLOG,create-workload-installers) /t:CreateWorkloadInstallers \ Xamarin.Android.sln \ $(if $(_MSBUILD_ARGS),"$(_MSBUILD_ARGS)") +# create-vsix.csproj dependencies do not yet support `dotnet build`: +# .nuget/packages/microsoft.vssdk.buildtools/17.0.4207-preview4/build/Microsoft.VSSDK.BuildTools.targets(16,5): error MSB4801: The task factory "CodeTaskFactory" is not supported on the .NET Core version of MSBuild. create-vsix: MONO_IOMAP=all MONO_OPTIONS="$(MONO_OPTIONS)" $(call MSBUILD_BINLOG,create-vsix) /p:Configuration=$(CONFIGURATION) /p:CreateVsixContainer=True \ build-tools/create-vsix/create-vsix.csproj \ diff --git a/build-tools/xaprepare/xaprepare/Application/GeneratedMakeRulesFile.cs b/build-tools/xaprepare/xaprepare/Application/GeneratedMakeRulesFile.cs index 832ed29a3db..92dee458e3a 100644 --- a/build-tools/xaprepare/xaprepare/Application/GeneratedMakeRulesFile.cs +++ b/build-tools/xaprepare/xaprepare/Application/GeneratedMakeRulesFile.cs @@ -129,8 +129,8 @@ void Generate (Context context, StreamWriter sw) WriteRuleLine ( "if [ $$? -ne 0 ] ; then \\"); WriteRuleLine ($"\trm -f {redistFile}; \\"); WriteRuleLine ( "fi; \\"); - WriteRuleLine ( "$(call MSBUILD_BINLOG,Mono.Android,$(_SLN_BUILD)) src/Mono.Android/Mono.Android.csproj \\"); - WriteRuleLine ( "\t/p:Configuration=$(CONFIGURATION) $(_MSBUILD_ARGS) \\"); + 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;"); @@ -170,8 +170,8 @@ void Generate (Context context, StreamWriter sw) void WriteMSBuildCall (string fileToRemovePath, string projectPath) { WriteRuleLine ($"rm -f {fileToRemovePath}"); - WriteRuleLine ($"$(call MSBUILD_BINLOG,NUnitLite,$(_SLN_BUILD)) $(MSBUILD_FLAGS) {projectPath} \\"); - WriteRuleLine ( "\t/p:Configuration=$(CONFIGURATION) $(_MSBUILD_ARGS) \\"); + 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;"); } diff --git a/external/debugger-libs b/external/debugger-libs index 08268b730a7..c53676b0800 160000 --- a/external/debugger-libs +++ b/external/debugger-libs @@ -1 +1 @@ -Subproject commit 08268b730a73cca0e3b3ac9c703f0b773a3be25b +Subproject commit c53676b08005c806fc170b7be5cda25e52fe9054 diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets index 0340249d051..4eb1d9f42d9 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets @@ -316,8 +316,7 @@ + Outputs="$(IntermediateOutputPath)ILRepacker.stamp" > <_InputAssembliesThatExist Include="@(InputAssemblies)" Condition="Exists('%(Identity)')" /> <_NetstandardPath Include="@(ReferencePath->'%(RootDir)%(Directory)')" Condition="'%(FileName)%(Extension)' == 'netstandard.dll'" /> diff --git a/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.targets b/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.targets index e54084dd29e..2ca5d80cb7c 100644 --- a/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.targets +++ b/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.targets @@ -2,7 +2,7 @@ + Condition=" '$(TargetFramework)' == 'net472' "> <_Source Include="$(OutputPath)Mono.Debugging.Soft.dll"> Mono.Cecil From 31395e44cb91a76983089b0ca58a8ff1aeb2f152 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Wed, 22 Dec 2021 15:47:17 -0500 Subject: [PATCH 2/3] Feedback --- Makefile | 2 +- ...amarin.Android.Tools.BootstrapTasks.csproj | 34 ++++++------------- build-tools/scripts/MonoUnixNative.targets | 30 ++++++++++++++++ .../Xamarin.Android.Build.Tasks.targets | 29 +--------------- 4 files changed, 43 insertions(+), 52 deletions(-) create mode 100644 build-tools/scripts/MonoUnixNative.targets diff --git a/Makefile b/Makefile index 3908a60f030..200c3194174 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ all-tests:: MSBUILD="$(MSBUILD)" $(call MSBUILD_BINLOG,all-tests,tools/scripts/xabuild) /restore $(MSBUILD_FLAGS) Xamarin.Android-Tests.sln pack-dotnet:: - $(call DOTNET_BINLOG,pack-dotnet) $(MSBUILD_FLAGS) $(SOLUTION) -m:1 -t:PackDotNet + $(call DOTNET_BINLOG,pack-dotnet) $(MSBUILD_FLAGS) $(SOLUTION) -t:PackDotNet install:: @if [ ! -d "bin/$(CONFIGURATION)" ]; then \ diff --git a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj index c01ea666449..77744a1cf37 100644 --- a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj +++ b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj @@ -1,4 +1,6 @@ - + + + $(TargetFrameworkNETStandard) @@ -19,28 +21,14 @@ - - - - <_MonoUnixDylib Include="$(PkgMono_Unix)\runtimes\osx-arm64\native\libMono.Unix.dylib" Condition=" '$(HostOS)' == 'Darwin' " /> - <_MonoUnixDylib Include="$(PkgMono_Unix)\runtimes\osx-x64\native\libMono.Unix.dylib" /> - - - <_MonoUnixOutputDylib>$(OutputPath)$(TargetFrameworkNETStandard)\libMono.Unix.dylib + + + + + + $(BuildDependsOn); + _MakeMonoUnixFatBinariesOSX; + - - - - diff --git a/build-tools/scripts/MonoUnixNative.targets b/build-tools/scripts/MonoUnixNative.targets new file mode 100644 index 00000000000..98124596d6c --- /dev/null +++ b/build-tools/scripts/MonoUnixNative.targets @@ -0,0 +1,30 @@ + + + + + + <_MonoUnixDylib Include="$(PkgMono_Unix)\runtimes\osx-arm64\native\libMono.Unix.dylib" Condition=" '$(HostOS)' == 'Darwin' " /> + <_MonoUnixDylib Include="$(PkgMono_Unix)\runtimes\osx-x64\native\libMono.Unix.dylib" /> + + + + <_MonoUnixOutputDylib>$(OutputPath)\libMono.Unix.dylib + + + + + + + + diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets index 4eb1d9f42d9..064581382d5 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets @@ -355,36 +355,9 @@ <_ExtraPackageSource Include="$(PkgMono_Unix)\lib\$(TargetFrameworkNETStandard)\Mono.Unix.dll" /> <_ExtraPackageTarget Include="$(OutputPath)\Mono.Unix.dll" /> - - <_ExtraPackageSource Include="$(PkgMono_Unix)\runtimes\linux-x64\native\libMono.Unix.so" /> - <_ExtraPackageTarget Include="$(OutputPath)\libMono.Unix.so" /> - - - - <_MonoUnixDylib Include="$(PkgMono_Unix)\runtimes\osx-arm64\native\libMono.Unix.dylib" Condition=" '$(HostOS)' == 'Darwin' " /> - <_MonoUnixDylib Include="$(PkgMono_Unix)\runtimes\osx-x64\native\libMono.Unix.dylib" /> - - <_MonoUnixOutputDylib>$(OutputPath)\libMono.Unix.dylib - - - - - - - + Date: Wed, 22 Dec 2021 15:48:12 -0500 Subject: [PATCH 3/3] Formatting --- .../Xamarin.Android.Tools.BootstrapTasks.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj index 77744a1cf37..d3ab591a159 100644 --- a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj +++ b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj @@ -24,7 +24,7 @@ - + $(BuildDependsOn); _MakeMonoUnixFatBinariesOSX;