Skip to content

Commit

Permalink
Bump to xamarin/Java.Interop/master@56c92c70 (#4376)
Browse files Browse the repository at this point in the history
Changes: dotnet/java-interop@1a086ff...56c92c7

  * dotnet/java-interop@56c92c7: [build] Remove cecil submodule (#597)
  * dotnet/java-interop@3091274: [build] Provide a default $(Configuration) value (#612)
  * dotnet/java-interop@cf3e7c2: [generator] Don't process duplicate reference assemblies (#611)
  * dotnet/java-interop@f5fa462: [jnienv-gen] Convert to SDK-style (#608)

Of particular note is [dotnet/java-interop@56c92c7][0], which
replaces the `mono/cecil` submodule within Java.Interop with the
[`Mono.Cecil` NuGet package][1] in an effort to simplify the
Java.Interop build system.

This simplifies the Java.Interop repo, and we *thought* that since
xamarin-android *doesn't even use* Java.Interop's cecil submodule-built
`Mono.Cecil.dll` -- instead the `Mono.Cecil.dll` from the
"mono archive" is "renamed" to `Xamarin.Android.Cecil.dll` during
`make prepare` (0c9f83b) -- surely this would be a simple change.

The removal of the cecil submodule also required changing
`ThirdPartyNotice.txt` generation so that the LICENSE for Cecil was
obtained from the mono archive instead of from Java.Interop.

Unfortunately, the integration was a tad more complicated than
anticipated.  With the ongoing adoption of MSBuild multi-targeting
and builds against the `netcoreapp3.1` target framework -- commit
e2854ee and numerous commits in Java.Interop -- we encountered a
problem with MSBuild semantics: If two `$(TargetFramework)` builds
share the same output directory, the `IncrementalClean` target will
*remove files created by previous builds*, e.g. when e.g.
`Java.Interop/tools/generator.csproj` builds the `netcoreapp3.1`
framework, it will *delete* the `generator.exe` built by the `net472`
framework, which results in subsequent build breaks.

The only path to sanity is to *ensure* that different
`$(TargetFramework)` builds have *completely separate* `$(OutputPath)`
values.  The "normal" approach to doing this is for `$(OutputPath)`
to end with `$(TargetFramework)`, which is the case when
`$(AppendTargetFrameworkToOutputPath)`=True (the default).

Unfortunately in xamarin-android we don't want `$(OutputPath)` to end
with `$(TargetFramework)`; we want the build tree structure to mirror
the installation directory structure, which -- at present -- doesn't
mention `$(TargetFramework)` at all.

The solution here is to use "non-overlapping" directories.  For
example, in e2854ee there are "two" `$(OutputPath)` values:

  * `MonoAndroid10.0`: `bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v10.0/Mono.Android.dll`
  *   `netcoreapp3.1`: `bin/Debug/lib/xamarin.android/xbuild-frameworks/Xamarin.Android.App/netcoreapp3.1/Mono.Android.dll`

The same "non-overlapping directories" strategy needs to be extended
to *all* multi-targeted projects from Java.Interop, *including*
dependencies.  Dependencies such as `Xamarin.Android.Cecil.dll`.

Define a new `$(UtilityOutputFullPathCoreApps)` MSBuild property so
that Java.Interop "utility" project builds, when building for the
`netcoreapp3.1` framework, use a *different* `Xamarin.Android.Cecil.dll`
than is used with the `net472`-related builds.

Update `xaprepare` to *create* this new `netcoreapp3.1`-correlated
`Xamarin.Android.Cecil.dll`.  It's the same file, just in a different
directory, to prevent "accidental" deletes by `IncrementalClean`.

Even with all that, MSBuild still had other ideas.  In particular,
MSBuild wasn't particularly happy about our attempt to use the
`$(UtilityOutputFullPath)` property to "switch" between using a
`@(PackageReference)` to the Mono.Cecil NuGet package vs. using a
`@(Reference)` to the `Xamarin.Android.Cecil.dll` assembly, because
MSBuild *caches* this information somewhere within `obj` directories.

To get MSBuild to re-evaluate it's assembly reference choices, we must
instead replace `msbuild` with `msbuild /restore`.

Which still isn't enough, because some of our MSBuild invocations are
via the `<MSBuild/>` task, within `msbuild`.  To get *that* working,
we need to explicitly invoke the `Restore` target through a *separate*
`<MSBuild/>` task invocation.  You ***CANNOT*** use
`<MSBuild Targets="Restore;Build" />`, as "obvious" as that may be,
because it [doesn't work reliably][2].  ([Yet.][3])

[0]: dotnet/java-interop@56c92c7
[1]: https://www.nuget.org/packages/Mono.Cecil/0.11.2
[2]: dotnet/msbuild#3000 (comment)
[3]: dotnet/msbuild#2811
  • Loading branch information
jonpryor authored Mar 27, 2020
1 parent d2e9a3f commit 295aff2
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Documentation/building/windows/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ MSBuild version 15 or later is required.

7. Build the project:

msbuild Xamarin.Android.sln
msbuild /restore Xamarin.Android.sln

After the solution has built successfully, you can [use your
build][using-your-build] to build Xamarin.Android application and library
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ BOOTSTRAP_BUILD_LOG = bin/Build$(CONFIGURATION)/bootstrap-build.binlog
BOOTSTRAP_MSBUILD_FLAGS = /t:Restore,Build /binaryLogger:"$(BOOTSTRAP_BUILD_LOG)" $(PREPARE_COMMON_MSBUILD_FLAGS)

all:
$(call MSBUILD_BINLOG,all,$(_SLN_BUILD)) $(MSBUILD_FLAGS) $(SOLUTION)
$(call MSBUILD_BINLOG,all,$(_SLN_BUILD)) /restore $(MSBUILD_FLAGS) $(SOLUTION)

-include bin/Build$(CONFIGURATION)/rules.mk

Expand Down
14 changes: 0 additions & 14 deletions Xamarin.Android.sln
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK", "src\OpenTK-1.0\Op
{3F1F2F50-AF1A-4A5A-BEDB-193372F068D7} = {3F1F2F50-AF1A-4A5A-BEDB-193372F068D7}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Cecil", "external\Java.Interop\src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.csproj", "{15945D4B-FF56-4BCC-B598-2718D199DD08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Cecil.Mdb", "external\Java.Interop\src\Xamarin.Android.Cecil\Xamarin.Android.Cecil.Mdb.csproj", "{C0487169-8F81-497F-919E-EB42B1D0243F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "proguard", "src\proguard\proguard.csproj", "{4B9D96BB-95AB-44E8-9F87-13B12C8BCED1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "api-xml-adjuster", "build-tools\api-xml-adjuster\api-xml-adjuster.csproj", "{8A6CB07C-E493-4A4F-AB94-038645A27118}"
Expand Down Expand Up @@ -263,14 +259,6 @@ Global
{5EB9E888-E357-417E-9F39-DDEC195CE47F}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{5EB9E888-E357-417E-9F39-DDEC195CE47F}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{5EB9E888-E357-417E-9F39-DDEC195CE47F}.Release|AnyCPU.Build.0 = Release|Any CPU
{15945D4B-FF56-4BCC-B598-2718D199DD08}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{15945D4B-FF56-4BCC-B598-2718D199DD08}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{15945D4B-FF56-4BCC-B598-2718D199DD08}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{15945D4B-FF56-4BCC-B598-2718D199DD08}.Release|AnyCPU.Build.0 = Release|Any CPU
{C0487169-8F81-497F-919E-EB42B1D0243F}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{C0487169-8F81-497F-919E-EB42B1D0243F}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{C0487169-8F81-497F-919E-EB42B1D0243F}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{C0487169-8F81-497F-919E-EB42B1D0243F}.Release|AnyCPU.Build.0 = Release|Any CPU
{4B9D96BB-95AB-44E8-9F87-13B12C8BCED1}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{4B9D96BB-95AB-44E8-9F87-13B12C8BCED1}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{4B9D96BB-95AB-44E8-9F87-13B12C8BCED1}.Release|AnyCPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -417,8 +405,6 @@ Global
{7387E151-48E3-4885-B2CA-A74434A34045} = {864062D3-A415-4A6F-9324-5820237BA058}
{B8F799C5-D7CE-4E09-9CE6-BAA4173E7EC8} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{5EB9E888-E357-417E-9F39-DDEC195CE47F} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{15945D4B-FF56-4BCC-B598-2718D199DD08} = {864062D3-A415-4A6F-9324-5820237BA058}
{C0487169-8F81-497F-919E-EB42B1D0243F} = {864062D3-A415-4A6F-9324-5820237BA058}
{4B9D96BB-95AB-44E8-9F87-13B12C8BCED1} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{8A6CB07C-E493-4A4F-AB94-038645A27118} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62}
{E0890301-F75F-40E7-B008-54C28B3BA542} = {864062D3-A415-4A6F-9324-5820237BA058}
Expand Down
3 changes: 2 additions & 1 deletion build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ stages:
inputs:
solution: Xamarin.Android.sln
configuration: $(XA.Build.Configuration)
msbuildArguments: /t:Build /bl:$(System.DefaultWorkingDirectory)\bin\Build$(XA.Build.Configuration)\msbuild-build.binlog
msbuildArguments: /restore /t:Build /bl:$(System.DefaultWorkingDirectory)\bin\Build$(XA.Build.Configuration)\msbuild-build.binlog

- task: MSBuild@1
displayName: msbuild create-vsix
Expand Down Expand Up @@ -307,6 +307,7 @@ stages:
solution: Xamarin.Android.sln
configuration: $(XA.Build.Configuration)
msbuildArguments: >
/restore
/t:RunJavaInteropTests
/p:TestAssembly="bin\Test$(XA.Build.Configuration)\generator-Tests.dll;bin\Test$(XA.Build.Configuration)\Java.Interop.Tools.JavaCallableWrappers-Tests.dll;bin\Test$(XA.Build.Configuration)\logcat-parse-Tests.dll;bin\Test$(XA.Build.Configuration)\Xamarin.Android.Tools.ApiXmlAdjuster-Tests.dll;bin\Test$(XA.Build.Configuration)\Xamarin.Android.Tools.Bytecode-Tests.dll"
/bl:$(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\msbuild-run-ji-tests.binlog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ steps:
solution: ${{ parameters.project }}
configuration: ${{ parameters.configuration }}
msbuildArguments: >
/restore
/t:AcquireAndroidTarget,SignAndroidPackage,DeployTest${{ parameters.packageType }}s,RecordApkSizes,RunTestApks,UndeployTestApks,RenameApkTestCases,ReportComponentFailures
/bl:$(System.DefaultWorkingDirectory)/bin/Test${{ parameters.configuration }}/run${{ parameters.testName }}.binlog
${{ parameters.extraBuildArgs }}
Expand Down
2 changes: 1 addition & 1 deletion build-tools/scripts/BuildEverything.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ endif
leeroy: leeroy-all framework-assemblies opentk-jcw

leeroy-all:
$(call MSBUILD_BINLOG,leeroy-all,$(_SLN_BUILD)) $(SOLUTION) /p:Configuration=$(CONFIGURATION) $(_MSBUILD_ARGS)
$(call MSBUILD_BINLOG,leeroy-all,$(_SLN_BUILD)) /restore $(SOLUTION) /p:Configuration=$(CONFIGURATION) $(_MSBUILD_ARGS)

opentk-jcw:
$(foreach api_level, $(API_LEVELS), \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<CecilSourceDirectory>$(MSBuildThisFileDirectory)..\..\external\mono\external\cecil</CecilSourceDirectory>
<UtilityOutputFullPath>$(MSBuildThisFileDirectory)..\..\bin\$(Configuration)\lib\xamarin.android\xbuild\Xamarin\Android\</UtilityOutputFullPath>
<UtilityOutputFullPathCoreApps>$(MSBuildThisFileDirectory)..\..\bin\$(Configuration)-netcoreapp3.1\</UtilityOutputFullPathCoreApps>
<XamarinAndroidToolsDirectory>$(MSBuildThisFileDirectory)..\..\external\xamarin-android-tools</XamarinAndroidToolsDirectory>
</PropertyGroup>
</Project>
6 changes: 6 additions & 0 deletions build-tools/scripts/RunTests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
/>
</Target>
<Target Name="RunJavaInteropTests">
<MSBuild
Condition=" '$(HostOS)' == 'Windows' "
Projects="$(JavaInteropSourceDirectory)\Java.Interop.sln"
Properties="_IsRestoring=true"
Targets="Restore"
/>
<MSBuild
Condition=" '$(HostOS)' == 'Windows' "
ContinueOnError="ErrorAndContinue"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ public static partial class Paths

public static string TestBinDir => GetCachedPath (ref testBinDir, () => Path.Combine (Configurables.Paths.BinDirRoot, $"Test{ctx.Configuration}"));
public static string BinDir => GetCachedPath (ref binDir, () => Path.Combine (Configurables.Paths.BinDirRoot, ctx.Configuration));
public static string NetCoreBinDir => GetCachedPath (ref binDir, () => Path.Combine (Configurables.Paths.BinDirRoot, $"{ctx.Configuration}-netcoreapp3.1"));
public static string BuildBinDir => GetCachedPath (ref buildBinDir, () => Path.Combine (Configurables.Paths.BinDirRoot, $"Build{ctx.Configuration}"));
public static string MingwBinDir => GetCachedPath (ref mingwBinDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidMxeFullPath), "bin"));
public static string ProfileAssembliesProjitemsPath => GetCachedPath (ref profileAssembliesProjitemsPath, () => Path.Combine (BuildBinDir, "ProfileAssemblies.projitems"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ async Task<bool> ConjureXamarinCecilAndRemapRef (Context context, bool haveManag
return false;
}

Utilities.CreateDirectory (Configurables.Paths.NetCoreBinDir);
Utilities.CopyFile (assemblyPath, Path.Combine (Configurables.Paths.NetCoreBinDir, "Xamarin.Android.Cecil.dll"));

StatusStep (context, "Re-signing Xamarin.Android.Cecil.Mdb.dll");
assemblyPath = Path.Combine (Configurables.Paths.BuildBinDir, "Xamarin.Android.Cecil.Mdb.dll");
result = await sn.ReSign (snkPath, assemblyPath, $"sign-xamarin-android-cecil-mdb");
Expand All @@ -132,6 +135,8 @@ async Task<bool> ConjureXamarinCecilAndRemapRef (Context context, bool haveManag
return false;
}

Utilities.CopyFile (assemblyPath, Path.Combine (Configurables.Paths.NetCoreBinDir, "Xamarin.Android.Cecil.Mdb.dll"));

return true;
}

Expand Down
12 changes: 0 additions & 12 deletions build-tools/xaprepare/xaprepare/ThirdPartyNotices/Java.Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class JavaInterop_External_Dependencies_Group : ThirdPartyNoticeGroup
public override List<ThirdPartyNotice> Notices => new List <ThirdPartyNotice> {
new JavaInterop_xamarin_Java_Interop_TPN (),
new JavaInterop_gityf_crc_TPN (),
new JavaInterop_xamarin_mono_cecil_TPN (),
new JavaInterop_jbevain_mono_linq_expressions_TPN (),
new JavaInterop_mono_csharp_TPN (),
new JavaInterop_mono_LineEditor_TPN (),
Expand Down Expand Up @@ -71,17 +70,6 @@ POSSIBILITY OF SUCH DAMAGE.
}

// git submodules of Java.Interop
class JavaInterop_xamarin_mono_cecil_TPN : ThirdPartyNotice
{
static readonly Uri url = new Uri ("https://github.com/mono/cecil/");
static readonly string licenseFile = Path.Combine (Configurables.Paths.ExternalJavaInteropDir, "external", "cecil", "LICENSE.txt");

public override string LicenseFile => licenseFile;
public override string Name => "mono/cecil";
public override Uri SourceUrl => url;
public override string LicenseText => null;
}

class JavaInterop_jbevain_mono_linq_expressions_TPN : ThirdPartyNotice
{
static readonly Uri url = new Uri ("https://github.com/jbevain/mono.linq.expressions/");
Expand Down
12 changes: 12 additions & 0 deletions build-tools/xaprepare/xaprepare/ThirdPartyNotices/mono.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class mono_External_Dependencies_Group : ThirdPartyNoticeGroup

public override List<ThirdPartyNotice> Notices => new List <ThirdPartyNotice> {
new mono_mono_mono_TPN (),
new mono_mono_cecil_TPN (),
new mono_mono_boringssl_TPN (),
new mono_mono_ikdasm_TPN (),
new mono_mono_ikvm_fork_TPN (),
Expand All @@ -23,6 +24,17 @@ class mono_External_Dependencies_Group : ThirdPartyNoticeGroup
};
}

class mono_mono_cecil_TPN : ThirdPartyNotice
{
static readonly Uri url = new Uri ("https://github.com/mono/cecil/");
static readonly string licenseFile = Path.Combine (Configurables.Paths.MonoSdksTpnPath, "external", "cecil", "LICENSE.txt");

public override string LicenseFile => licenseFile;
public override string Name => "mono/cecil";
public override Uri SourceUrl => url;
public override string LicenseText => null;
}

class mono_mono_mono_TPN : ThirdPartyNotice
{
static readonly Uri url = new Uri ("https://github.com/mono/");
Expand Down
2 changes: 1 addition & 1 deletion external/Java.Interop

0 comments on commit 295aff2

Please sign in to comment.