buildProject.bat 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. rem Local build settings.
  4. set GENERATE_SCRIPT=Yes
  5. rem set GENERATE_SCRIPT=No
  6. set TEMPORARY_FOLDER=%TEMP%
  7. set COMPILER_NAME=g++
  8. rem Get this script's folder.
  9. set BUILDER_FOLDER=%~dp0
  10. echo BUILDER_FOLDER = %BUILDER_FOLDER%
  11. rem Show which versions of the compiler are installed.
  12. echo Installed %COMPILER_NAME% compilers:
  13. where %COMPILER_NAME%
  14. rem Select the first instance.
  15. for /f "delims=" %%i in ('where %COMPILER_NAME% 2^>nul') do (
  16. set CPP_COMPILER_PATH=%%i
  17. goto :found_compiler
  18. )
  19. :found_compiler
  20. rem Abort if none could be found.
  21. if not exist !CPP_COMPILER_PATH! (
  22. echo Could not find !COMPILER_NAME!.
  23. exit /b 1
  24. )
  25. echo CPP_COMPILER_PATH = !CPP_COMPILER_PATH!
  26. rem Get the compiler's folder from the compiler's path.
  27. set CPP_COMPILER_FOLDER=!~dpCPP_COMPILER_PATH!
  28. echo CPP_COMPILER_FOLDER = !CPP_COMPILER_FOLDER!
  29. rem Using buildProject.bat
  30. rem %1 must be the *.DsrProj path or a folder containing such projects. The path is relative to the caller location.
  31. rem %2... are variable assignments sent as input to the given project file.
  32. echo Running buildProject.bat %*
  33. rem Get the build system's folder, where the build system is located.
  34. set BUILDER_FOLDER=%~dp0%
  35. echo BUILDER_FOLDER = %BUILDER_FOLDER%
  36. set BUILDER_EXECUTABLE=%BUILDER_FOLDER%builder.exe
  37. echo BUILDER_EXECUTABLE = %BUILDER_EXECUTABLE%
  38. set DFPSR_LIBRARY=%BUILDER_FOLDER%..\..\DFPSR
  39. echo DFPSR_LIBRARY = %DFPSR_LIBRARY%
  40. set BUILDER_SOURCE=%BUILDER_FOLDER%\code\main.cpp %BUILDER_FOLDER%\code\Machine.cpp %BUILDER_FOLDER%\code\generator.cpp %BUILDER_FOLDER%\code\analyzer.cpp %BUILDER_FOLDER%\code\expression.cpp %DFPSR_LIBRARY%\collection\collections.cpp %DFPSR_LIBRARY%\api\fileAPI.cpp %DFPSR_LIBRARY%\api\bufferAPI.cpp %DFPSR_LIBRARY%\api\stringAPI.cpp %DFPSR_LIBRARY%\api\timeAPI.cpp %DFPSR_LIBRARY%\base\SafePointer.cpp %DFPSR_LIBRARY%\base\virtualStack.cpp %DFPSR_LIBRARY%\base\heap.cpp
  41. echo BUILDER_SOURCE = %BUILDER_SOURCE%
  42. rem Check if the build system is compiled
  43. if exist "%BUILDER_EXECUTABLE%" (
  44. echo Found the build system's binary.
  45. ) else (
  46. echo Building the Builder build system for first time use.
  47. pushd %CPP_COMPILER_FOLDER%
  48. %CPP_COMPILER_PATH% -o %BUILDER_EXECUTABLE% %BUILDER_SOURCE% -static -static-libgcc -static-libstdc++ -std=c++14 -lstdc++
  49. if errorlevel 0 (
  50. echo Completed building the Builder build system.
  51. ) else (
  52. echo Failed building the Builder build system, which is needed to build your project!
  53. exit /b 1
  54. )
  55. popd
  56. )
  57. if "!GENERATE_SCRIPT!"=="Yes" (
  58. rem Calling the build system with a script path will generate the script for all actions.
  59. set SCRIPT_PATH=%TEMPORARY_FOLDER%\dfpsr_compile.bat
  60. echo Generating !SCRIPT_PATH! from %1%
  61. if exist "!SCRIPT_PATH!" (
  62. del "!SCRIPT_PATH!"
  63. )
  64. !BUILDER_EXECUTABLE! "!SCRIPT_PATH!" %* "Compiler=!CPP_COMPILER_PATH!" "CompileFrom=!CPP_COMPILER_FOLDER!"
  65. if exist "!SCRIPT_PATH!" (
  66. echo Running !SCRIPT_PATH!
  67. call "!SCRIPT_PATH!"
  68. echo Done calling !SCRIPT_PATH!
  69. )
  70. ) else (
  71. rem Calling the build system with only the temporary folder will call the compiler directly from the build system.
  72. echo No script path provided. Builder will call !COMPILER_NAME! directly instead of generating a script.
  73. !BUILDER_EXECUTABLE! "%TEMPORARY_FOLDER%" %* Compiler=!CPP_COMPILER_PATH! CompileFrom=!CPP_COMPILER_FOLDER!
  74. )
  75. endlocal