Add extra checks for MSVC and do other stuff I dunno #131

Merged
MartinFouilleul merged 2 commits from msvc-checks into main 2023-09-19 06:36:22 +00:00
4 changed files with 37 additions and 12 deletions

View File

@ -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 `./`!

7
orca
View File

@ -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():

View File

@ -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%

View File

@ -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: