Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix native code generation when marshal methods are disabled #7899

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ void AddEnvironment ()
Log
);
} else {
marshalMethodsAsmGen = new MarshalMethodsNativeAssemblyGenerator (uniqueAssemblyNames);
marshalMethodsAsmGen = new MarshalMethodsNativeAssemblyGenerator (assemblyCount, uniqueAssemblyNames);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is assemblyCount != uniqueAssemblyNames.Count? In what instances will assemblyCount be greater than uniqueAssemblyNames.Count? I guess UseAssemblyStore? https://github.com/xamarin/xamarin-android/blob/54a3f6e0bedc9f9b204a535aaf0f664e22285119/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs#L272-L275

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's the assembly stores case

}
marshalMethodsAsmGen.Init ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static class KnownProperties
public const string AndroidUseLatestPlatformSdk = "AndroidUseLatestPlatformSdk";
public const string AndroidUseAapt2 = "AndroidUseAapt2";
public const string AndroidCreatePackagePerAbi = "AndroidCreatePackagePerAbi";
public const string AndroidEnableMarshalMethods = "AndroidEnableMarshalMethods";

public const string AndroidSupportedAbis = "AndroidSupportedAbis";
public const string RuntimeIdentifier = "RuntimeIdentifier";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ public AndroidLinkMode AndroidLinkModeRelease {
set { SetProperty (ReleaseProperties, KnownProperties.AndroidLinkMode, value.ToString ()); }
}

public bool EnableMarshalMethods {
get { return string.Equals (GetProperty (KnownProperties.AndroidEnableMarshalMethods), "True", StringComparison.OrdinalIgnoreCase); }
set { SetProperty (KnownProperties.AndroidEnableMarshalMethods, value.ToString ()); }
}

public string AndroidManifest { get; set; }
public string LayoutMain { get; set; }
public string MainActivity { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ sealed class MarshalMethodName
/// <summary>
/// Constructor to be used ONLY when marshal methods are DISABLED
/// </summary>
public MarshalMethodsNativeAssemblyGenerator (ICollection<string> uniqueAssemblyNames)
public MarshalMethodsNativeAssemblyGenerator (int numberOfAssembliesInApk, ICollection<string> uniqueAssemblyNames)
{
this.numberOfAssembliesInApk = numberOfAssembliesInApk;
this.uniqueAssemblyNames = uniqueAssemblyNames ?? throw new ArgumentNullException (nameof (uniqueAssemblyNames));
generateEmptyCode = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Teardown ()
}

[Test]
public void NativeAssemblyCacheWithSatelliteAssemblies ()
public void NativeAssemblyCacheWithSatelliteAssemblies ([Values (true, false)] bool enableMarshalMethods)
{
var path = Path.Combine ("temp", TestName);
var lib = new XamarinAndroidLibraryProject {
Expand All @@ -49,6 +49,7 @@ public void NativeAssemblyCacheWithSatelliteAssemblies ()

proj = new XamarinAndroidApplicationProject {
IsRelease = true,
EnableMarshalMethods = enableMarshalMethods,
};
proj.References.Add (new BuildItem.ProjectReference ($"..\\{lib.ProjectName}\\{lib.ProjectName}.csproj", lib.ProjectName, lib.ProjectGuid));
proj.SetAndroidSupportedAbis ("armeabi-v7a", "arm64-v8a", "x86", "x86_64");
Expand Down