From 75c4f6f94d3c4b64867be087327981aa4176926b Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Sat, 23 Sep 2023 16:46:52 -0500 Subject: [PATCH 1/3] Revamp Clang checks for Windows; still need to do the same for Mac --- samples/breakout/build.bat | 14 ++++++++- samples/clock/build.bat | 14 ++++++++- samples/fluid/build.bat | 18 ++++++++++-- samples/triangle/build.bat | 14 ++++++++- samples/ui/build.bat | 14 ++++++++- scripts/sample_build_check.py | 53 +++++++++++++++++++++++++++++++++++ 6 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 scripts/sample_build_check.py diff --git a/samples/breakout/build.bat b/samples/breakout/build.bat index 331320b..85a0d41 100644 --- a/samples/breakout/build.bat +++ b/samples/breakout/build.bat @@ -1,4 +1,16 @@ @echo off +setlocal enabledelayedexpansion + +:: The following code simply checks that you have a compatible version of Clang. +:: This code exists to improve the experience of first-time Orca users and can +:: be safely deleted in your own projects if you wish. +if exist "..\..\scripts\sample_build_check.py" ( + python ..\..\scripts\sample_build_check.py + if !ERRORLEVEL! neq 0 exit /b 1 +) else ( + echo Could not check if you have the necessary tools to build the Orca samples. + echo If you have copied this script to your own project, you can delete this code. +) set ORCA_DIR=..\.. set STDLIB_DIR=%ORCA_DIR%\src\libc-shim @@ -16,6 +28,6 @@ set wasmFlags=--target=wasm32^ -I%ORCA_DIR%\src\ext clang %wasmFlags% -o .\module.wasm %ORCA_DIR%\src\orca.c %STDLIB_DIR%\src\*.c src\main.c -IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% +if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! orca bundle --orca-dir %ORCA_DIR% --name Breakout --icon icon.png --resource-dir data module.wasm diff --git a/samples/clock/build.bat b/samples/clock/build.bat index 95d92c8..55c3952 100644 --- a/samples/clock/build.bat +++ b/samples/clock/build.bat @@ -1,4 +1,16 @@ @echo off +setlocal enabledelayedexpansion + +:: The following code simply checks that you have a compatible version of Clang. +:: This code exists to improve the experience of first-time Orca users and can +:: be safely deleted in your own projects if you wish. +if exist "..\..\scripts\sample_build_check.py" ( + python ..\..\scripts\sample_build_check.py + if !ERRORLEVEL! neq 0 exit /b 1 +) else ( + echo Could not check if you have the necessary tools to build the Orca samples. + echo If you have copied this script to your own project, you can delete this code. +) set ORCA_DIR=..\.. set STDLIB_DIR=%ORCA_DIR%\src\libc-shim @@ -16,6 +28,6 @@ set wasmFlags=--target=wasm32^ -I%ORCA_DIR%\src\ext clang %wasmFlags% -o .\module.wasm %ORCA_DIR%\src\orca.c %STDLIB_DIR%\src\*.c src\main.c -IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% +if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! orca bundle --orca-dir %ORCA_DIR% --name Clock --icon icon.png --resource-dir data module.wasm diff --git a/samples/fluid/build.bat b/samples/fluid/build.bat index 73f4d72..5f5f127 100644 --- a/samples/fluid/build.bat +++ b/samples/fluid/build.bat @@ -1,4 +1,16 @@ @echo off +setlocal enabledelayedexpansion + +:: The following code simply checks that you have a compatible version of Clang. +:: This code exists to improve the experience of first-time Orca users and can +:: be safely deleted in your own projects if you wish. +if exist "..\..\scripts\sample_build_check.py" ( + python ..\..\scripts\sample_build_check.py + if !ERRORLEVEL! neq 0 exit /b 1 +) else ( + echo Could not check if you have the necessary tools to build the Orca samples. + echo If you have copied this script to your own project, you can delete this code. +) set ORCA_DIR=..\.. set STDLIB_DIR=%ORCA_DIR%\src\libc-shim @@ -30,10 +42,10 @@ set shaders=src/shaders/advect.glsl^ src/shaders/subtract_pressure.glsl -call python3 ../../scripts/embed_text_files.py --prefix=glsl_ --output src/glsl_shaders.h %shaders% -IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% +call python ../../scripts/embed_text_files.py --prefix=glsl_ --output src/glsl_shaders.h %shaders% +if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! clang %wasmFlags% -o .\module.wasm %ORCA_DIR%\src\orca.c %STDLIB_DIR%\src\*.c src\main.c -IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% +if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! orca bundle --orca-dir %ORCA_DIR% --name Fluid --icon icon.png module.wasm \ No newline at end of file diff --git a/samples/triangle/build.bat b/samples/triangle/build.bat index e364017..465ae78 100644 --- a/samples/triangle/build.bat +++ b/samples/triangle/build.bat @@ -1,4 +1,16 @@ @echo off +setlocal enabledelayedexpansion + +:: The following code simply checks that you have a compatible version of Clang. +:: This code exists to improve the experience of first-time Orca users and can +:: be safely deleted in your own projects if you wish. +if exist "..\..\scripts\sample_build_check.py" ( + python ..\..\scripts\sample_build_check.py + if !ERRORLEVEL! neq 0 exit /b 1 +) else ( + echo Could not check if you have the necessary tools to build the Orca samples. + echo If you have copied this script to your own project, you can delete this code. +) set ORCA_DIR=..\.. set STDLIB_DIR=%ORCA_DIR%\src\libc-shim @@ -16,6 +28,6 @@ set wasmFlags=--target=wasm32^ -I%ORCA_DIR%\src\ext clang %wasmFlags% -o .\module.wasm %ORCA_DIR%\src\orca.c %STDLIB_DIR%\src\*.c src\main.c -IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% +if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! orca bundle --orca-dir %ORCA_DIR% --name Triangle module.wasm diff --git a/samples/ui/build.bat b/samples/ui/build.bat index 46f5011..9137fa9 100644 --- a/samples/ui/build.bat +++ b/samples/ui/build.bat @@ -1,4 +1,16 @@ @echo off +setlocal enabledelayedexpansion + +:: The following code simply checks that you have a compatible version of Clang. +:: This code exists to improve the experience of first-time Orca users and can +:: be safely deleted in your own projects if you wish. +if exist "..\..\scripts\sample_build_check.py" ( + python ..\..\scripts\sample_build_check.py + if !ERRORLEVEL! neq 0 exit /b 1 +) else ( + echo Could not check if you have the necessary tools to build the Orca samples. + echo If you have copied this script to your own project, you can delete this code. +) set ORCA_DIR=..\.. set STDLIB_DIR=%ORCA_DIR%\src\libc-shim @@ -16,6 +28,6 @@ set wasmFlags=--target=wasm32^ -I%ORCA_DIR%\src\ext clang %wasmFlags% -o .\module.wasm %ORCA_DIR%\src\orca.c %STDLIB_DIR%\src\*.c src\main.c -IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL% +if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL! orca bundle --orca-dir %ORCA_DIR% --name UI --resource-dir data module.wasm diff --git a/scripts/sample_build_check.py b/scripts/sample_build_check.py new file mode 100644 index 0000000..96064ff --- /dev/null +++ b/scripts/sample_build_check.py @@ -0,0 +1,53 @@ +import platform +import re +import shutil +import subprocess +import textwrap + +CLANG_MAJOR, CLANG_MINOR = 11, 0 + +def printw(str=""): + print(textwrap.fill(str)) + +def print_clang_install_info(upgrade): + if platform.system() == "Windows": + printw(f"Please install Clang {CLANG_MAJOR}.{CLANG_MINOR} or newer. We recommend installing Clang via the Visual Studio installer. In the installer, search for \"C++ Clang Compiler\".") + elif platform.system() == "Darwin": + printw(f"Please install Clang {CLANG_MAJOR}.{CLANG_MINOR} or newer. We recommend installing Clang via Homebrew:") + printw() + if upgrade: + printw(" brew upgrade llvm") + else: + printw(" brew install llvm") + printw() + else: + printw(f"Please install Clang {CLANG_MAJOR}.{CLANG_MINOR} or newer.") + +try: + out = subprocess.run(["clang", "--version"], capture_output=True, text=True, check=True) + m = re.search(r"clang version (\d+)\.(\d+)\.(\d+)", out.stdout) + major, minor, patch = int(m.group(1)), int(m.group(2)), int(m.group(3)) + if major < CLANG_MAJOR or minor < CLANG_MINOR: + printw(f"ERROR: Your version of Clang is too old. You have version {major}.{minor}.{patch}, but version {CLANG_MAJOR}.{CLANG_MINOR} or greater is required.") + printw() + printw("This script is currently running the clang located at:") + printw(shutil.which("clang")) + printw() + print_clang_install_info(True) + exit(1) +except FileNotFoundError: + printw("ERROR: clang is not installed. The Orca samples require Clang in order to compile C programs to WebAssembly.") + printw() + print_clang_install_info(False) + exit(1) +except subprocess.CalledProcessError: + printw("WARNING: Could not check Clang version. You may encounter build errors.") + +try: + subprocess.run(["orca", "version"], capture_output=True, shell=True, check=True) +except subprocess.CalledProcessError: + printw("ERROR: The Orca tooling has not been installed to your system or is not on your PATH. From the root of the Orca source code, please run the following commands:") + printw() + printw(" python orca dev build-runtime") + printw(" python orca dev install") + exit(1) -- 2.25.1 From 1cc8778982113c12d477f9d920c05dc3ea833757 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Sat, 23 Sep 2023 17:04:13 -0500 Subject: [PATCH 2/3] Do clang checks on Mac --- samples/breakout/build.bat | 2 +- samples/breakout/build.sh | 15 ++++++++------- samples/clock/build.bat | 2 +- samples/clock/build.sh | 15 ++++++++------- samples/fluid/build.bat | 2 +- samples/fluid/build.sh | 15 ++++++++------- samples/triangle/build.bat | 2 +- samples/triangle/build.sh | 15 ++++++++------- samples/ui/build.bat | 2 +- samples/ui/build.sh | 15 ++++++++------- scripts/sample_build_check.py | 10 +++++++++- 11 files changed, 54 insertions(+), 41 deletions(-) diff --git a/samples/breakout/build.bat b/samples/breakout/build.bat index 85a0d41..a63b8ae 100644 --- a/samples/breakout/build.bat +++ b/samples/breakout/build.bat @@ -1,7 +1,7 @@ @echo off setlocal enabledelayedexpansion -:: The following code simply checks that you have a compatible version of Clang. +:: The following code checks if you have the necessary programs to compile the samples. :: This code exists to improve the experience of first-time Orca users and can :: be safely deleted in your own projects if you wish. if exist "..\..\scripts\sample_build_check.py" ( diff --git a/samples/breakout/build.sh b/samples/breakout/build.sh index b21abed..28b2d5d 100755 --- a/samples/breakout/build.sh +++ b/samples/breakout/build.sh @@ -2,13 +2,14 @@ set -euo pipefail -if [[ -x /usr/local/opt/llvm/bin/clang ]]; then - CLANG=/usr/local/opt/llvm/bin/clang -elif [[ -x /opt/homebrew/opt/llvm/bin/clang ]]; then - CLANG=/opt/homebrew/opt/llvm/bin/clang +# The following code checks if you have the necessary programs to compile the samples. +# This code exists to improve the experience of first-time Orca users and can +# be safely deleted in your own projects if you wish. +if [ -f ../../scripts/sample_build_check.py ]; then + python3 ../../scripts/sample_build_check.py else - echo "Could not find Homebrew clang; this script will probably not work." - CLANG=clang + echo "Could not check if you have the necessary tools to build the Orca samples." + echo "If you have copied this script to your own project, you can delete this code." fi ORCA_DIR=../.. @@ -25,6 +26,6 @@ wasmFlags="--target=wasm32 \ -I $ORCA_DIR/src \ -I $ORCA_DIR/src/ext" -$CLANG $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c +clang $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c orca bundle --orca-dir $ORCA_DIR --name Breakout --icon icon.png --resource-dir data module.wasm diff --git a/samples/clock/build.bat b/samples/clock/build.bat index 55c3952..f9579fb 100644 --- a/samples/clock/build.bat +++ b/samples/clock/build.bat @@ -1,7 +1,7 @@ @echo off setlocal enabledelayedexpansion -:: The following code simply checks that you have a compatible version of Clang. +:: The following code checks if you have the necessary programs to compile the samples. :: This code exists to improve the experience of first-time Orca users and can :: be safely deleted in your own projects if you wish. if exist "..\..\scripts\sample_build_check.py" ( diff --git a/samples/clock/build.sh b/samples/clock/build.sh index 41caf81..55b51fb 100755 --- a/samples/clock/build.sh +++ b/samples/clock/build.sh @@ -2,13 +2,14 @@ set -euo pipefail -if [[ -x /usr/local/opt/llvm/bin/clang ]]; then - CLANG=/usr/local/opt/llvm/bin/clang -elif [[ -x /opt/homebrew/opt/llvm/bin/clang ]]; then - CLANG=/opt/homebrew/opt/llvm/bin/clang +# The following code checks if you have the necessary programs to compile the samples. +# This code exists to improve the experience of first-time Orca users and can +# be safely deleted in your own projects if you wish. +if [ -f ../../scripts/sample_build_check.py ]; then + python3 ../../scripts/sample_build_check.py else - echo "Could not find Homebrew clang; this script will probably not work." - CLANG=clang + echo "Could not check if you have the necessary tools to build the Orca samples." + echo "If you have copied this script to your own project, you can delete this code." fi ORCA_DIR=../.. @@ -25,6 +26,6 @@ wasmFlags="--target=wasm32 \ -I $ORCA_DIR/src \ -I $ORCA_DIR/src/ext" -$CLANG $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c +clang $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c orca bundle --orca-dir $ORCA_DIR --name Clock --icon icon.png --resource-dir data module.wasm diff --git a/samples/fluid/build.bat b/samples/fluid/build.bat index 5f5f127..338a853 100644 --- a/samples/fluid/build.bat +++ b/samples/fluid/build.bat @@ -1,7 +1,7 @@ @echo off setlocal enabledelayedexpansion -:: The following code simply checks that you have a compatible version of Clang. +:: The following code checks if you have the necessary programs to compile the samples. :: This code exists to improve the experience of first-time Orca users and can :: be safely deleted in your own projects if you wish. if exist "..\..\scripts\sample_build_check.py" ( diff --git a/samples/fluid/build.sh b/samples/fluid/build.sh index 21e9cf2..79bbf06 100755 --- a/samples/fluid/build.sh +++ b/samples/fluid/build.sh @@ -2,13 +2,14 @@ set -euo pipefail -if [[ -x /usr/local/opt/llvm/bin/clang ]]; then - CLANG=/usr/local/opt/llvm/bin/clang -elif [[ -x /opt/homebrew/opt/llvm/bin/clang ]]; then - CLANG=/opt/homebrew/opt/llvm/bin/clang +# The following code checks if you have the necessary programs to compile the samples. +# This code exists to improve the experience of first-time Orca users and can +# be safely deleted in your own projects if you wish. +if [ -f ../../scripts/sample_build_check.py ]; then + python3 ../../scripts/sample_build_check.py else - echo "Could not find Homebrew clang; this script will probably not work." - CLANG=clang + echo "Could not check if you have the necessary tools to build the Orca samples." + echo "If you have copied this script to your own project, you can delete this code." fi ORCA_DIR=../.. @@ -27,6 +28,6 @@ wasmFlags="--target=wasm32 \ -I $ORCA_DIR/src \ -I $ORCA_DIR/src/ext" -$CLANG $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c +clang $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c orca bundle --orca-dir $ORCA_DIR --name Fluid --icon icon.png module.wasm diff --git a/samples/triangle/build.bat b/samples/triangle/build.bat index 465ae78..910e4c5 100644 --- a/samples/triangle/build.bat +++ b/samples/triangle/build.bat @@ -1,7 +1,7 @@ @echo off setlocal enabledelayedexpansion -:: The following code simply checks that you have a compatible version of Clang. +:: The following code checks if you have the necessary programs to compile the samples. :: This code exists to improve the experience of first-time Orca users and can :: be safely deleted in your own projects if you wish. if exist "..\..\scripts\sample_build_check.py" ( diff --git a/samples/triangle/build.sh b/samples/triangle/build.sh index cd74b6c..a83b61a 100755 --- a/samples/triangle/build.sh +++ b/samples/triangle/build.sh @@ -2,13 +2,14 @@ set -euo pipefail -if [[ -x /usr/local/opt/llvm/bin/clang ]]; then - CLANG=/usr/local/opt/llvm/bin/clang -elif [[ -x /opt/homebrew/opt/llvm/bin/clang ]]; then - CLANG=/opt/homebrew/opt/llvm/bin/clang +# The following code checks if you have the necessary programs to compile the samples. +# This code exists to improve the experience of first-time Orca users and can +# be safely deleted in your own projects if you wish. +if [ -f ../../scripts/sample_build_check.py ]; then + python3 ../../scripts/sample_build_check.py else - echo "Could not find Homebrew clang; this script will probably not work." - CLANG=clang + echo "Could not check if you have the necessary tools to build the Orca samples." + echo "If you have copied this script to your own project, you can delete this code." fi ORCA_DIR=../.. @@ -25,6 +26,6 @@ wasmFlags="--target=wasm32 \ -I $ORCA_DIR/src \ -I $ORCA_DIR/src/ext" -$CLANG $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c +clang $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c orca bundle --orca-dir $ORCA_DIR --name Triangle module.wasm diff --git a/samples/ui/build.bat b/samples/ui/build.bat index 9137fa9..4a7b1eb 100644 --- a/samples/ui/build.bat +++ b/samples/ui/build.bat @@ -1,7 +1,7 @@ @echo off setlocal enabledelayedexpansion -:: The following code simply checks that you have a compatible version of Clang. +:: The following code checks if you have the necessary programs to compile the samples. :: This code exists to improve the experience of first-time Orca users and can :: be safely deleted in your own projects if you wish. if exist "..\..\scripts\sample_build_check.py" ( diff --git a/samples/ui/build.sh b/samples/ui/build.sh index 2e15876..bffba7f 100755 --- a/samples/ui/build.sh +++ b/samples/ui/build.sh @@ -2,13 +2,14 @@ set -euo pipefail -if [[ -x /usr/local/opt/llvm/bin/clang ]]; then - CLANG=/usr/local/opt/llvm/bin/clang -elif [[ -x /opt/homebrew/opt/llvm/bin/clang ]]; then - CLANG=/opt/homebrew/opt/llvm/bin/clang +# The following code checks if you have the necessary programs to compile the samples. +# This code exists to improve the experience of first-time Orca users and can +# be safely deleted in your own projects if you wish. +if [ -f ../../scripts/sample_build_check.py ]; then + python3 ../../scripts/sample_build_check.py else - echo "Could not find Homebrew clang; this script will probably not work." - CLANG=clang + echo "Could not check if you have the necessary tools to build the Orca samples." + echo "If you have copied this script to your own project, you can delete this code." fi ORCA_DIR=../.. @@ -25,6 +26,6 @@ wasmFlags="--target=wasm32 \ -I $ORCA_DIR/src \ -I $ORCA_DIR/src/ext" -$CLANG $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c +clang $wasmFlags -o ./module.wasm $ORCA_DIR/src/orca.c $STDLIB_DIR/src/*.c src/main.c orca bundle --orca-dir $ORCA_DIR --name UI --resource-dir data module.wasm diff --git a/scripts/sample_build_check.py b/scripts/sample_build_check.py index 96064ff..bc31e28 100644 --- a/scripts/sample_build_check.py +++ b/scripts/sample_build_check.py @@ -13,7 +13,7 @@ def print_clang_install_info(upgrade): if platform.system() == "Windows": printw(f"Please install Clang {CLANG_MAJOR}.{CLANG_MINOR} or newer. We recommend installing Clang via the Visual Studio installer. In the installer, search for \"C++ Clang Compiler\".") elif platform.system() == "Darwin": - printw(f"Please install Clang {CLANG_MAJOR}.{CLANG_MINOR} or newer. We recommend installing Clang via Homebrew:") + printw(f"Please install Clang {CLANG_MAJOR}.{CLANG_MINOR} or newer. We recommend installing Clang via Homebrew (https://brew.sh/):") printw() if upgrade: printw(" brew upgrade llvm") @@ -43,6 +43,14 @@ except FileNotFoundError: except subprocess.CalledProcessError: printw("WARNING: Could not check Clang version. You may encounter build errors.") +try: + subprocess.run(["wasm-ld", "--version"], capture_output=True, check=True) +except FileNotFoundError: + printw("ERROR: wasm-ld was not found on your system. This is a component of Clang that is required in order to produce WebAssembly modules. This likely means that an old or otherwise incompatible version of Clang is being used, such as Apple's version of Clang.") + printw() + print_clang_install_info(False) + exit(1) + try: subprocess.run(["orca", "version"], capture_output=True, shell=True, check=True) except subprocess.CalledProcessError: -- 2.25.1 From 4f0738fe64b92710ce771f0fb96a124517c5497d Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Sat, 23 Sep 2023 17:15:08 -0500 Subject: [PATCH 3/3] Check for Xcode command-line tools --- Readme.md | 4 +++- scripts/dev.py | 29 ++++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Readme.md b/Readme.md index 9233cd5..cc54e86 100644 --- a/Readme.md +++ b/Readme.md @@ -29,12 +29,14 @@ The Orca command-line tools must be installed to your system in order to use the - Windows or Mac (Linux is not yet supported) - [Python 3.8](https://www.python.org/) or newer (for command line tools) -- Clang +- Clang (version 11.0 or newer) - **Windows users:** `clang` can be installed via the Visual Studio installer. Search for "C++ Clang Compiler". - **Mac users:** Apple's built-in `clang` does not support WebAssembly. We recommend installing `clang` via [Homebrew](https://brew.sh/) with `brew install llvm`. - MSVC (Visual Studio 2022 17.5 or newer) (Windows only) - This can be installed through the [Visual Studio Community](https://visualstudio.microsoft.com/) installer. Ensure that your Visual Studio installation includes "Desktop development with C++". - Please note the version requirement! Orca requires C11 atomics, which were only added to MSVC in late 2022. +- Xcode command-line tools (Mac only) + - These can be installed with `xcode-select --install`. ### Installation instructions diff --git a/scripts/dev.py b/scripts/dev.py index a286bf3..464165a 100644 --- a/scripts/dev.py +++ b/scripts/dev.py @@ -17,7 +17,7 @@ from .embed_text_files import * from .version import check_if_source, is_orca_source, orca_version ANGLE_VERSION = "2023-07-05" - +MAC_SDK_DIR = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" def attach_dev_commands(subparsers): dev_cmd = subparsers.add_parser("dev", help="Commands for building Orca itself. Must be run from within an Orca source checkout.") @@ -168,12 +168,10 @@ def build_platform_layer_lib_win(release): ], check=True) def build_platform_layer_lib_mac(release): - sdk_dir = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" - flags = ["-mmacos-version-min=10.15.4"] cflags = ["-std=c11"] debug_flags = ["-O3"] if release else ["-g", "-DOC_DEBUG", "-DOC_LOG_COMPILE_DEBUG"] - ldflags = [f"-L{sdk_dir}/usr/lib", f"-F{sdk_dir}/System/Library/Frameworks/"] + ldflags = [f"-L{MAC_SDK_DIR}/usr/lib", f"-F{MAC_SDK_DIR}/System/Library/Frameworks/"] includes = ["-Isrc", "-Isrc/util", "-Isrc/platform", "-Isrc/ext", "-Isrc/ext/angle/include"] # compile metal shader @@ -443,19 +441,24 @@ def ensure_programs(): msg.more("and \"C++ Clang Compiler\": https://visualstudio.microsoft.com/") exit(1) - try: - subprocess.run(["clang", "-v"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - except FileNotFoundError: - msg = log_error("clang was not found on your system.") - if platform.system() == "Windows": - msg.more("We recommend installing clang via the Visual Studio installer.") - elif platform.system() == "Darwin": + if platform.system() == "Darwin": + try: + subprocess.run(["clang", "-v"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + except FileNotFoundError: + msg = log_error("clang was not found on your system.") msg.more("Run the following to install it:") msg.more() msg.more(" brew install llvm") msg.more() - exit(1) - # TODO(ben): Check for xcode command line tools + exit(1) + + if not os.path.exists(MAC_SDK_DIR): + msg = log_error("The Xcode command-line tools are not installed.") + msg.more("Run the following to install them:") + msg.more() + msg.more(" xcode-select --install") + msg.more() + exit(1) def ensure_angle(): -- 2.25.1