build.rst 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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 git://github.com/bkaradzic/bx.git
  11. git clone git://github.com/bkaradzic/bimg.git
  12. git clone git://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 enironment 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-release32, nacl-debug64, nacl-arm-debug, pnacl-release,
  69. android-release, etc.
  70. Windows
  71. ~~~~~~~
  72. Visual Studio 2017 command line:
  73. ::
  74. make vs2017-release64
  75. Visual Studio 2017 IDE:
  76. ::
  77. start .build/projects/vs2017/bgfx.sln
  78. Xcode
  79. ~~~~~
  80. Xcode command line:
  81. ::
  82. make osx-release
  83. cd examples/runtime
  84. ../../.build/osx64_clang/bin/examples.app/Contents/MacOS/examplesRelease
  85. Xcode IDE:
  86. ::
  87. ../bx/tools/bin/darwin/genie --with-combined-examples --xcode=osx xcode9
  88. open .build/projects/xcode9-osx/bgfx.xcworkspace
  89. Due to `inability <https://github.com/bkaradzic/genie/blob/master/docs/scripting-reference.md#debugdirpath>`__
  90. to set working directory for an Xcode project from `GENie <https://github.com/bkaradzic/genie#genie---project-generator-tool>`__
  91. configuration file, it has to be set manually for each example project:
  92. 1. Open *"Edit scheme..."* dialog for a given project.
  93. 2. Select *"Run"* settings.
  94. 3. Check *"Use custom working directory"* and enter following path:
  95. ``${PROJECT_DIR}/../../../examples/runtime``.
  96. Linux
  97. ~~~~~
  98. ::
  99. make linux-release64
  100. WinRT / UWP
  101. ~~~~~~~~~~~
  102. ::
  103. ..\bx\tools\bin\windows\genie --vs=winstore100 vs2017
  104. Build the resulting solution and deploy to device.
  105. .. note:: Shaders will need to be compiled with the appropriate target profile for your platform.
  106. Amalgamated Build
  107. -----------------
  108. For ease of integration to other build system bgfx library can be built
  109. with single .cpp file. It's only necessary to build
  110. `src/amalgamated.cpp <https://github.com/bkaradzic/bgfx/blob/master/src/amalgamated.cpp>`__
  111. (for OSX/iOS use
  112. `src/amalgamated.mm <https://github.com/bkaradzic/bgfx/blob/master/src/amalgamated.mm>`__
  113. instead) inside different build system.
  114. Tools
  115. -----
  116. To build bgfx project files for tools, use ``--with-tools`` option:
  117. ::
  118. ..\bx\tools\bin\windows\genie --with-tools vs2017
  119. Alternative build systems
  120. -------------------------
  121. **CMake**
  122. - https://github.com/bkaradzic/bgfx.cmake
  123. - https://github.com/JoshuaBrookover/bgfx.cmake#bgfxcmake
  124. - https://github.com/pr0g/sdl-bgfx-imgui-starter#sdl-bgfx-imgui-starter
  125. - https://github.com/yuki-koyama/hello-bgfx
  126. - https://github.com/ataulien/bgfx-cmake
  127. **fips** is a highlevel build system wrapper written in Python for C/C++ projects.
  128. https://github.com/floooh/fips#fips
  129. **Conan** package
  130. https://github.com/firefalcom/bgfx-conan
  131. Minimal example without bgfx's example harness
  132. ----------------------------------------------
  133. This project demonstrates minimal amount of code needed to integrate bgfx with GLFW, but without
  134. any of existing bgfx example harness. It also demonstrates how to build bgfx with alternative build
  135. system.
  136. https://github.com/jpcy/bgfx-minimal-example