-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmsvc-build.bat
148 lines (121 loc) · 5.17 KB
/
msvc-build.bat
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
@echo off
cd %~dp0
set curdir=%CD%
@rem The visual studio solutions now target a specific windows SDK :-(
set winsdk=10.0.17134.0
@rem Defaults
set config=Debug
set platform=x64
set vsplatform=x64
set target=Build
@rem Help?
if /i "%1"=="help" goto help
if /i "%1"=="--help" goto help
if /i "%1"=="-help" goto help
if /i "%1"=="/help" goto help
if /i "%1"=="?" goto help
if /i "%1"=="-?" goto help
if /i "%1"=="--?" goto help
if /i "%1"=="/?" goto help
@rem Process arguments
:next-arg
if "%1"=="" goto args-done
if /i "%1"=="debug" set config=Debug&goto arg-ok
if /i "%1"=="release" set config=Release&goto arg-ok
if /i "%1"=="x86" set platform=x86&set vsplatform=Win32&goto arg-ok
if /i "%1"=="win32" set platform=x86&set vsplatform=Win32&goto arg-ok
if /i "%1"=="x64" set platform=x64&set vsplatform=x64&goto arg-ok
:arg-ok
shift
goto next-arg
:args-done
echo Looking for Visual Studio 2017
@rem Check if VS2017 is already setup, and for the requested arch.
if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%platform%_" goto found_vs2017
set "VSINSTALLDIR="
call deps\libuv\tools\vswhere_usability_wrapper.cmd
if "_%VCINSTALLDIR%_" == "__" goto error-need-vs2017
@rem Need to clear VSINSTALLDIR for vcvarsall to work as expected.
@rem Keep current working directory after call to vcvarsall
set "VSCMD_START_DIR=%CD%"
set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %platform%
echo calling: %vcvars_call%
call %vcvars_call%
if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%platform%_" goto found_vs2017
goto error-need-vs2017
:found_vs2017
echo Found MSVC version %VisualStudioVersion%
@rem Check if VS build env is available
if not defined VCINSTALLDIR goto error-need-msbuild
if not defined WindowsSDKDir goto error-need-msbuild
@rem Check Windows SDK version
if "_%WINDOWSSDKLIBVERSION%_" NEQ "_%winsdk%\_" goto error-wrong-winsdk
@rem Check for Python
if not defined PYTHON set PYTHON=python
@"%PYTHON%" --version
if errorlevel 1 goto error-need-python /b 1
echo.
echo Start build...
@rem Build libhandler
echo Build Libhandler... for %platform%, %vsplatform%
echo msbuild deps/libhandler/ide/msvc/libhandler.vcxproj /t:%target% /p:Configuration=%config% /p:Platform="%vsplatform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
msbuild deps/libhandler/ide/msvc/libhandler.vcxproj /t:%target% /p:Configuration=%config% /p:Platform="%vsplatform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 goto error-build /b 1
@rem Build libuv
echo.
echo Build LibUV...
call deps/libuv/vcbuild.bat %platform% %config% vs2017 static
cd %curdir%
if errorlevel 1 goto error-build /b 1
@rem Build zlib
echo.
echo Build ZLib...
set zlib-config=%config%
if "_%zlib-config%_"=="_Release_" set zlib-config=ReleaseWithoutAsm
echo msbuild deps/zlib/contrib/vstudio/vc14/zlibstat.vcxproj /t:%target% /p:Configuration=%zlib-config% /p:Platform="%vsplatform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
msbuild deps/zlib/contrib/vstudio/vc14/zlibstat.vcxproj /t:%target% /p:Configuration=%zlib-config% /p:Platform="%vsplatform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 goto error-build /b 1
@rem Build mbedTLS
echo.
echo Build mbedTLS...
copy /Y deps\mbedTLS-vs2017.vcxproj deps\mbedtls\visualc\VS2010
echo msbuild deps/mbedtls/visualc/VS2010/mbedTLS-vs2017.vcxproj /t:%target% /p:Configuration=%config% /p:Platform="%vsplatform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
msbuild deps/mbedtls/visualc/VS2010/mbedTLS-vs2017.vcxproj /t:%target% /p:Configuration=%config% /p:Platform="%vsplatform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 goto error-build /b 1
@rem Build NodeC
echo Build NodeC...
msbuild ide/msvc/nodec.vcxproj /t:%target% /p:Configuration=%config% /p:Platform="%vsplatform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
if errorlevel 1 goto error-build /b 1
:done
echo.
echo Success!
echo NodeC library generated as : "out/msvc-%vsplatform%/nodecx/%config%/nodecx.lib"
echo NodeC includes are found in: "out/msvc-%vsplatform%/nodecx/inc"
echo done.
goto end
:error-need-vs2017
echo ERROR: cannot find Visual Studio 2017.
echo You can install the free community edition from: https://visualstudio.microsoft.com/downloads
goto end
:error-need-msbuild
echo ERROR: cannot find msbuild, this file needs to run from the Visual Studio Developer command prompt.
goto end
:error-need-python
echo ERROR: cannot find Python -- it is needed to build libuv.
echo Either set the PYTHON environment variable, or
echo Install Python 2.7 from: https://www.python.org/downloads/release/python-2715
goto end
:error-wrong-winsdk
echo ERROR: Wrong Windows SDK version! Found "%WINDOWSSDKLIBVERSION%", but need "%winsdk%\".
echo Try "https://blogs.msdn.microsoft.com/chuckw/2018/05/02/windows-10-april-2018-update-sdk/" to upgrade the Windows SDK?
goto end
:error-build
echo ERROR: Build error.
goto end
:help
echo msvc-build.bat [debug/release] [x86/x64]
echo Examples:
echo msvc-build.bat : builds debug x64
echo msvc-build.bat release x86: builds 32bit release build
goto end
:end