|
| 1 | +@echo off |
| 2 | +setlocal enabledelayedexpansion |
| 3 | + |
| 4 | +set LLVM_VERSION=13.0.0 |
| 5 | +set MESA_VERSION=21.3.1 |
| 6 | + |
| 7 | +set PATH=%CD%\llvm\bin;%CD%\winflexbison;%PATH% |
| 8 | + |
| 9 | +rem *** check dependencies *** |
| 10 | + |
| 11 | +where /q python.exe || ( |
| 12 | + echo ERROR: "python.exe" not found |
| 13 | + exit /b 1 |
| 14 | +) |
| 15 | + |
| 16 | +where /q pip.exe || ( |
| 17 | + echo ERROR: "pip.exe" not found |
| 18 | + exit /b 1 |
| 19 | +) |
| 20 | + |
| 21 | +where /q meson.exe || ( |
| 22 | + pip install meson |
| 23 | + where /q meson.exe || ( |
| 24 | + echo ERROR: "meson.exe" not found |
| 25 | + exit /b 1 |
| 26 | + ) |
| 27 | +) |
| 28 | + |
| 29 | +python -c "import mako" 2>nul || ( |
| 30 | + pip install mako |
| 31 | + python -c "import mako" 2>nul || ( |
| 32 | + echo ERROR: "mako" module not found for python |
| 33 | + exit /b 1 |
| 34 | + ) |
| 35 | +) |
| 36 | + |
| 37 | +where /q git.exe || ( |
| 38 | + echo ERROR: "git.exe" not found |
| 39 | + exit /b 1 |
| 40 | +) |
| 41 | + |
| 42 | +where /q curl.exe || ( |
| 43 | + echo ERROR: "curl.exe" not found |
| 44 | + exit /b 1 |
| 45 | +) |
| 46 | + |
| 47 | +if exist "%ProgramFiles%\7-Zip\7z.exe" ( |
| 48 | + set SZIP="%ProgramFiles%\7-Zip\7z.exe" |
| 49 | +) else ( |
| 50 | + where /q 7za.exe || ( |
| 51 | + echo ERROR: 7-Zip installation or "7za.exe" not found |
| 52 | + exit /b 1 |
| 53 | + ) |
| 54 | + set SZIP=7za.exe |
| 55 | +) |
| 56 | + |
| 57 | +where /q cmake.exe || ( |
| 58 | + echo ERROR: "cmake.exe" not found |
| 59 | + exit /b 1 |
| 60 | +) |
| 61 | + |
| 62 | +where /q ninja.exe || ( |
| 63 | + curl -Lsf -o ninja-win.zip https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip || exit /b 1 |
| 64 | + %SZIP% x -bb0 -y ninja-win.zip 1>nul 2>nul || exit /b 1 |
| 65 | + del ninja-win.zip 1>nul 2>nul |
| 66 | +) |
| 67 | + |
| 68 | +rem *** Visual Studio environment *** |
| 69 | + |
| 70 | +where /Q cl.exe || ( |
| 71 | + set __VSCMD_ARG_NO_LOGO=1 |
| 72 | + for /f "tokens=*" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath') do set VS=%%i |
| 73 | + if "!VS!" equ "" ( |
| 74 | + echo ERROR: Visual Studio installation not found |
| 75 | + exit /b 1 |
| 76 | + ) |
| 77 | + call "!VS!\VC\Auxiliary\Build\vcvarsall.bat" amd64 || exit /b 1 |
| 78 | +) |
| 79 | + |
| 80 | +rem *** download sources *** |
| 81 | + |
| 82 | +echo Downloading llvm |
| 83 | +curl -sfL https://github.com/llvm/llvm-project/releases/download/llvmorg-%LLVM_VERSION%/llvm-%LLVM_VERSION%.src.tar.xz ^ |
| 84 | + | %SZIP% x -bb0 -txz -si -so ^ |
| 85 | + | %SZIP% x -bb0 -ttar -si -aoa 1>nul 2>nul |
| 86 | +move llvm-%LLVM_VERSION%.src llvm.src |
| 87 | + |
| 88 | +echo Downloading mesa |
| 89 | +curl -sfL https://archive.mesa3d.org//mesa-%MESA_VERSION%.tar.xz ^ |
| 90 | + | %SZIP% x -bb0 -txz -si -so ^ |
| 91 | + | %SZIP% x -bb0 -ttar -si -aoa 1>nul 2>nul |
| 92 | +move mesa-%MESA_VERSION% mesa.src |
| 93 | +git apply -p0 --directory=mesa.src mesa.patch || exit /b 1 |
| 94 | + |
| 95 | +echo Downloading win_flex_bison |
| 96 | +if not exist winflexbison ( |
| 97 | + mkdir winflexbison |
| 98 | + pushd winflexbison |
| 99 | + curl -sfL -o win_flex_bison-2.5.24.zip https://github.com/lexxmark/winflexbison/releases/download/v2.5.24/win_flex_bison-2.5.24.zip || exit /b 1 |
| 100 | + %SZIP% x -bb0 -y win_flex_bison-2.5.24.zip 1>nul 2>nul || exit /b 1 |
| 101 | + del win_flex_bison-2.5.24.zip 1>nul 2>nul |
| 102 | + popd |
| 103 | +) |
| 104 | + |
| 105 | +del "@PaxHeader" "HEAD" "pax_global_header" 1>nul 2>nul |
| 106 | + |
| 107 | +rem *** llvm *** |
| 108 | + |
| 109 | +cmake ^ |
| 110 | + -G Ninja ^ |
| 111 | + -S llvm.src ^ |
| 112 | + -B llvm.build ^ |
| 113 | + -D CMAKE_INSTALL_PREFIX="%CD%\llvm" ^ |
| 114 | + -D CMAKE_BUILD_TYPE="Release" ^ |
| 115 | + -D BUILD_SHARED_LIBS=OFF ^ |
| 116 | + -D LLVM_TARGETS_TO_BUILD="X86" ^ |
| 117 | + -D LLVM_ENABLE_BACKTRACES=OFF ^ |
| 118 | + -D LLVM_ENABLE_UNWIND_TABLES=OFF ^ |
| 119 | + -D LLVM_ENABLE_CRASH_OVERRIDES=OFF ^ |
| 120 | + -D LLVM_ENABLE_TERMINFO=OFF ^ |
| 121 | + -D LLVM_ENABLE_LIBXML2=OFF ^ |
| 122 | + -D LLVM_ENABLE_LIBEDIT=OFF ^ |
| 123 | + -D LLVM_ENABLE_LIBPFM=OFF ^ |
| 124 | + -D LLVM_ENABLE_ZLIB=OFF ^ |
| 125 | + -D LLVM_ENABLE_Z3_SOLVER=OFF ^ |
| 126 | + -D LLVM_ENABLE_WARNINGS=OFF ^ |
| 127 | + -D LLVM_ENABLE_PEDANTIC=OFF ^ |
| 128 | + -D LLVM_ENABLE_WERROR=OFF ^ |
| 129 | + -D LLVM_ENABLE_ASSERTIONS=OFF ^ |
| 130 | + -D LLVM_BUILD_UTILS=OFF ^ |
| 131 | + -D LLVM_BUILD_TESTS=OFF ^ |
| 132 | + -D LLVM_BUILD_DOCS=OFF ^ |
| 133 | + -D LLVM_BUILD_EXAMPLES=OFF ^ |
| 134 | + -D LLVM_BUILD_BENCHMARKS=OFF ^ |
| 135 | + -D LLVM_INCLUDE_UTILS=OFF ^ |
| 136 | + -D LLVM_INCLUDE_TESTS=OFF ^ |
| 137 | + -D LLVM_INCLUDE_DOCS=OFF ^ |
| 138 | + -D LLVM_INCLUDE_EXAMPLES=OFF ^ |
| 139 | + -D LLVM_INCLUDE_BENCHMARKS=OFF ^ |
| 140 | + -D LLVM_ENABLE_BINDINGS=OFF ^ |
| 141 | + -D LLVM_OPTIMIZED_TABLEGEN=ON ^ |
| 142 | + -D LLVM_ENABLE_PLUGINS=OFF ^ |
| 143 | + -D LLVM_USE_CRT_RELEASE=MT ^ |
| 144 | + -D LLVM_ENABLE_IDE=OFF || exit /b 1 |
| 145 | +ninja -C llvm.build |
| 146 | +ninja -C llvm.build install || exit /b 1 |
| 147 | + |
| 148 | +rem *** mesa llvmpipe *** |
| 149 | + |
| 150 | +rd /s /q mesa.build 1>nul 2>nul |
| 151 | +meson setup ^ |
| 152 | + mesa.build ^ |
| 153 | + mesa.src ^ |
| 154 | + --prefix="%CD%\mesa-llvmpipe" ^ |
| 155 | + --default-library=static ^ |
| 156 | + -Dbuildtype=release ^ |
| 157 | + -Db_ndebug=true ^ |
| 158 | + -Db_vscrt=mt ^ |
| 159 | + -Dllvm=enabled ^ |
| 160 | + -Dplatforms=windows ^ |
| 161 | + -Dosmesa=true ^ |
| 162 | + -Dgallium-drivers=swrast || exit /b 1 |
| 163 | +ninja -C mesa.build install || exit /b 1 |
| 164 | + |
| 165 | +rem *** mesa d3d12 *** |
| 166 | + |
| 167 | +rd /s /q mesa.build 1>nul 2>nul |
| 168 | +meson setup ^ |
| 169 | + mesa.build ^ |
| 170 | + mesa.src ^ |
| 171 | + --prefix="%CD%\mesa-d3d12" ^ |
| 172 | + --default-library=static ^ |
| 173 | + -Dbuildtype=release ^ |
| 174 | + -Db_ndebug=true ^ |
| 175 | + -Db_vscrt=mt ^ |
| 176 | + -Dllvm=disabled ^ |
| 177 | + -Dplatforms=windows ^ |
| 178 | + -Dosmesa=false ^ |
| 179 | + -Dgallium-drivers=d3d12 || exit /b 1 |
| 180 | +ninja -C mesa.build install || exit /b 1 |
| 181 | + |
| 182 | +rem *** done *** |
| 183 | +rem output is in mesa-d3d12 and mesa-llvmpipe folders |
| 184 | + |
| 185 | +if "%GITHUB_WORKFLOW%" neq "" ( |
| 186 | + mkdir archive-llvmpipe |
| 187 | + pushd archive-llvmpipe |
| 188 | + copy /y ..\mesa-llvmpipe\bin\opengl32.dll . |
| 189 | + %SZIP% a -mx=9 ..\mesa-llvmpipe-%MESA_VERSION%.zip |
| 190 | + popd |
| 191 | + |
| 192 | + mkdir archive-osmesa |
| 193 | + pushd archive-osmesa |
| 194 | + copy /y ..\mesa-llvmpipe\bin\osmesa.dll . |
| 195 | + copy /y ..\mesa-llvmpipe\lib\osmesa.lib . |
| 196 | + copy /y ..\mesa-llvmpipe\include\GL\osmesa.h . |
| 197 | + %SZIP% a -mx=9 ..\mesa-osmesa-%MESA_VERSION%.zip |
| 198 | + popd |
| 199 | + |
| 200 | + mkdir archive-d3d12 |
| 201 | + pushd archive-d3d12 |
| 202 | + copy /y ..\mesa-d3d12\bin\opengl32.dll . |
| 203 | + copy /y "%ProgramFiles(x86)%\Windows Kits\10\Redist\D3D\x64\dxil.dll" . |
| 204 | + %SZIP% a -mx=9 ..\mesa-d3d12-%MESA_VERSION%.zip |
| 205 | + popd |
| 206 | + |
| 207 | + echo ::set-output name=LLVM_VERSION::%LLVM_VERSION% |
| 208 | + echo ::set-output name=MESA_VERSION::%MESA_VERSION% |
| 209 | +) |
0 commit comments