From 609b993429b85eb88ffa08e03eefbcd5038475c6 Mon Sep 17 00:00:00 2001 From: Ted Xie Date: Tue, 9 Apr 2024 08:22:14 -0700 Subject: Conditionally pass DESUGAR_CONFIG to desugarer command line In the near future, we'll remove d8_desugar.sh's custom passing of --desugared_lib_config and hoist that flag handling to the rule implementations. PiperOrigin-RevId: 623173738 Change-Id: Ic0eb12802bb04ad11a40753c826e9df9bf30cafa --- tools/android/d8_desugar.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/android/d8_desugar.sh b/tools/android/d8_desugar.sh index f785b19..b44f7c3 100755 --- a/tools/android/d8_desugar.sh +++ b/tools/android/d8_desugar.sh @@ -49,9 +49,16 @@ if [[ "$#" -gt 0 ]]; then @*) params="${TMPDIR}/desugar.params" cat "${arg:1}" > "${params}" # cp would create file readonly - for o in "${DESUGAR_CONFIG[@]}"; do - echo "${o}" >> "${params}" - done + + # If --desugared_lib_config already in params file, don't add it again. + set +e + has_desugared_lib_config=$(grep -c "\-\-desugared_lib_config" "$params") + set -e + if [[ "$has_desugared_lib_config" == 0 ]]; then + for o in "${DESUGAR_CONFIG[@]}"; do + echo "${o}" >> "${params}" + done + fi "$DESUGAR_BINARY" \ "@${params}" # temp dir deleted by TRAP installed above -- cgit v1.2.3