Fix link to meson "subprojects" 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 uninstalled 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 ## Uninstalled environment
67
68 gst-build also contains a special `uninstalled` target that lets you enter an
69 uninstalled 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/ uninstalled
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 uninstalled environment, a fully usable prefix is also configured
82 in `gst-build/prefix` where you can install any extra dependency/project.
83
84 ## Update git subprojects
85
86 We added a special `update` target to update subprojects (it uses `git pull
87 --rebase` meaning you should always make sure the branches you work on are
88 following the right upstream branch, you can set it with `git branch
89 --set-upstream-to origin/master` if you are working on `gst-build` master
90 branch).
91
92 Update all GStreamer modules and rebuild:
93
94 ```
95 ninja -C build/ update
96 ```
97
98 Update all GStreamer modules without rebuilding:
99
100 ```
101 ninja -C build/ git-update
102 ```
103
104 ## Custom subprojects
105
106 We also added a meson option, `custom_subprojects`, that allows the user
107 to provide a comma-separated list of subprojects that should be built
108 alongside the default ones.
109
110 To use it:
111
112 ```
113 cd subprojects
114 git clone my_subproject
115 cd ../build
116 rm -rf * && meson .. -Dcustom_subprojects=my_subproject
117 ninja
118 ```
119
120 ## Run tests
121
122 You can easily run the test of all the components:
123
124 ```
125 meson test -C build
126 ```
127
128 To list all available tests:
129
130 ```
131 meson test -C build --list
132 ```
133
134 To run all the tests of a specific component:
135
136 ```
137 meson test -C build --suite gst-plugins-base
138 ```
139
140 Or to run a specific test file:
141
142 ```
143 meson test -C build/ --suite gstreamer gst_gstbuffer
144 ```
145
146 Run a specific test from a specific test file:
147
148 ```
149 GST_CHECKS=test_subbuffer meson test -C build/ --suite gstreamer gst_gstbuffer
150 ```
151
152 ## Optional Installation
153
154 `gst-build` has been created primarily for [uninstalled usage](#uninstalled-environment),
155 but you can also install everything that is built into a predetermined prefix like so:
156
157 ```
158 meson --prefix=/path/to/install/prefix build/
159 ninja -C build/
160 meson install -C build/
161 ```
162
163 Note that the installed files have `RPATH` stripped, so you will need to set
164 `LD_LIBRARY_PATH`, `DYLD_LIBRARY_PATH`, or `PATH` as appropriate for your
165 platform for things to work.
166
167 ## Checkout another branch using worktrees
168
169 If you need to have several versions of GStreamer coexisting (eg. `master` and `1.14`),
170 you can use the `checkout-branch-worktree` script provided by `gst-build`. It allows you
171 to create a new `gst-build` environment with new checkout of all the GStreamer modules as
172 [git worktrees](https://git-scm.com/docs/git-worktree).
173
174 For example to get a fresh checkout of `gst-1.14` from a `gst-build` in master already
175 built in a `build` directory you can simply run:
176
177 ```
178 ./checkout-branch-worktree ../gst-1.14 1.14 -C build/
179 ```
180
181 ## Add information about GStreamer development environment in your prompt line
182
183 ### Bash prompt
184
185 We automatically handle `bash` and set `$PS1` accordingly.
186
187 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:
188
189 ```bash
190 ...
191 if [[ -n "${GST_ENV-}" ]];
192 then
193   PS1+="[ ${GST_ENV} ]"
194 fi
195 ...
196
197 ```
198
199 ### Zsh prompt
200
201 In your `.zshrc`, you should add something like:
202
203 ```
204 export PROMPT="$GST_ENV-$PROMPT"
205 ```
206
207 ### Fish prompt
208
209 In your `~/.config/fish/functions/fish_prompt.fish`, you should add something like this at the end of the fish_prompt function body:
210
211 ```
212 if set -q GST_ENV
213   echo -n -s (set_color -b blue white) "(" (basename "$GST_ENV") ")" (set_color normal) " "
214 end
215 ```
216
217 ### Using powerline
218
219 In your powerline theme configuration file (by default in
220 `{POWERLINE INSTALLATION DIR}/config_files/themes/shell/default.json`)
221 you should add a new environment segment as follow:
222
223 ```
224 {
225   "function": "powerline.segments.common.env.environment",
226   "args": { "variable": "GST_ENV" },
227   "priority": 50
228 },
229 ```
230
231 ## Windows Prerequisites Setup
232
233 On Windows, some of the components may require special care.
234
235 ### Git for Windows
236
237 Use the [Git for Windows](https://gitforwindows.org/) installer. It will
238 install a `bash` prompt with basic shell utils and up-to-date git binaries.
239
240 During installation, when prompted about `PATH`, you should select the
241 following option:
242
243 ![Select "Git from the command line and also from 3rd-party software"](/data/images/git-installer-PATH.png)
244
245 ### Python 3.5+ on Windows
246
247 Use the [official Python installer](https://www.python.org/downloads/windows/).
248 You must ensure that Python is installed into `PATH`:
249
250 ![Enable Add Python to PATH, then click Customize Installation](/data/images/py-installer-page1.png)
251
252 You may also want to customize the installation and install it into
253 a system-wide location such as `C:\PythonXY`, but this is not required.
254
255 ### Ninja on Windows
256
257 The easiest way to install Ninja on Windows is with `pip3`, which will download
258 the compiled binary and place it into the `Scripts` directory inside your
259 Python installation:
260
261 ```
262 pip3 install ninja
263 ```
264
265 You can also download the [official release](https://github.com/ninja-build/ninja/releases)
266 and place it into `PATH`.
267
268 ### Meson on Windows
269
270 **IMPORTANT**: Do not use the Meson MSI installer since it is experimental and known to not
271 work with `gst-build`.
272
273 You can use `pip3` to install Meson, same as Ninja above:
274
275 ```
276 pip3 install meson
277 ```
278
279 Note that Meson is written entirely in Python, so you can also run it as-is
280 from the [git repository](https://github.com/mesonbuild/meson/) if you want to
281 use the latest master branch for some reason.