README: document updated meson requirement
[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.52 or newer is required.
24
25 For cross-compilation Meson 0.54 or newer is required.
26
27 On Linux and macOS you can get meson through your package manager or using:
28
29   $ pip3 install --user meson
30
31 This will install meson into `~/.local/bin` which may or may not be included
32 automatically in your PATH by default.
33
34 You should get `ninja` using your package manager or download the [official
35 release](https://github.com/ninja-build/ninja/releases) and put the `ninja`
36 binary in your PATH.
37
38 You can find [instructions for Windows below](#windows-prerequisites-setup).
39
40 ### Build GStreamer and its modules
41
42 You can get all GStreamer built running:
43
44 ```
45 meson builddir
46 ninja -C builddir
47 ```
48
49 This will automatically create the `build` directory and build everything
50 inside it.
51
52 NOTE: On Windows, you *must* run this from [inside the Visual Studio command
53 prompt](#running-meson-on-windows) of the appropriate architecture and version.
54
55 ### External dependencies
56
57 All mandatory dependencies of GStreamer are included as [meson subprojects](https://mesonbuild.com/Subprojects.html):
58 libintl, zlib, libffi, glib. Some optional dependencies are also included as
59 subprojects, such as ffmpeg, x264, json-glib, graphene, openh264, orc, etc.
60
61 Mandatory dependencies will be automatically built if meson cannot find them on
62 your system using pkg-config. The same is true for optional dependencies that
63 are included as subprojects. You can find a full list by looking at the
64 `subprojects` directory.
65
66 Plugins that need optional dependencies that aren't included can only be built
67 if they are provided by the system. Instructions on how to build some common
68 ones such as Qt5/QML are listed below. If you do not know how to provide an
69 optional dependency needed by a plugin, you should use [Cerbero](https://gitlab.freedesktop.org/gstreamer/cerbero/#description)
70 which handles this for you automatically.
71
72 Plugins will be automatically enabled if possible, but you can ensure that
73 a particular plugin (especially if it has external dependencies) is built by
74 enabling the gstreamer repository that ships it and the plugin inside it. For
75 example, to enable the Qt5 plugin in the gst-plugins-good repository, you need
76 to run meson as follows:
77
78 ```
79 meson -Dgood=enabled -Dgst-plugins-good:qt5=enabled builddir
80 ```
81
82 This will cause Meson to error out if the plugin could not be enabled. You can
83 also flip the default and disable all plugins except those explicitly enabled
84 like so:
85
86 ```
87 meson -Dauto_features=disabled -Dgstreamer:tools=enabled -Dbad=enabled -Dgst-plugins-bad:openh264=enabled
88 ```
89
90 This will disable all optional features and then enable the `openh264` plugin
91 and the tools that ship with the core gstreamer repository: `gst-inspect-1.0`,
92 `gst-launch-1.0`, etc. As usual, you can change these values on a builddir that
93 has already been setup with `meson configure -Doption=value`.
94
95 ### Building the Qt5 QML plugin
96
97 If `qmake` is not in `PATH` and pkgconfig files are not available, you can
98 point the `QMAKE` env var to the Qt5 installation of your choosing before
99 running `meson` as shown above.
100
101 The plugin will be automatically enabled if possible, but you can ensure that
102 it is built by passing `-Dgood=enabled -Dgst-plugins-good:qt5=enabled` to `meson`.
103
104 ### Building the Intel MSDK plugin
105
106 On Linux, you need to have development files for `libmfx` installed. On
107 Windows, if you have the [Intel Media SDK](https://software.intel.com/en-us/media-sdk),
108 it will set the `INTELMEDIASDKROOT` environment variable, which will be used by
109 the build files to find `libmfx`.
110
111 The plugin will be automatically enabled if possible, but you can ensure it by
112 passing `-Dbad=enabled -Dgst-plugins-bad:msdk=enabled` to `meson`.
113
114 # Development environment
115
116 ## Development environment target
117
118 gst-build also contains a special `devenv` target that lets you enter an
119 development environment where you will be able to work on GStreamer
120 easily. You can get into that environment running:
121
122 ```
123 ninja -C builddir devenv
124 ```
125
126 If your operating system handles symlinks, built modules source code will be
127 available at the root of `gst-build/` for example GStreamer core will be in
128 `gstreamer/`. Otherwise they will be present in `subprojects/`. You can simply
129 hack in there and to rebuild you just need to rerun `ninja -C builddir`.
130
131 NOTE: In the development environment, a fully usable prefix is also configured
132 in `gst-build/prefix` where you can install any extra dependency/project.
133
134 An external script can be run in development environment with:
135
136 ```
137 ./gst-env.py external_script.sh
138 ```
139
140 ## Update git subprojects
141
142 We added a special `update` target to update subprojects (it uses `git pull
143 --rebase` meaning you should always make sure the branches you work on are
144 following the right upstream branch, you can set it with `git branch
145 --set-upstream-to origin/master` if you are working on `gst-build` master
146 branch).
147
148 Update all GStreamer modules and rebuild:
149
150 ```
151 ninja -C builddir update
152 ```
153
154 Update all GStreamer modules without rebuilding:
155
156 ```
157 ninja -C builddir git-update
158 ```
159
160 ## Custom subprojects
161
162 We also added a meson option, `custom_subprojects`, that allows the user
163 to provide a comma-separated list of subprojects that should be built
164 alongside the default ones.
165
166 To use it:
167
168 ```
169 cd subprojects
170 git clone my_subproject
171 cd ../build
172 rm -rf * && meson .. -Dcustom_subprojects=my_subproject
173 ninja
174 ```
175
176 ## Run tests
177
178 You can easily run the test of all the components:
179
180 ```
181 meson test -C build
182 ```
183
184 To list all available tests:
185
186 ```
187 meson test -C builddir --list
188 ```
189
190 To run all the tests of a specific component:
191
192 ```
193 meson test -C builddir --suite gst-plugins-base
194 ```
195
196 Or to run a specific test file:
197
198 ```
199 meson test -C builddir --suite gstreamer gst_gstbuffer
200 ```
201
202 Run a specific test from a specific test file:
203
204 ```
205 GST_CHECKS=test_subbuffer meson test -C builddir --suite gstreamer gst_gstbuffer
206 ```
207
208 ## Optional Installation
209
210 `gst-build` has been created primarily for [development usage](#development-environment-target),
211 but you can also install everything that is built into a predetermined prefix like so:
212
213 ```
214 meson --prefix=/path/to/install/prefix builddir
215 ninja -C builddir
216 meson install -C builddir
217 ```
218
219 Note that the installed files have `RPATH` stripped, so you will need to set
220 `LD_LIBRARY_PATH`, `DYLD_LIBRARY_PATH`, or `PATH` as appropriate for your
221 platform for things to work.
222
223 ## Checkout another branch using worktrees
224
225 If you need to have several versions of GStreamer coexisting (eg. `master` and `1.16`),
226 you can use the `gst-worktree.py` script provided by `gst-build`. It allows you
227 to create a new `gst-build` environment with new checkout of all the GStreamer modules as
228 [git worktrees](https://git-scm.com/docs/git-worktree).
229
230 For example to get a fresh checkout of `gst-1.16` from a `gst-build` repository
231 that is checked out at master, you can run:
232
233 ```
234 ./gst-worktree.py add gst-build-1.16 origin/1.16
235 ```
236
237 This will create a new ``gst-build-1.16`` directory pointing to the given branch `1.16`
238 for all the subprojects (gstreamer, gst-plugins-base, etc.)
239
240
241 ## Add information about GStreamer development environment in your prompt line
242
243 ### Bash prompt
244
245 We automatically handle `bash` and set `$PS1` accordingly.
246
247 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:
248
249 ```bash
250 ...
251 if [[ -n "${GST_ENV-}" ]];
252 then
253   PS1+="[ ${GST_ENV} ]"
254 fi
255 ...
256 ```
257
258 ### Using powerline
259
260 In your powerline theme configuration file (by default in
261 `{POWERLINE INSTALLATION DIR}/config_files/themes/shell/default.json`)
262 you should add a new environment segment as follow:
263
264 ```
265 {
266   "function": "powerline.segments.common.env.environment",
267   "args": { "variable": "GST_ENV" },
268   "priority": 50
269 },
270 ```
271
272 ## Windows Prerequisites Setup
273
274 On Windows, some of the components may require special care.
275
276 ### Git for Windows
277
278 Use the [Git for Windows](https://gitforwindows.org/) installer. It will
279 install a `bash` prompt with basic shell utils and up-to-date git binaries.
280
281 During installation, when prompted about `PATH`, you should select the
282 following option:
283
284 ![Select "Git from the command line and also from 3rd-party software"](/data/images/git-installer-PATH.png)
285
286 ### Python 3.5+ on Windows
287
288 Use the [official Python installer](https://www.python.org/downloads/windows/).
289 You must ensure that Python is installed into `PATH`:
290
291 ![Enable Add Python to PATH, then click Customize Installation](/data/images/py-installer-page1.png)
292
293 You may also want to customize the installation and install it into
294 a system-wide location such as `C:\PythonXY`, but this is not required.
295
296 ### Ninja on Windows
297
298 The easiest way to install Ninja on Windows is with `pip3`, which will download
299 the compiled binary and place it into the `Scripts` directory inside your
300 Python installation:
301
302 ```
303 pip3 install ninja
304 ```
305
306 You can also download the [official release](https://github.com/ninja-build/ninja/releases)
307 and place it into `PATH`.
308
309 ### Meson on Windows
310
311 **IMPORTANT**: Do not use the Meson MSI installer since it is experimental and known to not
312 work with `gst-build`.
313
314 You can use `pip3` to install Meson, same as Ninja above:
315
316 ```
317 pip3 install meson
318 ```
319
320 Note that Meson is written entirely in Python, so you can also run it as-is
321 from the [git repository](https://github.com/mesonbuild/meson/) if you want to
322 use the latest master branch for some reason.
323
324 ### Running Meson on Windows
325
326 At present, to build with Visual Studio, you need to run Meson from inside the
327 VS 2019 command prompt. Press `Start`, and search for `VS 2019`, and click on
328 `x64 Native Tools Command Prompt for VS 2019`, or a prompt named similar to
329 that:
330
331 ![x64 Native Tools Command Prompt for VS 2019](/data/images/vs-2019-dev-prompt.png)
332
333
334 ### Setup a mingw/wine based development environment on linux
335
336 #### Install wine and mingw
337
338 ##### On fedora x64
339
340 ``` sh
341 sudo dnf install mingw64-gcc mingw64-gcc-c++ mingw64-pkg-config mingw64-winpthreads wine
342 ```
343
344 FIXME: Figure out what needs to be installed on other distros
345
346 #### Get meson from git
347
348 This simplifies the process and allows us to use the cross files
349 defined in meson itself.
350
351 ``` sh
352 git clone https://github.com/mesonbuild/meson.git
353 ```
354
355 #### Build and install
356
357 ```
358 BUILDDIR=$PWD/winebuild/
359 export WINEPREFIX=$BUILDDIR/wine-prefix/ && mkdir -p $WINEPREFIX
360 # Setting the prefix is mandatory as it is used to setup symlinks during uninstalled development
361 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
362 meson/meson.py install -C $BUILDDIR/
363 ```
364
365 > __NOTE__: You should use `meson install -C $BUILDDIR`  each time you make a change
366 > instead of the usual `ninja -C build` as the environment is not uninstalled.
367
368 #### The development environment
369
370 You can get into the development environment the usual way:
371
372 ```
373 ninja -C $BUILDDIR/ devenv
374 ```
375
376 Alternatively, if you'd rather not start a shell in your workflow, you
377 can mutate the current environment into a suitable state like so:
378
379 ```
380 gst-env.py --only-environment
381 ```
382
383 This will print output suitable for an sh-compatible `eval` function,
384 just like `ssh-agent -s`.
385
386 After setting up [binfmt] to use wine for windows binaries,
387 you can run GStreamer tools under wine by running:
388
389 ```
390 gst-launch-1.0.exe videotestsrc ! glimagesink
391 ```
392
393 [binfmt]: http://man7.org/linux/man-pages/man5/binfmt.d.5.html