/vcbuild.bat

http://github.com/joyent/libuv · Batch · 127 lines · 107 code · 20 blank · 0 comment · 44 complexity · e429f74606caea9985c066e151021278 MD5 · raw file

  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 2010
  40. if not defined VS100COMNTOOLS goto vc-set-2008
  41. if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2008
  42. call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
  43. set GYP_MSVS_VERSION=2010
  44. goto select-target
  45. :vc-set-2008
  46. @rem Look for Visual Studio 2008
  47. if not defined VS90COMNTOOLS goto vc-set-notfound
  48. if not exist "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-notfound
  49. call "%VS90COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset%
  50. set GYP_MSVS_VERSION=2008
  51. goto select-target
  52. :vc-set-notfound
  53. echo Warning: Visual Studio not found
  54. :select-target
  55. if not "%config%"=="" goto project-gen
  56. if "%run%"=="run-tests.exe" set config=Debug& goto project-gen
  57. if "%run%"=="run-benchmarks.exe" set config=Release& goto project-gen
  58. set config=Debug
  59. :project-gen
  60. @rem Skip project generation if requested.
  61. if defined noprojgen goto msbuild
  62. @rem Generate the VS project.
  63. if exist build\gyp goto have_gyp
  64. echo svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp
  65. svn co http://gyp.googlecode.com/svn/trunk@983 build/gyp
  66. if errorlevel 1 goto gyp_install_failed
  67. goto have_gyp
  68. :gyp_install_failed
  69. echo Failed to download gyp. Make sure you have subversion installed, or
  70. echo manually install gyp into %~dp0build\gyp.
  71. goto exit
  72. :have_gyp
  73. python gyp_uv -Dtarget_arch=%target_arch% -Dlibrary=%library%
  74. if errorlevel 1 goto create-msvs-files-failed
  75. if not exist uv.sln goto create-msvs-files-failed
  76. echo Project files generated.
  77. :msbuild
  78. @rem Skip project generation if requested.
  79. if defined nobuild goto run
  80. @rem Check if VS build env is available
  81. if not defined VCINSTALLDIR goto msbuild-not-found
  82. goto msbuild-found
  83. :msbuild-not-found
  84. echo Build skipped. To build, this file needs to run from VS cmd prompt.
  85. goto run
  86. @rem Build the sln with msbuild.
  87. :msbuild-found
  88. msbuild uv.sln /t:%target% /p:Configuration=%config% /p:Platform="%platform%" /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
  89. if errorlevel 1 goto exit
  90. :run
  91. @rem Run tests if requested.
  92. if "%run%"=="" goto exit
  93. if not exist %config%\%run% goto exit
  94. echo running '%config%\%run%'
  95. %config%\%run%
  96. goto exit
  97. :create-msvs-files-failed
  98. echo Failed to create vc project files.
  99. goto exit
  100. :help
  101. echo vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [x86/x64] [static/shared]
  102. echo Examples:
  103. echo vcbuild.bat : builds debug build
  104. echo vcbuild.bat test : builds debug build and runs tests
  105. echo vcbuild.bat release bench: builds release build and runs benchmarks
  106. goto exit
  107. :exit