Jooyung Han | 81538a7 | 2020-02-20 19:54:16 +0900 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (C) 2020 The Android Open Source Project |
| 4 | # |
| 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 | |
Martin Stjernholm | 73cccc4 | 2020-02-24 17:18:38 +0000 | [diff] [blame] | 17 | set -e |
Jooyung Han | 0441fd3 | 2020-03-31 16:14:56 +0900 | [diff] [blame] | 18 | shopt -s extglob |
Martin Stjernholm | 73cccc4 | 2020-02-24 17:18:38 +0000 | [diff] [blame] | 19 | |
Jooyung Han | 77d84bd | 2020-03-31 15:44:53 +0900 | [diff] [blame] | 20 | # to use relative paths |
| 21 | cd $(dirname $0) |
Jooyung Han | 81538a7 | 2020-02-20 19:54:16 +0900 | [diff] [blame] | 22 | |
Jooyung Han | 77d84bd | 2020-03-31 15:44:53 +0900 | [diff] [blame] | 23 | # when executed directly from commandline, build dependencies |
| 24 | if [[ $(basename $0) == "rundiff.sh" ]]; then |
| 25 | if [ -z $ANDROID_BUILD_TOP ]; then |
| 26 | echo "You need to source and lunch before you can use this script" |
| 27 | exit 1 |
| 28 | fi |
| 29 | $ANDROID_BUILD_TOP/build/soong/soong_ui.bash --make-mode linkerconfig conv_apex_manifest |
Jooyung Han | fcaa89a | 2020-03-20 18:20:23 +0900 | [diff] [blame] | 30 | else |
| 31 | # workaround to use host tools(conv_apex_manifest, linkerconfig) on build server |
| 32 | unzip -qqo linkerconfig_diff_test_host_tools.zip -d tools |
| 33 | export PATH=$(realpath tools)/bin:$PATH |
| 34 | export LD_LIBRARY_PATH=$(realpath tools)/lib64:$LD_LIBRARY_PATH |
Jooyung Han | 77d84bd | 2020-03-31 15:44:53 +0900 | [diff] [blame] | 35 | fi |
Jooyung Han | 81538a7 | 2020-02-20 19:54:16 +0900 | [diff] [blame] | 36 | |
Jooyung Han | 0441fd3 | 2020-03-31 16:14:56 +0900 | [diff] [blame] | 37 | # $1: tmp root |
| 38 | # $2: apex |
| 39 | function activate() { |
| 40 | cp -r ./testdata/root/apex/$2 $1/apex |
| 41 | } |
Jooyung Han | 81538a7 | 2020-02-20 19:54:16 +0900 | [diff] [blame] | 42 | |
Jooyung Han | 77d84bd | 2020-03-31 15:44:53 +0900 | [diff] [blame] | 43 | # $1: target output directory |
| 44 | function run_linkerconfig_to { |
Jooyung Han | 0441fd3 | 2020-03-31 16:14:56 +0900 | [diff] [blame] | 45 | # delete old output |
| 46 | rm -rf $1 |
| 47 | |
Jooyung Han | 0441fd3 | 2020-03-31 16:14:56 +0900 | [diff] [blame] | 48 | TMP_ROOT=$(mktemp -d -t linkerconfig-root-XXXXXXXX) |
Jooyung Han | 0441fd3 | 2020-03-31 16:14:56 +0900 | [diff] [blame] | 49 | |
Jooyung Han | fcaa89a | 2020-03-20 18:20:23 +0900 | [diff] [blame] | 50 | ./testdata/prepare_root.sh --in testdata/root --out $TMP_ROOT |
Jooyung Han | 0441fd3 | 2020-03-31 16:14:56 +0900 | [diff] [blame] | 51 | mkdir -p $1/stage0 |
| 52 | linkerconfig -v R -r $TMP_ROOT -t $1/stage0 |
| 53 | |
Jooyung Han | fcaa89a | 2020-03-20 18:20:23 +0900 | [diff] [blame] | 54 | ./testdata/prepare_root.sh --bootstrap --in testdata/root --out $TMP_ROOT |
Jooyung Han | 0441fd3 | 2020-03-31 16:14:56 +0900 | [diff] [blame] | 55 | mkdir -p $1/stage1 |
| 56 | linkerconfig -v R -r $TMP_ROOT -t $1/stage1 |
| 57 | |
Jooyung Han | fcaa89a | 2020-03-20 18:20:23 +0900 | [diff] [blame] | 58 | ./testdata/prepare_root.sh --all --in testdata/root --out $TMP_ROOT |
Jooyung Han | 0441fd3 | 2020-03-31 16:14:56 +0900 | [diff] [blame] | 59 | mkdir -p $1/stage2 |
| 60 | linkerconfig -v R -r $TMP_ROOT -t $1/stage2 |
Jooyung Han | 81538a7 | 2020-02-20 19:54:16 +0900 | [diff] [blame] | 61 | |
Jooyung Han | 0441fd3 | 2020-03-31 16:14:56 +0900 | [diff] [blame] | 62 | mkdir -p $1/product-enabled |
| 63 | linkerconfig -v R -p R -r $TMP_ROOT -t $1/product-enabled |
| 64 | |
Jooyung Han | 71b4bf3 | 2020-04-02 15:40:41 +0900 | [diff] [blame] | 65 | rm -iRf $TMP_ROOT/apex/com.android.vndk.vR |
| 66 | mkdir -p $1/legacy |
| 67 | linkerconfig -r $TMP_ROOT -t $1/legacy |
| 68 | |
Jooyung Han | 77d84bd | 2020-03-31 15:44:53 +0900 | [diff] [blame] | 69 | # clean up testdata root |
| 70 | rm -rf $TMP_ROOT |
| 71 | } |
Jooyung Han | 81538a7 | 2020-02-20 19:54:16 +0900 | [diff] [blame] | 72 | |
Jooyung Han | 77d84bd | 2020-03-31 15:44:53 +0900 | [diff] [blame] | 73 | # update golden_output |
| 74 | if [[ $1 == "--update" ]]; then |
| 75 | run_linkerconfig_to ./testdata/golden_output |
| 76 | echo "Updated" |
| 77 | exit 0 |
| 78 | fi |
Jooyung Han | 81538a7 | 2020-02-20 19:54:16 +0900 | [diff] [blame] | 79 | |
Jooyung Han | 77d84bd | 2020-03-31 15:44:53 +0900 | [diff] [blame] | 80 | echo "Running linkerconfig diff test..." |
| 81 | |
| 82 | run_linkerconfig_to ./testdata/output |
| 83 | if diff -ruN ./testdata/golden_output ./testdata/output ; then |
| 84 | echo "No changes." |
Jooyung Han | 81538a7 | 2020-02-20 19:54:16 +0900 | [diff] [blame] | 85 | else |
| 86 | echo |
| 87 | echo "------------------------------------------------------------------------------------------" |
| 88 | echo "if change looks fine, run following:" |
Jooyung Han | 77d84bd | 2020-03-31 15:44:53 +0900 | [diff] [blame] | 89 | echo " \$ANDROID_BUILD_TOP/system/linkerconfig/rundiff.sh --update" |
Jooyung Han | 81538a7 | 2020-02-20 19:54:16 +0900 | [diff] [blame] | 90 | echo "------------------------------------------------------------------------------------------" |
Jooyung Han | 77d84bd | 2020-03-31 15:44:53 +0900 | [diff] [blame] | 91 | # fail |
| 92 | exit 1 |
| 93 | fi |