quick-start.mdx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. ---
  2. sidebar_position: 10
  3. ---
  4. import clsx from "clsx";
  5. import Tabs from '@theme/Tabs';
  6. import TabItem from '@theme/TabItem';
  7. import styles from './getting-started.module.scss';
  8. # Quick Start
  9. Using Dockerized Build Environment (DBE) to start quickly
  10. There are more than one way to start using the Urho3D library. This section shows you how to start quickly by using docker containers that have the build environment already prepared for you. All you need is a working docker engine on your host system.
  11. :::tip
  12. Skip to the [Installation](installation) section, if you cannot use docker engine on your host system.
  13. :::
  14. :::info
  15. Both `docker` and `podman` are supported.
  16. :::
  17. :::caution
  18. - Android platform requires 16 GB of RAM on the host system.
  19. - Windows host system requires WSL2.
  20. :::
  21. ## Install Urho3D Library with DBE
  22. Clone the Urho3D project from the main branch, change directory to its project root, and execute the following commands to install the library for your desired target platform. Except for Android platform, which uses `~/.m2/repository/`, the default install location is: <code>~/.urho3d/install/<em>&lt;platform&gt;</em>/</code>. The "~" here refers to home directory mounted from a docker volume and as such it is persistent in between docker runs.
  23. <Tabs
  24. className={styles.dbeInstall}
  25. groupId={'target-platform'}
  26. defaultValue={'android'}
  27. values={[
  28. {label: 'Android', value: 'android'},
  29. {label: 'Apple', value: 'apple'},
  30. {label: 'Arm', value: 'arm'},
  31. {label: 'Linux', value: 'linux'},
  32. {label: 'RPI', value: 'rpi'},
  33. {label: 'Web', value: 'web'},
  34. {label: 'Windows', value: 'win'},
  35. ]
  36. }>
  37. <TabItem value={'android'}>
  38. ```bash
  39. git clone https://github.com/urho3d/Urho3D.git
  40. cd Urho3D
  41. # Install Urho3D library to Maven local repository
  42. script/dockerized.sh android rake build install
  43. ```
  44. </TabItem>
  45. <TabItem value={'apple'}>
  46. <div className={clsx('textBlock', styles.fixedHeight)}>
  47. Currently DBE does not support Apple platforms.<br/>
  48. However, Urho3D supports Apple platforms using native build environment.
  49. </div>
  50. </TabItem>
  51. <TabItem value={'arm'}>
  52. ```bash
  53. git clone https://github.com/urho3d/Urho3D.git
  54. cd Urho3D
  55. # Install Urho3D library to a default install location, substitute '?' accordingly
  56. ARM_ABI_FLAGS=? script/dockerized.sh arm rake build install
  57. ```
  58. </TabItem>
  59. <TabItem value={'linux'}>
  60. ```bash
  61. git clone https://github.com/urho3d/Urho3D.git
  62. cd Urho3D
  63. # Install Urho3D library to a default install location
  64. script/dockerized.sh linux rake build install
  65. ```
  66. </TabItem>
  67. <TabItem value={'rpi'}>
  68. ```bash
  69. git clone https://github.com/urho3d/Urho3D.git
  70. cd Urho3D
  71. # Install Urho3D library to a default install location, use the 32-bit compiler toolchain
  72. ARCH=32 script/dockerized.sh rpi rake build install
  73. ```
  74. </TabItem>
  75. <TabItem value={'web'}>
  76. ```bash
  77. git clone https://github.com/urho3d/Urho3D.git
  78. cd Urho3D
  79. # Install Urho3D library to a default install location
  80. script/dockerized.sh web rake build install
  81. ```
  82. </TabItem>
  83. <TabItem value={'win'}>
  84. ```bash
  85. git clone https://github.com/urho3d/Urho3D.git
  86. cd Urho3D
  87. # Install Urho3D library to a default install location
  88. script/dockerized.sh mingw rake build install
  89. ```
  90. </TabItem>
  91. </Tabs>
  92. The `script/dockerized.sh` spawns one of the docker container based on the specified platform name in the first argument. The rest of the arguments specify the command to be executed inside the container. The default command is `rake build`. You can invoke other rake tasks by passing the command explicitly as arguments. It is also possible to invoke multiple rake tasks in one go. Read Rake Tasks section for more details.
  93. ## Create a New UrhoApp with DBE
  94. You need an installed Urho3D library for the desired target platform to proceed. Although the Urho3D build system also supports linking the Urho3D library directly from its build tree, this quick start section will not be discussing it here. Assuming you have been following along from the previous section, execute the following commands to create a new UrhoApp project, and then build it.
  95. <Tabs
  96. className={styles.dbeBuildUrhoApp}
  97. groupId={'target-platform'}
  98. defaultValue={'android'}
  99. values={[
  100. {label: 'Android', value: 'android'},
  101. {label: 'Apple', value: 'apple'},
  102. {label: 'Arm', value: 'arm'},
  103. {label: 'Linux', value: 'linux'},
  104. {label: 'RPI', value: 'rpi'},
  105. {label: 'Web', value: 'web'},
  106. {label: 'Windows', value: 'win'},
  107. ]
  108. }>
  109. <TabItem value={'android'}>
  110. ```bash
  111. # Create a new UrhoApp
  112. script/dockerized.sh android rake new[AndroidUrhoApp,demo]
  113. cd demo/AndroidUrhoApp
  114. # Build the newly generated UrhoApp
  115. script/dockerized.sh android
  116. ```
  117. </TabItem>
  118. <TabItem value={'apple'}>
  119. <div className={clsx('textBlock', styles.fixedHeight)}>
  120. Currently DBE does not support Apple platforms.<br/>
  121. However, Urho3D supports Apple platforms using native build environment.
  122. </div>
  123. </TabItem>
  124. <TabItem value={'arm'}>
  125. ```bash
  126. # Create a new UrhoApp
  127. script/dockerized.sh arm rake new[ArmUrhoApp,demo]
  128. cd demo/ArmUrhoApp
  129. # Build the newly generated UrhoApp, substitute '?' accordingly
  130. ARM_ABI_FLAGS=? script/dockerized.sh arm
  131. ```
  132. </TabItem>
  133. <TabItem value={'linux'}>
  134. ```bash
  135. # Create a new UrhoApp
  136. script/dockerized.sh linux rake new[LinuxUrhoApp,demo]
  137. cd demo/LinuxUrhoApp
  138. # Build the newly generated UrhoApp
  139. script/dockerized.sh linux
  140. ```
  141. </TabItem>
  142. <TabItem value={'rpi'}>
  143. ```bash
  144. # Create a new UrhoApp
  145. script/dockerized.sh rpi rake new[PiUrhoApp,demo]
  146. cd demo/PiUrhoApp
  147. # Build the newly generated UrhoApp, use the 32-bit compiler toolchain
  148. ARCH=32 script/dockerized.sh rpi
  149. ```
  150. </TabItem>
  151. <TabItem value={'web'}>
  152. ```bash
  153. # Create a new UrhoApp
  154. script/dockerized.sh web rake new[WebUrhoApp,demo]
  155. cd demo/WebUrhoApp
  156. # Build the newly generated UrhoApp
  157. script/dockerized.sh web
  158. ```
  159. </TabItem>
  160. <TabItem value={'win'}>
  161. ```bash
  162. # Create a new UrhoApp
  163. script/dockerized.sh mingw rake new[WindowsUrhoApp,demo]
  164. cd demo/WindowsUrhoApp
  165. # Build the newly generated UrhoApp
  166. script/dockerized.sh mingw
  167. ```
  168. </TabItem>
  169. </Tabs>
  170. :::note
  171. This is not a copy/paste error. You can build your new UrhoApp exactly the same way as the Urho3D project itself! By default, DBE runs `rake build` command.
  172. :::
  173. Below is a sample screencast using DBE for Android platform.
  174. <div className={'text--center'}>
  175. <img src={'/img/docs/quick-start-screencast.svg'} alt={'Screencast'}/>
  176. </div>
  177. ## Dockerized Build Environment
  178. Inside the DBE docker container, you can run a single command. By default, the command to run is `rake`. Since the `rakefile` has defined `build` as the default task, effectively making the DBE defaults to perform the build task for the selected target platform. The DBE docker container automatically exits after the single command finished running. The docker container is ephemeral. To make the build artifacts persistent, they must be stored in a bind mount or a docker volume. With bind mount, DBE makes changes to the project root on the host machine after each run, typically in the `build/` directory. While DBE stores the build caches (from ccache and Gradle) and installed libraries (including Urho3D library), in the docker volume.
  179. ### Command Examples
  180. Following are a few other examples how the DBE docker container can be run. First, set up `dbe` alias for spawning a DBE docker container for, say, Web platform. You can replace it with other target platform.
  181. ```bash
  182. alias dbe='script/dockerized.sh web'
  183. ```
  184. #### `dbe env`
  185. Output the preconfigured environment variables for the target platform.
  186. #### `dbe rake info['install_dir']`
  187. Output the Urho3D default install location for the target platform.
  188. #### `dbe ls $(dbe rake info['install_dir'])`
  189. List the current content of the Urho3D default install location for the target platform.
  190. #### `dbe ccache -Cz`
  191. Clear the build cache and zero out the accumulated statistics from ccache.
  192. #### `dbe rake clean build`
  193. Perform a clean build.
  194. #### `dbe bash`
  195. Run an interactive `bash` shell where you can poke around inside the running docker container, execute any commands, including installing more software packages with `sudo` command for quick testing. Changes that are not in bind mount and docker volume will be lost after you type `exit`.
  196. ### Image Tags
  197. When the requested platform docker image has not been downloaded yet, the `script/dockerized.sh` automatically downloads the docker image from one of the **Urho3D official Docker Hub repositories**. It also attempts to download a matching docker image tag based on the current Git tag of the local source code repository, defaulted to use `master` tag if the detection mechanism failed. This behaviour can be overridden by setting the `DBE_TAG` environment variable to specify a docker image tag that you want to use explicitly. There are `master` and `latest` tag to choose from. More tags will be added as Urho3D project releases new version. The `master` tag should always work with the current main branch of the Urho3D project on GitHub, while the `latest` tag should only be used with future experimental or development branch of Urho3D project. The latter would contain build environment with updated OS version, or compiler toolchain version, etc, that may break the current main branch. To use the `latest` docker image tag, simply set it like so:
  198. ```bash
  199. DBE_TAG=latest dbe
  200. ```
  201. Note that both the `master` and `latest` tags are actually *rolling tag*. The tag can be updated to point to a newer docker image that meets the stipulated condition above. Depending on your own use case, this may or may not be desirable. If you don't track the Urho3D main branch frequently then all is good. The downloaded docker image can still be used locally even when it has been superseded globally. However, when you track the Urho3D main branch frequently then you may also need to refresh the local DBE image from time to time or whenever you encountered build failure after a `git pull` command. To refresh the docker image, simply set `DBE_REFRESH=1` as below:
  202. ```bash
  203. DBE_REFRESH=1 dbe
  204. ```
  205. :::tip
  206. Before refreshing, you can actually use `docker` or `podman` to retag the already downloaded docker image to be another custom tag. This way you have an option to revert to it when something goes wrong with the newly downloaded DBE image. The `DBE_TAG` environment variable works with custom tag too.
  207. :::
  208. ## Build Artifacts
  209. The build artifacts from DBE can be found in the usual location as the conventional (non-dockerized) build environment. In fact the build artifacts from DBE should function and work as if they are built using the conventional way too. With the exception for Android platform, the build artifacts can be found in the build tree under the `bin/` directory.
  210. ```bash
  211. ls $(dbe rake info['build_tree'])/bin
  212. ```
  213. The build artifacts for Android platform in the AAR or in the APK format can be found in the `build/outputs/aar/` or `build/outputs/apk/` directory, respectively, relative to the Android library or Android app module.
  214. ## Build Environment Variables
  215. You can pass Urho3D build options to the build system by using environment variables. One easy way to do that is to set them just in time on the same line before the actual command to be invoked. For example, `ARM_ABI_FLAGS='-mcpu=cortex-a53' script/dockerized.sh arm`. See the Urho3D Build Options section for all available build options.
  216. On top of that, DBE also recognizes `ARCH` environment variable to select between 32-bit and 64-bit (default) compiler toolchain. This is applicable to Arm, Linux, RPI, and Windows platforms. For example, use `ARCH=32 script/dockerized.sh rpi` to target 32-bit RPI platform.
  217. ## Don't have docker engine?
  218. Fret not! The next section describes how to prepare the build environment the conventional way for each target platform.