forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen-buildsys.cmd
More file actions
104 lines (89 loc) · 3.65 KB
/
Copy pathgen-buildsys.cmd
File metadata and controls
104 lines (89 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
@if not defined _echo @echo off
rem
rem This file invokes cmake and generates the build system for windows.
setlocal
set argC=0
for %%x in (%*) do Set /A argC+=1
if %argC% lss 4 GOTO :USAGE
if %1=="/?" GOTO :USAGE
setlocal enabledelayedexpansion
set basePath=%~dp0
set __repoRoot=%~dp0..\..\
:: remove quotes
set "basePath=%basePath:"=%"
:: remove trailing slash
if %basePath:~-1%==\ set "basePath=%basePath:~0,-1%"
set __SourceDir=%1
set __IntermediatesDir=%2
set __VSVersion=%3
set __Arch=%4
set __CmakeGenerator=Visual Studio
set __UseEmcmake=0
if /i "%__Ninja%" == "1" (
set __CmakeGenerator=Ninja
) else (
if /i NOT "%__Arch%" == "wasm" (
if /i "%__VSVersion%" == "vs2022" (set __CmakeGenerator=%__CmakeGenerator% 17 2022)
if /i "%__Arch%" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
if /i "%__Arch%" == "arm" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
if /i "%__Arch%" == "arm64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
if /i "%__Arch%" == "x86" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32)
) else (
set __CmakeGenerator=NMake Makefiles
)
)
if /i "%__Arch%" == "wasm" (
if "%EMSDK_PATH%" == "" (
if not exist "%__repoRoot%src\mono\wasm\emsdk" (
echo Error: Should set EMSDK_PATH environment variable pointing to emsdk root.
exit /B 1
)
set EMSDK_PATH=%__repoRoot%src\mono\wasm\emsdk
set EMSDK_PATH=!EMSDK_PATH:\=/!
)
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_TOOLCHAIN_FILE=!EMSDK_PATH!/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
set __UseEmcmake=1
) else (
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_SYSTEM_VERSION=10.0"
)
:loop
if [%5] == [] goto end_loop
set __ExtraCmakeParams=%__ExtraCmakeParams% %5
shift
goto loop
:end_loop
set __ExtraCmakeParams="-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DCLR_CMAKE_HOST_ARCH=%__Arch%" %__ExtraCmakeParams%
set __CmdLineOptionsUpToDateFile=%__IntermediatesDir%\cmake_cmd_line.txt
set __CMakeCmdLineCache=
if not "%__ConfigureOnly%" == "1" (
REM MSBuild can't reload from a CMake reconfigure during build correctly, so only do this
REM command-line up to date check for non-VS generators.
if "%__CmakeGenerator:Visual Studio=%" == "%__CmakeGenerator%" (
if exist "%__CmdLineOptionsUpToDateFile%" (
set /p __CMakeCmdLineCache=<"%__CmdLineOptionsUpToDateFile%"
REM Strip the extra space from the end of the cached command line
if "!__ExtraCmakeParams!" == "!__CMakeCmdLineCache:~0,-1!" (
echo The CMake command line is the same as the last run. Skipping running CMake.
exit /B 0
) else (
echo The CMake command line differs from the last run. Running CMake again.
echo %__ExtraCmakeParams% > %__CmdLineOptionsUpToDateFile%
)
) else (
echo %__ExtraCmakeParams% > %__CmdLineOptionsUpToDateFile%
)
)
)
if /i "%__UseEmcmake%" == "1" (
call "!EMSDK_PATH!/emsdk_env.bat" > nul 2>&1 && emcmake "%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
) else (
"%CMakePath%" %__ExtraCmakeParams% --no-warn-unused-cli -G "%__CmakeGenerator%" -B %__IntermediatesDir% -S %__SourceDir%
)
endlocal
exit /B %errorlevel%
:USAGE
echo "Usage..."
echo "gen-buildsys.cmd <path to top level CMakeLists.txt> <path to location for intermediate files> <VSVersion> <arch>"
echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP"
echo "Specify the VSVersion to be used - VS2017 or VS2019"
EXIT /B 1