build.rst 5.2 KB

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