Skip to content

Commit

Permalink
Allow including a notice file in aar_with_jni.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 702508218
  • Loading branch information
whhone authored and tensorflower-gardener committed Dec 4, 2024
1 parent 6b61521 commit f8cbda8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tensorflow/lite/java/aar_with_jni.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def aar_with_jni(
android_library,
headers = None,
flatten_headers = False,
strip_headers_prefix = ""):
strip_headers_prefix = "",
third_party_notice = None):
"""Generates an Android AAR with repo root license given an Android library target.
Args:
Expand All @@ -20,6 +21,7 @@ def aar_with_jni(
.aars with native libs that can be used directly by native clients.
flatten_headers: Whether to flatten the output paths of included headers.
strip_headers_prefix: The prefix to strip from the output paths of included headers.
third_party_notice: Optional. The third party dependency licenses as THIRD_PARTY_NOTICE.txt.
"""

# Generate dummy AndroidManifest.xml for dummy apk usage
Expand Down Expand Up @@ -95,6 +97,13 @@ zip $$origdir/$(location :{1}.aar) LICENSE
""".format(src, strip_headers_prefix.replace("/", "\\/"))
cmd += "zip -r $$origdir/$(location :{0}.aar) headers".format(name)

if third_party_notice:
srcs.append(third_party_notice)
cmd += """
cp $$origdir/$(location {0}) ./THIRD_PARTY_NOTICE.txt
zip $$origdir/$(location :{1}.aar) THIRD_PARTY_NOTICE.txt
""".format(third_party_notice, name)

native.genrule(
name = name,
srcs = srcs,
Expand Down

0 comments on commit f8cbda8

Please sign in to comment.