build_windows.cmd 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. @ECHO OFF
  2. REM
  3. REM Copyright (c) Contributors to the Open 3D Engine Project.
  4. REM For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. REM
  6. REM SPDX-License-Identifier: Apache-2.0 OR MIT
  7. REM
  8. REM
  9. SETLOCAL EnableDelayedExpansion
  10. CALL "%~dp0env_windows.cmd"
  11. IF NOT %ERRORLEVEL%==0 EXIT /b 1
  12. IF NOT EXIST "%OUTPUT_DIRECTORY%" (
  13. MKDIR %OUTPUT_DIRECTORY%.
  14. )
  15. SET SOURCE_DIRECTORY=%CD%
  16. PUSHD %OUTPUT_DIRECTORY%
  17. ECHO [ci_build] cmake --version
  18. cmake --version
  19. IF ERRORLEVEL 1 (
  20. ECHO [ci_build] CMAKE not found!
  21. EXIT /b 1
  22. )
  23. REM Compute half the amount of processors so some jobs can run
  24. SET /a HALF_PROCESSORS = NUMBER_OF_PROCESSORS / 2
  25. SET LAST_CONFIGURE_CMD_FILE=ci_last_configure_cmd.txt
  26. SET CONFIGURE_CMD=cmake "%SOURCE_DIRECTORY%" %CMAKE_OPTIONS% %EXTRA_CMAKE_OPTIONS%
  27. IF NOT "%CMAKE_LY_PROJECTS%"=="" (
  28. SET CONFIGURE_CMD=!CONFIGURE_CMD! -DLY_PROJECTS="%CMAKE_LY_PROJECTS%"
  29. )
  30. IF NOT EXIST CMakeCache.txt (
  31. ECHO [ci_build] First run, generating
  32. SET RUN_CONFIGURE=1
  33. ) ELSE IF NOT EXIST %LAST_CONFIGURE_CMD_FILE% (
  34. ECHO [ci_build] Last run command not found, generating
  35. SET RUN_CONFIGURE=1
  36. ) ELSE (
  37. REM Detect if the input has changed
  38. FOR /F "delims=" %%x in (%LAST_CONFIGURE_CMD_FILE%) DO SET LAST_CMD=%%x
  39. IF !LAST_CMD! NEQ !CONFIGURE_CMD! (
  40. ECHO [ci_build] Last run command different, generating
  41. SET RUN_CONFIGURE=1
  42. )
  43. )
  44. IF DEFINED RUN_CONFIGURE (
  45. call ECHO [ci_build] %CONFIGURE_CMD%
  46. call %CONFIGURE_CMD%
  47. IF NOT !ERRORLEVEL! EQU 0 GOTO :error
  48. ECHO !CONFIGURE_CMD!> %LAST_CONFIGURE_CMD_FILE%
  49. )
  50. REM Split the configuration on semi-colon and use the cmake --build wrapper to run the underlying build command for each
  51. FOR %%C in (%CONFIGURATION%) do (
  52. call ECHO [ci_build] cmake --build . --target %CMAKE_TARGET% --config %%C %CMAKE_BUILD_ARGS% -- %CMAKE_NATIVE_BUILD_ARGS%
  53. call cmake --build . --target %CMAKE_TARGET% --config %%C %CMAKE_BUILD_ARGS% -- %CMAKE_NATIVE_BUILD_ARGS%
  54. IF NOT !ERRORLEVEL! EQU 0 GOTO :error
  55. )
  56. POPD
  57. EXIT /b 0
  58. :error
  59. POPD
  60. EXIT /b 1