-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build-coredistools.cmd build-coredistools.sh build-tblgen.cmd
- Loading branch information
Showing
3 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
@echo off | ||
setlocal | ||
|
||
set RootDirectory=%~dp0 | ||
set SourcesDirectory=%RootDirectory%src | ||
set BinariesDirectory=%RootDirectory%obj | ||
set TargetOSArchitecture=%1 | ||
|
||
if /i "%TargetOSArchitecture%" == "windows-arm" ( | ||
set GeneratorPlatform=ARM | ||
) else if /i "%TargetOSArchitecture%" == "windows-arm64" ( | ||
set GeneratorPlatform=ARM64 | ||
) else if /i "%TargetOSArchitecture%" == "windows-x64" ( | ||
set GeneratorPlatform=x64 | ||
) else if /i "%TargetOSArchitecture%" == "windows-x86" ( | ||
set GeneratorPlatform=Win32 | ||
) else ( | ||
echo "Unknown target OS and architecture: %TargetOSArchitecture%" | ||
exit /b 1 | ||
) | ||
|
||
where /q llvm-tblgen.exe | ||
|
||
if %ERRORLEVEL% neq 0 ( | ||
echo llvm-tblgen.exe is not found in the PATH | ||
exit /b 1 | ||
) | ||
|
||
for /f %%I in ('where llvm-tblgen.exe') do ( | ||
set LLVMTableGen=%%~I | ||
) | ||
|
||
if not exist "%BinariesDirectory%" ( | ||
mkdir "%BinariesDirectory%" | ||
) | ||
|
||
pushd "%BinariesDirectory%" | ||
|
||
cmake.exe ^ | ||
-G "Visual Studio 16 2019" ^ | ||
-A %GeneratorPlatform% ^ | ||
-DCMAKE_INSTALL_PREFIX="%RootDirectory%\" ^ | ||
-DLLVM_EXTERNAL_PROJECTS=coredistools ^ | ||
-DLLVM_EXTERNAL_COREDISTOOLS_SOURCE_DIR="%SourcesDirectory%\coredistools" ^ | ||
-DLLVM_TABLEGEN="%LLVMTableGen%" ^ | ||
-DLLVM_TARGETS_TO_BUILD=AArch64;ARM;X86 ^ | ||
-DLLVM_TOOL_COREDISTOOLS_BUILD=ON ^ | ||
"%SourcesDirectory%\llvm-project\llvm" | ||
|
||
popd | ||
|
||
cmake.exe ^ | ||
--build "%BinariesDirectory%" ^ | ||
--target coredistools ^ | ||
--config Release | ||
|
||
if %ERRORLEVEL% neq 0 ( | ||
echo coredistools compilation has failed | ||
exit /b 1 | ||
) | ||
|
||
cmake.exe ^ | ||
--install "%BinariesDirectory%" ^ | ||
--component coredistools | ||
|
||
exit /b 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/usr/bin/env bash | ||
|
||
RootDirectory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
SourcesDirectory=$RootDirectory/src | ||
BinariesDirectory=$RootDirectory/obj | ||
TargetOSArchitecture=$1 | ||
CrossRootfsDirectory=$2 | ||
|
||
case "$TargetOSArchitecture" in | ||
linux-arm) | ||
CrossCompiling=1 | ||
TargetTriple=arm-linux-gnueabihf | ||
;; | ||
|
||
linux-arm64) | ||
CrossCompiling=1 | ||
TargetTriple=aarch64-linux-gnu | ||
;; | ||
|
||
linux-x64|macos-x64) | ||
CrossCompiling=0 | ||
;; | ||
|
||
*) | ||
echo "Unknown target OS and architecture: $TargetOSArchitecture" | ||
exit 1 | ||
esac | ||
|
||
if [[ $CrossCompiling -eq 1 && ! -d $CrossRootfsDirectory ]]; then | ||
echo "Invalid or unspecified CrossRootfsDirectory: $CrossRootfsDirectory" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d $BinariesDirectory ]; then | ||
mkdir -p $BinariesDirectory | ||
fi | ||
|
||
pushd "$BinariesDirectory" | ||
|
||
if [ "$CrossCompiling" -eq 1 ]; then | ||
cmake \ | ||
-G "Unix Makefiles" \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DCMAKE_CROSSCOMPILING=ON \ | ||
-DCMAKE_C_COMPILER=$(which clang) \ | ||
-DCMAKE_C_FLAGS="-target $TargetTriple --sysroot=$CrossRootfsDirectory" \ | ||
-DCMAKE_CXX_COMPILER=$(which clang++) \ | ||
-DCMAKE_CXX_FLAGS="-target $TargetTriple --sysroot=$CrossRootfsDirectory" \ | ||
-DCMAKE_INCLUDE_PATH=$CrossRootfsDirectory/usr/include \ | ||
-DCMAKE_INSTALL_PREFIX=$RootDirectory \ | ||
-DCMAKE_LIBRARY_PATH=$CrossRootfsDirectory/usr/lib/$TargetTriple \ | ||
-DLLVM_EXTERNAL_PROJECTS=coredistools \ | ||
-DLLVM_EXTERNAL_COREDISTOOLS_SOURCE_DIR=$SourcesDirectory/coredistools \ | ||
-DLLVM_HOST_TRIPLE=$TargetTriple \ | ||
-DLLVM_TABLEGEN=$(which llvm-tblgen) \ | ||
-DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86" \ | ||
-DLLVM_TOOL_COREDISTOOLS_BUILD=ON \ | ||
$SourcesDirectory/llvm-project/llvm | ||
else | ||
cmake \ | ||
-G "Unix Makefiles" \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DCMAKE_C_COMPILER=$(which clang) \ | ||
-DCMAKE_CXX_COMPILER=$(which clang++) \ | ||
-DCMAKE_INSTALL_PREFIX=$RootDirectory \ | ||
-DLLVM_EXTERNAL_PROJECTS=coredistools \ | ||
-DLLVM_EXTERNAL_COREDISTOOLS_SOURCE_DIR=$SourcesDirectory/coredistools \ | ||
-DLLVM_TABLEGEN=$(which llvm-tblgen) \ | ||
-DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86" \ | ||
-DLLVM_TOOL_COREDISTOOLS_BUILD=ON \ | ||
$SourcesDirectory/llvm-project/llvm | ||
fi | ||
|
||
popd | ||
|
||
cmake \ | ||
--build $BinariesDirectory \ | ||
--target coredistools | ||
|
||
if [ "$?" -ne 0 ]; then | ||
echo "coredistools compilation has failed" | ||
exit 1 | ||
fi | ||
|
||
cmake \ | ||
--install $BinariesDirectory \ | ||
--component coredistools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
@echo off | ||
setlocal | ||
|
||
set RootDirectory=%~dp0 | ||
set SourcesDirectory=%RootDirectory%src | ||
set BinariesDirectory=%RootDirectory%obj | ||
set StagingDirectory=%RootDirectory%bin | ||
|
||
if not exist "%BinariesDirectory%" ( | ||
mkdir "%BinariesDirectory%" | ||
) | ||
|
||
pushd "%BinariesDirectory%" | ||
|
||
cmake.exe ^ | ||
-G "Visual Studio 16 2019" ^ | ||
-DCMAKE_INSTALL_PREFIX="%RootDirectory%\" ^ | ||
-DLLVM_TARGETS_TO_BUILD=AArch64;ARM;X86 ^ | ||
"%SourcesDirectory%\llvm-project\llvm" | ||
|
||
popd | ||
|
||
cmake.exe ^ | ||
--build %BinariesDirectory% ^ | ||
--target llvm-tblgen ^ | ||
--config Release | ||
|
||
if %ERRORLEVEL% neq 0 ( | ||
echo llvm-tblgen compilation has failed | ||
exit /b 1 | ||
) | ||
|
||
if not exist "%StagingDirectory%" ( | ||
mkdir "%StagingDirectory%" | ||
) | ||
|
||
for /r "%BinariesDirectory%" %%I in (llvm-tblgen.ex?) do ( | ||
if "%%~nxI" == "llvm-tblgen.exe" ( | ||
xcopy "%%~I" "%StagingDirectory%" | ||
exit /b 0 | ||
) | ||
) | ||
|
||
echo llvm-tblgen.exe is not found in "%BinariesDirectory%" | ||
exit /b 1 |