message: Add support for bundling native headers with aar_with_jni
diff: load("@build_bazel_rules_android//android:rules.bzl", "android_binary")
  -def aar_with_jni(name, android_library):
  +def aar_with_jni(
  + name,
  + android_library,
  + headers = None):
  + """Generates an Android AAR given an Android library target.
  +
  + Args:
  + name: Name of the generated .aar file.
  + android_library: The `android_library` target to package. Note that the
  + AAR will contain *only that library's .jar` sources. It does not
  + package the transitive closure of all Java source dependencies.
  + headers: Optional Fileset of headers that will be included in the
  + generated .aar file. This is useful for distributing self-contained
  + .aars with native libs that can be used directly by native clients.
  + """
  +
  # Generate dummy AndroidManifest.xml for dummy apk usage
  # (dummy apk is generated by <name>_dummy_app_for_so target below)
  native.genrule(
  @@ -36,18 +51,29 @@ EOF
  ],
  )
  - native.genrule(
  - name = name,
  - srcs = [android_library + ".aar", name + "_dummy_app_for_so_unsigned.apk"],
  - outs = [name + ".aar"],
  - tags = ["manual"],
  + srcs = [android_library + ".aar", name + "_dummy_app_for_so_unsigned.apk"]
  +
  cmd = """
  -cp $(location {}.aar) $(location :{}.aar)
  -chmod +w $(location :{}.aar)
  +cp $(location {0}.aar) $(location :{1}.aar)
  +chmod +w $(location :{1}.aar)
  origdir=$$PWD
  cd $$(mktemp -d)
  -unzip $$origdir/$(location :{}_dummy_app_for_so_unsigned.apk) "lib/*"
  +unzip $$origdir/$(location :{1}_dummy_app_for_so_unsigned.apk) "lib/*"
  cp -r lib jni
  -zip -r $$origdir/$(location :{}.aar) jni/*/*.so
  -""".format(android_library, name, name, name, name),
  +zip -r $$origdir/$(location :{1}.aar) jni/*/*.so
  +""".format(android_library, name)
  +
  + if headers:
  + srcs += [headers]
  + cmd += """
  +cp -rL $$origdir/$(location {0}) headers
  +zip -r $$origdir/$(location :{1}.aar) headers
  +""".format(headers, name)
  +
  + native.genrule(
  + name = name,
  + srcs = srcs,
  + outs = [name + ".aar"],
  + tags = ["manual"],
  + cmd = cmd,
  )
  