Open madebr opened 2 years ago
Depending on your answer to https://github.com/google/prefab/issues/159, I think these two are probably the same FR (modeling for runtime-only dependencies).
Duplicate of #159
This is also a run-time dependency, but should only be satisfied when the application really needs it.
e.g. my game needs png support, so needs libpng. But my application does not need tiff support, so does not need libtiff. So I would like some way to make sure libpng is bundled in the .apk and not libtiff.
Oh, and that choice is made at build time?
Okay, I think not strictly a dup then, just closely related. Will reopen to track the optional aspect of runtime dependencies.
Oh, and that choice is made at build time?
Yes, the library must be included at build time.
The dependency here is made in the cmake script.
I'm not 100% sure this is a prefab issue though. If it isn't, can you please show me where to go instead or what alternatives there are?
I haven't thought about it very deeply yet, but I suspect prefab needs to be at least somewhat involved here, if only to pass along metadata to another system like AGP.
How do you envision this being controlled by the consumer? I think this probably ends up being something system-specific in your build script. For CMake this is probably something like https://cmake.org/cmake/help/latest/command/install.html#installing-runtime-dependencies?
install(RUNTIME_DEPENDENCY_SET package::optional-dependency)
install
seems to be how CMakes wants runtime dependencies declared. AGP doesn't currently use that model (it probably should have). We've considered adding support for that before, and this may require it.
ndk-build would need to grow a similar feature, but that's fairly easy.
Or did you have something else in mind? The other things I can think of would be something contained in the build.gradle
file, which seems like it'd be cumbersome for the author to keep in sync with the real build script; or doubling up on packaging some modules so it would expose both package::module
and package::module-with-optional-dependency
, which works today but is prone to combinatoric explosion for something like ffmpeg...
Is your feature request related to a problem? Please describe.
My application is able to dynamically load dependencies using
dlopen
+dladdr
. I have modeled every library using prefab json files.But I don't know of any way, other then explicitly do
target_link_libraries
to add a dynamic dependency to the.apk
.Describe the solution you'd like
I have 2 suggestions:
.apk
. Doingadd_dependencies(myexecutable dynamic_dependency)
, should adddynamic_dependency
to the.apk
as well.apk
:add_target_to_apk(dynamic_dependency)
Describe alternatives you've considered
Right now, I'm simply doing
This type of dependency is honored by android's cmake support, but should not be necessary.
Additional context
I have encountered this issue while creating a prefab aar for SDL_image. SDL_image provides decoders for various image formats. Because not every applications needs every decoder, these are dynamically loaded. Dynamically loading also reduces the file size of an
.apk
.