dev_env.bat 2.18 KB
Newer Older
1 2 3 4 5 6 7 8
@echo off
:: check input arguments
if %1.==. (
  echo "No arch"
  call :Help
  goto :eof
)

9 10 11 12 13 14
if %2.==. (
  echo "No project"
  call :Help
  goto :eof
)

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
if /I "%1"=="help" (
  call :Help
  goto :eof
)

if /I "%1"=="/help" (
  call :Help
  goto :eof
)

if /I "%1"=="-help" (
  call :Help
  goto :eof
)

set ARCH=%1
31
set PROJECT=%2
32

33
if %3.==. (
34
  set SHORT_TARGET=10
35
) else (
36
  set SHORT_TARGET=%3
37 38
)

39
if %4.==. (
40 41
  set VCVER=14.0
) else (
42
  set VCVER=%4
43 44
)

45 46 47 48 49
set TARGET=%SHORT_TARGET%
if "%TARGET%"=="10" (
  set TARGET=10.0.17763.0
)

Guillaume Pasero's avatar
Guillaume Pasero committed
50
:: Setup home dir (so that ssh configuration works fine)
51
:: if "%USERNAME%"=="otbbot" (
Guillaume Pasero's avatar
Guillaume Pasero committed
52 53
  set HOMEDRIVE=C:
  set HOMEPATH=\Users\otbbot
54
::)
Guillaume Pasero's avatar
Guillaume Pasero committed
55
echo Home dir: %HOMEDRIVE%%HOMEPATH%
Guillaume Pasero's avatar
Guillaume Pasero committed
56

57
:: Setup Python
58 59
set PATH=C:\tools\Python35-%ARCH%;%PATH%
set PATH=C:\tools\Python35-%ARCH%\Scripts;%PATH%
60

61
:: Setup GL dlls
Guillaume Pasero's avatar
Guillaume Pasero committed
62
set PATH=%PATH%;C:\tools\GL\%ARCH%\bin
63

64
:: Setup compiler
Guillaume Pasero's avatar
Guillaume Pasero committed
65
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" %ARCH% %TARGET% -vcvars_ver=%VCVER%
66 67

:: Setup Clcache
68
set CLCACHE_DIR=C:\clcache\%PROJECT%-%ARCH%-%TARGET%-%VCVER%
69
set CLCACHE_HARDLINK=1
70
:: set CLCACHE_SERVER=1
71
set CLCACHE_CL=
Guillaume Pasero's avatar
Guillaume Pasero committed
72 73
for /F "delims=" %%a in ('where cl.exe') do @if defined CLCACHE_CL (break ) else (set CLCACHE_CL=%%a)

74 75
echo CL path: "%CLCACHE_CL%"

76 77 78
:: install clcache.exe as cl.exe
copy C:\tools\Python35-%ARCH%\Scripts\clcache.exe C:\clcache\cl.exe
set PATH=C:\clcache;%PATH%
Guillaume Pasero's avatar
Guillaume Pasero committed
79

Guillaume Pasero's avatar
Guillaume Pasero committed
80
:: we need to change cache max size: clcache -M <size-in-bytes>
81 82 83
if "%PROJECT%"=="xdk" (
  call "clcache.exe" -M 3000000000
)
Guillaume Pasero's avatar
Guillaume Pasero committed
84 85 86
if "%PROJECT%"=="otb" (
  call "clcache.exe" -M 2000000000
)
87

88 89 90
set IMAGE_NAME=windows-%SHORT_TARGET%-%ARCH%-vc%VCVER%
echo Generated IMAGE_NAME: %IMAGE_NAME%

Guillaume Pasero's avatar
Guillaume Pasero committed
91 92 93
:: setup path to perl, but add it last ... (there is a libstdc++.dll in that folder...)
set PATH=%PATH%;C:\tools\perl\perl\bin

94 95 96 97
goto :eof

:Help
setlocal
98
echo "Usage: dev_env.bat <compiler_arch>  <project>  [<target-os>  [<vc_version>]]"
99
echo "  <compiler_arch> : 'x86' | 'x64'"
100
echo "  <project>       : 'xdk' | 'otb'"
101
echo "  <target-os>     : '8.1' | '10' (default)"
102 103 104 105 106
echo "  <vc_version>    :"
echo "    '14.20' (i.e. VS 2019)"
echo "    '14.16' (i.e. VS 2017)"
echo "    '14.0'  (i.e. VS 2015) (default)"
endlocal