Skip to content
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

[Android] Expand Java GN rules to support more complex usecases #9876

Merged
merged 2 commits into from
Sep 24, 2021

Conversation

austinh0
Copy link
Contributor

Problem

  • Our Java GN rules are very simple and don't support things such as a java_library depending on another java_library
  • In the next PR, will use Gradle to download JARs that we want to depend on, and need a GN rule to wrap around those "prebuilt" jars.

Change overview

  • The following changes are loosely based on Chromium (write_build_config, java_library_impl).
  • Add jar_path field in java_library template, mutually exclusive with sources. If set, the build rule skips the javac and jar actions and instead just copies the JAR from jar_path into the build directory.
  • Create write_build_config.py script, which outputs a JSON file ("build config") describing each build target.
    • Specifically, contains list of dependent build configs, and dependent JARs (recursive) for the target.
    • This allows us know about child JARs when compiling a parent build rule, and add them to the classpath.
  • Amend javac_runner.py to read a build config JSON and modify classpath accordingly.

Testing

  • Add python test, which checks that the correct JARs are created, and that the contents of build configs match expected.
    • Caveat: in order to test java_prebuilt rules, I created generate_jars_for_test.py. This script needs to be run before other Java things are built, or GN won't be able to find the jar_path.
  • In android.py, go back to copying JARs to libs/. The app only needsCHIPController.jar and SetupPayload.jar, but the chipSdkBuildDir approach would copy all JARs.

@austinh0
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants