From fbba6330e9953158f04257da66234c4f5c547891 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Sat, 8 Jul 2023 09:22:29 -0500 Subject: [PATCH] Add automatic ANGLE downloads --- .gitignore | 1 + scripts/build_runtime.py | 42 +++++++++++++++++++++++++++++++++++++++- scripts/checksums.json | 6 ++++-- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 23ada4b..25d7d9c 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ sdk/orca_surface.c .vscode/settings.json __pycache__ +scripts/files diff --git a/scripts/build_runtime.py b/scripts/build_runtime.py index 64c6012..f1fd1fb 100644 --- a/scripts/build_runtime.py +++ b/scripts/build_runtime.py @@ -1,7 +1,11 @@ import argparse +import glob import os import platform +import urllib.request +import shutil import subprocess +from zipfile import ZipFile import checksum from log import * @@ -173,4 +177,40 @@ def ensure_angle(): exit(1) if not angle_exists: - pass + download_angle() + + +def download_angle(): + print("Downloading ANGLE...") + if platform.system() == "Windows": + build = "win" + checksumkey = "angle.zip-win" + extension = "dll" + elif platform.system() == "Darwin": + extension = "dylib" + build = "macos-12" + checksumkey = "angle.zip-mac" + + # TODO(ben): make universal dylibs + if platform.machine() == "arm64": + log_error(f"automated ANGLE builds are not yet available for Apple silicon") + return + else: + log_error(f"could not automatically download ANGLE for unknown platform {platform.system()}") + return + + url = f"https://github.com/HandmadeNetwork/build-angle/releases/download/{ANGLE_VERSION}/angle-{build}-{ANGLE_VERSION}.zip" + with urllib.request.urlopen(url) as response: + os.makedirs("scripts/files", exist_ok=True) + with open("scripts/files/angle.zip", "wb") as out: + shutil.copyfileobj(response, out) + + if not checksum.checkfile(checksumkey, "scripts/files/angle.zip"): + log_error(f"ANGLE download did not match checksum") + exit(1) + + with ZipFile("scripts/files/angle.zip", "r") as anglezip: + anglezip.extractall(path="scripts/files") + + for filepath in glob.glob(f"scripts/files/angle/bin/*.{extension}"): + shutil.copy(filepath, "milepost/lib") diff --git a/scripts/checksums.json b/scripts/checksums.json index 1c2126f..d3289bf 100644 --- a/scripts/checksums.json +++ b/scripts/checksums.json @@ -1,6 +1,8 @@ { + "angle.zip-win": "pizza", + "angle.zip-mac-x64": "a3422c456278ff037ef89a7808e0ba256d972d4832d5272fc3d4aa4f7912c1e0", "libEGL-win": "3c8b22317664650deba704dd40bbd56447c579ee3a3de18a9c114449a883a36d", "libGLESv2-win": "a10e0ce850a981b11d3d0f01a7efbf8ce46ac74e5fa763b5c43a80c4238da389", - "libEGL-mac-arm64": "227445d896047207d1dcef91a8182d886692bc470f402033a6f0831eacb82592", - "libGLESv2-mac-arm64": "c814948060494796cda4a3febd8652e1bbf0787a69c2f7e9afd41fc666dc91fe" + "libEGL-mac": "227445d896047207d1dcef91a8182d886692bc470f402033a6f0831eacb82592", + "libGLESv2-mac": "c814948060494796cda4a3febd8652e1bbf0787a69c2f7e9afd41fc666dc91fe" }