1load(":android_mock.bzl", "android_binary", "android_library") 2load("@rules_license//tools:test_helpers.bzl", "golden_cmd_test") 3 4 5# These two rules today capture what an android_binary would look like. 6# This rule represents the Android specific code that displays licenses 7# on the display. Note that it does not depend on anything to get the 8# license contents; the implementation of these rules macros handle that 9# detail. 10android_library( 11 name = "licenses", 12 srcs = [ 13 "license_display.sh", 14 ], 15 data = [ 16 "@rules_license//distro:distro", 17 ], 18) 19 20# This captures how the application would be built. The dependencies of this 21# rule are crawled to identify third-party licenses in use. The macro definition 22# of this rule creates a graph to capture that process of identifying licenses, 23# building the licenses target, and finally invoking the "real" android_binary 24# rule to build the final output with the injected license content. 25android_binary( 26 name = "main", 27 srcs = ["main.sh"], 28 deps = [ 29 ], 30 data = [ 31 ":licenses", 32 ], 33) 34 35golden_cmd_test( 36 name = "main_test", 37 srcs = [], 38 cmd = "$(location :main)", 39 tools = [":main"], 40 golden = "main_golden.txt", 41) 42