Auto-build/update codegen

Exempt-From-Owner-Approval: introduces separate utility; doesn't touch anything around it
Test: 1. Manually enter version/presence of build artifact,
and ensure `codegen FILENAME` still works
2. run codegen again without altering version, ensure no build triggered
Change-Id: Iaa253a430e627d0e7c25781cde535958f77db97f
This commit is contained in:
Eugene Susla
2019-07-29 13:57:59 -07:00
parent ea6d637e07
commit 8ca7673cfc
2 changed files with 21 additions and 0 deletions

20
scripts/codegen Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/sh
top="$(dirname $0)/../.."
function buildCodegen() {
$top/build/soong/soong_ui.bash --build-mode --all-modules --dir="$PWD" -j codegen_cli 1>&2
}
if ! command -v codegen_cli 2>&1 >/dev/null; then
# First time running codegen
buildCodegen
else
latestVersion=$(cat $top/frameworks/base/tools/codegen/src/com/android/codegen/SharedConstants.kt | grep 'CODEGEN_VERSION =' | awk '{ print $5 }' | tr -d '"')
if [[ $(codegen_cli --version) != $latestVersion ]]; then
# Update codegen
buildCodegen
fi
fi
exec codegen_cli "$@"