README: Add instructions for Windows with screenshots
[platform/upstream/gstreamer.git] / README.md
1 # gst-build
2
3 GStreamer [meson](http://mesonbuild.com/) based repositories aggregrator
4
5 You can build GStreamer and all its modules at once using
6 meson and its [subproject](https://github.com/mesonbuild/meson/wiki/Subprojects) feature.
7
8 ## Getting started
9
10 ### Install git and python 3.5+
11
12 If you're on Linux, you probably already have these. On macOS, you can use the
13 [official Python installer](https://www.python.org/downloads/mac-osx/).
14
15 You can find [instructions for Windows below](#windows-prerequisites-setup).
16
17 ### Install meson and ninja
18
19 Meson 0.48 or newer is required.
20
21 On Linux and macOS you can get meson through your package manager or using:
22
23   $ pip3 install --user meson
24
25 This will install meson into `~/.local/bin` which may or may not be included
26 automatically in your PATH by default.
27
28 You should get `ninja` using your package manager or download the [official
29 release](https://github.com/ninja-build/ninja/releases) and put the `ninja`
30 binary in your PATH.
31
32 You can find [instructions for Windows below](#windows-prerequisites-setup).
33
34 ### Build GStreamer and its modules
35
36 You can get all GStreamer built running:
37
38 ```
39 meson build/
40 ninja -C build/
41 ```
42
43 This will automatically create the `build` directory and build everything
44 inside it.
45
46 NOTE: On Windows, you *must* run this from inside the Visual Studio command
47 prompt of the appropriate architecture and version.
48
49 # Development environment
50
51 ## Building the Qt5 QML plugin
52
53 If `qmake` is not in `PATH` and pkgconfig files are not available, you can
54 point the `QMAKE` env var to the Qt5 installation of your choosing before
55 running `meson` as shown above.
56
57 The plugin will be automatically enabled if possible, but you can ensure that
58 it is built by passing `-Dgst-plugins-good:qt5=enabled` to `meson`. This will
59 cause Meson to error out if the plugin could not be enabled. This also works
60 for all plugins in all GStreamer repositories.
61
62 ## Uninstalled environment
63
64 gst-build also contains a special `uninstalled` target that lets you enter an
65 uninstalled development environment where you will be able to work on GStreamer
66 easily. You can get into that environment running:
67
68 ```
69 ninja -C build/ uninstalled
70 ```
71
72 If your operating system handles symlinks, built modules source code will be
73 available at the root of `gst-build/` for example GStreamer core will be in
74 `gstreamer/`. Otherwise they will be present in `subprojects/`. You can simply
75 hack in there and to rebuild you just need to rerun `ninja -C build/`.
76
77 NOTE: In the uninstalled environment, a fully usable prefix is also configured
78 in `gst-build/prefix` where you can install any extra dependency/project.
79
80 ## Update git subprojects
81
82 We added a special `update` target to update subprojects (it uses `git pull
83 --rebase` meaning you should always make sure the branches you work on are
84 following the right upstream branch, you can set it with `git branch
85 --set-upstream-to origin/master` if you are working on `gst-build` master
86 branch).
87
88 Update all GStreamer modules and rebuild:
89
90 ```
91 ninja -C build/ update
92 ```
93
94 Update all GStreamer modules without rebuilding:
95
96 ```
97 ninja -C build/ git-update
98 ```
99
100 ## Custom subprojects
101
102 We also added a meson option, `custom_subprojects`, that allows the user
103 to provide a comma-separated list of subprojects that should be built
104 alongside the default ones.
105
106 To use it:
107
108 ```
109 cd subprojects
110 git clone my_subproject
111 cd ../build
112 rm -rf * && meson .. -Dcustom_subprojects=my_subproject
113 ninja
114 ```
115
116 ## Run tests
117
118 You can easily run the test of all the components:
119
120 ```
121 meson test -C build
122 ```
123
124 To list all available tests:
125
126 ```
127 meson test -C build --list
128 ```
129
130 To run all the tests of a specific component:
131
132 ```
133 meson test -C build --suite gst-plugins-base
134 ```
135
136 Or to run a specific test file:
137
138 ```
139 meson test -C build/ --suite gstreamer gst_gstbuffer
140 ```
141
142 Run a specific test from a specific test file:
143
144 ```
145 GST_CHECKS=test_subbuffer meson test -C build/ --suite gstreamer gst_gstbuffer
146 ```
147
148 ## Optional Installation
149
150 `gst-build` has been created primarily for [uninstalled usage](#uninstalled-environment),
151 but you can also install everything that is built into a predetermined prefix like so:
152
153 ```
154 meson --prefix=/path/to/install/prefix build/
155 ninja -C build/
156 meson install -C build/
157 ```
158
159 Note that the installed files have `RPATH` stripped, so you will need to set
160 `LD_LIBRARY_PATH`, `DYLD_LIBRARY_PATH`, or `PATH` as appropriate for your
161 platform for things to work.
162
163 ## Checkout another branch using worktrees
164
165 If you need to have several versions of GStreamer coexisting (eg. `master` and `1.14`),
166 you can use the `checkout-branch-worktree` script provided by `gst-build`. It allows you
167 to create a new `gst-build` environment with new checkout of all the GStreamer modules as
168 [git worktrees](https://git-scm.com/docs/git-worktree).
169
170 For example to get a fresh checkout of `gst-1.14` from a `gst-build` in master already
171 built in a `build` directory you can simply run:
172
173 ```
174 ./checkout-branch-worktree ../gst-1.14 1.14 -C build/
175 ```
176
177 ## Add information about GStreamer development environment in your prompt line
178
179 ### Bash prompt
180
181 We automatically handle `bash` and set `$PS1` accordingly.
182
183 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:
184
185 ```bash
186 ...
187 if [[ -n "${GST_ENV-}" ]];
188 then
189   PS1+="[ ${GST_ENV} ]"
190 fi
191 ...
192
193 ```
194
195 ### Zsh prompt
196
197 In your `.zshrc`, you should add something like:
198
199 ```
200 export PROMPT="$GST_ENV-$PROMPT"
201 ```
202
203 ### Fish prompt
204
205 In your `~/.config/fish/functions/fish_prompt.fish`, you should add something like this at the end of the fish_prompt function body:
206
207 ```
208 if set -q GST_ENV
209   echo -n -s (set_color -b blue white) "(" (basename "$GST_ENV") ")" (set_color normal) " "
210 end
211 ```
212
213 ### Using powerline
214
215 In your powerline theme configuration file (by default in
216 `{POWERLINE INSTALLATION DIR}/config_files/themes/shell/default.json`)
217 you should add a new environment segment as follow:
218
219 ```
220 {
221   "function": "powerline.segments.common.env.environment",
222   "args": { "variable": "GST_ENV" },
223   "priority": 50
224 },
225 ```
226
227 ## Windows Prerequisites Setup
228
229 On Windows, some of the components may require special care.
230
231 ### Git for Windows
232
233 Use the [Git for Windows](https://gitforwindows.org/) installer. It will
234 install a `bash` prompt with basic shell utils and up-to-date git binaries.
235
236 During installation, when prompted about `PATH`, you should select the
237 following option:
238
239 ![Select "Git from the command line and also from 3rd-party software"](/data/images/git-installer-PATH.png)
240
241 ### Python 3.5+ on Windows
242
243 Use the [official Python installer](https://www.python.org/downloads/windows/).
244 You must ensure that Python is installed into `PATH`:
245
246 ![Enable Add Python to PATH, then click Customize Installation](/data/images/py-installer-page1.png)
247
248 You may also want to customize the installation and install it into
249 a system-wide location such as `C:\PythonXY`, but this is not required.
250
251 ### Ninja on Windows
252
253 The easiest way to install Ninja on Windows is with `pip3`, which will download
254 the compiled binary and place it into the `Scripts` directory inside your
255 Python installation:
256
257 ```
258 pip3 install ninja
259 ```
260
261 You can also download the [official release](https://github.com/ninja-build/ninja/releases)
262 and place it into `PATH`.
263
264 ### Meson on Windows
265
266 **IMPORTANT**: Do not use the Meson MSI installer since it is experimental and known to not
267 work with `gst-build`.
268
269 You can use `pip3` to install Meson, same as Ninja above:
270
271 ```
272 pip3 install meson
273 ```
274
275 Note that Meson is written entirely in Python, so you can also run it as-is
276 from the [git repository](https://github.com/mesonbuild/meson/) if you want to
277 use the latest master branch for some reason.