|
| 1 | +# Build script for windows CPU |
| 2 | +# TODO unify this with the other Win scripts |
| 3 | + |
| 4 | +param ( |
| 5 | + [switch]$clone = $false, |
| 6 | + [switch]$install = $false, |
| 7 | + [string]$libsDir = "C:\" |
| 8 | +) |
| 9 | + |
| 10 | +$ErrorActionPreference = "Stop" |
| 11 | + |
| 12 | +$RepoURL = 'https://github.com/taichi-dev/taichi' |
| 13 | + |
| 14 | +function WriteInfo($text) { |
| 15 | + Write-Host -ForegroundColor Green "[BUILD] $text" |
| 16 | +} |
| 17 | + |
| 18 | +$libsDir = (Resolve-Path $libsDir).Path |
| 19 | +if (-not (Test-Path $libsDir)) { |
| 20 | + New-Item -ItemType Directory -Path $libsDir |
| 21 | +} |
| 22 | +Set-Location $libsDir |
| 23 | + |
| 24 | +if (-not (Test-Path "taichi_llvm")) { |
| 25 | + WriteInfo("Download and extract LLVM") |
| 26 | + curl.exe --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/taichi-llvm-10.0.0-msvc2019.zip -LO |
| 27 | + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE; } |
| 28 | + 7z x taichi-llvm-10.0.0-msvc2019.zip -otaichi_llvm |
| 29 | +} |
| 30 | +if (-not (Test-Path "taichi_clang")) { |
| 31 | + WriteInfo("Download and extract Clang") |
| 32 | + curl.exe --retry 10 --retry-delay 5 https://github.com/taichi-dev/taichi_assets/releases/download/llvm10/clang-10.0.0-win.zip -LO |
| 33 | + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE; } |
| 34 | + 7z x clang-10.0.0-win.zip -otaichi_clang |
| 35 | +} |
| 36 | + |
| 37 | +WriteInfo("Setting the env vars") |
| 38 | +$env:LLVM_DIR = "C://taichi_llvm" |
| 39 | + |
| 40 | +#TODO enable build test |
| 41 | +$env:TAICHI_CMAKE_ARGS = "-DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CC:BOOL=OFF -DTI_WITH_VULKAN:BOOL=OFF -DTI_WITH_CUDA:BOOL=OFF -DTI_BUILD_TESTS:BOOL=OFF" |
| 42 | + |
| 43 | +#TODO: For now we need to hard code the compiler path from build tools 2019 |
| 44 | +$env:TAICHI_CMAKE_ARGS +=' -DCMAKE_CXX_COMPILER=C:/Program\ Files\ (x86)/Microsoft\ Visual\ Studio/2019/BuildTools/vc/Tools/Llvm/x64/bin/clang++.exe -DCMAKE_C_COMPILER=C:/Program\ Files\ (x86)/Microsoft\ Visual\ Studio/2019/BuildTools/vc/Tools/Llvm/x64/bin/clang.exe' |
| 45 | +$env:TAICHI_CMAKE_ARGS += " -DCLANG_EXECUTABLE=C:\\taichi_clang\\bin\\clang++.exe" |
| 46 | +$env:TAICHI_CMAKE_ARGS += " -DLLVM_AS_EXECUTABLE=C:\\taichi_llvm\\bin\\llvm-as.exe -DTI_WITH_VULKAN:BOOL=OFF" |
| 47 | + |
| 48 | +WriteInfo("Checking clang compiler") |
| 49 | +clang --version |
| 50 | + |
| 51 | +WriteInfo("Enter the repository") |
| 52 | +Set-Location .\taichi |
| 53 | + |
| 54 | +# Get sccache |
| 55 | +WriteInfo("Downloading sccache") |
| 56 | +$env:CCACHE_DIR="${pwd}/ccache_cache" |
| 57 | +$env:CCACHE_MAXSIZE="128M" |
| 58 | +$env:CCACHE_LOGFILE="${pwd}/ccache_error.log" |
| 59 | +WriteInfo("ccache dir: $Env:CCACHE_DIR") |
| 60 | +md "$Env:CCACHE_DIR" -ea 0 |
| 61 | +if (-not (Test-Path "ccache-4.5.1-windows-64")) { |
| 62 | + curl.exe --retry 10 --retry-delay 5 https://github.com/ccache/ccache/releases/download/v4.5.1/ccache-4.5.1-windows-64.zip -LO |
| 63 | + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE; } |
| 64 | + 7z x ccache-4.5.1-windows-64.zip |
| 65 | + $env:PATH += ";${pwd}/ccache-4.5.1-windows-64" |
| 66 | +} |
| 67 | +ccache -v -s |
| 68 | + |
| 69 | +WriteInfo("Setting up Python environment") |
| 70 | +conda activate py37 |
| 71 | +python -m pip install -r requirements_dev.txt |
| 72 | +python -m pip install -r requirements_test.txt |
| 73 | + |
| 74 | +# These have to be re-installed to avoid strange certificate issue |
| 75 | +# on CPU docker environment |
| 76 | +python -m pip install --upgrade --force-reinstall numpy |
| 77 | +python -m pip install --upgrade --force-reinstall cmake |
| 78 | +python -m pip install --upgrade --force-reinstall wheel |
| 79 | +if (-not $?) { exit 1 } |
| 80 | + |
| 81 | +WriteInfo("Building Taichi") |
| 82 | +python setup.py install |
| 83 | +if (-not $?) { exit 1 } |
| 84 | +WriteInfo("Build finished") |
| 85 | +ccache -s -v |
| 86 | + |
| 87 | +# We skip the test for the moment due to the long job execution time. |
| 88 | +#$env:TI_ENABLE_PADDLE = "0" |
| 89 | +#WriteInfo("Testing Taichi") |
| 90 | +#python tests/run_tests.py -vr2 -t4 -k "not torch and not paddle" -a cpu |
| 91 | +#WriteInfo("Test finished") |
0 commit comments