scripts:iree: Add control to download the iree compiler at a tag Allows CI (or the typical workflow) to pin the tool to a snapshot Also adjust the commit mismatch message Bug: 200203680 Change-Id: I2a228957c0e8cc763aec4fbe4d8b2bf7aa406f99
diff --git a/check-iree-commit.sh b/check-iree-commit.sh index 9942f11..5119956 100755 --- a/check-iree-commit.sh +++ b/check-iree-commit.sh
@@ -33,6 +33,7 @@ if grep -q "${COMMIT}" "${IREE_COMPILER_DIR}/tag"; then echo "Source code commit matches with the compiler." else - echo "!!! Source code commit mismatches with the compiler. Please re-download \ -the compiler ('m iree_compiler') and resync the repo if you hit the compiler error.!!!" + echo -e "!!!!Source code commit mismatches with the compiler.\n\ +Please check the info at \"${IREE_COMPILER_DIR}/tag\" with\n\ +\"${IREE_SRC}\" if you hit the compilation/runtime errors.!!!!" fi
diff --git a/download_iree_compiler.py b/download_iree_compiler.py index e18aa1d..dba4705 100755 --- a/download_iree_compiler.py +++ b/download_iree_compiler.py
@@ -4,6 +4,7 @@ import os import sys import tarfile +import argparse import requests import wget @@ -12,20 +13,41 @@ print("Please run 'source build/setup.sh' first") sys.exit(-1) +parser = argparse.ArgumentParser( + description="Download IREE host compiler from snapshot releases") +parser.add_argument( + "--tag_name", action="store", default="", + help="snapshot tag to download. If not set, download the latest") +args = parser.parse_args() r = requests.get( - "https://api.github.com/repos/google/iree/releases?per_page=1", auth=( + "https://api.github.com/repos/google/iree/releases?per_page=60", auth=( 'user', 'pass')) if r.status_code != 200: - print("Not getting the right snapshot information. Status code: %d", r.status_code) + print("Not getting the right snapshot information. Status code: %d", + r.status_code) sys.exit(-1) -snapshot = r.json()[0] +TAG_FOUND = False +if args.tag_name: + for x in r.json(): + if x["tag_name"] == args.tag_name: + TAG_FOUND = True + snapshot = x + break +else: + TAG_FOUND = True + snapshot = r.json()[0] + +if not TAG_FOUND: + print("!!!!!IREE snapshot can't be found with tag %s, please try a " + "different tag!!!!!" % args.tag_name) + sys.exit(-1) tag_name = snapshot["tag_name"] commit_sha = snapshot["target_commitish"] -print("Latest snapshot: %s" % tag_name) +print("Snapshot: %s" % tag_name) tag_file = os.path.join(iree_compiler_dir, "tag") @@ -44,6 +66,13 @@ print("IREE compiler is up-to-date") sys.exit(0) +# Install IREE TFLite tool +# Python whl version can be found in tag_name as "snapshot-<version>" +version=tag_name[9:] +cmd = ("pip3 install iree-tools-tflite-snapshot==%s -f " + "https://github.com/google/iree/releases/ --no-cache-dir" % version) +os.system(cmd) + # Find the linux tarball and download it. TAR_MATCH = False for asset in snapshot["assets"]: