1#!/usr/bin/env bash 2 3top="$(dirname $0)/../.." 4 5function buildCodegen() { 6 $top/build/soong/soong_ui.bash --build-mode --all-modules --dir="$PWD" -j codegen_cli 1>&2 7} 8 9if ! command -v codegen_cli 2>&1 >/dev/null; then 10 # First time running codegen 11 buildCodegen 12else 13 latestVersion=$(cat $top/frameworks/base/tools/codegen/src/com/android/codegen/SharedConstants.kt | grep 'CODEGEN_VERSION =' | awk '{ print $5 }' | tr -d '"') 14 if [[ $(codegen_cli --version) != $latestVersion ]]; then 15 # Update codegen 16 buildCodegen 17 fi 18fi 19 20exec codegen_cli "$@" 21