1// Copyright (C) 2018 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package { 16 default_applicable_licenses: ["Android-Apache-2.0"], 17} 18 19apexer_tools = [ 20 "aapt2", 21 "avbtool", 22 "conv_apex_manifest", 23 "e2fsdroid", 24 "mke2fs", 25 "resize2fs", 26 "sefcontext_compile", 27 "zipalign", 28 "make_f2fs", 29 "sload_f2fs", 30 "mkfs.erofs", 31 // TODO(b/124476339) apex doesn't follow 'required' dependencies so we need to include this 32 // manually for 'avbtool'. 33 "fec", 34] 35 36// TODO(b/157110982): cannot specify "required" dependency on go binary 37apexer_go_tools = [ 38 "merge_zips", 39 "soong_zip", 40] 41 42python_library_host { 43 name: "apex_manifest", 44 srcs: [ 45 "apex_manifest.py", 46 ], 47 libs: [ 48 "apex_manifest_proto", 49 ], 50} 51 52// This is a hack to move mke2fs_conf into the current folder for bazel builds. 53// Normally bazel would keep it under a system/extras/ext4_utils/ folder. 54genrule { 55 name: "mke2fs_conf_for_apexer", 56 srcs: [":mke2fs_conf"], 57 out: ["mke2fs.conf"], 58 cmd: "cp $(in) $(out)", 59} 60 61python_binary_host { 62 name: "apexer", 63 srcs: [ 64 "apexer.py", 65 ], 66 // TODO(b/157625953) mke2fs.conf can't embedded directly. 67 data: [ 68 ":mke2fs_conf_for_apexer", 69 ], 70 libs: [ 71 "apex_manifest", 72 "apex_build_info_proto", 73 "manifest_utils", 74 ], 75 required: apexer_tools, 76} 77 78python_binary_host { 79 name: "conv_apex_manifest", 80 srcs: [ 81 "conv_apex_manifest.py", 82 ], 83 libs: [ 84 "apex_manifest_proto", 85 ], 86} 87 88// TODO(b/148659029): this test can't run in TEST_MAPPING. 89python_test_host { 90 name: "apexer_test", 91 pkg_path: "apexer_test", 92 main: "apexer_test.py", 93 srcs: [ 94 "apexer_test.py", 95 ], 96 data: [ 97 ":apexer_test_host_tools", 98 "testdata/com.android.example.apex.avbpubkey", 99 "testdata/com.android.example.apex.pem", 100 "testdata/com.android.example.apex.pk8", 101 "testdata/com.android.example.apex.x509.pem", 102 "testdata/manifest.json", 103 ], 104 device_common_data: [ 105 ":com.android.example.apex", 106 ":com.android.example-legacy.apex", 107 ":com.android.example-logging_parent.apex", 108 ":com.android.example-overridden_package_name.apex", 109 ], 110 test_suites: ["general-tests"], 111 libs: [ 112 "apex_manifest", 113 ], 114} 115 116apexer_deps_minus_go_tools = apexer_tools + [ 117 "apexer", 118 "deapexer", 119 "debugfs_static", 120 "blkid", 121 "fsck.erofs", 122] 123 124apexer_deps_tools = apexer_deps_minus_go_tools + apexer_go_tools 125 126genrule_defaults { 127 name: "apexer_test_host_tools_list", 128 tools: apexer_deps_tools + [ 129 "signapk", 130 ], 131 srcs: [ 132 ":current_android_jar", 133 ], 134} 135 136genrule { 137 name: "apexer_test_host_tools", 138 srcs: [ 139 ":current_android_jar", 140 ], 141 out: ["apexer_test_host_tools.zip"], 142 tools: apexer_deps_tools + [ 143 // To force signapk.jar generated in out/host 144 "signapk", 145 "bundletool", 146 ], 147 cmd: "HOST_OUT_BIN=$$(dirname $(location apexer)) && " + 148 "HOST_SOONG_OUT=$$(dirname $$HOST_OUT_BIN) && " + 149 "SIGNAPK_JAR=$$(find $${HOST_SOONG_OUT}/framework -name \"signapk*\") && " + 150 "BUNDLETOOL_JAR=$$(find $${HOST_SOONG_OUT}/framework -name \"bundletool*.jar\") && " + 151 "LIBCPLUSPLUS=$$(find $${HOST_SOONG_OUT}/lib64 -name \"libc++.*\") && " + 152 "LIBCONSCRYPT_OPENJDK_JNI=$$(find $${HOST_SOONG_OUT}/lib64 -name \"libconscrypt_openjdk_jni.*\") && " + 153 "BASE=$(genDir)/binary_files && " + 154 "BIN=$$BASE/bin && " + 155 "LIB=$$BASE/lib64 && " + 156 "mkdir -p $$BIN && " + 157 "mkdir -p $$LIB && " + 158 "cp $(in) $$BIN && " + 159 "cp $(location apexer) $$BIN && " + 160 "cp $(location conv_apex_manifest) $$BIN && " + 161 "cp $(location deapexer) $$BIN && " + 162 "cp $(location avbtool) $$BIN && " + 163 "cp $(location aapt2) $$BIN && " + 164 "cp $(location e2fsdroid) $$BIN && " + 165 "cp $(location mkfs.erofs) $$BIN && " + 166 "cp $(location merge_zips) $$BIN && " + 167 "cp $(location mke2fs) $$BIN && " + 168 "cp $(location resize2fs) $$BIN && " + 169 "cp $(location sefcontext_compile) $$BIN && " + 170 "cp $(location soong_zip) $$BIN && " + 171 "cp $(location fec) $$BIN && " + 172 "cp $(location zipalign) $$BIN && " + 173 "cp $(location debugfs_static) $$BIN && " + 174 "cp $(location blkid) $$BIN && " + 175 "cp $(location fsck.erofs) $$BIN && " + 176 "cp $$SIGNAPK_JAR $$BIN && " + 177 "cp $$BUNDLETOOL_JAR $$BIN && " + 178 "cp $$LIBCPLUSPLUS $$LIB && " + 179 "cp $$LIBCONSCRYPT_OPENJDK_JNI $$LIB && " + 180 "$(location soong_zip) -C $$BASE -D $$BASE -o $(out) && " + 181 "rm -rf $$BASE", 182} 183