From 8ca7673cfcdbe60d4bad7217fc3c67c283af18bf Mon Sep 17 00:00:00 2001 From: Eugene Susla Date: Mon, 29 Jul 2019 13:57:59 -0700 Subject: [PATCH] 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 --- scripts/OWNERS | 1 + scripts/codegen | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 scripts/codegen diff --git a/scripts/OWNERS b/scripts/OWNERS index 2f9e5942d..dbae40ffc 100644 --- a/scripts/OWNERS +++ b/scripts/OWNERS @@ -4,3 +4,4 @@ danalbert@google.com enh@google.com jmgao@google.com rprichard@google.com +per-file codegen = eugenesusla@google.com \ No newline at end of file diff --git a/scripts/codegen b/scripts/codegen new file mode 100755 index 000000000..799347ce2 --- /dev/null +++ b/scripts/codegen @@ -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 "$@"