From ab3280ed4edacbe0fa84627a2d951759d552e95a Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Mon, 18 Sep 2023 22:05:48 -0500 Subject: [PATCH 1/2] Add extra checks for MSVC --- scripts/dev.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/scripts/dev.py b/scripts/dev.py index c71c934..c9d3292 100644 --- a/scripts/dev.py +++ b/scripts/dev.py @@ -1,6 +1,7 @@ import glob import os import platform +import re import urllib.request import shutil import subprocess @@ -406,16 +407,33 @@ def gen_all_bindings(): def ensure_programs(): if platform.system() == "Windows": + MSVC_MAJOR, MSVC_MINOR = 19, 35 try: - # TODO: Verify that the output includes `x64` - subprocess.run(["cl"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + result = subprocess.run(["cl"], capture_output=True, text=True) + if "for x64" not in result.stderr: + msg = log_error("MSVC is not running in 64-bit mode. Make sure you are running in") + msg.more("an x64 Visual Studio command prompt, such as the \"x64 Native Tools") + msg.more("Command Prompt\" from your Start Menu.") + msg.more() + msg.more("MSVC reported itself as:") + msg.more(result.stderr.splitlines()[0]) + exit(1) + + m = re.search(r"Version (\d+)\.(\d+).(\d+)", result.stderr) + major, minor, patch = int(m.group(1)), int(m.group(2)), int(m.group(3)) + if major < MSVC_MAJOR or minor < MSVC_MINOR: + msg = log_error(f"Your version of MSVC is too old. You have version {major}.{minor}.{patch},") + msg.more(f"but version {MSVC_MAJOR}.{MSVC_MINOR} or greater is required.") + msg.more() + msg.more("Please update Visual Studio to the latest version and try again.") + exit(1) except FileNotFoundError: msg = log_error("MSVC was not found on your system.") msg.more("If you have already installed Visual Studio, make sure you are running in an") - msg.more("x64 Visual Studio command prompt or you have run vcvarsall.bat with x64 for") - msg.more("the architecture. Otherwise, download and install Visual Studio, and ensure") - msg.more("that your installation includes \"Desktop development with C++\" and") - msg.more("\"C++ Clang Compiler\": https://visualstudio.microsoft.com/") + msg.more("x64 Visual Studio command prompt, such as the \"x64 Native Tools Command") + msg.more("Prompt\" from your Start Menu. Otherwise, download and install Visual Studio,") + msg.more("and ensure that your installation includes \"Desktop development with C++\"") + msg.more("and \"C++ Clang Compiler\": https://visualstudio.microsoft.com/") exit(1) try: -- 2.25.1 From 43273cc170b951c0f56c62fd076c9eeb9c199eb8 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Mon, 18 Sep 2023 22:30:25 -0500 Subject: [PATCH 2/2] Switch from `python3` to `python` on Windows and just make other things nicer I dunno --- Readme.md | 10 +++++----- orca | 7 +++++++ orca.bat | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 4dba169..9233cd5 100644 --- a/Readme.md +++ b/Readme.md @@ -23,15 +23,15 @@ To learn more about the project and its goals, read the [announcement post](http The Orca command-line tools must be installed to your system in order to use them in your own projects. -**At this early stage, you must build Orca yourself - in the future, this installation process will be streamlined.** +**At this early stage, you must build Orca yourself - in the future, there will be fewer dependencies and this installation process will be streamlined.** ### Requirements - Windows or Mac (Linux is not yet supported) -- [Python 3](https://www.python.org/) (for command line tools) +- [Python 3.8](https://www.python.org/) or newer (for command line tools) - Clang - **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 clang`. + - **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. @@ -50,13 +50,13 @@ cd orca Build the Orca runtime: ``` -./orca dev build-runtime +python orca dev build-runtime ``` Install the Orca dev tools. If on Windows, the tool can automatically add `orca` to your PATH. Otherwise, you must manually add the Orca install directory to your PATH, e.g. by updating `.zshrc` or `.bashrc`. ``` -./orca dev install +python orca dev install ``` Finally, verify that Orca is successfully installed by running the `orca version` command. Note the lack of `./`! diff --git a/orca b/orca index c973d97..650ca33 100755 --- a/orca +++ b/orca @@ -7,10 +7,17 @@ import os import sys +MAJOR, MINOR = 3, 8 + if __name__ != "__main__": print("why are you importing the orca command-line tool as a Python module, you absolute goofball") exit(1) +if sys.version_info.major < MAJOR or sys.version_info.minor < MINOR: + print("Your Python version is too old.") + print("Orca requires version {}.{}, but you have version {}.{}.".format(MAJOR, MINOR, sys.version_info.major, sys.version_info.minor)) + exit(1) + # If you modify this, be sure to modify the version in scripts/dev.py as well. def check_if_source(): diff --git a/orca.bat b/orca.bat index 99adab7..7a9e437 100644 --- a/orca.bat +++ b/orca.bat @@ -3,5 +3,5 @@ rem Get the directory of this batch script set "script_dir=%~dp0" -python3 "%script_dir%orca" %* +python "%script_dir%orca" %* exit /b %errorlevel% -- 2.25.1