bazelbuild / rules_android

Android rules for Bazel
Apache License 2.0
174 stars 37 forks source link

Support customizing toolchain level jvm_flags #141

Open Bencodes opened 11 months ago

Bencodes commented 11 months ago

Users are unable to easily customize the jvm_flags backing some of the tools in toolchain.bzl as they are all being passed as their raw deploy jars instead of their executable Bazel types.

This means that JVM resource tuning changes like https://github.com/bazelbuild/rules_android/pull/140 will always need to be checked into rules_android or kept in forks rather than leveraging the existing attributes that Bazel provides.

Bencodes commented 11 months ago

Some refactoring will need to be done but something like this would add some flexibility:

java_binary(
    name = "r8",
    main_class = "com.android.tools.r8.R8",
    visibility = ["//visibility:public"],
    jvm_flags = ["-Xmx8G",  "-XX:ThreadStackSize=2048", ...]
    runtime_deps = ["@android_gmaven_r8//jar"],
)
    r8 = attr.label(
        cfg = "exec",
        default = "//tools/android:r8", # Use the R8 runnable target instead of the deploy jar
        executable = True,
        allow_files = True,
    ),