Delaying the definition of the generateSDKBindings task's arguments
ensures the android.bootClasspath has been populated.
Updating AGP apparently changes the default location of apilint's
apilint-result.json and api.txt, this moves them to a less foreign
location. Unfortunately apilint only seems to use relative paths here.
Differential Revision: https://phabricator.services.mozilla.com/D215654
This is intended for Searchfox, to analyse and display the bindings
between Java and C++ code.
When the @WrapForJNI annotation is set on a method marked as native,
the code generator creates 3 files, for instance for EventDispatcher:
* GeneratedJNIEventDispatcherWrappers.cpp
* GeneratedJNI/EventDispatcherWrappers.h
* GeneratedJNI/EventDispatcherNatives.h
The class that implements the member function bound from Java inherits
from EventDispatcher::Natives. That member function is defined in yet
another implementation file.
The mozsearch clang plugin only sees one single translation unit at a
time, so when it sees the definition of the actual bound method (and
when it emits the related data), it doesn't see the EventDispatcher
wrappers implementation anymore. At the moment it misses the name of
the wrapped Java class qualified class name.
This moves the name initialization from the wrappers impl file to the
header so that the mozsearch clang plugin can see the whole picture at
once when analysing the actual member functions' implementations.
The Java class members names were already initialized in the header so
this also makes things a bit more consistent in that regard.
Differential Revision: https://phabricator.services.mozilla.com/D196795
And android.view.SurfaceControl$Transaction.
In order to generate these bindings we must increase the maximum SDK
version argument we pass to SDKProcessor to 29. However, doing so
means that we now attempt to generate bindings for both Surface's
Surface(SurfaceTexture) and Surface(SurfaceControl)
constructors. These both translate in to C++ functions with identical
signatures - Surface::New(jni::Object::Param) - causing a compilation
failure.
This patch therefore also allows the stubName property to override
constructor names, and overrides the latter to
Surface::FromSurfaceControl(), thereby avoiding the conflict.
Differential Revision: https://phabricator.services.mozilla.com/D143484
For example, the SDK class android.media.MediaDrm$KeyStatus will now
be defined as MediaDrm::KeyStatus rather than just KeyStatus.
Not only does this avoid polluting the top-level namespace, but it
also avoids a bug where invalid type names were generated if the
nested class contains a method with a parameter or return of the outer
class' type.
Differential Revision: https://phabricator.services.mozilla.com/D143043
This patch adds some code to our annotation processor that produces comments in
our generated JNI headers to help the developer understand which types are
involved. There are two new types of comments:
* For generated methods from native to Java, we produce a simplified Java method
signature (sans package names) to help the caller disambiguate parameter
types. This is helpful since the machine-readable method signature tend to
use `mozilla::jni::Object::Param` instead of actual types (for the purposes of
avoiding dependency hell, presumably).
* For Java to native methods, we produce a sample signature that is usable for
the implementation of the native method.
While we did discuss some ideas about other locations where we could output this
data, I'd like to start with the generated header files for now. We can make
adjustments to the output location in future bugs.
I will be attaching an example of a generated header that contains these new
comments to the bug.
Differential Revision: https://phabricator.services.mozilla.com/D96236
Our annotation processing for `enum`s kind of sucks.
The typical use case is that we want to generate wrappers for the values of the
`enum`.
On the one hand, we can annotate each individual enumerated value with
`@WrapForJNI` which is noisy and error-prone.
On the other hand, we can mark the entire `enum` as `@WrapForJNI`, which causes
everything in the enum to get JNI wrappers, including private members that we
typically don't care about. This pollutes the generated JNI wrappers with noise
and makes it harder for somebody inspecting the generated C++ header to find
relevant information.
This patch modifies the annotation processor so that `enum`s are treated as a
special case: when we mark an entire `enum` as `@WrapForJNI`, only the
enumerated values will be wrapped. Any additional fields or methods that we need
to wrap may then be annotated on a case-by-case basis.
This should give us both cleaner Java and cleaner generated C++.
Differential Revision: https://phabricator.services.mozilla.com/D95203
We update the name generation code to dump the files into:
```
OBJDIR/widget/android/GeneratedJNI
```
which are then exported to `mozilla/java`
Differential Revision: https://phabricator.services.mozilla.com/D74720
This establishes a "high-water" mark that will make new files not be
"unified", and will allow to burn down the list of files require
unification.
Depends on D58573
Differential Revision: https://phabricator.services.mozilla.com/D58574
It's not trivial to split the existing "unified" include declaration
into granular include declarations, so we continue generating a
unified header that can be incrementally abandoned until it can be
jettisoned.
Depends on D58572
Differential Revision: https://phabricator.services.mozilla.com/D58573
This handles the build system bits.
The subsequent patch will restore the "unified"
GeneratedJNI{Natives,Wrappers}.h header files, and will be folded into
this one before landing.
What will still remain is to update the consumers of the .h files (all
the current #include lines) to use the fine-grained imports. At that
time the "unified" header files can be removed entirely.
Differential Revision: https://phabricator.services.mozilla.com/D58572
We update the name generation code to dump the files into:
```
OBJDIR/widget/android/jni/GeneratedJNI{Natives, Wrappers}
```
which are then exported to `mozilla/jni/natives` and `mozilla/jni/wrappers`
Differential Revision: https://phabricator.services.mozilla.com/D74720
This establishes a "high-water" mark that will make new files not be
"unified", and will allow to burn down the list of files require
unification.
Depends on D58573
Differential Revision: https://phabricator.services.mozilla.com/D58574
It's not trivial to split the existing "unified" include declaration
into granular include declarations, so we continue generating a
unified header that can be incrementally abandoned until it can be
jettisoned.
Depends on D58572
Differential Revision: https://phabricator.services.mozilla.com/D58573
This handles the build system bits.
The subsequent patch will restore the "unified"
GeneratedJNI{Natives,Wrappers}.h header files, and will be folded into
this one before landing.
What will still remain is to update the consumers of the .h files (all
the current #include lines) to use the fine-grained imports. At that
time the "unified" header files can be removed entirely.
Differential Revision: https://phabricator.services.mozilla.com/D58572
This was fallout from Bug 1509572, which moved the "invalidation
smarts" to Gradle. Unfortunately, those smarts are not smart enough:
there are many situations where the annotations might change (a new
method) but where they don't actually change (a new method that isn't
annotated with @JNITarget).
Since we don't want to spend the time to make the "invalidation
smarts" truly smart, we need to bring back this little bit of Bug
1509572.
While we're here, we ensure that there is only one JNI wrapper
generation task for GeckoView and Fennec, regardless of variant.
Right now, those are named like:
- geckoview:generateJNIWrappersForGeneratedWithGeckoBinariesDebug
- app:generateJNIWrappersForFennecWithoutGeckoBinariesDebug
See https://bugzilla.mozilla.org/show_bug.cgi?id=1509539#c1 for some
discussion of these JNI wrapper generation tasks.
Differential Revision: https://phabricator.services.mozilla.com/D26427
Before, we always ran the "generate JNI wrappers" command and had the
command be smart about updating the output. Now we move the smarts to
the Gradle side to streamline the build.
Differential Revision: https://phabricator.services.mozilla.com/D12795
I'm not sure how this ever worked in the `android-gradle-dependencies`
task -- it must have been because of `--continue`.
Differential Revision: https://phabricator.services.mozilla.com/D12793
Before, we always ran the "generate JNI wrappers" command and had the
command be smart about updating the output. Now we move the smarts to
the Gradle side to streamline the build.
Depends on D12794
Differential Revision: https://phabricator.services.mozilla.com/D12795
I'm not sure how this ever worked in the `android-gradle-dependencies`
task -- it must have been because of `--continue`.
Depends on D12792
Differential Revision: https://phabricator.services.mozilla.com/D12793
Right now we skip generating natives binding for a class if the class
doesn't have native methods. However, we should still generate the
natives binding for JNIObject classes because these classes can still be
attached to C++ objects even without native methods.
Differential Revision: https://phabricator.services.mozilla.com/D7106
This allows us to invoke AnnotationProcessor more than is strictly
necessary and not trigger expensive native code compilations unless
the native code has actually evolved.
MozReview-Commit-ID: H1BIzJsdyIh