-
Notifications
You must be signed in to change notification settings - Fork 564
[Xamarin.Android.Build.Tasks] Generate marshal methods for user assem… #1751
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
[Xamarin.Android.Build.Tasks] Generate marshal methods for user assem… #1751
Conversation
…blies Use `jnimarshalmethod-gen` on resolved user assemblies. As a preview feature it is conditional and only enabled when `JniMarshalMethods` is True. This feature implements main part of https://github.com/xamarin/xamarin-android/projects/1
|
It requires these PRs to be merged first: #1739 and dotnet/java-interop#321 |
| </Target> | ||
|
|
||
| <Target Name="_GenerateJniMarshalMethods" | ||
| Condition="'$(JniMarshalMethods)' == 'True' And '$(Configuration)' == 'Release' And '$(AndroidLinkMode)' != 'None'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, $(JniMarshalMethods) does appear to control generation as well, wrt #1745 (comment).
Thus, $(AndroidGenerateJniMarshalMethods) seems appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Convention (also not followed consistently, but let's not make it worse):
For XML, attributes are indented one "tab stop" more than child elements. Additionally, prefer spaces over tabs, and use two-space "tab stops". Thus:
<Target Name="_GenerateJniMarshalMethods"
Condition=" '$(AndroidGenerateJniMarshalMethods)' == 'True' And '$(Configuration)' == 'Release' And '$(AndroidLinkMode)' != 'None' "
DependsOnTargets="_GetReferenceAssemblyPaths"
Inputs="@(ResolvedUserAssemblies->'$(MonoAndroidLinkerInputDir)%(Filename)%(Extension)')"
Outputs="$(_AndroidJniMarshalMethodsFlag)">
<Exec
Command="MONO_PATH=$(_XATargetFrameworkDirectories) $(MonoAndroidBinDirectory)\mono $(MonoAndroidBinDirectory)\..\jnimarshalmethod-gen.exe @(ResolvedUserAssemblies->'$(MonoAndroidLinkerInputDir)%(Filename)%(Extension)')"
/>
</Target>There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not use '$(Configuration)' == 'Release'. $(Configuration) values are convention, and developers are able to add arbitrary names. (For example, Java.Interop had a XAIntegrationRelease configuration for quite some time.)
Any check against $(Configuration) is a "code smell." (I think we still have one anyway -- though I can't currently find it -- but, again, we shouldn't make things worse.)
| Outputs="$(_AndroidJniMarshalMethodsFlag)"> | ||
|
|
||
| <Exec | ||
| Command="MONO_PATH=$(_XATargetFrameworkDirectories) $(MonoAndroidBinDirectory)\mono $(MonoAndroidBinDirectory)\..\jnimarshalmethod-gen.exe @(ResolvedUserAssemblies->'$(MonoAndroidLinkerInputDir)%(Filename)%(Extension)')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we also need to update the GetMonoBundleItems target within src/mono-runtimes/mono-runtimes.targets so that mono is included in the bundle*.zip file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$(_XATargetFrameworkDirectories) should be quoted, in case it contains spaces:
Command="MONO_PATH="$(_XATargetFrameworkDirectories)" ...Additionally, I believe that $(_XATargetFrameworkDirectories) will be incomplete: it should contain only the directories (directory) for MonoAndroid,Version=v1.0, which will not be a directory which contains Mono.Android.dll.
For example (from a random full xamarin-android build log I have lying around):
Task "ResolveSdks" (TaskId:1387)
...
Task Parameter:ReferenceAssemblyPaths=/Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0/ (TaskId:1387)
...
Output Property: _XATargetFrameworkDirectories=/Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0/ (TaskId:1387)
If e.g. .../xbuild-frameworks/MonoAndroid/v8.1 isn't included, how will Mono.Android.dll be found?
Alternatively, perhaps MONO_PATH should be set to $(MonoAndroidLinkerInputDir) and called after that directory has been setup, e.g. after _CopyIntermediateAssemblies?
|
This PR should also pick a project to have |
|
Superseded by #2153 |
…blies
Use
jnimarshalmethod-genon resolved user assemblies. As a previewfeature it is conditional and only enabled when
JniMarshalMethodsisTrue.
This feature implements main part of
https://github.com/xamarin/xamarin-android/projects/1