Status Update
Comments
jo...@google.com <jo...@google.com> #2
Hey Fred, I haven't seen a request like that before. Maybe Dan has though. It sounds reasonable to me but the devil could be in the details.
Have you gone as far as thinking about what the Gradle DSL should look like for your situation? I can only speculate based on the name of setExportLibrariesFieldInModuleJson.
da...@google.com <da...@google.com> #3
I wonder if any of it could be automatic. Ignoring ndk-build for the moment since we can fix that if needed, does CMake expose the various PUBLIC
and INTERFACE
properties to us?
jo...@google.com <jo...@google.com> #4
I think those wouldn't be apparent in the build.ninja that CMake generates so it would have to come from CMake's file API (
da...@google.com <da...@google.com> #5
Hmm. Not sure but I think you're right.
If it does need to be user specified, something like:
prefab {
foo {
exportLibs {
"//bar:baz",
"-lwhatever",
...
}
}
}
would probably be fine?
fs...@google.com <fs...@google.com> #6
the devil could be in the details.
Always. :)
EDIT: Didn't see Dan already made the same suggestion but more succinct. Thanks!
da...@google.com <da...@google.com> #7
Your post (before being edited) did let me know that I should be more explicit about one aspect though :)
exportLibs
This shouldn't generically fill in this field in the json file IMO, we should only allow explicitly supported fields from the DSL. We might add other fields in the future that are either not suitable for setting manually and we shouldn't offer that footgun, or there might be differences in behavior for manually set properites (some might override the default behavior, some might merge, etc).
sf...@google.com <sf...@google.com> #8
I agree with
sf...@google.com <sf...@google.com> #9
Apologies in advance if this is all too obvious, I was trying to figure out how hard it would be to plumb the dependencies from CMake to the prefab module.json.
The information about each target ends up in Target
objects, the linkLibraries
property of that seems like it might be what you'd need:
It's a bit weird because the CMake Server docs imply that field is a JSON list, but the Target
class has it as a String, not sure how the JSON reader handles that. Possibly it should be List<String>
:
NativeLibraryValue
is set from Target
here, as part of building NativeBuildConfigValue
:
NativeBuildConfigValueMini
is populated from NativeBuildConfigValue
JSON by the visitor here (which transforms NativeLibraryValue
to NativeLibraryValueMini
):
We can get the relevant NativeLibraryValueMini
like this:
And use it in createModuleJson
to set export_libraries
:
ha...@gmail.com <ha...@gmail.com> #10
Using NDK 23.1.7779620
, the trick described in the OP produces the "PACKAGE_PATH" error described in 25.1.8937393
seems to work though.
Description
Prefab allows setting module metadata in
module.json
, but AGP doesn't expose a way to set those fields. I'm currently working around by editing the file after it's generated. For example:It would be great to be able to do this directly with AGP. Sorry if this is a duplicate, I didn't see it tracked anywhere.