[vlc-commits] [Git][videolan/vlc][master] 4 commits: doc: buildsystem: document the new enabled option

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat Apr 27 09:59:43 UTC 2024



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
021c7cbf by Alexandre Janniaux at 2024-04-27T09:39:37+00:00
doc: buildsystem: document the new enabled option

The enabled option allows modules to be declared even though they won't
be compiled, which provides better interactions with tests.

- - - - -
814f6814 by Alexandre Janniaux at 2024-04-27T09:39:37+00:00
doc: buildsystem: document contribs usage with meson

- - - - -
c618f81f by Alexandre Janniaux at 2024-04-27T09:39:37+00:00
doc: buildsystem: fix typo

- - - - -
f50ba69f by Alexandre Janniaux at 2024-04-27T09:39:37+00:00
doc: buildsystem: document meson tests

The buildsystem provides a dedicated meson array for tests to generate
the test executables and test scenarios in a unified way while declaring
the dependencies to runtime dependencies (mainly plugins).

- - - - -


1 changed file:

- doc/standalone/buildsystem.md


Changes:

=====================================
doc/standalone/buildsystem.md
=====================================
@@ -88,7 +88,7 @@ vlc_modules += {
 ```
 
 @warning 	Make sure to not accidentally overwrite the `vlc_modules` variable by using
-		 	and `=` instead of `+=` when appending the dictionary.
+		 	an `=` instead of `+=` when appending the dictionary.
 
 Currently the modules dict accepts the following keys:
 
@@ -98,6 +98,9 @@ Currently the modules dict accepts the following keys:
 @param 	sources
 		The source files for the module, use [`files()`][mref_files] to specify them. **Required**
 
+ at param  enabled
+        A boolean indicating whether the module should be built or not.
+
 @param  dependencies
 		The dependencies needed by the module. Only list external dependencies
 		here, not libraries that are built as part of the VLC build, for these
@@ -173,13 +176,12 @@ Now we can just look up the option and use that for the `required` argument of t
 ```meson
 # dav1d AV1 decoder
 dav1d_dep = dependency('dav1d', version: '>= 0.5.0', required: get_option('dav1d'))
-if dav1d_dep.found()
-    vlc_modules += {
-        'name' : 'dav1d',
-        'sources' : files('dav1d.c'),
-        'dependencies' : [dav1d_dep]
-    }
-endif
+vlc_modules += {
+    'name' : 'dav1d',
+    'sources' : files('dav1d.c'),
+    'dependencies' : [dav1d_dep],
+    'enabled' : dav1d_dep.found(),
+}
 ```
 
 As the option defaults to `auto`, meson will look it up, and if its is found, add the module.
@@ -191,11 +193,13 @@ cases of conditional dependencies. For example suppose we want an option to be d
 cases when it is set to `auto`:
 
 ```meson
-if (get_option('x11')
-    .disable_auto_if(host_system in ['darwin', 'windows'])
-    .allowed())
-    # Do something here if the X11 option is enabled
-endif
+vlc_modules += {
+    'name' : 'xcb',
+    'sources' : files('xcb.c'),
+    'enabled' : get_option('x11') \
+        .disable_auto_if(host_system in ['darwin', 'windows']) \
+        .allowed(),
+}
 ```
 
 This will disable the `x11` option if it is set to auto, when on `darwin` or `windows`.
@@ -212,6 +216,102 @@ endif
 it would not do what you might expect, as `disable_auto_if` returns a new option and does not mutate the
 existing one. The returned option object is never assigned to any variable, so it is lost.
 
+### Adding new tests
+
+VLC tests are also meson dictionaries added to the special array named `vlc_tests`.
+This mechanism allows a test to reference modules that should be available when
+running the test.
+
+To add a new test, simply append to that variable:
+
+```meson
+vlc_tests += {
+    'name' : 'test_src_input_thumbnail',
+    'sources' : files('input/thumbnail.c'),
+    'suite' : ['src', 'test_src'],
+    'link_with' : [libvlc, libvlccore],
+    'module_depends' : ['demux_mock', 'rawvideo']
+}
+```
+
+ at warning    Make sure to not accidentally overwrite the `vlc_tests` variable
+            by using an `=` instead of `+=` when appending the dictionary.
+
+Currently the modules dictionary accepts the following keys:
+
+ at param  name
+        The name of the new VLC test, which will map to the executable name. **Required**
+
+ at param  sources
+        The source files for the new test, use [`files()`][mref_files] to specify them. **Required**
+
+ at param  suite
+        The meson test suites to which this test should be available.
+
+ at param  dependencies
+		The dependencies needed by the test. Only list external dependencies
+		here, not libraries that are built as part of the VLC build, for these
+		use `link_with` instead.
+
+ at param  link_with
+		The dependencies needed by the test that are part of the VLC build.
+        For external dependencies, use `dependencies` instead.
+
+ at param  include_directories
+		Additional include directories that should be used when compiling the test.
+		These should be specified using the [`include_directories()`][mref_include_directories]
+		function.
+
+ at param  module_depends
+        The list of module names this test depends upon.
+
+ at param  moc_headers
+        A list of header files that should be transformed by Qt's moc
+        source translater built for the test.
+
+ at param  c_args
+	    Additional flags to pass to the C compiler.
+
+ at param  cpp_args
+		Additional flags to pass to the C++ compiler.
+
+ at param  objc_args
+		Additional flags to pass to the Objective-C compiler.
+
+To run a specific test, you can directly use:
+
+```bash
+meson test -C build-meson test_src_input_thumbnail
+```
+
+where `test_src_input_thumbnail` can be replaced by the `name` of the test.
+Make sure that a module really depends upon the module it's using through the
+`module_depends` variable. If every modules should be used to run the test,
+you can use the special value `vlc_plugins_targets.keys()`, but adding more
+module dependencies than necessary will drastically increase the compile time
+when running a specific test in cases like automated `git bisect`.
+
+#### Compiling with contribs
+
+The meson build system also supports using dependencies and binaries provided
+by the contrib system. 
+
+Once the contrib has been prepared, a meson machine file will be generated
+in the installation prefix. For native linux x86_64, it will typically be
+found at the following location:
+
+    vlc/contrib/x86_64-pc-linux-gnu/share/meson/native/contrib.ini
+
+Then you can setup meson with this file using the following command:
+
+    meson setup build-meson \
+        --native-file contrib/x86_64-pc-linux-gnu/share/meson/native/contrib.ini 
+
+When cross-compiling, both the crossfile and the contrib machine file
+can be supplied at the same time:
+
+    meson setup build-meson --cross-file win32.crossfile \
+        --cross-file contrib/x86_64-w64-mingw32/share/meson/cross/contrib.ini 
 
 [mref_files]: https://mesonbuild.com/Reference-manual_functions.html#files
 [mref_include_directories]: https://mesonbuild.com/Reference-manual_functions.html#include_directories



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9ad3dd748b9b58e6afc04cb3d16ad9c6b0706ebc...f50ba69fe6f5586507cf361f4d6fd7dadf86823c

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9ad3dd748b9b58e6afc04cb3d16ad9c6b0706ebc...f50ba69fe6f5586507cf361f4d6fd7dadf86823c
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list