dev environment: update documentation
[platform/upstream/gstreamer.git] / README.md
1 # gst-build
2
3 GStreamer [meson](http://mesonbuild.com/) based repositories aggregrator.
4
5 Check out this module and run meson on it, and it will git clone the other
6 GStreamer modules as [meson subprojects](http://mesonbuild.com/Subprojects.html)
7 and build everything in one go. Once that is done you can switch into an
8 development environment which allows you to easily develop and test the latest
9 version of GStreamer without the need to install anything or touch an existing
10 GStreamer system installation.
11
12 ## Getting started
13
14 ### Install git and python 3.5+
15
16 If you're on Linux, you probably already have these. On macOS, you can use the
17 [official Python installer](https://www.python.org/downloads/mac-osx/).
18
19 You can find [instructions for Windows below](#windows-prerequisites-setup).
20
21 ### Install meson and ninja
22
23 Meson 0.48 or newer is required.
24
25 On Linux and macOS you can get meson through your package manager or using:
26
27   $ pip3 install --user meson
28
29 This will install meson into `~/.local/bin` which may or may not be included
30 automatically in your PATH by default.
31
32 You should get `ninja` using your package manager or download the [official
33 release](https://github.com/ninja-build/ninja/releases) and put the `ninja`
34 binary in your PATH.
35
36 You can find [instructions for Windows below](#windows-prerequisites-setup).
37
38 ### Build GStreamer and its modules
39
40 You can get all GStreamer built running:
41
42 ```
43 meson build/
44 ninja -C build/
45 ```
46
47 This will automatically create the `build` directory and build everything
48 inside it.
49
50 NOTE: On Windows, you *must* run this from inside the Visual Studio command
51 prompt of the appropriate architecture and version.
52
53 # Development environment
54
55 ## Building the Qt5 QML plugin
56
57 If `qmake` is not in `PATH` and pkgconfig files are not available, you can
58 point the `QMAKE` env var to the Qt5 installation of your choosing before
59 running `meson` as shown above.
60
61 The plugin will be automatically enabled if possible, but you can ensure that
62 it is built by passing `-Dgst-plugins-good:qt5=enabled` to `meson`. This will
63 cause Meson to error out if the plugin could not be enabled. This also works
64 for all plugins in all GStreamer repositories.
65
66 ## Development environment target
67
68 gst-build also contains a special `devenv` target that lets you enter an
69 development environment where you will be able to work on GStreamer
70 easily. You can get into that environment running:
71
72 ```
73 ninja -C build/ devenv
74 ```
75
76 If your operating system handles symlinks, built modules source code will be
77 available at the root of `gst-build/` for example GStreamer core will be in
78 `gstreamer/`. Otherwise they will be present in `subprojects/`. You can simply
79 hack in there and to rebuild you just need to rerun `ninja -C build/`.
80
81 NOTE: In the development environment, a fully usable prefix is also configured
82 in `gst-build/prefix` where you can install any extra dependency/project.
83
84 An external script can be run in development environment with:
85
86 ```
87 ./gst-env.py external_script.sh
88 ```
89
90 ## Update git subprojects
91
92 We added a special `update` target to update subprojects (it uses `git pull
93 --rebase` meaning you should always make sure the branches you work on are
94 following the right upstream branch, you can set it with `git branch
95 --set-upstream-to origin/master` if you are working on `gst-build` master
96 branch).
97
98 Update all GStreamer modules and rebuild:
99
100 ```
101 ninja -C build/ update
102 ```
103
104 Update all GStreamer modules without rebuilding:
105
106 ```
107 ninja -C build/ git-update
108 ```
109
110 ## Custom subprojects
111
112 We also added a meson option, `custom_subprojects`, that allows the user
113 to provide a comma-separated list of subprojects that should be built
114 alongside the default ones.
115
116 To use it:
117
118 ```
119 cd subprojects
120 git clone my_subproject
121 cd ../build
122 rm -rf * && meson .. -Dcustom_subprojects=my_subproject
123 ninja
124 ```
125
126 ## Run tests
127
128 You can easily run the test of all the components:
129
130 ```
131 meson test -C build
132 ```
133
134 To list all available tests:
135
136 ```
137 meson test -C build --list
138 ```
139
140 To run all the tests of a specific component:
141
142 ```
143 meson test -C build --suite gst-plugins-base
144 ```
145
146 Or to run a specific test file:
147
148 ```
149 meson test -C build/ --suite gstreamer gst_gstbuffer
150 ```
151
152 Run a specific test from a specific test file:
153
154 ```
155 GST_CHECKS=test_subbuffer meson test -C build/ --suite gstreamer gst_gstbuffer
156 ```
157
158 ## Optional Installation
159
160 `gst-build` has been created primarily for [development usage](#development-environment-target),
161 but you can also install everything that is built into a predetermined prefix like so:
162
163 ```
164 meson --prefix=/path/to/install/prefix build/
165 ninja -C build/
166 meson install -C build/
167 ```
168
169 Note that the installed files have `RPATH` stripped, so you will need to set
170 `LD_LIBRARY_PATH`, `DYLD_LIBRARY_PATH`, or `PATH` as appropriate for your
171 platform for things to work.
172
173 ## Checkout another branch using worktrees
174
175 If you need to have several versions of GStreamer coexisting (eg. `master` and `1.14`),
176 you can use the `checkout-branch-worktree` script provided by `gst-build`. It allows you
177 to create a new `gst-build` environment with new checkout of all the GStreamer modules as
178 [git worktrees](https://git-scm.com/docs/git-worktree).
179
180 For example to get a fresh checkout of `gst-1.14` from a `gst-build` in master **already
181 built** in a `build` directory you can simply run:
182
183 ```
184 ./checkout-branch-worktree ../gst-build-1.14 origin/1.14 -C build/
185 ```
186
187 This will create a new ``gst-build-1.14`` folder at the same level of ``gst-build`` pointing to the given branch ie *1.14*
188 for all the subprojects ( gstreamer, gst-plugins-base etc.)
189
190
191 ## Add information about GStreamer development environment in your prompt line
192
193 ### Bash prompt
194
195 We automatically handle `bash` and set `$PS1` accordingly.
196
197 If the automatic `$PS1` override is not desired (maybe you have a fancy custom prompt), set the `$GST_BUILD_DISABLE_PS1_OVERRIDE` environment variable to `TRUE` and use `$GST_ENV` when setting the custom prompt, for example with a snippet like the following:
198
199 ```bash
200 ...
201 if [[ -n "${GST_ENV-}" ]];
202 then
203   PS1+="[ ${GST_ENV} ]"
204 fi
205 ...
206
207 ```
208
209 ### Zsh prompt
210
211 In your `.zshrc`, you should add something like:
212
213 ```
214 export PROMPT="$GST_ENV-$PROMPT"
215 ```
216
217 ### Fish prompt
218
219 In your `~/.config/fish/functions/fish_prompt.fish`, you should add something like this at the end of the fish_prompt function body:
220
221 ```
222 if set -q GST_ENV
223   echo -n -s (set_color -b blue white) "(" (basename "$GST_ENV") ")" (set_color normal) " "
224 end
225 ```
226
227 ### Using powerline
228
229 In your powerline theme configuration file (by default in
230 `{POWERLINE INSTALLATION DIR}/config_files/themes/shell/default.json`)
231 you should add a new environment segment as follow:
232
233 ```
234 {
235   "function": "powerline.segments.common.env.environment",
236   "args": { "variable": "GST_ENV" },
237   "priority": 50
238 },
239 ```
240
241 ## Windows Prerequisites Setup
242
243 On Windows, some of the components may require special care.
244
245 ### Git for Windows
246
247 Use the [Git for Windows](https://gitforwindows.org/) installer. It will
248 install a `bash` prompt with basic shell utils and up-to-date git binaries.
249
250 During installation, when prompted about `PATH`, you should select the
251 following option:
252
253 ![Select "Git from the command line and also from 3rd-party software"](/data/images/git-installer-PATH.png)
254
255 ### Python 3.5+ on Windows
256
257 Use the [official Python installer](https://www.python.org/downloads/windows/).
258 You must ensure that Python is installed into `PATH`:
259
260 ![Enable Add Python to PATH, then click Customize Installation](/data/images/py-installer-page1.png)
261
262 You may also want to customize the installation and install it into
263 a system-wide location such as `C:\PythonXY`, but this is not required.
264
265 ### Ninja on Windows
266
267 The easiest way to install Ninja on Windows is with `pip3`, which will download
268 the compiled binary and place it into the `Scripts` directory inside your
269 Python installation:
270
271 ```
272 pip3 install ninja
273 ```
274
275 You can also download the [official release](https://github.com/ninja-build/ninja/releases)
276 and place it into `PATH`.
277
278 ### Meson on Windows
279
280 **IMPORTANT**: Do not use the Meson MSI installer since it is experimental and known to not
281 work with `gst-build`.
282
283 You can use `pip3` to install Meson, same as Ninja above:
284
285 ```
286 pip3 install meson
287 ```
288
289 Note that Meson is written entirely in Python, so you can also run it as-is
290 from the [git repository](https://github.com/mesonbuild/meson/) if you want to
291 use the latest master branch for some reason.
292
293
294 ### Setup a mingw/wine based development environment on linux
295
296 #### Install wine and mingw
297
298 ##### On fedora x64
299
300 ``` sh
301 sudo dnf install mingw64-gcc mingw64-gcc-c++ mingw64-pkg-config mingw64-winpthreads wine
302 ```
303
304 FIXME: Figure out what needs to be installed on other distros
305
306 #### Get meson from git
307
308 This simplifies the process and allows us to use the cross files
309 defined in meson itself.
310
311 ``` sh
312 git clone https://github.com/mesonbuild/meson.git
313 ```
314
315 #### Build and install
316
317 ```
318 BUILDDIR=$PWD/winebuild/
319 export WINEPREFIX=$BUILDDIR/wine-prefix/ && mkdir -p $WINEPREFIX
320 # Setting the prefix is mandatory as it is used to setup symlinks during uninstalled development
321 meson/meson.py $BUILDDIR --cross-file meson/cross/linux-mingw-w64-64bit.txt -Dgst-plugins-bad:vulkan=disabled -Dorc:gtk_doc=disabled --prefix=$BUILDDIR/wininstall/ -Djson-glib:gtk_doc=disabled
322 meson/meson.py install -C $BUILDDIR/
323 ```
324
325 > __NOTE__: You should use `meson install -C $BUILDDIR`  each time you make a change
326 > instead of the usual `ninja -C build` as the environment is not uninstalled.
327
328 #### The development environment
329
330 You can get into the development environment the usual way:
331
332 ```
333 ninja -C $BUILDDIR/ devenv
334 ```
335
336 After setting up [binfmt] to use wine for windows binaries,
337 you can run GStreamer tools under wine by running:
338
339 ```
340 gst-launch-1.0.exe videotestsrc ! glimagesink
341 ```
342
343 [binfmt]: http://man7.org/linux/man-pages/man5/binfmt.d.5.html