From 2c291aed4bb80f07e8557284d3399cf1e2a4ccb9 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 1 Mar 2026 18:09:44 +0100 Subject: Improve Windows build support. - Use multithreading (works with a sufficiently recent version of the Microsoft developer tools / C SDK). - Detect CPU architecture and use AVX2 or NEON when appropriate. - Automatically detect python installation path. --- build.bat | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'build.bat') diff --git a/build.bat b/build.bat index 909ff01..9f9f5f1 100644 --- a/build.bat +++ b/build.bat @@ -9,15 +9,25 @@ if [%1]==[/d] ( SET CC=clang SET CXX=clang++ -SET ARCH=PORTABLE -SET THREADS=1 +SET THREADS=16 SET SANITIZE= -:: TODO depends on ARCH variable -SET ARCHOPTS= -:: TODO depends on SANITIZE variable -SET DFLAGS=-g3 -DDEBUG +SET ARCH=PORTABLE +clang -march=native -dM -E - < NUL | findstr /C:"__AVX2__" >NUL 2>&1 +if %ERRORLEVEL% EQU 0 ( + SET ARCH=AVX2 + SET ARCHOPTS=-mavx2 + goto :ArchDone +) +clang -march=native -dM -E - < NUL | findstr /C:"__ARM_NEON" >NUL 2>&1 +if %ERRORLEVEL% EQU 0 ( + SET ARCH=NEON + goto :ArchDone +) +:ArchDone + +SET DFLAGS=-g3 -DDEBUG SET WARNINGS=-Wno-deprecated-declarations SET VARIABLES=-DTHREADS=%THREADS% -D%ARCH% SET OFLAGS=-O3 @@ -28,7 +38,9 @@ SET STACKSIZE=-Wl,-stack:16777216 SET LFLAGS=%STACKSIZE% :: Python libraries - change to match your local installation -SET PYPATH=%userprofile%\AppData\Local\Programs\Python\Python313 +for /f "delims=" %%i in ('python -c "import sys; print(sys.base_prefix)"') do set PYPATH=%%i +::SET PYPATH=%userprofile%\AppData\Local\Programs\Python\Python313 + SET PYINCLUDE=%PYPATH%\include SET PYLIBS=%PYPATH%\libs -- cgit v1.3