env.bat 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. echo off
  2. set "SCRIPTROOT=%~dp0"
  3. set "SCRIPTROOT=%SCRIPTROOT:~0,-1%"
  4. rem ----- Reset values to defaults -----
  5. set "VCVER=vc14"
  6. set "ARCH=64"
  7. set "CASDEB="
  8. if not ["%1"] == [""] set "VCVER=%1"
  9. if not ["%2"] == [""] set "ARCH=%2"
  10. if /I ["%ARCH%"] == ["win32"] set "ARCH=32"
  11. if /I ["%ARCH%"] == ["win64"] set "ARCH=64"
  12. if /I ["%3"] == ["debug"] set "CASDEB=d"
  13. if /I ["%3"] == ["d"] set "CASDEB=d"
  14. if /I ["%3"] == ["i"] set "CASDEB=i"
  15. if /I ["%3"] == ["relwithdeb"] set "CASDEB=i"
  16. rem ----- Decode VCVER variable and define related ones -----
  17. rem
  18. rem VCFMT - "vc" followed by full version number of Visual Studio toolset
  19. rem (same as VCVER without optional suffix "-uwp")
  20. rem VCLIB - name of folder contining binaries
  21. rem (same as VCVER except without third version in number)
  22. rem VCPROP - name of required Visual Studion Workload (starting with VS 2017)
  23. rem
  24. rem Note that for VS before 2015 (vc14) always
  25. rem VCFMT=VCLIB=VCVER and VCPROP=NativeDesktop
  26. rem Since VS 2017, environment variables like VS100COMNTOOLS are not defined
  27. rem any more, we can only use vswhere.exe tool to find Visual Studio.
  28. rem Add path to vswhere.exe
  29. if /I not "%VCFMT%" == "gcc" (
  30. set "PATH=%PATH%;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
  31. )
  32. rem for vc10-12, interpretation is trivial
  33. set VCFMT=%VCVER%
  34. set VCLIB=%VCVER:~0,4%
  35. set VCPROP=NativeDesktop
  36. rem vc14 and later can have optional suffix "-uwp"
  37. if "%VCVER:~-4%" == "-uwp" (
  38. set VCFMT=%VCVER:~0,-4%
  39. set VCLIB=%VCLIB%-uwp
  40. set VCPROP=Universal
  41. )
  42. rem echo VCVER=%VCVER% VCFMT=%VCFMT% VCLIB=%VCLIB% VCPROP=%VCPROP%
  43. rem ----- Parsing of Visual Studio platform -----
  44. set "VisualStudioExpressName=VCExpress"
  45. if not "%DevEnvDir%" == "" (
  46. rem If DevEnvDir is already defined (e.g. in custom.bat), use that value
  47. ) else if /I "%VCFMT%" == "vc9" (
  48. set "DevEnvDir=%VS90COMNTOOLS%..\IDE"
  49. ) else if /I "%VCFMT%" == "vc10" (
  50. set "DevEnvDir=%VS100COMNTOOLS%..\IDE"
  51. ) else if /I "%VCFMT%" == "vc11" (
  52. set "DevEnvDir=%VS110COMNTOOLS%..\IDE"
  53. rem Visual Studio Express starting from VS 2012 is called "for Windows Desktop"
  54. rem and has a new name for executable - WDExpress
  55. set "VisualStudioExpressName=WDExpress"
  56. ) else if /I "%VCFMT%" == "vc12" (
  57. set "DevEnvDir=%VS120COMNTOOLS%..\IDE"
  58. set "VisualStudioExpressName=WDExpress"
  59. ) else if /I "%VCFMT%" == "vc14" (
  60. set "DevEnvDir=%VS140COMNTOOLS%..\IDE"
  61. ) else if /I "%VCFMT%" == "vc141" (
  62. for /f "usebackq delims=" %%i in (`vswhere.exe -version "[15.0,15.99]" -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
  63. set "DevEnvDir=%%i\Common7\IDE\"
  64. )
  65. ) else if /I "%VCFMT%" == "vc142" (
  66. for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
  67. set "DevEnvDir=%%i\Common7\IDE\"
  68. )
  69. ) else if /I "%VCFMT%" == "gcc" (
  70. rem MinGW
  71. ) else (
  72. echo Error: wrong VS identifier
  73. exit /B
  74. )
  75. rem ----- Parsing vcvarsall for qt samples and define PlatformToolset -----
  76. if /I "%VCFMT%" == "vc9" (
  77. set "VCVARS=%VS90COMNTOOLS%..\..\VC\vcvarsall.bat"
  78. set "VCPlatformToolSet=v90"
  79. ) else if /I "%VCFMT%" == "vc10" (
  80. set "VCVARS=%VS100COMNTOOLS%..\..\VC\vcvarsall.bat"
  81. set "VCPlatformToolSet=v100"
  82. ) else if /I "%VCFMT%" == "vc11" (
  83. set "VCVARS=%VS110COMNTOOLS%..\..\VC\vcvarsall.bat"
  84. set "VCPlatformToolSet=v110"
  85. ) else if /I "%VCFMT%" == "vc12" (
  86. set "VCVARS=%VS120COMNTOOLS%..\..\VC\vcvarsall.bat"
  87. set "VCPlatformToolSet=v120"
  88. ) else if /I "%VCFMT%" == "vc14" (
  89. set "VCVARS=%VS140COMNTOOLS%..\..\VC\vcvarsall.bat"
  90. set "VCPlatformToolSet=v140"
  91. ) else if /I "%VCFMT%" == "vc141" (
  92. for /f "usebackq delims=" %%i in (`vswhere.exe -version "[15.0,15.99]" -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
  93. set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
  94. )
  95. set "VCPlatformToolSet=v141"
  96. ) else if /I "%VCFMT%" == "vc142" (
  97. for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
  98. set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
  99. )
  100. set "VCPlatformToolSet=v142"
  101. ) else if /I "%VCFMT%" == "gcc" (
  102. rem MinGW
  103. ) else (
  104. echo Error: first argument ^(%VCVER%^) should specify supported version of Visual C++,
  105. echo one of: vc10 ^(VS 2010 SP3^), vc11 ^(VS 2012 SP3^), vc12 ^(VS 2013^) or vc14 ^(VS 2015^)
  106. exit
  107. )
  108. rem ----- For compatibility with external application using CASROOT -----
  109. if ["%CASROOT%"] == [""] set "CASROOT=%SCRIPTROOT%"
  110. rem ----- Define path to 3rdparty products -----
  111. if ["%THIRDPARTY_DIR%"] == [""] set "THIRDPARTY_DIR="
  112. if ["%ARCH%"] == ["32"] set VCARCH=x86
  113. if ["%ARCH%"] == ["64"] set VCARCH=amd64
  114. if /I ["%1"] == ["vc141"] set "VCVER=vc14"
  115. if /I ["%1"] == ["vc142"] set "VCVER=vc14"
  116. if exist "%CASROOT%\custom.bat" (
  117. call "%CASROOT%\custom.bat" %VCVER% %ARCH% %CASDEB%
  118. )
  119. if not ["%TCL_DIR%"] == [""] set "PATH=%TCL_DIR%;%PATH%"
  120. if not ["%TK_DIR%"] == [""] set "PATH=%TK_DIR%;%PATH%"
  121. if not ["%FREETYPE_DIR%"] == [""] set "PATH=%FREETYPE_DIR%;%PATH%"
  122. if not ["%FREEIMAGE_DIR%"] == [""] set "PATH=%FREEIMAGE_DIR%;%PATH%"
  123. if not ["%EGL_DIR%"] == [""] set "PATH=%EGL_DIR%;%PATH%"
  124. if not ["%GLES2_DIR%"] == [""] set "PATH=%GLES2_DIR%;%PATH%"
  125. if not ["%TBB_DIR%"] == [""] set "PATH=%TBB_DIR%;%PATH%"
  126. if not ["%VTK_DIR%"] == [""] set "PATH=%VTK_DIR%;%PATH%"
  127. if not ["%FFMPEG_DIR%"] == [""] set "PATH=%FFMPEG_DIR%;%PATH%"
  128. if not ["%OPENVR_DIR%"] == [""] set "PATH=%OPENVR_DIR%;%PATH%"
  129. if not ["%QTDIR%"] == [""] (
  130. set "PATH=%QTDIR%/bin;%PATH%"
  131. set "QT_PLUGIN_PATH=%QTDIR%/plugins"
  132. )
  133. rem ----- Set path to 3rd party and OCCT libraries -----
  134. if not "%CSF_OCCTBinPath%" == "" (
  135. set "PATH=%CSF_OCCTBinPath%;%PATH%"
  136. )
  137. if not ["%TK_DIR%"] == ["%TCL_DIR%"] (
  138. if not ["%TK_DIR%"] == [""] set "TK_LIBRARY=%TK_DIR%/../lib/tk%TK_VERSION_WITH_DOT%"
  139. if not ["%TCL_DIR%"] == [""] set "TCL_LIBRARY=%TCL_DIR%/../lib/tcl%TCL_VERSION_WITH_DOT%"
  140. )
  141. rem ----- Set envoronment variables used by OCCT -----
  142. set CSF_LANGUAGE=us
  143. set MMGT_CLEAR=1
  144. set "CSF_SHMessage=%CSF_OCCTResourcePath%\SHMessage"
  145. set "CSF_MDTVTexturesDirectory=%CSF_OCCTResourcePath%\Textures"
  146. set "CSF_ShadersDirectory=%CSF_OCCTResourcePath%\Shaders"
  147. set "CSF_XSMessage=%CSF_OCCTResourcePath%\XSMessage"
  148. set "CSF_TObjMessage=%CSF_OCCTResourcePath%\TObj"
  149. set "CSF_StandardDefaults=%CSF_OCCTResourcePath%\StdResource"
  150. set "CSF_PluginDefaults=%CSF_OCCTResourcePath%\StdResource"
  151. set "CSF_XCAFDefaults=%CSF_OCCTResourcePath%\StdResource"
  152. set "CSF_TObjDefaults=%CSF_OCCTResourcePath%\StdResource"
  153. set "CSF_StandardLiteDefaults=%CSF_OCCTResourcePath%\StdResource"
  154. set "CSF_IGESDefaults=%CSF_OCCTResourcePath%\XSTEPResource"
  155. set "CSF_STEPDefaults=%CSF_OCCTResourcePath%\XSTEPResource"
  156. set "CSF_XmlOcafResource=%CSF_OCCTResourcePath%\XmlOcafResource"
  157. set "CSF_MIGRATION_TYPES=%CSF_OCCTResourcePath%\StdResource\MigrationSheet.txt"
  158. rem ----- Draw Harness special stuff -----
  159. if exist "%CSF_OCCTResourcePath%\DrawResources" (
  160. set "DRAWHOME=%CSF_OCCTResourcePath%\DrawResources"
  161. set "CSF_DrawPluginDefaults=%CSF_OCCTResourcePath%\DrawResources"
  162. if exist "%CSF_OCCTResourcePath%\DrawResources\DrawDefault" (
  163. set "DRAWDEFAULT=%CSF_OCCTResourcePath%\DrawResources\DrawDefault"
  164. )
  165. )