summaryrefslogtreecommitdiff
path: root/tools/cpp-define-generator/presubmit-check-files-up-to-date
diff options
context:
space:
mode:
author Igor Murashkin <iam@google.com> 2017-02-06 10:34:14 -0800
committer Igor Murashkin <iam@google.com> 2017-02-06 10:49:57 -0800
commit2bb70d31ee7749b18b5e0e5ce50a12d30bc1f27c (patch)
tree789efed4ffafdd03ac9ffd1c06d7f74ea962d2d2 /tools/cpp-define-generator/presubmit-check-files-up-to-date
parent7b220d60e3cb58c384a0d245106406080c6f3e37 (diff)
Revert "Revert "build: Generate asm_support_gen.h from the build, validate up-to-date""
This reverts commit 592505c340e82091a6e13e2dff3d8589255df0bb. Fix HOST_PREFER_32_BIT=true causing buildbot to fail with the new asm_support genrule. Test: SOONG_ALLOW_MISSING_DEPENDENCIES=true HOST_PREFER_32_BIT=true\ make -j32 build-art-host-tests Original-Change-Id: I1f0f94914d328c396906583d0732e281c076e69f Change-Id: Ie08a11fdb9486b697d6cef4cec41b23ff120b205
Diffstat (limited to 'tools/cpp-define-generator/presubmit-check-files-up-to-date')
-rwxr-xr-xtools/cpp-define-generator/presubmit-check-files-up-to-date67
1 files changed, 67 insertions, 0 deletions
diff --git a/tools/cpp-define-generator/presubmit-check-files-up-to-date b/tools/cpp-define-generator/presubmit-check-files-up-to-date
new file mode 100755
index 0000000000..67a702adc7
--- /dev/null
+++ b/tools/cpp-define-generator/presubmit-check-files-up-to-date
@@ -0,0 +1,67 @@
+#!/bin/bash
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# ---------------------------------------------------------------------------
+
+# Generates asm_support_gen.h into a temporary location.
+# Then verifies it is the same as our local stored copy.
+
+GEN_TOOL=cpp-define-generator-data
+
+if ! which "$GEN_TOOL"; then
+ echo "ERROR: Please build cpp-define-generator-data or source build/envsetup.sh" >&2
+ exit 1
+fi
+
+#######################
+#######################
+
+PREUPLOAD_COMMIT_COPY="$(mktemp ${TMPDIR:-/tmp}/tmp.XXXXXX)"
+BUILD_COPY="$(mktemp ${TMPDIR:-/tmp}/tmp.XXXXXX)"
+
+function finish() {
+ # Delete temp files.
+ [[ -f "$PREUPLOAD_COMMIT_COPY" ]] && rm "$PREUPLOAD_COMMIT_COPY"
+ [[ -f "$BUILD_COPY" ]] && rm "$BUILD_COPY"
+}
+trap finish EXIT
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+ART_DIR="$( cd "$DIR/../.." && pwd )"
+ASM_SUPPORT_GEN_CHECKED_IN_COPY="runtime/generated/asm_support_gen.h"
+
+# Repo upload hook runs inside of the top-level git directory.
+# If we run this script manually, be in the right place for git.
+cd "$ART_DIR"
+
+if [[ -z $PREUPLOAD_COMMIT ]]; then
+ echo "WARNING: Not running as a pre-upload hook. Assuming commit to check = 'HEAD'"
+ PREUPLOAD_COMMIT=HEAD
+fi
+
+# Get version we are about to push into git.
+git show "$PREUPLOAD_COMMIT:$ASM_SUPPORT_GEN_CHECKED_IN_COPY" > "$PREUPLOAD_COMMIT_COPY" || exit 1
+# Get version that our build would have made.
+"$GEN_TOOL" > "$BUILD_COPY" || exit 1
+
+if ! diff "$PREUPLOAD_COMMIT_COPY" "$BUILD_COPY"; then
+ echo "asm-support: ERROR: Checked-in copy of '$ASM_SUPPORT_GEN_CHECKED_IN_COPY' " >&2
+ echo " has diverged from the build copy." >&2
+ echo " Please re-run the 'generate-asm-support' command to resync the header." >&2
+ exit 1
+fi
+
+# Success. Print nothing to avoid spamming users.