vcbuild.bat 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. @echo off
  2. cd %~dp0
  3. if /i "%1"=="help" goto help
  4. if /i "%1"=="--help" goto help
  5. if /i "%1"=="-help" goto help
  6. if /i "%1"=="/help" goto help
  7. if /i "%1"=="?" goto help
  8. if /i "%1"=="-?" goto help
  9. if /i "%1"=="--?" goto help
  10. if /i "%1"=="/?" goto help
  11. @rem Process arguments.
  12. set config=
  13. set target=Build
  14. set noprojgen=
  15. set nobuild=
  16. set run=
  17. set target_arch=ia32
  18. set vs_toolset=x86
  19. set platform=WIN32
  20. set library=static_library
  21. :next-arg
  22. if "%1"=="" goto args-done
  23. if /i "%1"=="debug" set config=Debug&goto arg-ok
  24. if /i "%1"=="release" set config=Release&goto arg-ok
  25. if /i "%1"=="test" set run=run-tests.exe&goto arg-ok
  26. if /i "%1"=="bench" set run=run-benchmarks.exe&goto arg-ok
  27. if /i "%1"=="clean" set target=Clean&goto arg-ok
  28. if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok
  29. if /i "%1"=="nobuild" set nobuild=1&goto arg-ok
  30. if /i "%1"=="x86" set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok
  31. if /i "%1"=="ia32" set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok
  32. if /i "%1"=="x64" set target_arch=x64&set platform=amd64&set vs_toolset=x64&goto arg-ok
  33. if /i "%1"=="shared" set library=shared_library&goto arg-ok
  34. if /i "%1"=="static" set library=static_library&goto arg-ok
  35. :arg-ok
  36. shift
  37. goto next-arg
  38. :args-done
  39. @rem Look for Visual Studio 2012
  40. if not defined VS110COMNTOOLS goto vc-set-2010
  41. if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010
  42. call "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
  43. set GYP_MSVS_VERSION=2012
  44. goto select-target
  45. :vc-set-2010
  46. @rem Look for Visual Studio 2010
  47. if not defined VS100COMNTOOLS goto vc-set-2008
  48. if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2008
  49. call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
  50. set GYP_MSVS_VERSION=2010
  51. goto select-target
  52. :vc-set-2008
  53. @rem Look for Visual Studio 2008
  54. if not defined VS90COMNTOOLS goto vc-set-notfound
  55. if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound
  56. call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
  57. set GYP_MSVS_VERSION=2008
  58. goto select-target
  59. :vc-set-notfound
  60. echo Warning: Visual Studio not found
  61. :select-target
  62. if not "%config%"=="" goto project-gen
  63. if "%run%"=="run-tests.exe" set config=Debug& goto project-gen
  64. if "%run%"=="run-benchmarks.exe" set config=Release& goto project-gen
  65. set config=Debug
  66. :project-gen
  67. @rem Skip project generation if requested.
  68. if defined noprojgen goto msbuild
  69. @rem Generate the VS project.
  70. if exist build\gyp goto have_gyp
  71. echo git clone https://git.chromium.org/external/gyp.git build/gyp
  72. git clone https://git.chromium.org/external/gyp.git build/gyp
  73. if errorlevel 1 goto gyp_install_failed
  74. goto have_gyp
  75. :gyp_install_failed
  76. echo Failed to download gyp. Make sure you have git installed, or
  77. echo manually install gyp into %~dp0build\gyp.
  78. exit /b 1
  79. :have_gyp
  80. if not defined PYTHON set PYTHON="python"
  81. %PYTHON% gyp_uv -Dtarget_arch=%target_arch% -Dlibrary=%library%
  82. if errorlevel 1 goto create-msvs-files-failed
  83. if not exist uv.sln goto create-msvs-files-failed
  84. echo Project files generated.
  85. :msbuild
  86. @rem Skip project generation if requested.
  87. if defined nobuild goto run
  88. @rem Check if VS build env is available
  89. if not defined VCINSTALLDIR goto msbuild-not-found
  90. goto msbuild-found
  91. :msbuild-not-found
  92. echo Build skipped. To build, this file needs to run from VS cmd prompt.
  93. goto run
  94. @rem Build the sln with msbuild.
  95. :msbuild-found
  96. msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
  97. if errorlevel 1 exit /b 1
  98. :run
  99. @rem Run tests if requested.
  100. if "%run%"=="" goto exit
  101. if not exist %config%\%run% goto exit
  102. echo running '%config%\%run%'
  103. %config%\%run%
  104. goto exit
  105. :create-msvs-files-failed
  106. echo Failed to create vc project files.
  107. exit /b 1
  108. :help
  109. echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [x86/x64] [static/shared]
  110. echo Examples:
  111. echo vcbuild.bat : builds debug build
  112. echo vcbuild.bat test : builds debug build and runs tests
  113. echo vcbuild.bat release bench: builds release build and runs benchmarks
  114. goto exit
  115. :exit