build.rst 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. Building
  2. ========
  3. Dependencies
  4. ------------
  5. https://github.com/bkaradzic/bx
  6. https://github.com/bkaradzic/bimg
  7. Getting Source
  8. --------------
  9. ::
  10. git clone https://github.com/bkaradzic/bx.git
  11. git clone https://github.com/bkaradzic/bimg.git
  12. git clone https://github.com/bkaradzic/bgfx.git
  13. Quick Start
  14. -----------
  15. These are step for users who use Windows with Visual Studio.
  16. Enter bgfx directory:
  17. ::
  18. cd bgfx
  19. Generate Visual Studio 2017 project files:
  20. ::
  21. ..\bx\tools\bin\windows\genie --with-examples vs2017
  22. Open bgfx solution in Visual Studio 2017:
  23. ::
  24. start .build\projects\vs2017\bgfx.sln
  25. .. note:: For more detailed prerequisites and build steps on other platforms see below.
  26. Prerequisites
  27. -------------
  28. Android
  29. ~~~~~~~
  30. Download Android NDK (r23 or newer):
  31. - https://developer.android.com/tools/sdk/ndk/index.html
  32. Set following environment variables:
  33. ::
  34. setx ANDROID_NDK_ROOT <path to AndroidNDK directory>
  35. Linux
  36. ~~~~~
  37. ::
  38. sudo apt-get install libgl1-mesa-dev x11proto-core-dev libx11-dev
  39. Windows
  40. ~~~~~~~
  41. Windows users download GnuWin32 utilities:
  42. - http://gnuwin32.sourceforge.net/packages/make.htm
  43. - http://gnuwin32.sourceforge.net/packages/coreutils.htm
  44. - http://gnuwin32.sourceforge.net/packages/libiconv.htm
  45. - http://gnuwin32.sourceforge.net/packages/libintl.htm
  46. .. note:: **MSYS**, **Cygwin**, etc. shells are not supported!
  47. You must use use **cmd.exe** with provided makefiles.
  48. Build
  49. -----
  50. bgfx uses `GENie - Project generator tool <https://github.com/bkaradzic/genie#genie---project-generator-tool>`__
  51. to generate project files for various platform. Binaries for Linux, OSX, and Windows are included in
  52. bx repository.
  53. General
  54. ~~~~~~~
  55. ::
  56. cd bgfx
  57. make
  58. After calling ``make``, .build/projects/\* directory will be generated.
  59. All intermediate files generated by compiler will be inside .build
  60. directory structure. Deleting .build directory at any time is safe.
  61. ::
  62. make <configuration>
  63. Configuration is ``<platform>-<debug/release>[32/64]``. For example:
  64. ::
  65. linux-release64, wasm-debug, wasm-release, osx-debug, osx-release, android-arm64-release, etc.
  66. Windows
  67. ~~~~~~~
  68. Visual Studio 2017 command line:
  69. ::
  70. make vs2017-release64
  71. Visual Studio 2017 IDE:
  72. ::
  73. start .build/projects/vs2017/bgfx.sln
  74. Xcode
  75. ~~~~~
  76. Xcode command line:
  77. ::
  78. make osx-release
  79. cd examples/runtime
  80. ../../.build/osx64_clang/bin/examples.app/Contents/MacOS/examplesRelease
  81. Xcode IDE:
  82. ::
  83. ../bx/tools/bin/darwin/genie --with-combined-examples --xcode=osx xcode9
  84. open .build/projects/xcode9-osx/bgfx.xcworkspace
  85. Due to `inability <https://github.com/bkaradzic/genie/blob/master/docs/scripting-reference.md#debugdirpath>`__
  86. to set working directory for an Xcode project from `GENie <https://github.com/bkaradzic/genie#genie---project-generator-tool>`__
  87. configuration file, it has to be set manually for each example project:
  88. 1. Open *"Edit scheme..."* dialog for a given project.
  89. 2. Select *"Run"* settings.
  90. 3. Check *"Use custom working directory"* and enter following path:
  91. ``${PROJECT_DIR}/../../../examples/runtime``.
  92. Linux
  93. ~~~~~
  94. ::
  95. make linux-release64
  96. WinRT / UWP
  97. ~~~~~~~~~~~
  98. ::
  99. ..\bx\tools\bin\windows\genie --vs=winstore100 vs2017
  100. Build the resulting solution and deploy to device.
  101. .. note:: Shaders will need to be compiled with the appropriate target profile for your platform.
  102. Amalgamated Build
  103. -----------------
  104. For ease of integration to other build system bgfx library can be built
  105. with single .cpp file. It's only necessary to build
  106. `src/amalgamated.cpp <https://github.com/bkaradzic/bgfx/blob/master/src/amalgamated.cpp>`__
  107. (for OSX/iOS use
  108. `src/amalgamated.mm <https://github.com/bkaradzic/bgfx/blob/master/src/amalgamated.mm>`__
  109. instead) inside different build system.
  110. Tools
  111. -----
  112. To build bgfx project files for tools, use ``--with-tools`` option:
  113. ::
  114. ..\bx\tools\bin\windows\genie --with-tools vs2017
  115. Alternative build systems
  116. -------------------------
  117. **CMake**
  118. - https://github.com/bkaradzic/bgfx.cmake
  119. - https://github.com/JoshuaBrookover/bgfx.cmake#bgfxcmake
  120. - https://github.com/pr0g/sdl-bgfx-imgui-starter#sdl-bgfx-imgui-starter
  121. - https://github.com/yuki-koyama/hello-bgfx
  122. - https://github.com/ataulien/bgfx-cmake
  123. **fips** is a highlevel build system wrapper written in Python for C/C++ projects.
  124. https://github.com/floooh/fips#fips
  125. **Conan** package
  126. https://github.com/firefalcom/bgfx-conan
  127. Minimal example without bgfx's example harness
  128. ----------------------------------------------
  129. This project demonstrates minimal amount of code needed to integrate bgfx with GLFW, but without
  130. any of existing bgfx example harness. It also demonstrates how to build bgfx with alternative build
  131. system.
  132. https://github.com/jpcy/bgfx-minimal-example