-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
android: Added android_usecase kwargs to executable #13767
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
Conversation
306eeec to
fa774c2
Compare
|
Could you not already do this with the |
|
Perhaps. However my goal is to have a builder tool that you can just point at a meson project to create an apk from. While you still have to modify your meson sources and to add the android_usecase, it seems less invasive than doing having users switch their excecutables to What about adding a |
|
Since you seem to have knowledge about this could you answer some questions I have about this? How are Android applications actually done? FWICT it used to be the case that you could not have actual executables, instead it needed to be a shared library which you then opened from the Java side with whatever the equivalent of |
|
It was always possible to have actual 'executables' on Android. Its just Linux after all and The thing is that users usually don't interact with them directly (outside of developers using
No, you can make executables not applications. Applications are still special (Zygote) and need Java (ART) to interact with the stable OS interfaces provided. My work of porting GTK to Android proper, needs an "Application" to work with and essentially works by having glue expose the proper JNI symbol and then calls |
|
Why don't you simply add a user option or a property to the cross file, and use it for the target type? |
My idea was need as little changes as possible to the meson files of existing applications and this was just my initial attempt. A better (but gtk specific solution) is proposed in #13800. It cuts down the currently needed |
|
So, basically, the actual thing that you need to get is "build this target as an executable on all other platforms, but as a shared library in Android"? Are there any other use cases that need to be covered? If true, then this could be implemented in one of several ways:
The kwarg in this MR is similar to how |
There should be some mechanism that link-wholes a glue library (that provides the JNI entry function symbol) into the shared library. The idea I had originally for this MR was to have the ability to specify the dependency name in the cross file, but I didn't really look into how to implement it specifically. Obv. the alternative GNOME/GTK specific PR doesn't need that as it can just lookup the
That was the idea behind it :) |
|
I'm not very fond of the name |
|
Sure, About the issue of needing to include glue code: I've taken a closer look at how QT does it, and it looks like they initialize themselves in the I think I should be able to implement a similar mechanism for GTK, which means the the changes of this MR would be enough to make it acceptably work. The downsides of this however would be:
EDIT: I'm seemingly not able to get the symbol visible with a version script, as a) it seemingly only operates on non-hidden symbols, so it seemingly fully ignores main and b) it hides all the other symbols that were previously explicitly marked visible. Any ideas if this can somehow be fixed without requiring the main function to be annotated with attribute(visibility(default))? |
|
Assuming we merge this can the listed issues be fixed later once they actually come up without breaking bw compatibility with this change? |
|
The only real issue that can be fixed is the one about the hidden main symbol (the other ones are more "technical limitations" one has to live with). The hidden main symbol should be fixed however (as the problem will be encountered immediately due to the gtk4-demo) because adding I've wondered if it may be possible to generate and add with |
|
Can the change be done basically with this: If yes, this seems like the simplest solution. |
|
Sure that'd work too (realistically the __ANDROID__ isn't even needed), but it would require affected users to update their code. |
b25cd54 to
6075319
Compare
6075319 to
1cab7e4
Compare
|
Another thing that came to mind. Would it be possible to implement this in a simpler way? Namely:
This would save us from adding a lot of |
|
Sure, that might work too. It would however require us to strip any executable specific kwargs (gui_app, win_subsystem, export_dynamic?), not just android_exe_type, as shared_library would complain about it otherwise I guess I can just hard code them for now, but the current solution with what kwargs apply to specific targets compared to all targets (and build_target) isn't particularly scalable. |
|
There should be a named method like |
|
I'm facing a weird issue with that, and I suspect its due to annotation magic which I don't understand. I have: def _strip_exe_specific_kwargs(self, kwargs: kwtypes.Executable) -> kwtypes._BuildTarget:
kwargs = kwargs.copy()
for exe_kwarg in _EXCLUSIVE_EXECUTABLE_KWS:
del kwargs[exe_kwarg.name]
return kwargs
@permittedKwargs(build.known_exe_kwargs)
@typed_pos_args('executable', str, varargs=SOURCES_VARARGS)
@typed_kwargs('executable', *EXECUTABLE_KWS, allow_unknown=True)
def func_executable(self, node: mparser.BaseNode,
args: T.Tuple[str, SourcesVarargsType],
kwargs: kwtypes.Executable) -> build.Executable:
for_machine = kwargs['native']
m = self.environment.machines[for_machine]
if m.is_android() and kwargs.get('android_exe_type') == 'application':
return self.func_shared_lib(node, args, self._strip_exe_specific_kwargs(kwargs))
return self.build_target(node, args, kwargs, build.Executable)
[...]
@permittedKwargs(build.known_shlib_kwargs)
@typed_pos_args('shared_library', str, varargs=SOURCES_VARARGS)
@typed_kwargs('shared_library', *SHARED_LIB_KWS, allow_unknown=True)
def func_shared_lib(self, node: mparser.BaseNode,
args: T.Tuple[str, SourcesVarargsType],
kwargs: kwtypes.SharedLibrary) -> build.SharedLibrary:
holder = self.build_target(node, args, kwargs, build.SharedLibrary)
holder.shared_library_only = True
return holderbut running the testcase results in the following: any idea why? |
You cannot call |
1cab7e4 to
9db83b6
Compare
|
that assert needs to be And please do use the set, the python byte compiler can do some optimization around that which makes the lookup faster. |
dcbaker
left a comment
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.
Thanks for making those changes, with the CI turned green this looks good to me.
|
@dcbaker I've seen that. I'm just wondering why its necessary, given that |
If the key is not in dict, |
|
In case this won't be ready for rc1, it can be merged after that. |
9db83b6 to
ff74796
Compare
executable did not respect the name_prefix kwarg
d8836c1 to
15f5c6d
Compare
whats the release schedule like? Any chance I can get #13854 looked at before release? I could work around it (by running |
By setting android_exe_type to `application`, the executable gets actually built as a shared library instead of an executable. This makes it possible to use an application within an android application process. mesonbuild#13758 https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7555/
15f5c6d to
f8a27cd
Compare
Release freeze starts when rc1 is tagged and published. Roughly ~weekly release candidates until we are happy with the results and ready for final release. Only bugfixes and documentation changes allowed for the most part, new features need an explicit Release Freeze exemption from @jpakkane. That PR you linked may be safe to backport though, even if it misses the final release. |
This is the idea I've came up with in regards to #13758
It doesn't do anything regarding application glue right now, as I'm unsure if and how to implement it, but I thought about it some more and belive having it would simplify things quite a bit.
By setting android_usecase to
application, the executable gets actually built as a shared library instead of an executable. This makes it possible to use an application within an android application process.https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7555/