|
| 1 | +$LLVM_VERSION = $args[0] |
| 2 | +$LLVM_REPO_URL = $args[1] |
| 3 | + |
| 4 | +if ([string]::IsNullOrEmpty($LLVM_REPO_URL)) { |
| 5 | + $LLVM_REPO_URL = "https://github.com/llvm/llvm-project.git" |
| 6 | +} |
| 7 | + |
| 8 | +if ([string]::IsNullOrEmpty($LLVM_VERSION)) { |
| 9 | + Write-Output "Usage: $PSCommandPath <llvm-version> <llvm-repository-url>" |
| 10 | + Write-Output "" |
| 11 | + Write-Output "# Arguments" |
| 12 | + Write-Output " llvm-version The name of a LLVM release branch without the 'release/' prefix" |
| 13 | + Write-Output " llvm-repository-url The URL used to clone LLVM sources (default: https://github.com/llvm/llvm-project.git)" |
| 14 | + |
| 15 | + exit 1 |
| 16 | +} |
| 17 | + |
| 18 | +# Clone the LLVM project. |
| 19 | +if (-not (Test-Path -Path "llvm-project" -PathType Container)) { |
| 20 | + git clone "$LLVM_REPO_URL" llvm-project |
| 21 | +} |
| 22 | + |
| 23 | +Set-Location llvm-project |
| 24 | +git fetch origin |
| 25 | +git checkout "release/$LLVM_VERSION" |
| 26 | +git reset --hard origin/"release/$LLVM_VERSION" |
| 27 | + |
| 28 | +# Create a directory to build the project. |
| 29 | +New-Item -Path "build" -Force -ItemType "directory" |
| 30 | +Set-Location build |
| 31 | + |
| 32 | +# Create a directory to receive the complete installation. |
| 33 | +New-Item -Path "install" -Force -ItemType "directory" |
| 34 | + |
| 35 | +# Adjust compilation based on the OS. |
| 36 | +$CMAKE_ARGUMENTS = "" |
| 37 | + |
| 38 | +# Adjust cross compilation |
| 39 | +$CROSS_COMPILE = "" |
| 40 | + |
| 41 | +# Run `cmake` to configure the project. |
| 42 | +cmake ` |
| 43 | + -G "Visual Studio 16 2019" ` |
| 44 | + -DCMAKE_BUILD_TYPE=MinSizeRel ` |
| 45 | + -DCMAKE_INSTALL_PREFIX=destdir ` |
| 46 | + -DLLVM_ENABLE_PROJECTS="clang;lld" ` |
| 47 | + -DLLVM_ENABLE_TERMINFO=OFF ` |
| 48 | + -DLLVM_ENABLE_ZLIB=OFF ` |
| 49 | + -DLLVM_INCLUDE_DOCS=OFF ` |
| 50 | + -DLLVM_INCLUDE_EXAMPLES=OFF ` |
| 51 | + -DLLVM_INCLUDE_GO_TESTS=OFF ` |
| 52 | + -DLLVM_INCLUDE_TESTS=OFF ` |
| 53 | + -DLLVM_INCLUDE_TOOLS=ON ` |
| 54 | + -DLLVM_INCLUDE_UTILS=OFF ` |
| 55 | + -DLLVM_OPTIMIZED_TABLEGEN=ON ` |
| 56 | + -DLLVM_TARGETS_TO_BUILD="X86;AArch64" ` |
| 57 | + $CROSS_COMPILE ` |
| 58 | + $CMAKE_ARGUMENTS ` |
| 59 | + ../llvm |
| 60 | + |
| 61 | +# Showtime! |
| 62 | +cmake --build . --config Release |
| 63 | + |
| 64 | +# Not using DESTDIR here, quote from |
| 65 | +# https://cmake.org/cmake/help/latest/envvar/DESTDIR.html |
| 66 | +# > `DESTDIR` may not be used on Windows because installation prefix |
| 67 | +# > usually contains a drive letter like in `C:/Program Files` which cannot |
| 68 | +# > be prepended with some other prefix. |
| 69 | +cmake --install . --strip --config Release |
0 commit comments