build.rst 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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 AndroidNDK:
  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. setx ANDROID_NDK_ARM <path to AndroidNDK directory>\toolchains\arm-linux-androideabi-4.7\prebuilt\windows-x86_64
  36. setx ANDROID_NDK_MIPS <path to AndroidNDK directory>\toolchains\mipsel-linux-android-4.7\prebuilt\windows-x86_64
  37. setx ANDROID_NDK_X86 <path to AndroidNDK directory>\toolchains\x86-4.7\prebuilt\windows-x86_64
  38. To deploy on Android you can use bgfx android activity:
  39. - https://github.com/Nodrev/bgfx-android-activity#bgfx-android-activity---android-glue-for-bgfx
  40. Linux
  41. ~~~~~
  42. ::
  43. sudo apt-get install libgl1-mesa-dev x11proto-core-dev libx11-dev
  44. Windows
  45. ~~~~~~~
  46. Windows users download GnuWin32 utilities:
  47. - http://gnuwin32.sourceforge.net/packages/make.htm
  48. - http://gnuwin32.sourceforge.net/packages/coreutils.htm
  49. - http://gnuwin32.sourceforge.net/packages/libiconv.htm
  50. - http://gnuwin32.sourceforge.net/packages/libintl.htm
  51. Build
  52. -----
  53. bgfx uses `GENie - Project generator tool <https://github.com/bkaradzic/genie#genie---project-generator-tool>`__
  54. to generate project files for various platform. Binaries for Linux, OSX, and Windows are included in
  55. bx repository.
  56. General
  57. ~~~~~~~
  58. ::
  59. cd bgfx
  60. make
  61. After calling ``make``, .build/projects/\* directory will be generated.
  62. All intermediate files generated by compiler will be inside .build
  63. directory structure. Deleting .build directory at any time is safe.
  64. ::
  65. make <configuration>
  66. Configuration is ``<platform>-<debug/release>[32/64]``. For example:
  67. ::
  68. linux-release64, wasm-debug, wasm-release, osx-debug, osx-release, android-arm64-release, etc.
  69. Windows
  70. ~~~~~~~
  71. Visual Studio 2017 command line:
  72. ::
  73. make vs2017-release64
  74. Visual Studio 2017 IDE:
  75. ::
  76. start .build/projects/vs2017/bgfx.sln
  77. Xcode
  78. ~~~~~
  79. Xcode command line:
  80. ::
  81. make osx-release
  82. cd examples/runtime
  83. ../../.build/osx64_clang/bin/examples.app/Contents/MacOS/examplesRelease
  84. Xcode IDE:
  85. ::
  86. ../bx/tools/bin/darwin/genie --with-combined-examples --xcode=osx xcode9
  87. open .build/projects/xcode9-osx/bgfx.xcworkspace
  88. Due to `inability <https://github.com/bkaradzic/genie/blob/master/docs/scripting-reference.md#debugdirpath>`__
  89. to set working directory for an Xcode project from `GENie <https://github.com/bkaradzic/genie#genie---project-generator-tool>`__
  90. configuration file, it has to be set manually for each example project:
  91. 1. Open *"Edit scheme..."* dialog for a given project.
  92. 2. Select *"Run"* settings.
  93. 3. Check *"Use custom working directory"* and enter following path:
  94. ``${PROJECT_DIR}/../../../examples/runtime``.
  95. Linux
  96. ~~~~~
  97. ::
  98. make linux-release64
  99. WinRT / UWP
  100. ~~~~~~~~~~~
  101. ::
  102. ..\bx\tools\bin\windows\genie --vs=winstore100 vs2017
  103. Build the resulting solution and deploy to device.
  104. .. note:: Shaders will need to be compiled with the appropriate target profile for your platform.
  105. Amalgamated Build
  106. -----------------
  107. For ease of integration to other build system bgfx library can be built
  108. with single .cpp file. It's only necessary to build
  109. `src/amalgamated.cpp <https://github.com/bkaradzic/bgfx/blob/master/src/amalgamated.cpp>`__
  110. (for OSX/iOS use
  111. `src/amalgamated.mm <https://github.com/bkaradzic/bgfx/blob/master/src/amalgamated.mm>`__
  112. instead) inside different build system.
  113. Tools
  114. -----
  115. To build bgfx project files for tools, use ``--with-tools`` option:
  116. ::
  117. ..\bx\tools\bin\windows\genie --with-tools vs2017
  118. Alternative build systems
  119. -------------------------
  120. **CMake**
  121. - https://github.com/bkaradzic/bgfx.cmake
  122. - https://github.com/JoshuaBrookover/bgfx.cmake#bgfxcmake
  123. - https://github.com/pr0g/sdl-bgfx-imgui-starter#sdl-bgfx-imgui-starter
  124. - https://github.com/yuki-koyama/hello-bgfx
  125. - https://github.com/ataulien/bgfx-cmake
  126. **fips** is a highlevel build system wrapper written in Python for C/C++ projects.
  127. https://github.com/floooh/fips#fips
  128. **Conan** package
  129. https://github.com/firefalcom/bgfx-conan
  130. Minimal example without bgfx's example harness
  131. ----------------------------------------------
  132. This project demonstrates minimal amount of code needed to integrate bgfx with GLFW, but without
  133. any of existing bgfx example harness. It also demonstrates how to build bgfx with alternative build
  134. system.
  135. https://github.com/jpcy/bgfx-minimal-example