Sasha Smundak | 0d7c521 | 2019-11-11 10:42:19 -0800 | [diff] [blame] | 1 | #!/bin/bash -eu |
Colin Cross | 9297fad | 2020-08-10 12:18:51 -0700 | [diff] [blame] | 2 | |
| 3 | # Copyright 2020 Google Inc. All rights reserved. |
Sasha Smundak | 0d7c521 | 2019-11-11 10:42:19 -0800 | [diff] [blame] | 4 | # |
Colin Cross | 9297fad | 2020-08-10 12:18:51 -0700 | [diff] [blame] | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
Sasha Smundak | 0d7c521 | 2019-11-11 10:42:19 -0800 | [diff] [blame] | 17 | # Builds cumulative cross-reference extraction file (.kzip) for all the |
| 18 | # modules defined and buildable in this repository. |
| 19 | # Usage: |
| 20 | # cd <repository top> && OUT_DIR=<output dir> prebuilts/build-tools-kzip.sh |
| 21 | # Generates $OUT_DIR/all.zkip |
| 22 | |
| 23 | declare -r corpus=android.googlesource.com/platform/superproject |
| 24 | mkdir -p "${OUT_DIR:?Specify output directory}/soong" |
| 25 | |
| 26 | # Build for x86, ignore missing references. |
| 27 | printf '{"Allow_missing_dependencies": true, "HostArch":"x86_64" }\n' >"${OUT_DIR}/soong/soong.variables" |
| 28 | |
| 29 | # Some of targets will fail because of the missing references, but there |
| 30 | # will be sufficient number of successfully compiled modules. |
Colin Cross | 27b1e62 | 2021-10-28 16:32:22 -0700 | [diff] [blame] | 31 | XREF_CORPUS="${corpus}" build/soong/soong_ui.bash --make-mode --skip-config --soong-only -k xref_java xref_cxx || echo Ignoring errors |
Sasha Smundak | 0d7c521 | 2019-11-11 10:42:19 -0800 | [diff] [blame] | 32 | |
| 33 | # Package it all into a single .kzip, ignoring duplicates. |
| 34 | allkzip=$(realpath "${OUT_DIR}/all.kzip") |
| 35 | rm -f "${allkzip}" |
| 36 | tempdir=$(mktemp -d) |
| 37 | for zip in $(find "${OUT_DIR}" -name '*.kzip'); do |
| 38 | unzip -qn "${zip}" -d "${tempdir}" |
| 39 | done |
| 40 | (cd "${tempdir}" && zip -9rmq "${allkzip}" . && rmdir "${tempdir}") |
| 41 | printf "Created %s with %d compilation units\n" "${allkzip}" $(zipinfo "${allkzip}" 'root/units/?*' | wc -l) |
| 42 | |