Skip to contentSkip to conversation

Introduce the meson build system

RFC PATCH In review Ezequiel Garcia 6 participants 16 messages Mar 15, 2020 – Mar 27, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Introduce the meson build system

Here's a first step towards using meson:

https://mesonbuild.com/

As you can see, this doesn't include all tools and libraries (are there any libv4l1 users?), but otherwise tries to cover as much as possible.

I'm sending this early patch, hoping to get some reviews and possibly some testing.

Let me know what you think.

Thanks,

Ezequiel Garcia (1):
Add support for meson building

 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in
Signature · 1 line
2.25.0
#1 lore raw

RFC PATCH 1/1 Introduce support for meson building

Currently supports:

* libdvbv5
* libv4l2
* libv4lconvert
* cec-ctl
* cec-compliance
* cec-follower
* ir-ctl
* media-ctl
* v4l2-ctl
* v4l2-compliance

---
 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in
gen-version.sh new file +36 -0
new file mode 100755
index 000000000000..9223ab7d0a32
@@ -0,0 +1,36 @@
+#!/bin/sh
+# gen-version.sh script taken from the libcamera project.
+# Generate a version string using git describe.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+build_dir="$1"
+
+# Bail out if the directory isn't under git control
+src_dir=$(git rev-parse --git-dir 2>&1) || exit 1
+src_dir=$(readlink -f "$src_dir/..")
+
+# Get a short description from the tree.
+version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null)
+
+if [ -z "$version" ]
+then
+	# Handle an un-tagged repository
+	sha=$(git describe --abbrev=8 --always 2>/dev/null)
+	commits=$(git log --oneline | wc -l 2>/dev/null)
+	version="v4l-utils-0.0.0-$commits-g$sha"
+fi
+
+# Append a '-dirty' suffix if the working tree is dirty. Prevent false
+# positives due to changed timestamps by running git update-index.
+if [ -z "$build_dir" ] || (echo "$build_dir" | grep -q "$src_dir")
+then
+	git update-index --refresh > /dev/null 2>&1
+fi
+git diff-index --quiet HEAD || version="$version-dirty"
+
+# Replace first '-' with a '+' to denote build metadata, strip the 'g' in from
+# of the git SHA1 and remove the initial 'v'.
+version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 11-)
+
+echo "$version"
lib/libdvbv5/meson.build new file +87 -0

87 lines not on this page · raw message

lib/libv4l2/meson.build new file +43 -0

43 lines not on this page · raw message

lib/libv4lconvert/meson.build new file +79 -0

79 lines not on this page · raw message

lib/meson.build new file +6 -0
new file mode 100644
index 000000000000..a9c064b2b2dd
@@ -0,0 +1,6 @@
+if with_libdvbv5
+    subdir('libdvbv5')
+endif
+
+subdir('libv4lconvert')
+subdir('libv4l2')
meson.build new file +108 -0

108 lines not on this page · raw message

meson_options.txt new file +19 -0
new file mode 100644
index 000000000000..93cc71f1592d
@@ -0,0 +1,19 @@
+option('v4l-utils',
+        type : 'boolean',
+        description : 'Enable v4l-utils')
+
+option('v4l2-compliance-libv4l',
+        type : 'boolean',
+        description : 'Enable use of libv4l in v4l2-compliance')
+
+option('v4l2-ctl-libv4l',
+        type : 'boolean',
+        description : 'Enable use of libv4l in v4l2-ctl')
+
+option('v4l2-ctl-stream-to',
+        type : 'boolean',
+        description : 'Enable use of --stream-to in v4l2-ctl')
+
+option('v4l-plugins',
+        type : 'boolean',
+        description : 'V4L plugin support')
utils/cec-compliance/meson.build new file +39 -0
new file mode 100644
index 000000000000..fd165586fc0d
@@ -0,0 +1,39 @@
+name = 'cec-compliance'
+
+cec_compliance_sources = files(
+    'cec-compliance.cpp',
+    'cec-compliance.h',
+    'cec-test.cpp',
+    'cec-test-adapter.cpp',
+    'cec-test-audio.cpp',
+    'cec-test-power.cpp',
+    'cec-test-fuzzing.cpp',
+)
+
+cec_compliance_sources += version_h
+cec_compliance_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+
+cec_compliance_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_compliance_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_compliance = executable(name,
+                      cec_compliance_sources,
+                      install : true,
+                      dependencies : cec_compliance_deps,
+                      cpp_args : cec_compliance_cpp_args,
+                      include_directories : cec_compliance_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/cec-ctl/meson.build new file +33 -0
new file mode 100644
index 000000000000..5030cfd16de9
@@ -0,0 +1,33 @@
+name = 'cec-ctl'
+
+cec_ctl_sources = files(
+    'cec-ctl.cpp',
+    'cec-pin.cpp',
+    'cec-ctl.h',
+)
+
+cec_ctl_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+cec_ctl_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_ctl_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_ctl = executable(name,
+                     cec_ctl_sources,
+                     install : true,
+                     dependencies : cec_ctl_deps,
+                     cpp_args : cec_ctl_cpp_args,
+		     include_directories : cec_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/cec-follower/meson.build new file +35 -0
new file mode 100644
index 000000000000..bfa707b5d62a
@@ -0,0 +1,35 @@
+name = 'cec-follower'
+
+cec_follower_sources = files(
+    'cec-follower.cpp',
+    'cec-follower.h',
+    'cec-processing.cpp',
+    'cec-tuner.cpp',
+)
+
+cec_follower_sources += version_h
+cec_follower_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+cec_follower_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_follower_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_follower = executable(name,
+                      cec_follower_sources,
+                      install : true,
+                      dependencies : cec_follower_deps,
+                      cpp_args : cec_follower_cpp_args,
+		      include_directories : cec_follower_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/gen_media_bus_format_codes.sh new file +7 -0
new file mode 100644
index 000000000000..18d1e9f3f317
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+src="$1"
+
+sed -e \
+'/#define MEDIA_BUS_FMT/ ! d; s/.*#define //; /FIXED/ d; s/\t.*//; s/.*/ &,/;' \
+${src}
utils/gen_media_bus_format_names.sh new file +7 -0
new file mode 100644
index 000000000000..79cb16756bc3
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+src="$1"
+
+sed -e \
+'/#define MEDIA_BUS_FMT/ ! d; s/.*FMT_//; /FIXED/ d; s/\t.*//; s/.*/{ \"&\", MEDIA_BUS_FMT_& },/;' \
+${src}
utils/ir-ctl/meson.build new file +30 -0
new file mode 100644
index 000000000000..3c0db8aa769a
@@ -0,0 +1,30 @@
+name = 'ir-ctl'
+
+ir_ctl_sources = files(
+    'ir-ctl.c',
+    'ir-encode.c',
+    'ir-encode.h',
+    'toml.c',
+    'toml.h',
+    'keymap.c',
+    'keymap.h',
+    'bpf_encoder.c',
+    'bpf_encoder.h'
+)
+
+ir_ctl_deps = []
+ir_ctl_cpp_args = []
+ir_ctl_incdir = []
+
+ir_ctl = executable(name,
+                    ir_ctl_sources,
+                    install : true,
+                    dependencies : ir_ctl_deps,
+                    cpp_args : ir_ctl_cpp_args,
+		    include_directories : ir_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/libcecutil/meson.build new file +46 -0

46 lines not on this page · raw message

utils/media-ctl/meson.build new file +35 -0
new file mode 100644
index 000000000000..258aea7bea3f
@@ -0,0 +1,35 @@
+libmediactl_sources = files(
+    'libmediactl.c',
+    'mediactl-priv.h',
+)
+
+libmediactl_deps = []
+
+libmediactl = static_library('mediactl',
+                             libmediactl_sources,
+                             dependencies : libmediactl_deps)
+
+pkg.generate(
+    name : 'libmediactl',
+    libraries : libmediactl,
+    version : meson.project_version(),
+    description : 'Media controller library')
+
+libv4l2subdev_sources = files('libv4l2subdev.c')
+libv4l2subdev_sources += media_bus_format_names_h
+libv4l2subdev_sources += media_bus_format_codes_h
+
+libv4l2subdev = static_library('v4l2subdev',
+                               libv4l2subdev_sources)
+
+media_ctl_sources = files(
+    'media-ctl.c',
+    'options.c',
+    'options.h',
+    'tools.h',
+)
+
+media_ctl = executable('media-ctl',
+                       media_ctl_sources,
+                       install : true,
+		       link_with : [libmediactl, libv4l2subdev])
utils/meson.build new file +32 -0
new file mode 100644
index 000000000000..d4bb4b50142d
@@ -0,0 +1,32 @@
+utils_common_incdir = include_directories('common')
+
+# Generate targets for media-bus-format-{names,codes}.h
+foreach x: [ 'names', 'codes' ]
+    output_file = 'media-bus-format-@[email protected]'.format(x)
+    input_file = 'gen_media_bus_format_@[email protected]'.format(x)
+
+    target = custom_target(
+        output_file,
+        output : output_file,
+        input : input_file,
+	command : [
+            prog_bash, '@INPUT@', files('../include/linux/media-bus-format.h'),
+        ],
+        capture : true,
+    )
+    set_variable(output_file.underscorify(), target)
+endforeach
+
+# Libraries
+subdir('libcecutil')
+
+# Utils
+subdir('cec-ctl')
+subdir('cec-follower')
+subdir('ir-ctl')
+subdir('media-ctl')
+subdir('v4l2-ctl')
+
+# Compliance tools
+subdir('cec-compliance')
+subdir('v4l2-compliance')
utils/v4l2-compliance/meson.build new file +52 -0

52 lines not on this page · raw message

utils/v4l2-ctl/meson.build new file +65 -0

65 lines not on this page · raw message

version.h.in new file +1 -0
new file mode 100644
index 000000000000..2506ed9bc6cc
@@ -0,0 +1 @@
+#define SHA @VCS_TAG@
Signature · 1 line
2.25.0
#2 lore raw

Re: [RFC PATCH v4l-utils 1/1] Introduce support for meson building

Hi Ezequiel,

Thank you for the patch.

Quoted 61 lines · Ezequiel Garcia

Currently supports:

* libdvbv5
* libv4l2
* libv4lconvert
* cec-ctl
* cec-compliance
* cec-follower
* ir-ctl
* media-ctl
* v4l2-ctl
* v4l2-compliance

---
 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in
gen-version.sh new file +0 -0
new file mode 100755
index 000000000000..9223ab7d0a32

gen-version.sh line 2

Quoted 2 lines
gen-version.sh new file +2 -0
@@ -0,0 +1,36 @@
+#!/bin/sh
+# gen-version.sh script taken from the libcamera project.

Nice to see this being useful :-)

Quoted 106 lines
gen-version.sh new file +34 -0
+# Generate a version string using git describe.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+build_dir="$1"
+
+# Bail out if the directory isn't under git control
+src_dir=$(git rev-parse --git-dir 2>&1) || exit 1
+src_dir=$(readlink -f "$src_dir/..")
+
+# Get a short description from the tree.
+version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null)
+
+if [ -z "$version" ]
+then
+	# Handle an un-tagged repository
+	sha=$(git describe --abbrev=8 --always 2>/dev/null)
+	commits=$(git log --oneline | wc -l 2>/dev/null)
+	version="v4l-utils-0.0.0-$commits-g$sha"
+fi
+
+# Append a '-dirty' suffix if the working tree is dirty. Prevent false
+# positives due to changed timestamps by running git update-index.
+if [ -z "$build_dir" ] || (echo "$build_dir" | grep -q "$src_dir")
+then
+	git update-index --refresh > /dev/null 2>&1
+fi
+git diff-index --quiet HEAD || version="$version-dirty"
+
+# Replace first '-' with a '+' to denote build metadata, strip the 'g' in from
+# of the git SHA1 and remove the initial 'v'.
+version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 11-)
+
+echo "$version"
lib/libdvbv5/meson.build new file +66 -0
new file mode 100644
index 000000000000..35eda2da4692
@@ -0,0 +1,87 @@
+libdvbv5_sources = files(
+    'compat-soname.c',
+    'crc32.c',
+    'countries.c',
+    'dvb-legacy-channel-format.c',
+    'dvb-zap-format.c',
+    'dvb-vdr-format.c',
+    'dvb-v5.c',
+    'dvb-v5.h',
+    'parse_string.c',
+    'parse_string.h',
+    'dvb-demux.c',
+    'dvb-dev.c',
+    'dvb-dev-local.c',
+    'dvb-dev-priv.h',
+    'dvb-dev-remote.c',
+    'dvb-fe.c',
+    'dvb-fe-priv.h',
+    'dvb-log.c',
+    'dvb-file.c',
+    'dvb-v5-std.c',
+    'dvb-sat.c',
+    'dvb-scan.c',
+    'descriptors.c',
+    'tables/header.c',
+    'tables/pat.c',
+    'tables/pmt.c',
+    'tables/nit.c',
+    'tables/sdt.c',
+    'tables/vct.c',
+    'tables/mgt.c',
+    'tables/eit.c',
+    'tables/cat.c',
+    'tables/atsc_eit.c',
+    'tables/mpeg_ts.c',
+    'tables/mpeg_pes.c',
+    'tables/mpeg_es.c',
+    'descriptors/desc_language.c',
+    'descriptors/desc_network_name.c',
+    'descriptors/desc_cable_delivery.c',
+    'descriptors/desc_sat.c',
+    'descriptors/desc_terrestrial_delivery.c',
+    'descriptors/desc_t2_delivery.c',
+    'descriptors/desc_service.c',
+    'descriptors/desc_frequency_list.c',
+    'descriptors/desc_event_short.c',
+    'descriptors/desc_event_extended.c',
+    'descriptors/desc_atsc_service_location.c',
+    'descriptors/desc_hierarchy.c',
+    'descriptors/desc_extension.c',
+    'descriptors/desc_isdbt_delivery.c',
+    'descriptors/desc_logical_channel.c',
+    'descriptors/desc_ts_info.c',
+    'descriptors/desc_partial_reception.c',
+    'descriptors/desc_ca.c',
+    'descriptors/desc_ca_identifier.c',
+)
+
+libdvbv5_deps = [
+    dep_libm,
+    dep_threads,
+    dep_udev,
+]
+
+libdvbv5_incdir = [
+    v4l2_utils_incdir,

lib/libdvbv5/meson.build line 76

Quoted 10 lines
lib/libdvbv5/meson.build new file +10 -0
+]
+
+libdvbv5_c_args = [
+    '-DHAVE_DVBV5_REMOTE',
+]
+
+libdvbv5 = shared_library('dvbv5',
+                         libdvbv5_sources,
+                         install : true,
+			 dependencies : libdvbv5_deps,

Identation is mixing tabs and spaces. There are a few other occurrences below too.

lib/libdvbv5/meson.build line 78

Quoted 2 lines
lib/libdvbv5/meson.build new file +2 -0
+                         c_args : libdvbv5_c_args,
+                         include_directories : libdvbv5_incdir)

You could set this to v4l2_utils_incdir directory, I don't think the indirection brings much, and it hinders readability a little bit. Maybe libdvbv5_deps should be inlined too ? This comment applies to several locations below too.

Quoted 15 lines
lib/libdvbv5/meson.build new file +9 -0
+
+dep_libdvbv5 = declare_dependency(link_with : libdvbv5)
+
+pkg.generate(
+    name : 'libdvbv5',
+    libraries : libdvbv5,
+    version : meson.project_version(),
+    requires_private : 'libudev',
+    description : 'DVBv5 utility library')
lib/libv4l2/meson.build new file +0 -0
new file mode 100644
index 000000000000..eefe680620c5

lib/libv4l2/meson.build line 9

Quoted 9 lines
lib/libv4l2/meson.build new file +9 -0
@@ -0,0 +1,43 @@
+libv4l2_sources = files(
+    'libv4l2.c',
+    'log.c',
+    'libv4l2-priv.h',
+)
+
+libv4l2_deps = [
+    dep_libv4lconvert,
+    dep_libdl,

Alphabetical order ?

lib/libv4l2/meson.build line 21

Quoted 12 lines
lib/libv4l2/meson.build new file +12 -0
+    dep_threads,
+]
+
+libv4l2_incdir = [
+    v4l2_utils_incdir,
+]
+
+libv4l2_c_args = []
+
+if with_v4l_plugins
+    libv4l2_sources += files('v4l2-plugin.c')
+    libv4l2_plugins_dir = join_paths(get_option('prefix'), get_option('libdir'), 'libv4l/plugins')

If we were to target Windows I'd write this as

    libv4l2_plugins_dir = join_paths(get_option('prefix'), get_option('libdir'), 'libv4l', 'plugins')
Quoted 9 lines
lib/libv4l2/meson.build new file +9 -0
+    libv4l2_c_args += [
+        '-DHAVE_V4L_PLUGINS',
+        '-DLIBV4L2_PLUGIN_DIR="@0@"'.format(libv4l2_plugins_dir)
+    ]
+endif
+
+libv4l2 = shared_library('v4l2',
+                         libv4l2_sources,
+                         install : true,

lib/libv4l2/meson.build line 40

Quoted 10 lines
lib/libv4l2/meson.build new file +10 -0
+                         dependencies : libv4l2_deps,
+                         c_args : libv4l2_c_args,
+                         include_directories : libv4l2_incdir)
+
+dep_libv4l2 = declare_dependency(link_with : libv4l2)
+
+pkg.generate(
+    name : 'libv4l2',
+    libraries : libv4l2,
+    libraries_private : '-lpthread',

Quoting the meson documentation,

"libraries_private list of built libraries or strings to put in the Libs.private field. Since 0.45.0 dependencies of built libraries will be automatically added, see the Implicit dependencies section below for the exact rules."

Is this needed ?

Same for the other occurrence below.

Quoted 22 lines
lib/libv4l2/meson.build new file +3 -0
+    version : meson.project_version(),
+    requires_private : 'libv4lconvert',
+    description : 'v4l2 device access library')
lib/libv4lconvert/meson.build new file +13 -0
new file mode 100644
index 000000000000..cd6c4b4574f2
@@ -0,0 +1,79 @@
+libv4lconvert_sources = files(
+    'libv4lconvert.c',
+    'tinyjpeg.c',
+    'sn9c10x.c',
+    'sn9c20x.c',
+    'pac207.c',
+    'mr97310a.c',
+    'flip.c',
+    'crop.c',
+    'jidctflt.c',
+    'spca561-decompress.c',
+    'rgbyuv.c',
+    'sn9c2028-decomp.c',

lib/libv4lconvert/meson.build line 23

Quoted 10 lines
lib/libv4lconvert/meson.build new file +10 -0
+    'spca501.c',
+    'sq905c.c',
+    'bayer.c',
+    'hm12.c',
+    'stv0680.c',
+    'cpia1.c',
+    'se401.c',
+    'jpgl.c',
+    'jpeg.c',
+    'jl2005bcd.c',

Alphabetical order ? Same where applicable below.

Quoted 26 lines
lib/libv4lconvert/meson.build new file +26 -0
+    'control/libv4lcontrol.c',
+    'control/libv4lcontrol.h',
+    'control/libv4lcontrol-priv.h',
+    'processing/libv4lprocessing.c',
+    'processing/whitebalance.c',
+    'processing/autogain.c',
+    'processing/gamma.c',
+    'processing/libv4lprocessing.h',
+    'processing/libv4lprocessing-priv.h',
+    'helper-funcs.h',
+    'libv4lconvert-priv.h',
+    'libv4lsyscall-priv.h',
+    'tinyjpeg.h',
+    'tinyjpeg-internal.h',
+)
+
+libv4lconvert_deps = [
+    dep_libm,
+    dep_librt,
+]
+
+libv4lconvert_priv_libs = [
+    '-lrt',
+    '-lm',
+]
+

lib/libv4lconvert/meson.build line 59

Quoted 10 lines
lib/libv4lconvert/meson.build new file +10 -0
+libv4lconvert_incdir = [
+    v4l2_utils_incdir,
+]
+
+libv4lconvert_c_args = []
+
+if with_jpeg
+    libv4lconvert_deps += dep_jpeg
+    libv4lconvert_priv_libs += dep_jpeg_priv_libs
+    libv4lconvert_sources += files('jpeg_memsrcdest.c', 'jpeg_memsrcdest.h')

I'd write this

    libv4lconvert_sources += files(
        'jpeg_memsrcdest.c',
        'jpeg_memsrcdest.h'
    )
Quoted 38 lines
lib/libv4lconvert/meson.build new file +20 -0
+    libv4lconvert_c_args += [
+        '-DHAVE_JPEG',
+    ]
+endif
+
+libv4lconvert = shared_library('v4lconvert',
+                         libv4lconvert_sources,
+                         install : true,
+			 dependencies : libv4lconvert_deps,
+                         c_args : libv4lconvert_c_args,
+                         include_directories : libv4lconvert_incdir)
+
+dep_libv4lconvert = declare_dependency(link_with : libv4lconvert)
+
+pkg.generate(
+    name : 'libv4lconvert',
+    libraries : libv4lconvert,
+    libraries_private : libv4lconvert_priv_libs,
+    version : meson.project_version(),
+    description : 'v4l format conversion library')
lib/meson.build new file +6 -0
new file mode 100644
index 000000000000..a9c064b2b2dd
@@ -0,0 +1,6 @@
+if with_libdvbv5
+    subdir('libdvbv5')
+endif
+
+subdir('libv4lconvert')
+subdir('libv4l2')
meson.build new file +0 -0
new file mode 100644
index 000000000000..8dfa3b7252a5

meson.build line 6

Quoted 6 lines
meson.build new file +6 -0
@@ -0,0 +1,108 @@
+project('v4l-utils', 'c', 'cpp',
+    version: '1.19.0',
+    default_options : [
+        'warning_level=1',
+    ],
+    license : 'LGPL 2.1+')

Should we set a minimum meson version ?

Quoted 6 lines
meson.build new file +6 -0
+
+cc = meson.get_compiler('c')
+pkg = import('pkgconfig')
+
+conf = configuration_data()
+conf.set_quoted('V4L_UTILS_VERSION', meson.project_version())

meson.build line 22

Quoted 10 lines
meson.build new file +10 -0
+conf.set('PACKAGE_VERSION', meson.project_version())
+
+common_arguments = [
+    '-Wpointer-arith',
+    '-D_GNU_SOURCE',
+    '-I.', # Needed for config.h
+    '-DPROMOTED_MODE_T=int'
+]
+
+v4l2_utils_incdir = include_directories('include', 'lib/include/')

Maybe

v4l2_utils_incdir = include_directories(

    'include',
    'lib/include/',

)

?

Quoted 32 lines
meson.build new file +32 -0
+
+prog_bash = find_program('bash')
+prog_perl = find_program('perl')
+
+dep_libdl = cc.find_library('dl')
+dep_libm = cc.find_library('m')
+dep_librt = cc.find_library('rt')
+dep_threads = dependency('threads')
+
+have_iconv = false
+if cc.has_function('iconv_open')
+    dep_iconv = dependency('', required : false)
+    have_iconv = true
+else
+    dep_iconv = cc.find_library('iconv', required : false)
+    have_iconv = dep_iconv.found()
+endif
+
+if have_iconv
+    conf.set('HAVE_ICONV', 1)
+    iconv_const_test = '''#include <iconv.h>
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+'''
+    if cc.compiles(iconv_const_test, dependencies : dep_iconv)
+        conf.set('ICONV_CONST', '')
+    else
+        conf.set('ICONV_CONST', 'const')
+    endif
+endif
+
+
+# Optional dependencies

meson.build line 64

Quoted 10 lines
meson.build new file +10 -0
+dep_jpeg = dependency('libjpeg', required : false)
+if dep_jpeg.found()
+    with_jpeg = true
+    dep_jpeg_priv_libs = '-ljpeg'
+endif
+
+dep_udev = dependency('libudev', required : false)
+if dep_udev.found()
+    with_udev = true
+    with_libdvbv5 = true

libdvbv5 isn't a dependency. Wouldn't it be better to enclose the corresponding subdir or shared_library with 'if with_udev' ?

Quoted 59 lines
meson.build new file +44 -0
+else
+    with_udev = false
+    with_libdvbv5 = false
+    warning('udev library not available')
+endif
+
+# Found options
+with_v4l_plugins = get_option('v4l-plugins')
+
+c_arguments = []
+cpp_arguments = []
+
+c_arguments += common_arguments
+cpp_arguments += common_arguments
+
+add_project_arguments(c_arguments, language : 'c')
+add_project_arguments(cpp_arguments, language : 'cpp')
+add_project_link_arguments(cpp_arguments, language : 'cpp')
+
+version_h = vcs_tag(command : ['gen-version.sh', meson.build_root()],
+                    input : 'version.h.in',
+                    output : 'version.h',
+                    fallback : meson.project_version())
+
+subdir('lib')
+
+if get_option('v4l-utils')
+    subdir('utils')
+endif
+
+configure_file(output : 'config.h', configuration : conf)
+
+message('')
+message('  jpeg                       @0@'.format(with_jpeg ? 'yes' : 'no' ))
+message('  udev                       @0@'.format(with_udev ? 'yes' : 'no' ))
+message('  libdvbv5                   @0@'.format(with_libdvbv5 ? 'yes' : 'no' ))
+message('  v4l plugins                @0@'.format(with_v4l_plugins ? 'yes' : 'no' ))
+message('  v4l-utils                  @0@'.format(get_option('v4l-utils') ? 'yes' : 'no' ))
+if get_option('v4l-utils')
+message('  v4l2-compliance-libv4l2    @0@'.format(get_option('v4l2-compliance-libv4l') ? 'yes' : 'no' ))
+message('  v4l2-ctl-libv4l            @0@'.format(get_option('v4l2-ctl-libv4l') ? 'yes' : 'no' ))
+message('  v4l2-ctl-stream-to         @0@'.format(get_option('v4l2-ctl-stream-to') ? 'yes' : 'no' ))
+endif
+message('')
meson_options.txt new file +9 -0
new file mode 100644
index 000000000000..93cc71f1592d
@@ -0,0 +1,19 @@
+option('v4l-utils',
+        type : 'boolean',
+        description : 'Enable v4l-utils')
+
+option('v4l2-compliance-libv4l',
+        type : 'boolean',
+        description : 'Enable use of libv4l in v4l2-compliance')
+
+option('v4l2-ctl-libv4l',

meson_options.txt line 19

Quoted 10 lines
meson_options.txt new file +10 -0
+        type : 'boolean',
+        description : 'Enable use of libv4l in v4l2-ctl')
+
+option('v4l2-ctl-stream-to',
+        type : 'boolean',
+        description : 'Enable use of --stream-to in v4l2-ctl')
+
+option('v4l-plugins',
+        type : 'boolean',
+        description : 'V4L plugin support')

Alphabetical order ? :-)

Quoted 17 lines
utils/cec-compliance/meson.build new file +11 -0
new file mode 100644
index 000000000000..fd165586fc0d
@@ -0,0 +1,39 @@
+name = 'cec-compliance'
+
+cec_compliance_sources = files(
+    'cec-compliance.cpp',
+    'cec-compliance.h',
+    'cec-test.cpp',
+    'cec-test-adapter.cpp',
+    'cec-test-audio.cpp',
+    'cec-test-power.cpp',
+    'cec-test-fuzzing.cpp',
+)

utils/cec-compliance/meson.build line 21

Quoted 10 lines
utils/cec-compliance/meson.build new file +10 -0
+
+cec_compliance_sources += version_h
+cec_compliance_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+
+cec_compliance_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')

Here you use this variable to refer to the includes needed to use libcecutil, while below, in libcecutil, you use it to refer to the includes required by libcecutil itself. That's confusing. I think we need to clean up the names. Can't you add the libcecutil headers include path to dep_libcecutil ? That way I think you could drop this one. This may be applicable to other incdir variables too. In any case, if we were to keep this variable, it should be defined in utils/libcecutil/meson.build.

utils/cec-compliance/meson.build line 32

Quoted 11 lines
utils/cec-compliance/meson.build new file +11 -0
+
+cec_compliance_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_compliance = executable(name,
+                      cec_compliance_sources,
+                      install : true,
+                      dependencies : cec_compliance_deps,
+                      cpp_args : cec_compliance_cpp_args,

This is empty, can't you leave it out ? Same in a few other locations below.

utils/cec-compliance/meson.build line 39

Quoted 7 lines
utils/cec-compliance/meson.build new file +7 -0
+                      include_directories : cec_compliance_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)

As all man pages are handled the same way, would it make sense to create a global array of man pages, add an entry to the array here, and move the configure_file() to a more global location in a foreach loop ?

Quoted 164 lines
utils/cec-ctl/meson.build new file +33 -0
new file mode 100644
index 000000000000..5030cfd16de9
@@ -0,0 +1,33 @@
+name = 'cec-ctl'
+
+cec_ctl_sources = files(
+    'cec-ctl.cpp',
+    'cec-pin.cpp',
+    'cec-ctl.h',
+)
+
+cec_ctl_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+cec_ctl_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_ctl_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_ctl = executable(name,
+                     cec_ctl_sources,
+                     install : true,
+                     dependencies : cec_ctl_deps,
+                     cpp_args : cec_ctl_cpp_args,
+		     include_directories : cec_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/cec-follower/meson.build new file +35 -0
new file mode 100644
index 000000000000..bfa707b5d62a
@@ -0,0 +1,35 @@
+name = 'cec-follower'
+
+cec_follower_sources = files(
+    'cec-follower.cpp',
+    'cec-follower.h',
+    'cec-processing.cpp',
+    'cec-tuner.cpp',
+)
+
+cec_follower_sources += version_h
+cec_follower_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+cec_follower_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_follower_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_follower = executable(name,
+                      cec_follower_sources,
+                      install : true,
+                      dependencies : cec_follower_deps,
+                      cpp_args : cec_follower_cpp_args,
+		      include_directories : cec_follower_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/gen_media_bus_format_codes.sh new file +7 -0
new file mode 100644
index 000000000000..18d1e9f3f317
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+src="$1"
+
+sed -e \
+'/#define MEDIA_BUS_FMT/ ! d; s/.*#define //; /FIXED/ d; s/\t.*//; s/.*/ &,/;' \
+${src}
utils/gen_media_bus_format_names.sh new file +7 -0
new file mode 100644
index 000000000000..79cb16756bc3
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+src="$1"
+
+sed -e \
+'/#define MEDIA_BUS_FMT/ ! d; s/.*FMT_//; /FIXED/ d; s/\t.*//; s/.*/{ \"&\", MEDIA_BUS_FMT_& },/;' \
+${src}
utils/ir-ctl/meson.build new file +30 -0
new file mode 100644
index 000000000000..3c0db8aa769a
@@ -0,0 +1,30 @@
+name = 'ir-ctl'
+
+ir_ctl_sources = files(
+    'ir-ctl.c',
+    'ir-encode.c',
+    'ir-encode.h',
+    'toml.c',
+    'toml.h',
+    'keymap.c',
+    'keymap.h',
+    'bpf_encoder.c',
+    'bpf_encoder.h'
+)
+
+ir_ctl_deps = []
+ir_ctl_cpp_args = []
+ir_ctl_incdir = []
+
+ir_ctl = executable(name,
+                    ir_ctl_sources,
+                    install : true,
+                    dependencies : ir_ctl_deps,
+                    cpp_args : ir_ctl_cpp_args,
+		    include_directories : ir_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/libcecutil/meson.build new file +16 -0
new file mode 100644
index 000000000000..097cb274cfa3
@@ -0,0 +1,46 @@
+libcecutil_sources = files(
+    'cec-info.cpp',
+    'cec-log.cpp',
+    'cec-parse.cpp',
+    'cec-info.h',
+    'cec-log.h',
+    'cec-parse.h',
+    'cec-htng.h',
+    'cec-htng-funcs.h',
+)
+
+libcecutil_deps = [
+    dep_libv4lconvert,
+    dep_libdl,
+    dep_threads,
+]

utils/libcecutil/meson.build line 26

Quoted 10 lines
utils/libcecutil/meson.build new file +10 -0
+
+libcecutil_incdir = [
+    utils_common_incdir,
+    v4l2_utils_incdir,
+]
+
+libcecutil_c_args = []
+
+cec_gen_sources = files(
+    '../../include/linux/cec.h',

Referencing sources from parent directories is usually a sign that the abstractions are not well designed, but in this case there may be no better way.

Quoted 70 lines
utils/libcecutil/meson.build new file +20 -0
+    'cec-htng.h',
+    '../../include/linux/cec-funcs.h',
+    'cec-htng-funcs.h',
+)
+
+configure_file(
+    input : 'cec-gen.pl',
+    output : 'cec-gen-dummy.stamp',
+    command: [
+        prog_perl, '@INPUT@', cec_gen_sources, 'utils/libcecutil'
+    ]
+)
+
+libcecutil = static_library('cecutil',
+                         libcecutil_sources,
+                         install : true,
+                         dependencies : libcecutil_deps,
+                         c_args : libcecutil_c_args,
+                         include_directories : libcecutil_incdir)
+dep_libcecutil = declare_dependency(link_with : libcecutil)
utils/media-ctl/meson.build new file +35 -0
new file mode 100644
index 000000000000..258aea7bea3f
@@ -0,0 +1,35 @@
+libmediactl_sources = files(
+    'libmediactl.c',
+    'mediactl-priv.h',
+)
+
+libmediactl_deps = []
+
+libmediactl = static_library('mediactl',
+                             libmediactl_sources,
+                             dependencies : libmediactl_deps)
+
+pkg.generate(
+    name : 'libmediactl',
+    libraries : libmediactl,
+    version : meson.project_version(),
+    description : 'Media controller library')
+
+libv4l2subdev_sources = files('libv4l2subdev.c')
+libv4l2subdev_sources += media_bus_format_names_h
+libv4l2subdev_sources += media_bus_format_codes_h
+
+libv4l2subdev = static_library('v4l2subdev',
+                               libv4l2subdev_sources)
+
+media_ctl_sources = files(
+    'media-ctl.c',
+    'options.c',
+    'options.h',
+    'tools.h',
+)
+
+media_ctl = executable('media-ctl',
+                       media_ctl_sources,
+                       install : true,
+		       link_with : [libmediactl, libv4l2subdev])
utils/meson.build new file +3 -0
new file mode 100644
index 000000000000..d4bb4b50142d
@@ -0,0 +1,32 @@
+utils_common_incdir = include_directories('common')
+
+# Generate targets for media-bus-format-{names,codes}.h

utils/meson.build line 13

Quoted 10 lines
utils/meson.build new file +10 -0
+foreach x: [ 'names', 'codes' ]
+    output_file = 'media-bus-format-@[email protected]'.format(x)
+    input_file = 'gen_media_bus_format_@[email protected]'.format(x)
+
+    target = custom_target(
+        output_file,
+        output : output_file,
+        input : input_file,
+	command : [
+            prog_bash, '@INPUT@', files('../include/linux/media-bus-format.h'),

If you used

#!/bin/bash

as the first line of the gen_media_bus_format_*.sh scripts, could you get rid of prog_bash and use the script directly ? input_file should be ../include/linux/media-bus-format.h to proper dependency handling.

Quoted 52 lines
utils/meson.build new file +19 -0
+        ],
+        capture : true,
+    )
+    set_variable(output_file.underscorify(), target)
+endforeach
+
+# Libraries
+subdir('libcecutil')
+
+# Utils
+subdir('cec-ctl')
+subdir('cec-follower')
+subdir('ir-ctl')
+subdir('media-ctl')
+subdir('v4l2-ctl')
+
+# Compliance tools
+subdir('cec-compliance')
+subdir('v4l2-compliance')
utils/v4l2-compliance/meson.build new file +27 -0
new file mode 100644
index 000000000000..534b7bf4cb4e
@@ -0,0 +1,52 @@
+name = 'v4l2-compliance'
+
+v4l2_compliance_sources = files(
+    'v4l2-compliance.cpp',
+    'v4l2-compliance.h',
+    'v4l2-test-debug.cpp',
+    'v4l2-test-input-output.cpp',
+    'v4l2-test-controls.cpp',
+    'v4l2-test-io-config.cpp',
+    'v4l2-test-formats.cpp',
+    'v4l2-test-buffers.cpp',
+    'v4l2-test-codecs.cpp',
+    'v4l2-test-subdevs.cpp',
+    'v4l2-test-media.cpp',
+    'v4l2-test-colors.cpp',
+    'media-info.cpp',
+    'v4l2-info.cpp',
+)
+
+v4l2_compliance_sources += version_h
+v4l2_compliance_deps = [
+    dep_librt,
+    dep_threads,
+]
+v4l2_compliance_cpp_args = []
+
+if get_option('v4l2-compliance-libv4l')

utils/v4l2-compliance/meson.build line 37

Quoted 10 lines
utils/v4l2-compliance/meson.build new file +10 -0
+    v4l2_compliance_deps += dep_libv4lconvert
+    v4l2_compliance_deps += dep_libv4l2
+else
+    v4l2_compliance_cpp_args += '-DNO_LIBV4L2'
+endif
+
+common_incdir = include_directories('../common')
+
+v4l2_compliance_incdir = [
+    common_incdir,

Can't you reuse utils_common_incdir ?

Quoted 93 lines
utils/v4l2-compliance/meson.build new file +15 -0
+    v4l2_utils_incdir,
+]
+
+v4l2_compliance = executable(name,
+                      v4l2_compliance_sources,
+                      install : true,
+                      dependencies : v4l2_compliance_deps,
+                      cpp_args : v4l2_compliance_cpp_args,
+                      include_directories : v4l2_compliance_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/v4l2-ctl/meson.build new file +65 -0
new file mode 100644
index 000000000000..1bbc7fe44313
@@ -0,0 +1,65 @@
+name = 'v4l2-ctl'
+
+v4l2_ctl_sources = files(
+    'v4l2-ctl.cpp',
+    'v4l2-ctl.h',
+    'v4l2-ctl-common.cpp',
+    'v4l2-ctl-tuner.cpp',
+    'v4l2-ctl-io.cpp',
+    'v4l2-ctl-stds.cpp',
+    'v4l2-ctl-vidcap.cpp',
+    'v4l2-ctl-vidout.cpp',
+    'v4l2-ctl-overlay.cpp',
+    'v4l2-ctl-vbi.cpp',
+    'v4l2-ctl-selection.cpp',
+    'v4l2-ctl-misc.cpp',
+    'v4l2-ctl-streaming.cpp',
+    'v4l2-ctl-sdr.cpp',
+    'v4l2-ctl-edid.cpp',
+    'v4l2-ctl-modes.cpp',
+    'v4l2-ctl-subdev.cpp',
+    'v4l2-tpg-colors.c',
+    'v4l2-tpg-core.c',
+    'v4l-stream.c',
+    'v4l2-ctl-meta.cpp',
+    'media-info.cpp',
+    'v4l2-info.cpp',
+    'codec-fwht.c',
+    'codec-v4l2-fwht.c',
+)
+v4l2_ctl_sources += media_bus_format_names_h
+
+v4l2_ctl_deps = [
+    dep_librt,
+    dep_threads,
+]
+v4l2_ctl_cpp_args = []
+
+if get_option('v4l2-ctl-libv4l')
+    v4l2_ctl_deps += dep_libv4lconvert
+    v4l2_ctl_deps += dep_libv4l2
+else
+    v4l2_ctl_cpp_args += '-DNO_LIBV4L2'
+endif
+
+if not get_option('v4l2-ctl-stream-to')
+    v4l2_ctl_cpp_args += '-DNO_STREAM_TO'
+endif
+
+v4l2_ctl_incdir = [
+    utils_common_incdir,
+    v4l2_utils_incdir,
+]
+
+v4l2_ctl = executable(name,
+                      v4l2_ctl_sources,
+                      install : true,
+                      dependencies : v4l2_ctl_deps,
+                      cpp_args : v4l2_ctl_cpp_args,
+		      include_directories : v4l2_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
version.h.in new file +1 -0
new file mode 100644
index 000000000000..2506ed9bc6cc
@@ -0,0 +1 @@
+#define SHA @VCS_TAG@
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

Re: [RFC PATCH v4l-utils 1/1] Introduce support for meson building

Hey Laurent,

Thanks a lot for reviewing.

(Adding Nicolas and Antonio who are interested in this).

Quoted 182 lines · Laurent Pinchart

Hi Ezequiel,

Thank you for the patch.

Quoted 61 lines · Ezequiel Garcia

Currently supports:

* libdvbv5
* libv4l2
* libv4lconvert
* cec-ctl
* cec-compliance
* cec-follower
* ir-ctl
* media-ctl
* v4l2-ctl
* v4l2-compliance

---
 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in
gen-version.sh new file +0 -0
new file mode 100755
index 000000000000..9223ab7d0a32

gen-version.sh line 2

Quoted 2 lines
gen-version.sh new file +2 -0
@@ -0,0 +1,36 @@
+#!/bin/sh
+# gen-version.sh script taken from the libcamera project.

Nice to see this being useful :-)

Quoted 111 lines
gen-version.sh new file +34 -0
+# Generate a version string using git describe.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+build_dir="$1"
+
+# Bail out if the directory isn't under git control
+src_dir=$(git rev-parse --git-dir 2>&1) || exit 1
+src_dir=$(readlink -f "$src_dir/..")
+
+# Get a short description from the tree.
+version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null)
+
+if [ -z "$version" ]
+then
+	# Handle an un-tagged repository
+	sha=$(git describe --abbrev=8 --always 2>/dev/null)
+	commits=$(git log --oneline | wc -l 2>/dev/null)
+	version="v4l-utils-0.0.0-$commits-g$sha"
+fi
+
+# Append a '-dirty' suffix if the working tree is dirty. Prevent false
+# positives due to changed timestamps by running git update-index.
+if [ -z "$build_dir" ] || (echo "$build_dir" | grep -q "$src_dir")
+then
+	git update-index --refresh > /dev/null 2>&1
+fi
+git diff-index --quiet HEAD || version="$version-dirty"
+
+# Replace first '-' with a '+' to denote build metadata, strip the 'g' in from
+# of the git SHA1 and remove the initial 'v'.
+version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 11-)
+
+echo "$version"
lib/libdvbv5/meson.build new file +71 -0
new file mode 100644
index 000000000000..35eda2da4692
@@ -0,0 +1,87 @@
+libdvbv5_sources = files(
+    'compat-soname.c',
+    'crc32.c',
+    'countries.c',
+    'dvb-legacy-channel-format.c',
+    'dvb-zap-format.c',
+    'dvb-vdr-format.c',
+    'dvb-v5.c',
+    'dvb-v5.h',
+    'parse_string.c',
+    'parse_string.h',
+    'dvb-demux.c',
+    'dvb-dev.c',
+    'dvb-dev-local.c',
+    'dvb-dev-priv.h',
+    'dvb-dev-remote.c',
+    'dvb-fe.c',
+    'dvb-fe-priv.h',
+    'dvb-log.c',
+    'dvb-file.c',
+    'dvb-v5-std.c',
+    'dvb-sat.c',
+    'dvb-scan.c',
+    'descriptors.c',
+    'tables/header.c',
+    'tables/pat.c',
+    'tables/pmt.c',
+    'tables/nit.c',
+    'tables/sdt.c',
+    'tables/vct.c',
+    'tables/mgt.c',
+    'tables/eit.c',
+    'tables/cat.c',
+    'tables/atsc_eit.c',
+    'tables/mpeg_ts.c',
+    'tables/mpeg_pes.c',
+    'tables/mpeg_es.c',
+    'descriptors/desc_language.c',
+    'descriptors/desc_network_name.c',
+    'descriptors/desc_cable_delivery.c',
+    'descriptors/desc_sat.c',
+    'descriptors/desc_terrestrial_delivery.c',
+    'descriptors/desc_t2_delivery.c',
+    'descriptors/desc_service.c',
+    'descriptors/desc_frequency_list.c',
+    'descriptors/desc_event_short.c',
+    'descriptors/desc_event_extended.c',
+    'descriptors/desc_atsc_service_location.c',
+    'descriptors/desc_hierarchy.c',
+    'descriptors/desc_extension.c',
+    'descriptors/desc_isdbt_delivery.c',
+    'descriptors/desc_logical_channel.c',
+    'descriptors/desc_ts_info.c',
+    'descriptors/desc_partial_reception.c',
+    'descriptors/desc_ca.c',
+    'descriptors/desc_ca_identifier.c',
+)
+
+libdvbv5_deps = [
+    dep_libm,
+    dep_threads,
+    dep_udev,
+]
+
+libdvbv5_incdir = [
+    v4l2_utils_incdir,
+]
+
+libdvbv5_c_args = [
+    '-DHAVE_DVBV5_REMOTE',
+]
Quoted 9 lines

lib/libdvbv5/meson.build line 76

Quoted 5 lines
lib/libdvbv5/meson.build new file +5 -0
+
+libdvbv5 = shared_library('dvbv5',
+                         libdvbv5_sources,
+                         install : true,
+			 dependencies : libdvbv5_deps,

Identation is mixing tabs and spaces. There are a few other occurrences below too.

Oops.

Quoted 8 lines

lib/libdvbv5/meson.build line 78

Quoted 2 lines
lib/libdvbv5/meson.build new file +2 -0
+                         c_args : libdvbv5_c_args,
+                         include_directories : libdvbv5_incdir)

You could set this to v4l2_utils_incdir directory, I don't think the indirection brings much, and it hinders readability a little bit. Maybe libdvbv5_deps should be inlined too ? This comment applies to several locations below too.

Readability can be subjective. This was chosen with two reasons in mind. First, I usually like to have consistency, even if it's slightly more bloated.

Second, it would seem this is more extensible.

But I'm open to change if we believe it's really less readable/maintainable.

Quoted 18 lines
Quoted 18 lines
lib/libdvbv5/meson.build new file +9 -0
+
+dep_libdvbv5 = declare_dependency(link_with : libdvbv5)
+
+pkg.generate(
+    name : 'libdvbv5',
+    libraries : libdvbv5,
+    version : meson.project_version(),
+    requires_private : 'libudev',
+    description : 'DVBv5 utility library')
lib/libv4l2/meson.build new file +3 -0
new file mode 100644
index 000000000000..eefe680620c5
@@ -0,0 +1,43 @@
+libv4l2_sources = files(
+    'libv4l2.c',
+    'log.c',
Quoted 9 lines

lib/libv4l2/meson.build line 9

Quoted 6 lines
lib/libv4l2/meson.build new file +6 -0
+    'libv4l2-priv.h',
+)
+
+libv4l2_deps = [
+    dep_libv4lconvert,
+    dep_libdl,

Alphabetical order ?

+1

Quoted 15 lines

lib/libv4l2/meson.build line 21

Quoted 12 lines
lib/libv4l2/meson.build new file +12 -0
+    dep_threads,
+]
+
+libv4l2_incdir = [
+    v4l2_utils_incdir,
+]
+
+libv4l2_c_args = []
+
+if with_v4l_plugins
+    libv4l2_sources += files('v4l2-plugin.c')
+    libv4l2_plugins_dir = join_paths(get_option('prefix'), get_option('libdir'), 'libv4l/plugins')

If we were to target Windows I'd write this as

Quoted 2 lines
    libv4l2_plugins_dir = join_paths(get_option('prefix'), get_option('libdir'), 'libv4l', 'plugins')

+1

Quoted 22 lines
Quoted 9 lines
lib/libv4l2/meson.build new file +9 -0
+    libv4l2_c_args += [
+        '-DHAVE_V4L_PLUGINS',
+        '-DLIBV4L2_PLUGIN_DIR="@0@"'.format(libv4l2_plugins_dir)
+    ]
+endif
+
+libv4l2 = shared_library('v4l2',
+                         libv4l2_sources,
+                         install : true,

lib/libv4l2/meson.build line 40

Quoted 10 lines
lib/libv4l2/meson.build new file +10 -0
+                         dependencies : libv4l2_deps,
+                         c_args : libv4l2_c_args,
+                         include_directories : libv4l2_incdir)
+
+dep_libv4l2 = declare_dependency(link_with : libv4l2)
+
+pkg.generate(
+    name : 'libv4l2',
+    libraries : libv4l2,
+    libraries_private : '-lpthread',

Quoting the meson documentation,

Quoted 7 lines

"libraries_private list of built libraries or strings to put in the Libs.private field. Since 0.45.0 dependencies of built libraries will be automatically added, see the Implicit dependencies section below for the exact rules."

Is this needed ?

Yes, I saw that, but it's still needed even with meson 0.53.0.

We should report it upstream, but for now, let's make sure our .pc are good :-)

Quoted 28 lines

Same for the other occurrence below.

Quoted 26 lines
lib/libv4l2/meson.build new file +3 -0
+    version : meson.project_version(),
+    requires_private : 'libv4lconvert',
+    description : 'v4l2 device access library')
lib/libv4lconvert/meson.build new file +17 -0
new file mode 100644
index 000000000000..cd6c4b4574f2
@@ -0,0 +1,79 @@
+libv4lconvert_sources = files(
+    'libv4lconvert.c',
+    'tinyjpeg.c',
+    'sn9c10x.c',
+    'sn9c20x.c',
+    'pac207.c',
+    'mr97310a.c',
+    'flip.c',
+    'crop.c',
+    'jidctflt.c',
+    'spca561-decompress.c',
+    'rgbyuv.c',
+    'sn9c2028-decomp.c',
+    'spca501.c',
+    'sq905c.c',
+    'bayer.c',
+    'hm12.c',
Quoted 9 lines

lib/libv4lconvert/meson.build line 23

Quoted 6 lines
lib/libv4lconvert/meson.build new file +6 -0
+    'stv0680.c',
+    'cpia1.c',
+    'se401.c',
+    'jpgl.c',
+    'jpeg.c',
+    'jl2005bcd.c',

Alphabetical order ? Same where applicable below.

This is copy pasted from Makefile.am. I'll fix the order.

Quoted 39 lines
Quoted 26 lines
lib/libv4lconvert/meson.build new file +26 -0
+    'control/libv4lcontrol.c',
+    'control/libv4lcontrol.h',
+    'control/libv4lcontrol-priv.h',
+    'processing/libv4lprocessing.c',
+    'processing/whitebalance.c',
+    'processing/autogain.c',
+    'processing/gamma.c',
+    'processing/libv4lprocessing.h',
+    'processing/libv4lprocessing-priv.h',
+    'helper-funcs.h',
+    'libv4lconvert-priv.h',
+    'libv4lsyscall-priv.h',
+    'tinyjpeg.h',
+    'tinyjpeg-internal.h',
+)
+
+libv4lconvert_deps = [
+    dep_libm,
+    dep_librt,
+]
+
+libv4lconvert_priv_libs = [
+    '-lrt',
+    '-lm',
+]
+

lib/libv4lconvert/meson.build line 59

Quoted 10 lines
lib/libv4lconvert/meson.build new file +10 -0
+libv4lconvert_incdir = [
+    v4l2_utils_incdir,
+]
+
+libv4lconvert_c_args = []
+
+if with_jpeg
+    libv4lconvert_deps += dep_jpeg
+    libv4lconvert_priv_libs += dep_jpeg_priv_libs
+    libv4lconvert_sources += files('jpeg_memsrcdest.c', 'jpeg_memsrcdest.h')

I'd write this

Quoted 5 lines
    libv4lconvert_sources += files(
        'jpeg_memsrcdest.c',
        'jpeg_memsrcdest.h'
    )

+1

Quoted 38 lines
Quoted 38 lines
lib/libv4lconvert/meson.build new file +20 -0
+    libv4lconvert_c_args += [
+        '-DHAVE_JPEG',
+    ]
+endif
+
+libv4lconvert = shared_library('v4lconvert',
+                         libv4lconvert_sources,
+                         install : true,
+			 dependencies : libv4lconvert_deps,
+                         c_args : libv4lconvert_c_args,
+                         include_directories : libv4lconvert_incdir)
+
+dep_libv4lconvert = declare_dependency(link_with : libv4lconvert)
+
+pkg.generate(
+    name : 'libv4lconvert',
+    libraries : libv4lconvert,
+    libraries_private : libv4lconvert_priv_libs,
+    version : meson.project_version(),
+    description : 'v4l format conversion library')
lib/meson.build new file +6 -0
new file mode 100644
index 000000000000..a9c064b2b2dd
@@ -0,0 +1,6 @@
+if with_libdvbv5
+    subdir('libdvbv5')
+endif
+
+subdir('libv4lconvert')
+subdir('libv4l2')
meson.build new file +0 -0
new file mode 100644
index 000000000000..8dfa3b7252a5
@@ -0,0 +1,108 @@
Quoted 9 lines

meson.build line 6

Quoted 6 lines
meson.build new file +6 -0
+project('v4l-utils', 'c', 'cpp',
+    version: '1.19.0',
+    default_options : [
+        'warning_level=1',
+    ],
+    license : 'LGPL 2.1+')

Should we set a minimum meson version ?

Probably yes.

Quoted 19 lines
Quoted 6 lines
meson.build new file +6 -0
+
+cc = meson.get_compiler('c')
+pkg = import('pkgconfig')
+
+conf = configuration_data()
+conf.set_quoted('V4L_UTILS_VERSION', meson.project_version())

meson.build line 22

Quoted 10 lines
meson.build new file +10 -0
+conf.set('PACKAGE_VERSION', meson.project_version())
+
+common_arguments = [
+    '-Wpointer-arith',
+    '-D_GNU_SOURCE',
+    '-I.', # Needed for config.h
+    '-DPROMOTED_MODE_T=int'
+]
+
+v4l2_utils_incdir = include_directories('include', 'lib/include/')

Maybe

Quoted 7 lines

v4l2_utils_incdir = include_directories(

    'include',
    'lib/include/',

)

?

+1

And I guess we need to treat this portably as well.

Quoted 37 lines
Quoted 37 lines
meson.build new file +37 -0
+
+prog_bash = find_program('bash')
+prog_perl = find_program('perl')
+
+dep_libdl = cc.find_library('dl')
+dep_libm = cc.find_library('m')
+dep_librt = cc.find_library('rt')
+dep_threads = dependency('threads')
+
+have_iconv = false
+if cc.has_function('iconv_open')
+    dep_iconv = dependency('', required : false)
+    have_iconv = true
+else
+    dep_iconv = cc.find_library('iconv', required : false)
+    have_iconv = dep_iconv.found()
+endif
+
+if have_iconv
+    conf.set('HAVE_ICONV', 1)
+    iconv_const_test = '''#include <iconv.h>
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+'''
+    if cc.compiles(iconv_const_test, dependencies : dep_iconv)
+        conf.set('ICONV_CONST', '')
+    else
+        conf.set('ICONV_CONST', 'const')
+    endif
+endif
+
+
+# Optional dependencies
+dep_jpeg = dependency('libjpeg', required : false)
+if dep_jpeg.found()
+    with_jpeg = true
+    dep_jpeg_priv_libs = '-ljpeg'
+endif
Quoted 9 lines

meson.build line 64

Quoted 5 lines
meson.build new file +5 -0
+
+dep_udev = dependency('libudev', required : false)
+if dep_udev.found()
+    with_udev = true
+    with_libdvbv5 = true

libdvbv5 isn't a dependency. Wouldn't it be better to enclose the corresponding subdir or shared_library with 'if with_udev' ?

Right, it's true that "with_libdvbv5" sounds confusing.

Quoted 63 lines
Quoted 63 lines
meson.build new file +44 -0
+else
+    with_udev = false
+    with_libdvbv5 = false
+    warning('udev library not available')
+endif
+
+# Found options
+with_v4l_plugins = get_option('v4l-plugins')
+
+c_arguments = []
+cpp_arguments = []
+
+c_arguments += common_arguments
+cpp_arguments += common_arguments
+
+add_project_arguments(c_arguments, language : 'c')
+add_project_arguments(cpp_arguments, language : 'cpp')
+add_project_link_arguments(cpp_arguments, language : 'cpp')
+
+version_h = vcs_tag(command : ['gen-version.sh', meson.build_root()],
+                    input : 'version.h.in',
+                    output : 'version.h',
+                    fallback : meson.project_version())
+
+subdir('lib')
+
+if get_option('v4l-utils')
+    subdir('utils')
+endif
+
+configure_file(output : 'config.h', configuration : conf)
+
+message('')
+message('  jpeg                       @0@'.format(with_jpeg ? 'yes' : 'no' ))
+message('  udev                       @0@'.format(with_udev ? 'yes' : 'no' ))
+message('  libdvbv5                   @0@'.format(with_libdvbv5 ? 'yes' : 'no' ))
+message('  v4l plugins                @0@'.format(with_v4l_plugins ? 'yes' : 'no' ))
+message('  v4l-utils                  @0@'.format(get_option('v4l-utils') ? 'yes' : 'no' ))
+if get_option('v4l-utils')
+message('  v4l2-compliance-libv4l2    @0@'.format(get_option('v4l2-compliance-libv4l') ? 'yes' : 'no' ))
+message('  v4l2-ctl-libv4l            @0@'.format(get_option('v4l2-ctl-libv4l') ? 'yes' : 'no' ))
+message('  v4l2-ctl-stream-to         @0@'.format(get_option('v4l2-ctl-stream-to') ? 'yes' : 'no' ))
+endif
+message('')
meson_options.txt new file +13 -0
new file mode 100644
index 000000000000..93cc71f1592d
@@ -0,0 +1,19 @@
+option('v4l-utils',
+        type : 'boolean',
+        description : 'Enable v4l-utils')
+
+option('v4l2-compliance-libv4l',
+        type : 'boolean',
+        description : 'Enable use of libv4l in v4l2-compliance')
+
+option('v4l2-ctl-libv4l',
+        type : 'boolean',
+        description : 'Enable use of libv4l in v4l2-ctl')
+
+option('v4l2-ctl-stream-to',
Quoted 9 lines

meson_options.txt line 19

Quoted 6 lines
meson_options.txt new file +6 -0
+        type : 'boolean',
+        description : 'Enable use of --stream-to in v4l2-ctl')
+
+option('v4l-plugins',
+        type : 'boolean',
+        description : 'V4L plugin support')

Alphabetical order ? :-)

Yeah.

Quoted 37 lines
Quoted 17 lines
utils/cec-compliance/meson.build new file +11 -0
new file mode 100644
index 000000000000..fd165586fc0d
@@ -0,0 +1,39 @@
+name = 'cec-compliance'
+
+cec_compliance_sources = files(
+    'cec-compliance.cpp',
+    'cec-compliance.h',
+    'cec-test.cpp',
+    'cec-test-adapter.cpp',
+    'cec-test-audio.cpp',
+    'cec-test-power.cpp',
+    'cec-test-fuzzing.cpp',
+)

utils/cec-compliance/meson.build line 21

Quoted 10 lines
utils/cec-compliance/meson.build new file +10 -0
+
+cec_compliance_sources += version_h
+cec_compliance_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+
+cec_compliance_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')

Here you use this variable to refer to the includes needed to use libcecutil, while below, in libcecutil, you use it to refer to the includes required by libcecutil itself. That's confusing. I think we need to clean up the names. Can't you add the libcecutil headers include path to dep_libcecutil ? That way I think you could drop this one. This may be applicable to other incdir variables too. In any case, if we were to keep this variable, it should be defined in utils/libcecutil/meson.build.

Quoted 15 lines

utils/cec-compliance/meson.build line 32

Quoted 11 lines
utils/cec-compliance/meson.build new file +11 -0
+
+cec_compliance_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_compliance = executable(name,
+                      cec_compliance_sources,
+                      install : true,
+                      dependencies : cec_compliance_deps,
+                      cpp_args : cec_compliance_cpp_args,

This is empty, can't you leave it out ? Same in a few other locations below.

OK.

Quoted 12 lines

utils/cec-compliance/meson.build line 39

Quoted 7 lines
utils/cec-compliance/meson.build new file +7 -0
+                      include_directories : cec_compliance_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)

As all man pages are handled the same way, would it make sense to create a global array of man pages, add an entry to the array here, and move the configure_file() to a more global location in a foreach loop ?

Good idea, yes.

Quoted 170 lines
Quoted 170 lines
utils/cec-ctl/meson.build new file +33 -0
new file mode 100644
index 000000000000..5030cfd16de9
@@ -0,0 +1,33 @@
+name = 'cec-ctl'
+
+cec_ctl_sources = files(
+    'cec-ctl.cpp',
+    'cec-pin.cpp',
+    'cec-ctl.h',
+)
+
+cec_ctl_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+cec_ctl_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_ctl_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_ctl = executable(name,
+                     cec_ctl_sources,
+                     install : true,
+                     dependencies : cec_ctl_deps,
+                     cpp_args : cec_ctl_cpp_args,
+		     include_directories : cec_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/cec-follower/meson.build new file +35 -0
new file mode 100644
index 000000000000..bfa707b5d62a
@@ -0,0 +1,35 @@
+name = 'cec-follower'
+
+cec_follower_sources = files(
+    'cec-follower.cpp',
+    'cec-follower.h',
+    'cec-processing.cpp',
+    'cec-tuner.cpp',
+)
+
+cec_follower_sources += version_h
+cec_follower_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+cec_follower_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_follower_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_follower = executable(name,
+                      cec_follower_sources,
+                      install : true,
+                      dependencies : cec_follower_deps,
+                      cpp_args : cec_follower_cpp_args,
+		      include_directories : cec_follower_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/gen_media_bus_format_codes.sh new file +7 -0
new file mode 100644
index 000000000000..18d1e9f3f317
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+src="$1"
+
+sed -e \
+'/#define MEDIA_BUS_FMT/ ! d; s/.*#define //; /FIXED/ d; s/\t.*//; s/.*/ &,/;' \
+${src}
utils/gen_media_bus_format_names.sh new file +7 -0
new file mode 100644
index 000000000000..79cb16756bc3
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+src="$1"
+
+sed -e \
+'/#define MEDIA_BUS_FMT/ ! d; s/.*FMT_//; /FIXED/ d; s/\t.*//; s/.*/{ \"&\", MEDIA_BUS_FMT_& },/;' \
+${src}
utils/ir-ctl/meson.build new file +30 -0
new file mode 100644
index 000000000000..3c0db8aa769a
@@ -0,0 +1,30 @@
+name = 'ir-ctl'
+
+ir_ctl_sources = files(
+    'ir-ctl.c',
+    'ir-encode.c',
+    'ir-encode.h',
+    'toml.c',
+    'toml.h',
+    'keymap.c',
+    'keymap.h',
+    'bpf_encoder.c',
+    'bpf_encoder.h'
+)
+
+ir_ctl_deps = []
+ir_ctl_cpp_args = []
+ir_ctl_incdir = []
+
+ir_ctl = executable(name,
+                    ir_ctl_sources,
+                    install : true,
+                    dependencies : ir_ctl_deps,
+                    cpp_args : ir_ctl_cpp_args,
+		    include_directories : ir_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/libcecutil/meson.build new file +22 -0
new file mode 100644
index 000000000000..097cb274cfa3
@@ -0,0 +1,46 @@
+libcecutil_sources = files(
+    'cec-info.cpp',
+    'cec-log.cpp',
+    'cec-parse.cpp',
+    'cec-info.h',
+    'cec-log.h',
+    'cec-parse.h',
+    'cec-htng.h',
+    'cec-htng-funcs.h',
+)
+
+libcecutil_deps = [
+    dep_libv4lconvert,
+    dep_libdl,
+    dep_threads,
+]
+
+libcecutil_incdir = [
+    utils_common_incdir,
+    v4l2_utils_incdir,
+]
+
Quoted 9 lines

utils/libcecutil/meson.build line 26

Quoted 4 lines
utils/libcecutil/meson.build new file +4 -0
+libcecutil_c_args = []
+
+cec_gen_sources = files(
+    '../../include/linux/cec.h',

Referencing sources from parent directories is usually a sign that the abstractions are not well designed, but in this case there may be no better way.

Indeed. Note also how cec-gen.pl requires a
configure_file instead of custom_target.

We could clean up this later.

Quoted 83 lines
Quoted 70 lines
utils/libcecutil/meson.build new file +20 -0
+    'cec-htng.h',
+    '../../include/linux/cec-funcs.h',
+    'cec-htng-funcs.h',
+)
+
+configure_file(
+    input : 'cec-gen.pl',
+    output : 'cec-gen-dummy.stamp',
+    command: [
+        prog_perl, '@INPUT@', cec_gen_sources, 'utils/libcecutil'
+    ]
+)
+
+libcecutil = static_library('cecutil',
+                         libcecutil_sources,
+                         install : true,
+                         dependencies : libcecutil_deps,
+                         c_args : libcecutil_c_args,
+                         include_directories : libcecutil_incdir)
+dep_libcecutil = declare_dependency(link_with : libcecutil)
utils/media-ctl/meson.build new file +35 -0
new file mode 100644
index 000000000000..258aea7bea3f
@@ -0,0 +1,35 @@
+libmediactl_sources = files(
+    'libmediactl.c',
+    'mediactl-priv.h',
+)
+
+libmediactl_deps = []
+
+libmediactl = static_library('mediactl',
+                             libmediactl_sources,
+                             dependencies : libmediactl_deps)
+
+pkg.generate(
+    name : 'libmediactl',
+    libraries : libmediactl,
+    version : meson.project_version(),
+    description : 'Media controller library')
+
+libv4l2subdev_sources = files('libv4l2subdev.c')
+libv4l2subdev_sources += media_bus_format_names_h
+libv4l2subdev_sources += media_bus_format_codes_h
+
+libv4l2subdev = static_library('v4l2subdev',
+                               libv4l2subdev_sources)
+
+media_ctl_sources = files(
+    'media-ctl.c',
+    'options.c',
+    'options.h',
+    'tools.h',
+)
+
+media_ctl = executable('media-ctl',
+                       media_ctl_sources,
+                       install : true,
+		       link_with : [libmediactl, libv4l2subdev])
utils/meson.build new file +3 -0
new file mode 100644
index 000000000000..d4bb4b50142d
@@ -0,0 +1,32 @@
+utils_common_incdir = include_directories('common')
+
+# Generate targets for media-bus-format-{names,codes}.h

utils/meson.build line 13

Quoted 10 lines
utils/meson.build new file +10 -0
+foreach x: [ 'names', 'codes' ]
+    output_file = 'media-bus-format-@[email protected]'.format(x)
+    input_file = 'gen_media_bus_format_@[email protected]'.format(x)
+
+    target = custom_target(
+        output_file,
+        output : output_file,
+        input : input_file,
+	command : [
+            prog_bash, '@INPUT@', files('../include/linux/media-bus-format.h'),

If you used

Quoted 6 lines

#!/bin/bash

as the first line of the gen_media_bus_format_*.sh scripts, could you get rid of prog_bash and use the script directly ? input_file should be ../include/linux/media-bus-format.h to proper dependency handling.

Hm, that's not really working here. I think the .input argument handles paths.

Quoted 56 lines
Quoted 56 lines
utils/meson.build new file +19 -0
+        ],
+        capture : true,
+    )
+    set_variable(output_file.underscorify(), target)
+endforeach
+
+# Libraries
+subdir('libcecutil')
+
+# Utils
+subdir('cec-ctl')
+subdir('cec-follower')
+subdir('ir-ctl')
+subdir('media-ctl')
+subdir('v4l2-ctl')
+
+# Compliance tools
+subdir('cec-compliance')
+subdir('v4l2-compliance')
utils/v4l2-compliance/meson.build new file +31 -0
new file mode 100644
index 000000000000..534b7bf4cb4e
@@ -0,0 +1,52 @@
+name = 'v4l2-compliance'
+
+v4l2_compliance_sources = files(
+    'v4l2-compliance.cpp',
+    'v4l2-compliance.h',
+    'v4l2-test-debug.cpp',
+    'v4l2-test-input-output.cpp',
+    'v4l2-test-controls.cpp',
+    'v4l2-test-io-config.cpp',
+    'v4l2-test-formats.cpp',
+    'v4l2-test-buffers.cpp',
+    'v4l2-test-codecs.cpp',
+    'v4l2-test-subdevs.cpp',
+    'v4l2-test-media.cpp',
+    'v4l2-test-colors.cpp',
+    'media-info.cpp',
+    'v4l2-info.cpp',
+)
+
+v4l2_compliance_sources += version_h
+v4l2_compliance_deps = [
+    dep_librt,
+    dep_threads,
+]
+v4l2_compliance_cpp_args = []
+
+if get_option('v4l2-compliance-libv4l')
+    v4l2_compliance_deps += dep_libv4lconvert
+    v4l2_compliance_deps += dep_libv4l2
+else
+    v4l2_compliance_cpp_args += '-DNO_LIBV4L2'
Quoted 9 lines

utils/v4l2-compliance/meson.build line 37

Quoted 6 lines
utils/v4l2-compliance/meson.build new file +6 -0
+endif
+
+common_incdir = include_directories('../common')
+
+v4l2_compliance_incdir = [
+    common_incdir,

Can't you reuse utils_common_incdir ?

Ah, good catch.

Quoted 93 lines
Quoted 93 lines
utils/v4l2-compliance/meson.build new file +15 -0
+    v4l2_utils_incdir,
+]
+
+v4l2_compliance = executable(name,
+                      v4l2_compliance_sources,
+                      install : true,
+                      dependencies : v4l2_compliance_deps,
+                      cpp_args : v4l2_compliance_cpp_args,
+                      include_directories : v4l2_compliance_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/v4l2-ctl/meson.build new file +65 -0
new file mode 100644
index 000000000000..1bbc7fe44313
@@ -0,0 +1,65 @@
+name = 'v4l2-ctl'
+
+v4l2_ctl_sources = files(
+    'v4l2-ctl.cpp',
+    'v4l2-ctl.h',
+    'v4l2-ctl-common.cpp',
+    'v4l2-ctl-tuner.cpp',
+    'v4l2-ctl-io.cpp',
+    'v4l2-ctl-stds.cpp',
+    'v4l2-ctl-vidcap.cpp',
+    'v4l2-ctl-vidout.cpp',
+    'v4l2-ctl-overlay.cpp',
+    'v4l2-ctl-vbi.cpp',
+    'v4l2-ctl-selection.cpp',
+    'v4l2-ctl-misc.cpp',
+    'v4l2-ctl-streaming.cpp',
+    'v4l2-ctl-sdr.cpp',
+    'v4l2-ctl-edid.cpp',
+    'v4l2-ctl-modes.cpp',
+    'v4l2-ctl-subdev.cpp',
+    'v4l2-tpg-colors.c',
+    'v4l2-tpg-core.c',
+    'v4l-stream.c',
+    'v4l2-ctl-meta.cpp',
+    'media-info.cpp',
+    'v4l2-info.cpp',
+    'codec-fwht.c',
+    'codec-v4l2-fwht.c',
+)
+v4l2_ctl_sources += media_bus_format_names_h
+
+v4l2_ctl_deps = [
+    dep_librt,
+    dep_threads,
+]
+v4l2_ctl_cpp_args = []
+
+if get_option('v4l2-ctl-libv4l')
+    v4l2_ctl_deps += dep_libv4lconvert
+    v4l2_ctl_deps += dep_libv4l2
+else
+    v4l2_ctl_cpp_args += '-DNO_LIBV4L2'
+endif
+
+if not get_option('v4l2-ctl-stream-to')
+    v4l2_ctl_cpp_args += '-DNO_STREAM_TO'
+endif
+
+v4l2_ctl_incdir = [
+    utils_common_incdir,
+    v4l2_utils_incdir,
+]
+
+v4l2_ctl = executable(name,
+                      v4l2_ctl_sources,
+                      install : true,
+                      dependencies : v4l2_ctl_deps,
+                      cpp_args : v4l2_ctl_cpp_args,
+		      include_directories : v4l2_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
version.h.in new file +1 -0
new file mode 100644
index 000000000000..2506ed9bc6cc
@@ -0,0 +1 @@
+#define SHA @VCS_TAG@
#4 lore raw

Re: [RFC PATCH v4l-utils 1/1] Introduce support for meson building

In reply to Ezequiel Garcia
Quoted 207 lines · Ezequiel Garcia

Currently supports:

* libdvbv5
* libv4l2
* libv4lconvert
* cec-ctl
* cec-compliance
* cec-follower
* ir-ctl
* media-ctl
* v4l2-ctl
* v4l2-compliance

---
 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in
gen-version.sh new file +36 -0
new file mode 100755
index 000000000000..9223ab7d0a32
@@ -0,0 +1,36 @@
+#!/bin/sh
+# gen-version.sh script taken from the libcamera project.
+# Generate a version string using git describe.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+build_dir="$1"
+
+# Bail out if the directory isn't under git control
+src_dir=$(git rev-parse --git-dir 2>&1) || exit 1
+src_dir=$(readlink -f "$src_dir/..")
+
+# Get a short description from the tree.
+version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null)
+
+if [ -z "$version" ]
+then
+	# Handle an un-tagged repository
+	sha=$(git describe --abbrev=8 --always 2>/dev/null)
+	commits=$(git log --oneline | wc -l 2>/dev/null)
+	version="v4l-utils-0.0.0-$commits-g$sha"
+fi
+
+# Append a '-dirty' suffix if the working tree is dirty. Prevent false
+# positives due to changed timestamps by running git update-index.
+if [ -z "$build_dir" ] || (echo "$build_dir" | grep -q "$src_dir")
+then
+	git update-index --refresh > /dev/null 2>&1
+fi
+git diff-index --quiet HEAD || version="$version-dirty"
+
+# Replace first '-' with a '+' to denote build metadata, strip the 'g' in from
+# of the git SHA1 and remove the initial 'v'.
+version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 11-)
+
+echo "$version"
lib/libdvbv5/meson.build new file +87 -0
new file mode 100644
index 000000000000..35eda2da4692
@@ -0,0 +1,87 @@
+libdvbv5_sources = files(
+    'compat-soname.c',
+    'crc32.c',
+    'countries.c',
+    'dvb-legacy-channel-format.c',
+    'dvb-zap-format.c',
+    'dvb-vdr-format.c',
+    'dvb-v5.c',
+    'dvb-v5.h',
+    'parse_string.c',
+    'parse_string.h',
+    'dvb-demux.c',
+    'dvb-dev.c',
+    'dvb-dev-local.c',
+    'dvb-dev-priv.h',
+    'dvb-dev-remote.c',
+    'dvb-fe.c',
+    'dvb-fe-priv.h',
+    'dvb-log.c',
+    'dvb-file.c',
+    'dvb-v5-std.c',
+    'dvb-sat.c',
+    'dvb-scan.c',
+    'descriptors.c',
+    'tables/header.c',
+    'tables/pat.c',
+    'tables/pmt.c',
+    'tables/nit.c',
+    'tables/sdt.c',
+    'tables/vct.c',
+    'tables/mgt.c',
+    'tables/eit.c',
+    'tables/cat.c',
+    'tables/atsc_eit.c',
+    'tables/mpeg_ts.c',
+    'tables/mpeg_pes.c',
+    'tables/mpeg_es.c',
+    'descriptors/desc_language.c',
+    'descriptors/desc_network_name.c',
+    'descriptors/desc_cable_delivery.c',
+    'descriptors/desc_sat.c',
+    'descriptors/desc_terrestrial_delivery.c',
+    'descriptors/desc_t2_delivery.c',
+    'descriptors/desc_service.c',
+    'descriptors/desc_frequency_list.c',
+    'descriptors/desc_event_short.c',
+    'descriptors/desc_event_extended.c',
+    'descriptors/desc_atsc_service_location.c',
+    'descriptors/desc_hierarchy.c',
+    'descriptors/desc_extension.c',
+    'descriptors/desc_isdbt_delivery.c',
+    'descriptors/desc_logical_channel.c',
+    'descriptors/desc_ts_info.c',
+    'descriptors/desc_partial_reception.c',
+    'descriptors/desc_ca.c',
+    'descriptors/desc_ca_identifier.c',
+)
+
+libdvbv5_deps = [
+    dep_libm,
+    dep_threads,
+    dep_udev,
+]
+
+libdvbv5_incdir = [
+    v4l2_utils_incdir,
+]
+
+libdvbv5_c_args = [
+    '-DHAVE_DVBV5_REMOTE',
+]
+
+libdvbv5 = shared_library('dvbv5',
+                         libdvbv5_sources,
+                         install : true,
+			 dependencies : libdvbv5_deps,
+                         c_args : libdvbv5_c_args,
+                         include_directories : libdvbv5_incdir)
+
+dep_libdvbv5 = declare_dependency(link_with : libdvbv5)
+
+pkg.generate(
+    name : 'libdvbv5',
+    libraries : libdvbv5,
+    version : meson.project_version(),
+    requires_private : 'libudev',
+    description : 'DVBv5 utility library')
lib/libv4l2/meson.build new file +11 -0
new file mode 100644
index 000000000000..eefe680620c5
@@ -0,0 +1,43 @@
+libv4l2_sources = files(
+    'libv4l2.c',
+    'log.c',
+    'libv4l2-priv.h',
+)
+
+libv4l2_deps = [
+    dep_libv4lconvert,
+    dep_libdl,
+    dep_threads,
+]

lib/libv4l2/meson.build line 21

Quoted 10 lines
lib/libv4l2/meson.build new file +10 -0
+
+libv4l2_incdir = [
+    v4l2_utils_incdir,
+]
+
+libv4l2_c_args = []
+
+if with_v4l_plugins
+    libv4l2_sources += files('v4l2-plugin.c')
+    libv4l2_plugins_dir = join_paths(get_option('prefix'), get_option('libdir'), 'libv4l/plugins')

Meson now have the / operator, that allow you do write the same line as:

+ libv4l2_plugins_dir = get_option('prefix') / get_option('libdir') / 'libv4l' / 'plugins'

Specially that in this case you use the portable join_paths, and then have a "libv4l2/plugins" later, which is not very consitent (but this is Linux library, so not problematic.

I'm stopping there, as I'm sure you get the idea how to improve this. Nice work.

Quoted 137 lines
lib/libv4l2/meson.build new file +22 -0
+    libv4l2_c_args += [
+        '-DHAVE_V4L_PLUGINS',
+        '-DLIBV4L2_PLUGIN_DIR="@0@"'.format(libv4l2_plugins_dir)
+    ]
+endif
+
+libv4l2 = shared_library('v4l2',
+                         libv4l2_sources,
+                         install : true,
+                         dependencies : libv4l2_deps,
+                         c_args : libv4l2_c_args,
+                         include_directories : libv4l2_incdir)
+
+dep_libv4l2 = declare_dependency(link_with : libv4l2)
+
+pkg.generate(
+    name : 'libv4l2',
+    libraries : libv4l2,
+    libraries_private : '-lpthread',
+    version : meson.project_version(),
+    requires_private : 'libv4lconvert',
+    description : 'v4l2 device access library')
lib/libv4lconvert/meson.build new file +79 -0
new file mode 100644
index 000000000000..cd6c4b4574f2
@@ -0,0 +1,79 @@
+libv4lconvert_sources = files(
+    'libv4lconvert.c',
+    'tinyjpeg.c',
+    'sn9c10x.c',
+    'sn9c20x.c',
+    'pac207.c',
+    'mr97310a.c',
+    'flip.c',
+    'crop.c',
+    'jidctflt.c',
+    'spca561-decompress.c',
+    'rgbyuv.c',
+    'sn9c2028-decomp.c',
+    'spca501.c',
+    'sq905c.c',
+    'bayer.c',
+    'hm12.c',
+    'stv0680.c',
+    'cpia1.c',
+    'se401.c',
+    'jpgl.c',
+    'jpeg.c',
+    'jl2005bcd.c',
+    'control/libv4lcontrol.c',
+    'control/libv4lcontrol.h',
+    'control/libv4lcontrol-priv.h',
+    'processing/libv4lprocessing.c',
+    'processing/whitebalance.c',
+    'processing/autogain.c',
+    'processing/gamma.c',
+    'processing/libv4lprocessing.h',
+    'processing/libv4lprocessing-priv.h',
+    'helper-funcs.h',
+    'libv4lconvert-priv.h',
+    'libv4lsyscall-priv.h',
+    'tinyjpeg.h',
+    'tinyjpeg-internal.h',
+)
+
+libv4lconvert_deps = [
+    dep_libm,
+    dep_librt,
+]
+
+libv4lconvert_priv_libs = [
+    '-lrt',
+    '-lm',
+]
+
+libv4lconvert_incdir = [
+    v4l2_utils_incdir,
+]
+
+libv4lconvert_c_args = []
+
+if with_jpeg
+    libv4lconvert_deps += dep_jpeg
+    libv4lconvert_priv_libs += dep_jpeg_priv_libs
+    libv4lconvert_sources += files('jpeg_memsrcdest.c', 'jpeg_memsrcdest.h')
+    libv4lconvert_c_args += [
+        '-DHAVE_JPEG',
+    ]
+endif
+
+libv4lconvert = shared_library('v4lconvert',
+                         libv4lconvert_sources,
+                         install : true,
+			 dependencies : libv4lconvert_deps,
+                         c_args : libv4lconvert_c_args,
+                         include_directories : libv4lconvert_incdir)
+
+dep_libv4lconvert = declare_dependency(link_with : libv4lconvert)
+
+pkg.generate(
+    name : 'libv4lconvert',
+    libraries : libv4lconvert,
+    libraries_private : libv4lconvert_priv_libs,
+    version : meson.project_version(),
+    description : 'v4l format conversion library')
lib/meson.build new file +6 -0
new file mode 100644
index 000000000000..a9c064b2b2dd
@@ -0,0 +1,6 @@
+if with_libdvbv5
+    subdir('libdvbv5')
+endif
+
+subdir('libv4lconvert')
+subdir('libv4l2')
meson.build new file +12 -0
new file mode 100644
index 000000000000..8dfa3b7252a5
@@ -0,0 +1,108 @@
+project('v4l-utils', 'c', 'cpp',
+    version: '1.19.0',
+    default_options : [
+        'warning_level=1',
+    ],
+    license : 'LGPL 2.1+')
+
+cc = meson.get_compiler('c')
+pkg = import('pkgconfig')
+
+conf = configuration_data()
+conf.set_quoted('V4L_UTILS_VERSION', meson.project_version())

meson.build line 22

Quoted 10 lines
meson.build new file +10 -0
+conf.set('PACKAGE_VERSION', meson.project_version())
+
+common_arguments = [
+    '-Wpointer-arith',
+    '-D_GNU_SOURCE',
+    '-I.', # Needed for config.h
+    '-DPROMOTED_MODE_T=int'
+]
+
+v4l2_utils_incdir = include_directories('include', 'lib/include/')

You can remove the / at the end.

Quoted 7 lines
meson.build new file +7 -0
+
+prog_bash = find_program('bash')
+prog_perl = find_program('perl')
+
+dep_libdl = cc.find_library('dl')
+dep_libm = cc.find_library('m')
+dep_librt = cc.find_library('rt')

meson.build line 39

Quoted 10 lines
meson.build new file +10 -0
+dep_threads = dependency('threads')
+
+have_iconv = false
+if cc.has_function('iconv_open')
+    dep_iconv = dependency('', required : false)
+    have_iconv = true
+else
+    dep_iconv = cc.find_library('iconv', required : false)
+    have_iconv = dep_iconv.found()
+endif

I think iconv should be a feature, this way we could explicitly decide to have it or now with -Diconv=disable/disable/auto.

Feature are important for packagers, as they want to decide which deps are included and have the build fail wanted deps is missing. This is something usually very badly implemented in custom autotools scripts.

Quoted 6 lines
meson.build new file +6 -0
+
+if have_iconv
+    conf.set('HAVE_ICONV', 1)
+    iconv_const_test = '''#include <iconv.h>
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+'''

meson.build line 55

Quoted 10 lines
meson.build new file +10 -0
+    if cc.compiles(iconv_const_test, dependencies : dep_iconv)
+        conf.set('ICONV_CONST', '')
+    else
+        conf.set('ICONV_CONST', 'const')
+    endif
+endif
+
+
+# Optional dependencies
+dep_jpeg = dependency('libjpeg', required : false)

Should be a feature.

meson.build line 58

Quoted 3 lines
meson.build new file +3 -0
+if dep_jpeg.found()
+    with_jpeg = true
+    dep_jpeg_priv_libs = '-ljpeg'

Probably imported from autotools, but I don't think you need that, meson generate the .pc files properly, and know the private libs. with_jpeg should go away, if you use a feature, and pass get_option("jpeg") to the required: in dependency() call, then the dep object is sufficient.

meson.build line 61

Quoted 3 lines
meson.build new file +3 -0
+endif
+
+dep_udev = dependency('libudev', required : false)

Should also be a feature.

meson.build line 69

Quoted 8 lines
meson.build new file +8 -0
+if dep_udev.found()
+    with_udev = true
+    with_libdvbv5 = true
+else
+    with_udev = false
+    with_libdvbv5 = false
+    warning('udev library not available')
+endif

And all those with_ variable should go away.

meson.build line 72

Quoted 3 lines
meson.build new file +3 -0
+
+# Found options
+with_v4l_plugins = get_option('v4l-plugins')

You shouldn't hide options, just call get_option when needed.

Quoted 25 lines
meson.build new file +25 -0
+
+c_arguments = []
+cpp_arguments = []
+
+c_arguments += common_arguments
+cpp_arguments += common_arguments
+
+add_project_arguments(c_arguments, language : 'c')
+add_project_arguments(cpp_arguments, language : 'cpp')
+add_project_link_arguments(cpp_arguments, language : 'cpp')
+
+version_h = vcs_tag(command : ['gen-version.sh', meson.build_root()],
+                    input : 'version.h.in',
+                    output : 'version.h',
+                    fallback : meson.project_version())
+
+subdir('lib')
+
+if get_option('v4l-utils')
+    subdir('utils')
+endif
+
+configure_file(output : 'config.h', configuration : conf)
+
+message('')

meson.build line 107

Quoted 10 lines
meson.build new file +10 -0
+message('  jpeg                       @0@'.format(with_jpeg ? 'yes' : 'no' ))
+message('  udev                       @0@'.format(with_udev ? 'yes' : 'no' ))
+message('  libdvbv5                   @0@'.format(with_libdvbv5 ? 'yes' : 'no' ))
+message('  v4l plugins                @0@'.format(with_v4l_plugins ? 'yes' : 'no' ))
+message('  v4l-utils                  @0@'.format(get_option('v4l-utils') ? 'yes' : 'no' ))
+if get_option('v4l-utils')
+message('  v4l2-compliance-libv4l2    @0@'.format(get_option('v4l2-compliance-libv4l') ? 'yes' : 'no' ))
+message('  v4l2-ctl-libv4l            @0@'.format(get_option('v4l2-ctl-libv4l') ? 'yes' : 'no' ))
+message('  v4l2-ctl-stream-to         @0@'.format(get_option('v4l2-ctl-stream-to') ? 'yes' : 'no' ))
+endif

Custom reporting is no longer recommended, meson have a option driven report (summary). The plus side is that it will be printed at the end properly even if this project is used as subproject.

Quoted 480 lines
meson.build new file +1 -0
+message('')
meson_options.txt new file +19 -0
new file mode 100644
index 000000000000..93cc71f1592d
@@ -0,0 +1,19 @@
+option('v4l-utils',
+        type : 'boolean',
+        description : 'Enable v4l-utils')
+
+option('v4l2-compliance-libv4l',
+        type : 'boolean',
+        description : 'Enable use of libv4l in v4l2-compliance')
+
+option('v4l2-ctl-libv4l',
+        type : 'boolean',
+        description : 'Enable use of libv4l in v4l2-ctl')
+
+option('v4l2-ctl-stream-to',
+        type : 'boolean',
+        description : 'Enable use of --stream-to in v4l2-ctl')
+
+option('v4l-plugins',
+        type : 'boolean',
+        description : 'V4L plugin support')
utils/cec-compliance/meson.build new file +39 -0
new file mode 100644
index 000000000000..fd165586fc0d
@@ -0,0 +1,39 @@
+name = 'cec-compliance'
+
+cec_compliance_sources = files(
+    'cec-compliance.cpp',
+    'cec-compliance.h',
+    'cec-test.cpp',
+    'cec-test-adapter.cpp',
+    'cec-test-audio.cpp',
+    'cec-test-power.cpp',
+    'cec-test-fuzzing.cpp',
+)
+
+cec_compliance_sources += version_h
+cec_compliance_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+
+cec_compliance_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_compliance_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_compliance = executable(name,
+                      cec_compliance_sources,
+                      install : true,
+                      dependencies : cec_compliance_deps,
+                      cpp_args : cec_compliance_cpp_args,
+                      include_directories : cec_compliance_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/cec-ctl/meson.build new file +33 -0
new file mode 100644
index 000000000000..5030cfd16de9
@@ -0,0 +1,33 @@
+name = 'cec-ctl'
+
+cec_ctl_sources = files(
+    'cec-ctl.cpp',
+    'cec-pin.cpp',
+    'cec-ctl.h',
+)
+
+cec_ctl_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+cec_ctl_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_ctl_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_ctl = executable(name,
+                     cec_ctl_sources,
+                     install : true,
+                     dependencies : cec_ctl_deps,
+                     cpp_args : cec_ctl_cpp_args,
+		     include_directories : cec_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/cec-follower/meson.build new file +35 -0
new file mode 100644
index 000000000000..bfa707b5d62a
@@ -0,0 +1,35 @@
+name = 'cec-follower'
+
+cec_follower_sources = files(
+    'cec-follower.cpp',
+    'cec-follower.h',
+    'cec-processing.cpp',
+    'cec-tuner.cpp',
+)
+
+cec_follower_sources += version_h
+cec_follower_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+cec_follower_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_follower_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_follower = executable(name,
+                      cec_follower_sources,
+                      install : true,
+                      dependencies : cec_follower_deps,
+                      cpp_args : cec_follower_cpp_args,
+		      include_directories : cec_follower_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/gen_media_bus_format_codes.sh new file +7 -0
new file mode 100644
index 000000000000..18d1e9f3f317
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+src="$1"
+
+sed -e \
+'/#define MEDIA_BUS_FMT/ ! d; s/.*#define //; /FIXED/ d; s/\t.*//; s/.*/ &,/;' \
+${src}
utils/gen_media_bus_format_names.sh new file +7 -0
new file mode 100644
index 000000000000..79cb16756bc3
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+src="$1"
+
+sed -e \
+'/#define MEDIA_BUS_FMT/ ! d; s/.*FMT_//; /FIXED/ d; s/\t.*//; s/.*/{ \"&\", MEDIA_BUS_FMT_& },/;' \
+${src}
utils/ir-ctl/meson.build new file +30 -0
new file mode 100644
index 000000000000..3c0db8aa769a
@@ -0,0 +1,30 @@
+name = 'ir-ctl'
+
+ir_ctl_sources = files(
+    'ir-ctl.c',
+    'ir-encode.c',
+    'ir-encode.h',
+    'toml.c',
+    'toml.h',
+    'keymap.c',
+    'keymap.h',
+    'bpf_encoder.c',
+    'bpf_encoder.h'
+)
+
+ir_ctl_deps = []
+ir_ctl_cpp_args = []
+ir_ctl_incdir = []
+
+ir_ctl = executable(name,
+                    ir_ctl_sources,
+                    install : true,
+                    dependencies : ir_ctl_deps,
+                    cpp_args : ir_ctl_cpp_args,
+		    include_directories : ir_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/libcecutil/meson.build new file +46 -0
new file mode 100644
index 000000000000..097cb274cfa3
@@ -0,0 +1,46 @@
+libcecutil_sources = files(
+    'cec-info.cpp',
+    'cec-log.cpp',
+    'cec-parse.cpp',
+    'cec-info.h',
+    'cec-log.h',
+    'cec-parse.h',
+    'cec-htng.h',
+    'cec-htng-funcs.h',
+)
+
+libcecutil_deps = [
+    dep_libv4lconvert,
+    dep_libdl,
+    dep_threads,
+]
+
+libcecutil_incdir = [
+    utils_common_incdir,
+    v4l2_utils_incdir,
+]
+
+libcecutil_c_args = []
+
+cec_gen_sources = files(
+    '../../include/linux/cec.h',
+    'cec-htng.h',
+    '../../include/linux/cec-funcs.h',
+    'cec-htng-funcs.h',
+)
+
+configure_file(
+    input : 'cec-gen.pl',
+    output : 'cec-gen-dummy.stamp',
+    command: [
+        prog_perl, '@INPUT@', cec_gen_sources, 'utils/libcecutil'
+    ]
+)
+
+libcecutil = static_library('cecutil',
+                         libcecutil_sources,
+                         install : true,
+                         dependencies : libcecutil_deps,
+                         c_args : libcecutil_c_args,
+                         include_directories : libcecutil_incdir)
+dep_libcecutil = declare_dependency(link_with : libcecutil)
utils/media-ctl/meson.build new file +35 -0
new file mode 100644
index 000000000000..258aea7bea3f
@@ -0,0 +1,35 @@
+libmediactl_sources = files(
+    'libmediactl.c',
+    'mediactl-priv.h',
+)
+
+libmediactl_deps = []
+
+libmediactl = static_library('mediactl',
+                             libmediactl_sources,
+                             dependencies : libmediactl_deps)
+
+pkg.generate(
+    name : 'libmediactl',
+    libraries : libmediactl,
+    version : meson.project_version(),
+    description : 'Media controller library')
+
+libv4l2subdev_sources = files('libv4l2subdev.c')
+libv4l2subdev_sources += media_bus_format_names_h
+libv4l2subdev_sources += media_bus_format_codes_h
+
+libv4l2subdev = static_library('v4l2subdev',
+                               libv4l2subdev_sources)
+
+media_ctl_sources = files(
+    'media-ctl.c',
+    'options.c',
+    'options.h',
+    'tools.h',
+)
+
+media_ctl = executable('media-ctl',
+                       media_ctl_sources,
+                       install : true,
+		       link_with : [libmediactl, libv4l2subdev])
utils/meson.build new file +32 -0
new file mode 100644
index 000000000000..d4bb4b50142d
@@ -0,0 +1,32 @@
+utils_common_incdir = include_directories('common')
+
+# Generate targets for media-bus-format-{names,codes}.h
+foreach x: [ 'names', 'codes' ]
+    output_file = 'media-bus-format-@[email protected]'.format(x)
+    input_file = 'gen_media_bus_format_@[email protected]'.format(x)
+
+    target = custom_target(
+        output_file,
+        output : output_file,
+        input : input_file,
+	command : [
+            prog_bash, '@INPUT@', files('../include/linux/media-bus-format.h'),
+        ],
+        capture : true,
+    )
+    set_variable(output_file.underscorify(), target)
+endforeach
+
+# Libraries
+subdir('libcecutil')
+
+# Utils
+subdir('cec-ctl')
+subdir('cec-follower')
+subdir('ir-ctl')
+subdir('media-ctl')
+subdir('v4l2-ctl')
+
+# Compliance tools
+subdir('cec-compliance')
+subdir('v4l2-compliance')
utils/v4l2-compliance/meson.build new file +52 -0
new file mode 100644
index 000000000000..534b7bf4cb4e
@@ -0,0 +1,52 @@
+name = 'v4l2-compliance'
+
+v4l2_compliance_sources = files(
+    'v4l2-compliance.cpp',
+    'v4l2-compliance.h',
+    'v4l2-test-debug.cpp',
+    'v4l2-test-input-output.cpp',
+    'v4l2-test-controls.cpp',
+    'v4l2-test-io-config.cpp',
+    'v4l2-test-formats.cpp',
+    'v4l2-test-buffers.cpp',
+    'v4l2-test-codecs.cpp',
+    'v4l2-test-subdevs.cpp',
+    'v4l2-test-media.cpp',
+    'v4l2-test-colors.cpp',
+    'media-info.cpp',
+    'v4l2-info.cpp',
+)
+
+v4l2_compliance_sources += version_h
+v4l2_compliance_deps = [
+    dep_librt,
+    dep_threads,
+]
+v4l2_compliance_cpp_args = []
+
+if get_option('v4l2-compliance-libv4l')
+    v4l2_compliance_deps += dep_libv4lconvert
+    v4l2_compliance_deps += dep_libv4l2
+else
+    v4l2_compliance_cpp_args += '-DNO_LIBV4L2'
+endif
+
+common_incdir = include_directories('../common')
+
+v4l2_compliance_incdir = [
+    common_incdir,
+    v4l2_utils_incdir,
+]
+
+v4l2_compliance = executable(name,
+                      v4l2_compliance_sources,
+                      install : true,
+                      dependencies : v4l2_compliance_deps,
+                      cpp_args : v4l2_compliance_cpp_args,
+                      include_directories : v4l2_compliance_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/v4l2-ctl/meson.build new file +65 -0
new file mode 100644
index 000000000000..1bbc7fe44313
@@ -0,0 +1,65 @@
+name = 'v4l2-ctl'
+
+v4l2_ctl_sources = files(
+    'v4l2-ctl.cpp',
+    'v4l2-ctl.h',
+    'v4l2-ctl-common.cpp',
+    'v4l2-ctl-tuner.cpp',
+    'v4l2-ctl-io.cpp',
+    'v4l2-ctl-stds.cpp',
+    'v4l2-ctl-vidcap.cpp',
+    'v4l2-ctl-vidout.cpp',
+    'v4l2-ctl-overlay.cpp',
+    'v4l2-ctl-vbi.cpp',
+    'v4l2-ctl-selection.cpp',
+    'v4l2-ctl-misc.cpp',
+    'v4l2-ctl-streaming.cpp',
+    'v4l2-ctl-sdr.cpp',
+    'v4l2-ctl-edid.cpp',
+    'v4l2-ctl-modes.cpp',
+    'v4l2-ctl-subdev.cpp',
+    'v4l2-tpg-colors.c',
+    'v4l2-tpg-core.c',
+    'v4l-stream.c',
+    'v4l2-ctl-meta.cpp',
+    'media-info.cpp',
+    'v4l2-info.cpp',
+    'codec-fwht.c',
+    'codec-v4l2-fwht.c',
+)
+v4l2_ctl_sources += media_bus_format_names_h
+
+v4l2_ctl_deps = [
+    dep_librt,
+    dep_threads,
+]
+v4l2_ctl_cpp_args = []
+
+if get_option('v4l2-ctl-libv4l')
+    v4l2_ctl_deps += dep_libv4lconvert
+    v4l2_ctl_deps += dep_libv4l2
+else
+    v4l2_ctl_cpp_args += '-DNO_LIBV4L2'
+endif
+
+if not get_option('v4l2-ctl-stream-to')
+    v4l2_ctl_cpp_args += '-DNO_STREAM_TO'
+endif
+
+v4l2_ctl_incdir = [
+    utils_common_incdir,
+    v4l2_utils_incdir,
+]
+
+v4l2_ctl = executable(name,
+                      v4l2_ctl_sources,
+                      install : true,
+                      dependencies : v4l2_ctl_deps,
+                      cpp_args : v4l2_ctl_cpp_args,
+		      include_directories : v4l2_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
version.h.in new file +1 -0
new file mode 100644
index 000000000000..2506ed9bc6cc
@@ -0,0 +1 @@
+#define SHA @VCS_TAG@
#5 lore raw

Re: [RFC PATCH v4l-utils 1/1] Introduce support for meson building

Hey Nicolas!

Thanks for the review.

Quoted 222 lines · Nicolas Dufresne
Quoted 207 lines · Ezequiel Garcia

Currently supports:

* libdvbv5
* libv4l2
* libv4lconvert
* cec-ctl
* cec-compliance
* cec-follower
* ir-ctl
* media-ctl
* v4l2-ctl
* v4l2-compliance

---
 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in
gen-version.sh new file +36 -0
new file mode 100755
index 000000000000..9223ab7d0a32
@@ -0,0 +1,36 @@
+#!/bin/sh
+# gen-version.sh script taken from the libcamera project.
+# Generate a version string using git describe.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+build_dir="$1"
+
+# Bail out if the directory isn't under git control
+src_dir=$(git rev-parse --git-dir 2>&1) || exit 1
+src_dir=$(readlink -f "$src_dir/..")
+
+# Get a short description from the tree.
+version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null)
+
+if [ -z "$version" ]
+then
+	# Handle an un-tagged repository
+	sha=$(git describe --abbrev=8 --always 2>/dev/null)
+	commits=$(git log --oneline | wc -l 2>/dev/null)
+	version="v4l-utils-0.0.0-$commits-g$sha"
+fi
+
+# Append a '-dirty' suffix if the working tree is dirty. Prevent false
+# positives due to changed timestamps by running git update-index.
+if [ -z "$build_dir" ] || (echo "$build_dir" | grep -q "$src_dir")
+then
+	git update-index --refresh > /dev/null 2>&1
+fi
+git diff-index --quiet HEAD || version="$version-dirty"
+
+# Replace first '-' with a '+' to denote build metadata, strip the 'g' in from
+# of the git SHA1 and remove the initial 'v'.
+version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 11-)
+
+echo "$version"
lib/libdvbv5/meson.build new file +87 -0
new file mode 100644
index 000000000000..35eda2da4692
@@ -0,0 +1,87 @@
+libdvbv5_sources = files(
+    'compat-soname.c',
+    'crc32.c',
+    'countries.c',
+    'dvb-legacy-channel-format.c',
+    'dvb-zap-format.c',
+    'dvb-vdr-format.c',
+    'dvb-v5.c',
+    'dvb-v5.h',
+    'parse_string.c',
+    'parse_string.h',
+    'dvb-demux.c',
+    'dvb-dev.c',
+    'dvb-dev-local.c',
+    'dvb-dev-priv.h',
+    'dvb-dev-remote.c',
+    'dvb-fe.c',
+    'dvb-fe-priv.h',
+    'dvb-log.c',
+    'dvb-file.c',
+    'dvb-v5-std.c',
+    'dvb-sat.c',
+    'dvb-scan.c',
+    'descriptors.c',
+    'tables/header.c',
+    'tables/pat.c',
+    'tables/pmt.c',
+    'tables/nit.c',
+    'tables/sdt.c',
+    'tables/vct.c',
+    'tables/mgt.c',
+    'tables/eit.c',
+    'tables/cat.c',
+    'tables/atsc_eit.c',
+    'tables/mpeg_ts.c',
+    'tables/mpeg_pes.c',
+    'tables/mpeg_es.c',
+    'descriptors/desc_language.c',
+    'descriptors/desc_network_name.c',
+    'descriptors/desc_cable_delivery.c',
+    'descriptors/desc_sat.c',
+    'descriptors/desc_terrestrial_delivery.c',
+    'descriptors/desc_t2_delivery.c',
+    'descriptors/desc_service.c',
+    'descriptors/desc_frequency_list.c',
+    'descriptors/desc_event_short.c',
+    'descriptors/desc_event_extended.c',
+    'descriptors/desc_atsc_service_location.c',
+    'descriptors/desc_hierarchy.c',
+    'descriptors/desc_extension.c',
+    'descriptors/desc_isdbt_delivery.c',
+    'descriptors/desc_logical_channel.c',
+    'descriptors/desc_ts_info.c',
+    'descriptors/desc_partial_reception.c',
+    'descriptors/desc_ca.c',
+    'descriptors/desc_ca_identifier.c',
+)
+
+libdvbv5_deps = [
+    dep_libm,
+    dep_threads,
+    dep_udev,
+]
+
+libdvbv5_incdir = [
+    v4l2_utils_incdir,
+]
+
+libdvbv5_c_args = [
+    '-DHAVE_DVBV5_REMOTE',
+]
+
+libdvbv5 = shared_library('dvbv5',
+                         libdvbv5_sources,
+                         install : true,
+			 dependencies : libdvbv5_deps,
+                         c_args : libdvbv5_c_args,
+                         include_directories : libdvbv5_incdir)
+
+dep_libdvbv5 = declare_dependency(link_with : libdvbv5)
+
+pkg.generate(
+    name : 'libdvbv5',
+    libraries : libdvbv5,
+    version : meson.project_version(),
+    requires_private : 'libudev',
+    description : 'DVBv5 utility library')
lib/libv4l2/meson.build new file +11 -0
new file mode 100644
index 000000000000..eefe680620c5
@@ -0,0 +1,43 @@
+libv4l2_sources = files(
+    'libv4l2.c',
+    'log.c',
+    'libv4l2-priv.h',
+)
+
+libv4l2_deps = [
+    dep_libv4lconvert,
+    dep_libdl,
+    dep_threads,
+]

lib/libv4l2/meson.build line 21

Quoted 10 lines
lib/libv4l2/meson.build new file +10 -0
+
+libv4l2_incdir = [
+    v4l2_utils_incdir,
+]
+
+libv4l2_c_args = []
+
+if with_v4l_plugins
+    libv4l2_sources += files('v4l2-plugin.c')
+    libv4l2_plugins_dir = join_paths(get_option('prefix'), get_option('libdir'), 'libv4l/plugins')

Meson now have the / operator, that allow you do write the same line as:

Quoted 6 lines

+ libv4l2_plugins_dir = get_option('prefix') / get_option('libdir') / 'libv4l' / 'plugins'

Specially that in this case you use the portable join_paths, and then have a "libv4l2/plugins" later, which is not very consitent (but this is Linux library, so not problematic.

Yup, my bad.

Quoted 1 line

I'm stopping there, as I'm sure you get the idea how to improve this.

Yup, thanks!

Quoted 143 lines

Nice work.

Quoted 141 lines
lib/libv4l2/meson.build new file +22 -0
+    libv4l2_c_args += [
+        '-DHAVE_V4L_PLUGINS',
+        '-DLIBV4L2_PLUGIN_DIR="@0@"'.format(libv4l2_plugins_dir)
+    ]
+endif
+
+libv4l2 = shared_library('v4l2',
+                         libv4l2_sources,
+                         install : true,
+                         dependencies : libv4l2_deps,
+                         c_args : libv4l2_c_args,
+                         include_directories : libv4l2_incdir)
+
+dep_libv4l2 = declare_dependency(link_with : libv4l2)
+
+pkg.generate(
+    name : 'libv4l2',
+    libraries : libv4l2,
+    libraries_private : '-lpthread',
+    version : meson.project_version(),
+    requires_private : 'libv4lconvert',
+    description : 'v4l2 device access library')
lib/libv4lconvert/meson.build new file +79 -0
new file mode 100644
index 000000000000..cd6c4b4574f2
@@ -0,0 +1,79 @@
+libv4lconvert_sources = files(
+    'libv4lconvert.c',
+    'tinyjpeg.c',
+    'sn9c10x.c',
+    'sn9c20x.c',
+    'pac207.c',
+    'mr97310a.c',
+    'flip.c',
+    'crop.c',
+    'jidctflt.c',
+    'spca561-decompress.c',
+    'rgbyuv.c',
+    'sn9c2028-decomp.c',
+    'spca501.c',
+    'sq905c.c',
+    'bayer.c',
+    'hm12.c',
+    'stv0680.c',
+    'cpia1.c',
+    'se401.c',
+    'jpgl.c',
+    'jpeg.c',
+    'jl2005bcd.c',
+    'control/libv4lcontrol.c',
+    'control/libv4lcontrol.h',
+    'control/libv4lcontrol-priv.h',
+    'processing/libv4lprocessing.c',
+    'processing/whitebalance.c',
+    'processing/autogain.c',
+    'processing/gamma.c',
+    'processing/libv4lprocessing.h',
+    'processing/libv4lprocessing-priv.h',
+    'helper-funcs.h',
+    'libv4lconvert-priv.h',
+    'libv4lsyscall-priv.h',
+    'tinyjpeg.h',
+    'tinyjpeg-internal.h',
+)
+
+libv4lconvert_deps = [
+    dep_libm,
+    dep_librt,
+]
+
+libv4lconvert_priv_libs = [
+    '-lrt',
+    '-lm',
+]
+
+libv4lconvert_incdir = [
+    v4l2_utils_incdir,
+]
+
+libv4lconvert_c_args = []
+
+if with_jpeg
+    libv4lconvert_deps += dep_jpeg
+    libv4lconvert_priv_libs += dep_jpeg_priv_libs
+    libv4lconvert_sources += files('jpeg_memsrcdest.c', 'jpeg_memsrcdest.h')
+    libv4lconvert_c_args += [
+        '-DHAVE_JPEG',
+    ]
+endif
+
+libv4lconvert = shared_library('v4lconvert',
+                         libv4lconvert_sources,
+                         install : true,
+			 dependencies : libv4lconvert_deps,
+                         c_args : libv4lconvert_c_args,
+                         include_directories : libv4lconvert_incdir)
+
+dep_libv4lconvert = declare_dependency(link_with : libv4lconvert)
+
+pkg.generate(
+    name : 'libv4lconvert',
+    libraries : libv4lconvert,
+    libraries_private : libv4lconvert_priv_libs,
+    version : meson.project_version(),
+    description : 'v4l format conversion library')
lib/meson.build new file +6 -0
new file mode 100644
index 000000000000..a9c064b2b2dd
@@ -0,0 +1,6 @@
+if with_libdvbv5
+    subdir('libdvbv5')
+endif
+
+subdir('libv4lconvert')
+subdir('libv4l2')
meson.build new file +16 -0
new file mode 100644
index 000000000000..8dfa3b7252a5
@@ -0,0 +1,108 @@
+project('v4l-utils', 'c', 'cpp',
+    version: '1.19.0',
+    default_options : [
+        'warning_level=1',
+    ],
+    license : 'LGPL 2.1+')
+
+cc = meson.get_compiler('c')
+pkg = import('pkgconfig')
+
+conf = configuration_data()
+conf.set_quoted('V4L_UTILS_VERSION', meson.project_version())
+conf.set('PACKAGE_VERSION', meson.project_version())
+
+common_arguments = [
+    '-Wpointer-arith',
Quoted 9 lines

meson.build line 22

Quoted 6 lines
meson.build new file +6 -0
+    '-D_GNU_SOURCE',
+    '-I.', # Needed for config.h
+    '-DPROMOTED_MODE_T=int'
+]
+
+v4l2_utils_incdir = include_directories('include', 'lib/include/')

You can remove the / at the end.

OK.

Quoted 21 lines
Quoted 7 lines
meson.build new file +7 -0
+
+prog_bash = find_program('bash')
+prog_perl = find_program('perl')
+
+dep_libdl = cc.find_library('dl')
+dep_libm = cc.find_library('m')
+dep_librt = cc.find_library('rt')

meson.build line 39

Quoted 10 lines
meson.build new file +10 -0
+dep_threads = dependency('threads')
+
+have_iconv = false
+if cc.has_function('iconv_open')
+    dep_iconv = dependency('', required : false)
+    have_iconv = true
+else
+    dep_iconv = cc.find_library('iconv', required : false)
+    have_iconv = dep_iconv.found()
+endif

I think iconv should be a feature, this way we could explicitly decide to have it or now with -Diconv=disable/disable/auto.

Quoted 4 lines

Feature are important for packagers, as they want to decide which deps are included and have the build fail wanted deps is missing. This is something usually very badly implemented in custom autotools scripts.

Got it.

Quoted 10 lines
Quoted 10 lines
meson.build new file +10 -0
+
+if have_iconv
+    conf.set('HAVE_ICONV', 1)
+    iconv_const_test = '''#include <iconv.h>
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+'''
+    if cc.compiles(iconv_const_test, dependencies : dep_iconv)
+        conf.set('ICONV_CONST', '')
+    else
+        conf.set('ICONV_CONST', 'const')
Quoted 9 lines

meson.build line 55

Quoted 6 lines
meson.build new file +6 -0
+    endif
+endif
+
+
+# Optional dependencies
+dep_jpeg = dependency('libjpeg', required : false)

Should be a feature.

Got it.

Quoted 10 lines

meson.build line 58

Quoted 3 lines
meson.build new file +3 -0
+if dep_jpeg.found()
+    with_jpeg = true
+    dep_jpeg_priv_libs = '-ljpeg'

Probably imported from autotools, but I don't think you need that, meson generate the .pc files properly, and know the private libs. with_jpeg should go away, if you use a feature, and pass get_option("jpeg") to the required: in dependency() call, then the dep object is sufficient.

I was aware of it, however, without this the .pc
lacks -ljpeg:

$ cat build/meson-private/libv4lconvert.pc 
prefix=/usr/local
libdir=${prefix}/lib/x86_64-linux-gnu
includedir=${prefix}/include

Name: libv4lconvert
Description: v4l format conversion library
Version: 1.19.0
Libs: -L${libdir} -lv4lconvert
Libs.private: -lrt -lm
Cflags: -I${includedir}

As I said to Laurent, perhaps we need to report this upstream but for the time being, it seems needed.

Quoted 6 lines

meson.build line 61

Quoted 3 lines
meson.build new file +3 -0
+endif
+
+dep_udev = dependency('libudev', required : false)

Should also be a feature.

OK.

Quoted 11 lines

meson.build line 69

Quoted 8 lines
meson.build new file +8 -0
+if dep_udev.found()
+    with_udev = true
+    with_libdvbv5 = true
+else
+    with_udev = false
+    with_libdvbv5 = false
+    warning('udev library not available')
+endif

And all those with_ variable should go away.

Quoted 6 lines

meson.build line 72

Quoted 3 lines
meson.build new file +3 -0
+
+# Found options
+with_v4l_plugins = get_option('v4l-plugins')

You shouldn't hide options, just call get_option when needed.

OK.

Quoted 31 lines
Quoted 31 lines
meson.build new file +31 -0
+
+c_arguments = []
+cpp_arguments = []
+
+c_arguments += common_arguments
+cpp_arguments += common_arguments
+
+add_project_arguments(c_arguments, language : 'c')
+add_project_arguments(cpp_arguments, language : 'cpp')
+add_project_link_arguments(cpp_arguments, language : 'cpp')
+
+version_h = vcs_tag(command : ['gen-version.sh', meson.build_root()],
+                    input : 'version.h.in',
+                    output : 'version.h',
+                    fallback : meson.project_version())
+
+subdir('lib')
+
+if get_option('v4l-utils')
+    subdir('utils')
+endif
+
+configure_file(output : 'config.h', configuration : conf)
+
+message('')
+message('  jpeg                       @0@'.format(with_jpeg ? 'yes' : 'no' ))
+message('  udev                       @0@'.format(with_udev ? 'yes' : 'no' ))
+message('  libdvbv5                   @0@'.format(with_libdvbv5 ? 'yes' : 'no' ))
+message('  v4l plugins                @0@'.format(with_v4l_plugins ? 'yes' : 'no' ))
+message('  v4l-utils                  @0@'.format(get_option('v4l-utils') ? 'yes' : 'no' ))
+if get_option('v4l-utils')
Quoted 9 lines

meson.build line 107

Quoted 4 lines
meson.build new file +4 -0
+message('  v4l2-compliance-libv4l2    @0@'.format(get_option('v4l2-compliance-libv4l') ? 'yes' : 'no' ))
+message('  v4l2-ctl-libv4l            @0@'.format(get_option('v4l2-ctl-libv4l') ? 'yes' : 'no' ))
+message('  v4l2-ctl-stream-to         @0@'.format(get_option('v4l2-ctl-stream-to') ? 'yes' : 'no' ))
+endif

Custom reporting is no longer recommended, meson have a option driven report (summary). The plus side is that it will be printed at the end properly even if this project is used as subproject.

OK.

Thanks,
Ezequiel

Quoted 480 lines
Quoted 480 lines
meson.build new file +1 -0
+message('')
meson_options.txt new file +19 -0
new file mode 100644
index 000000000000..93cc71f1592d
@@ -0,0 +1,19 @@
+option('v4l-utils',
+        type : 'boolean',
+        description : 'Enable v4l-utils')
+
+option('v4l2-compliance-libv4l',
+        type : 'boolean',
+        description : 'Enable use of libv4l in v4l2-compliance')
+
+option('v4l2-ctl-libv4l',
+        type : 'boolean',
+        description : 'Enable use of libv4l in v4l2-ctl')
+
+option('v4l2-ctl-stream-to',
+        type : 'boolean',
+        description : 'Enable use of --stream-to in v4l2-ctl')
+
+option('v4l-plugins',
+        type : 'boolean',
+        description : 'V4L plugin support')
utils/cec-compliance/meson.build new file +39 -0
new file mode 100644
index 000000000000..fd165586fc0d
@@ -0,0 +1,39 @@
+name = 'cec-compliance'
+
+cec_compliance_sources = files(
+    'cec-compliance.cpp',
+    'cec-compliance.h',
+    'cec-test.cpp',
+    'cec-test-adapter.cpp',
+    'cec-test-audio.cpp',
+    'cec-test-power.cpp',
+    'cec-test-fuzzing.cpp',
+)
+
+cec_compliance_sources += version_h
+cec_compliance_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+
+cec_compliance_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_compliance_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_compliance = executable(name,
+                      cec_compliance_sources,
+                      install : true,
+                      dependencies : cec_compliance_deps,
+                      cpp_args : cec_compliance_cpp_args,
+                      include_directories : cec_compliance_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/cec-ctl/meson.build new file +33 -0
new file mode 100644
index 000000000000..5030cfd16de9
@@ -0,0 +1,33 @@
+name = 'cec-ctl'
+
+cec_ctl_sources = files(
+    'cec-ctl.cpp',
+    'cec-pin.cpp',
+    'cec-ctl.h',
+)
+
+cec_ctl_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+cec_ctl_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_ctl_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_ctl = executable(name,
+                     cec_ctl_sources,
+                     install : true,
+                     dependencies : cec_ctl_deps,
+                     cpp_args : cec_ctl_cpp_args,
+		     include_directories : cec_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/cec-follower/meson.build new file +35 -0
new file mode 100644
index 000000000000..bfa707b5d62a
@@ -0,0 +1,35 @@
+name = 'cec-follower'
+
+cec_follower_sources = files(
+    'cec-follower.cpp',
+    'cec-follower.h',
+    'cec-processing.cpp',
+    'cec-tuner.cpp',
+)
+
+cec_follower_sources += version_h
+cec_follower_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+cec_follower_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_follower_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_follower = executable(name,
+                      cec_follower_sources,
+                      install : true,
+                      dependencies : cec_follower_deps,
+                      cpp_args : cec_follower_cpp_args,
+		      include_directories : cec_follower_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/gen_media_bus_format_codes.sh new file +7 -0
new file mode 100644
index 000000000000..18d1e9f3f317
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+src="$1"
+
+sed -e \
+'/#define MEDIA_BUS_FMT/ ! d; s/.*#define //; /FIXED/ d; s/\t.*//; s/.*/ &,/;' \
+${src}
utils/gen_media_bus_format_names.sh new file +7 -0
new file mode 100644
index 000000000000..79cb16756bc3
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+src="$1"
+
+sed -e \
+'/#define MEDIA_BUS_FMT/ ! d; s/.*FMT_//; /FIXED/ d; s/\t.*//; s/.*/{ \"&\", MEDIA_BUS_FMT_& },/;' \
+${src}
utils/ir-ctl/meson.build new file +30 -0
new file mode 100644
index 000000000000..3c0db8aa769a
@@ -0,0 +1,30 @@
+name = 'ir-ctl'
+
+ir_ctl_sources = files(
+    'ir-ctl.c',
+    'ir-encode.c',
+    'ir-encode.h',
+    'toml.c',
+    'toml.h',
+    'keymap.c',
+    'keymap.h',
+    'bpf_encoder.c',
+    'bpf_encoder.h'
+)
+
+ir_ctl_deps = []
+ir_ctl_cpp_args = []
+ir_ctl_incdir = []
+
+ir_ctl = executable(name,
+                    ir_ctl_sources,
+                    install : true,
+                    dependencies : ir_ctl_deps,
+                    cpp_args : ir_ctl_cpp_args,
+		    include_directories : ir_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/libcecutil/meson.build new file +46 -0
new file mode 100644
index 000000000000..097cb274cfa3
@@ -0,0 +1,46 @@
+libcecutil_sources = files(
+    'cec-info.cpp',
+    'cec-log.cpp',
+    'cec-parse.cpp',
+    'cec-info.h',
+    'cec-log.h',
+    'cec-parse.h',
+    'cec-htng.h',
+    'cec-htng-funcs.h',
+)
+
+libcecutil_deps = [
+    dep_libv4lconvert,
+    dep_libdl,
+    dep_threads,
+]
+
+libcecutil_incdir = [
+    utils_common_incdir,
+    v4l2_utils_incdir,
+]
+
+libcecutil_c_args = []
+
+cec_gen_sources = files(
+    '../../include/linux/cec.h',
+    'cec-htng.h',
+    '../../include/linux/cec-funcs.h',
+    'cec-htng-funcs.h',
+)
+
+configure_file(
+    input : 'cec-gen.pl',
+    output : 'cec-gen-dummy.stamp',
+    command: [
+        prog_perl, '@INPUT@', cec_gen_sources, 'utils/libcecutil'
+    ]
+)
+
+libcecutil = static_library('cecutil',
+                         libcecutil_sources,
+                         install : true,
+                         dependencies : libcecutil_deps,
+                         c_args : libcecutil_c_args,
+                         include_directories : libcecutil_incdir)
+dep_libcecutil = declare_dependency(link_with : libcecutil)
utils/media-ctl/meson.build new file +35 -0
new file mode 100644
index 000000000000..258aea7bea3f
@@ -0,0 +1,35 @@
+libmediactl_sources = files(
+    'libmediactl.c',
+    'mediactl-priv.h',
+)
+
+libmediactl_deps = []
+
+libmediactl = static_library('mediactl',
+                             libmediactl_sources,
+                             dependencies : libmediactl_deps)
+
+pkg.generate(
+    name : 'libmediactl',
+    libraries : libmediactl,
+    version : meson.project_version(),
+    description : 'Media controller library')
+
+libv4l2subdev_sources = files('libv4l2subdev.c')
+libv4l2subdev_sources += media_bus_format_names_h
+libv4l2subdev_sources += media_bus_format_codes_h
+
+libv4l2subdev = static_library('v4l2subdev',
+                               libv4l2subdev_sources)
+
+media_ctl_sources = files(
+    'media-ctl.c',
+    'options.c',
+    'options.h',
+    'tools.h',
+)
+
+media_ctl = executable('media-ctl',
+                       media_ctl_sources,
+                       install : true,
+		       link_with : [libmediactl, libv4l2subdev])
utils/meson.build new file +32 -0
new file mode 100644
index 000000000000..d4bb4b50142d
@@ -0,0 +1,32 @@
+utils_common_incdir = include_directories('common')
+
+# Generate targets for media-bus-format-{names,codes}.h
+foreach x: [ 'names', 'codes' ]
+    output_file = 'media-bus-format-@[email protected]'.format(x)
+    input_file = 'gen_media_bus_format_@[email protected]'.format(x)
+
+    target = custom_target(
+        output_file,
+        output : output_file,
+        input : input_file,
+	command : [
+            prog_bash, '@INPUT@', files('../include/linux/media-bus-format.h'),
+        ],
+        capture : true,
+    )
+    set_variable(output_file.underscorify(), target)
+endforeach
+
+# Libraries
+subdir('libcecutil')
+
+# Utils
+subdir('cec-ctl')
+subdir('cec-follower')
+subdir('ir-ctl')
+subdir('media-ctl')
+subdir('v4l2-ctl')
+
+# Compliance tools
+subdir('cec-compliance')
+subdir('v4l2-compliance')
utils/v4l2-compliance/meson.build new file +52 -0
new file mode 100644
index 000000000000..534b7bf4cb4e
@@ -0,0 +1,52 @@
+name = 'v4l2-compliance'
+
+v4l2_compliance_sources = files(
+    'v4l2-compliance.cpp',
+    'v4l2-compliance.h',
+    'v4l2-test-debug.cpp',
+    'v4l2-test-input-output.cpp',
+    'v4l2-test-controls.cpp',
+    'v4l2-test-io-config.cpp',
+    'v4l2-test-formats.cpp',
+    'v4l2-test-buffers.cpp',
+    'v4l2-test-codecs.cpp',
+    'v4l2-test-subdevs.cpp',
+    'v4l2-test-media.cpp',
+    'v4l2-test-colors.cpp',
+    'media-info.cpp',
+    'v4l2-info.cpp',
+)
+
+v4l2_compliance_sources += version_h
+v4l2_compliance_deps = [
+    dep_librt,
+    dep_threads,
+]
+v4l2_compliance_cpp_args = []
+
+if get_option('v4l2-compliance-libv4l')
+    v4l2_compliance_deps += dep_libv4lconvert
+    v4l2_compliance_deps += dep_libv4l2
+else
+    v4l2_compliance_cpp_args += '-DNO_LIBV4L2'
+endif
+
+common_incdir = include_directories('../common')
+
+v4l2_compliance_incdir = [
+    common_incdir,
+    v4l2_utils_incdir,
+]
+
+v4l2_compliance = executable(name,
+                      v4l2_compliance_sources,
+                      install : true,
+                      dependencies : v4l2_compliance_deps,
+                      cpp_args : v4l2_compliance_cpp_args,
+                      include_directories : v4l2_compliance_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/v4l2-ctl/meson.build new file +65 -0
new file mode 100644
index 000000000000..1bbc7fe44313
@@ -0,0 +1,65 @@
+name = 'v4l2-ctl'
+
+v4l2_ctl_sources = files(
+    'v4l2-ctl.cpp',
+    'v4l2-ctl.h',
+    'v4l2-ctl-common.cpp',
+    'v4l2-ctl-tuner.cpp',
+    'v4l2-ctl-io.cpp',
+    'v4l2-ctl-stds.cpp',
+    'v4l2-ctl-vidcap.cpp',
+    'v4l2-ctl-vidout.cpp',
+    'v4l2-ctl-overlay.cpp',
+    'v4l2-ctl-vbi.cpp',
+    'v4l2-ctl-selection.cpp',
+    'v4l2-ctl-misc.cpp',
+    'v4l2-ctl-streaming.cpp',
+    'v4l2-ctl-sdr.cpp',
+    'v4l2-ctl-edid.cpp',
+    'v4l2-ctl-modes.cpp',
+    'v4l2-ctl-subdev.cpp',
+    'v4l2-tpg-colors.c',
+    'v4l2-tpg-core.c',
+    'v4l-stream.c',
+    'v4l2-ctl-meta.cpp',
+    'media-info.cpp',
+    'v4l2-info.cpp',
+    'codec-fwht.c',
+    'codec-v4l2-fwht.c',
+)
+v4l2_ctl_sources += media_bus_format_names_h
+
+v4l2_ctl_deps = [
+    dep_librt,
+    dep_threads,
+]
+v4l2_ctl_cpp_args = []
+
+if get_option('v4l2-ctl-libv4l')
+    v4l2_ctl_deps += dep_libv4lconvert
+    v4l2_ctl_deps += dep_libv4l2
+else
+    v4l2_ctl_cpp_args += '-DNO_LIBV4L2'
+endif
+
+if not get_option('v4l2-ctl-stream-to')
+    v4l2_ctl_cpp_args += '-DNO_STREAM_TO'
+endif
+
+v4l2_ctl_incdir = [
+    utils_common_incdir,
+    v4l2_utils_incdir,
+]
+
+v4l2_ctl = executable(name,
+                      v4l2_ctl_sources,
+                      install : true,
+                      dependencies : v4l2_ctl_deps,
+                      cpp_args : v4l2_ctl_cpp_args,
+		      include_directories : v4l2_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
version.h.in new file +1 -0
new file mode 100644
index 000000000000..2506ed9bc6cc
@@ -0,0 +1 @@
+#define SHA @VCS_TAG@
#6 lore raw

Re: [RFC PATCH v4l-utils 1/1] Introduce support for meson building

In reply to Nicolas Dufresne

Hi Nicolas,

Quoted 489 lines · Nicolas Dufresne
Quoted 207 lines · Ezequiel Garcia

Currently supports:

* libdvbv5
* libv4l2
* libv4lconvert
* cec-ctl
* cec-compliance
* cec-follower
* ir-ctl
* media-ctl
* v4l2-ctl
* v4l2-compliance

---
 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in
gen-version.sh new file +36 -0
new file mode 100755
index 000000000000..9223ab7d0a32
@@ -0,0 +1,36 @@
+#!/bin/sh
+# gen-version.sh script taken from the libcamera project.
+# Generate a version string using git describe.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+build_dir="$1"
+
+# Bail out if the directory isn't under git control
+src_dir=$(git rev-parse --git-dir 2>&1) || exit 1
+src_dir=$(readlink -f "$src_dir/..")
+
+# Get a short description from the tree.
+version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null)
+
+if [ -z "$version" ]
+then
+	# Handle an un-tagged repository
+	sha=$(git describe --abbrev=8 --always 2>/dev/null)
+	commits=$(git log --oneline | wc -l 2>/dev/null)
+	version="v4l-utils-0.0.0-$commits-g$sha"
+fi
+
+# Append a '-dirty' suffix if the working tree is dirty. Prevent false
+# positives due to changed timestamps by running git update-index.
+if [ -z "$build_dir" ] || (echo "$build_dir" | grep -q "$src_dir")
+then
+	git update-index --refresh > /dev/null 2>&1
+fi
+git diff-index --quiet HEAD || version="$version-dirty"
+
+# Replace first '-' with a '+' to denote build metadata, strip the 'g' in from
+# of the git SHA1 and remove the initial 'v'.
+version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 11-)
+
+echo "$version"
lib/libdvbv5/meson.build new file +87 -0
new file mode 100644
index 000000000000..35eda2da4692
@@ -0,0 +1,87 @@
+libdvbv5_sources = files(
+    'compat-soname.c',
+    'crc32.c',
+    'countries.c',
+    'dvb-legacy-channel-format.c',
+    'dvb-zap-format.c',
+    'dvb-vdr-format.c',
+    'dvb-v5.c',
+    'dvb-v5.h',
+    'parse_string.c',
+    'parse_string.h',
+    'dvb-demux.c',
+    'dvb-dev.c',
+    'dvb-dev-local.c',
+    'dvb-dev-priv.h',
+    'dvb-dev-remote.c',
+    'dvb-fe.c',
+    'dvb-fe-priv.h',
+    'dvb-log.c',
+    'dvb-file.c',
+    'dvb-v5-std.c',
+    'dvb-sat.c',
+    'dvb-scan.c',
+    'descriptors.c',
+    'tables/header.c',
+    'tables/pat.c',
+    'tables/pmt.c',
+    'tables/nit.c',
+    'tables/sdt.c',
+    'tables/vct.c',
+    'tables/mgt.c',
+    'tables/eit.c',
+    'tables/cat.c',
+    'tables/atsc_eit.c',
+    'tables/mpeg_ts.c',
+    'tables/mpeg_pes.c',
+    'tables/mpeg_es.c',
+    'descriptors/desc_language.c',
+    'descriptors/desc_network_name.c',
+    'descriptors/desc_cable_delivery.c',
+    'descriptors/desc_sat.c',
+    'descriptors/desc_terrestrial_delivery.c',
+    'descriptors/desc_t2_delivery.c',
+    'descriptors/desc_service.c',
+    'descriptors/desc_frequency_list.c',
+    'descriptors/desc_event_short.c',
+    'descriptors/desc_event_extended.c',
+    'descriptors/desc_atsc_service_location.c',
+    'descriptors/desc_hierarchy.c',
+    'descriptors/desc_extension.c',
+    'descriptors/desc_isdbt_delivery.c',
+    'descriptors/desc_logical_channel.c',
+    'descriptors/desc_ts_info.c',
+    'descriptors/desc_partial_reception.c',
+    'descriptors/desc_ca.c',
+    'descriptors/desc_ca_identifier.c',
+)
+
+libdvbv5_deps = [
+    dep_libm,
+    dep_threads,
+    dep_udev,
+]
+
+libdvbv5_incdir = [
+    v4l2_utils_incdir,
+]
+
+libdvbv5_c_args = [
+    '-DHAVE_DVBV5_REMOTE',
+]
+
+libdvbv5 = shared_library('dvbv5',
+                         libdvbv5_sources,
+                         install : true,
+			 dependencies : libdvbv5_deps,
+                         c_args : libdvbv5_c_args,
+                         include_directories : libdvbv5_incdir)
+
+dep_libdvbv5 = declare_dependency(link_with : libdvbv5)
+
+pkg.generate(
+    name : 'libdvbv5',
+    libraries : libdvbv5,
+    version : meson.project_version(),
+    requires_private : 'libudev',
+    description : 'DVBv5 utility library')
lib/libv4l2/meson.build new file +11 -0
new file mode 100644
index 000000000000..eefe680620c5
@@ -0,0 +1,43 @@
+libv4l2_sources = files(
+    'libv4l2.c',
+    'log.c',
+    'libv4l2-priv.h',
+)
+
+libv4l2_deps = [
+    dep_libv4lconvert,
+    dep_libdl,
+    dep_threads,
+]

lib/libv4l2/meson.build line 21

Quoted 10 lines
lib/libv4l2/meson.build new file +10 -0
+
+libv4l2_incdir = [
+    v4l2_utils_incdir,
+]
+
+libv4l2_c_args = []
+
+if with_v4l_plugins
+    libv4l2_sources += files('v4l2-plugin.c')
+    libv4l2_plugins_dir = join_paths(get_option('prefix'), get_option('libdir'), 'libv4l/plugins')

Meson now have the / operator, that allow you do write the same line as:

+ libv4l2_plugins_dir = get_option('prefix') / get_option('libdir') / 'libv4l' / 'plugins'

Specially that in this case you use the portable join_paths, and then have a "libv4l2/plugins" later, which is not very consitent (but this is Linux library, so not problematic.

I'm stopping there, as I'm sure you get the idea how to improve this. Nice work.

Quoted 137 lines
lib/libv4l2/meson.build new file +22 -0
+    libv4l2_c_args += [
+        '-DHAVE_V4L_PLUGINS',
+        '-DLIBV4L2_PLUGIN_DIR="@0@"'.format(libv4l2_plugins_dir)
+    ]
+endif
+
+libv4l2 = shared_library('v4l2',
+                         libv4l2_sources,
+                         install : true,
+                         dependencies : libv4l2_deps,
+                         c_args : libv4l2_c_args,
+                         include_directories : libv4l2_incdir)
+
+dep_libv4l2 = declare_dependency(link_with : libv4l2)
+
+pkg.generate(
+    name : 'libv4l2',
+    libraries : libv4l2,
+    libraries_private : '-lpthread',
+    version : meson.project_version(),
+    requires_private : 'libv4lconvert',
+    description : 'v4l2 device access library')
lib/libv4lconvert/meson.build new file +79 -0
new file mode 100644
index 000000000000..cd6c4b4574f2
@@ -0,0 +1,79 @@
+libv4lconvert_sources = files(
+    'libv4lconvert.c',
+    'tinyjpeg.c',
+    'sn9c10x.c',
+    'sn9c20x.c',
+    'pac207.c',
+    'mr97310a.c',
+    'flip.c',
+    'crop.c',
+    'jidctflt.c',
+    'spca561-decompress.c',
+    'rgbyuv.c',
+    'sn9c2028-decomp.c',
+    'spca501.c',
+    'sq905c.c',
+    'bayer.c',
+    'hm12.c',
+    'stv0680.c',
+    'cpia1.c',
+    'se401.c',
+    'jpgl.c',
+    'jpeg.c',
+    'jl2005bcd.c',
+    'control/libv4lcontrol.c',
+    'control/libv4lcontrol.h',
+    'control/libv4lcontrol-priv.h',
+    'processing/libv4lprocessing.c',
+    'processing/whitebalance.c',
+    'processing/autogain.c',
+    'processing/gamma.c',
+    'processing/libv4lprocessing.h',
+    'processing/libv4lprocessing-priv.h',
+    'helper-funcs.h',
+    'libv4lconvert-priv.h',
+    'libv4lsyscall-priv.h',
+    'tinyjpeg.h',
+    'tinyjpeg-internal.h',
+)
+
+libv4lconvert_deps = [
+    dep_libm,
+    dep_librt,
+]
+
+libv4lconvert_priv_libs = [
+    '-lrt',
+    '-lm',
+]
+
+libv4lconvert_incdir = [
+    v4l2_utils_incdir,
+]
+
+libv4lconvert_c_args = []
+
+if with_jpeg
+    libv4lconvert_deps += dep_jpeg
+    libv4lconvert_priv_libs += dep_jpeg_priv_libs
+    libv4lconvert_sources += files('jpeg_memsrcdest.c', 'jpeg_memsrcdest.h')
+    libv4lconvert_c_args += [
+        '-DHAVE_JPEG',
+    ]
+endif
+
+libv4lconvert = shared_library('v4lconvert',
+                         libv4lconvert_sources,
+                         install : true,
+			 dependencies : libv4lconvert_deps,
+                         c_args : libv4lconvert_c_args,
+                         include_directories : libv4lconvert_incdir)
+
+dep_libv4lconvert = declare_dependency(link_with : libv4lconvert)
+
+pkg.generate(
+    name : 'libv4lconvert',
+    libraries : libv4lconvert,
+    libraries_private : libv4lconvert_priv_libs,
+    version : meson.project_version(),
+    description : 'v4l format conversion library')
lib/meson.build new file +6 -0
new file mode 100644
index 000000000000..a9c064b2b2dd
@@ -0,0 +1,6 @@
+if with_libdvbv5
+    subdir('libdvbv5')
+endif
+
+subdir('libv4lconvert')
+subdir('libv4l2')
meson.build new file +12 -0
new file mode 100644
index 000000000000..8dfa3b7252a5
@@ -0,0 +1,108 @@
+project('v4l-utils', 'c', 'cpp',
+    version: '1.19.0',
+    default_options : [
+        'warning_level=1',
+    ],
+    license : 'LGPL 2.1+')
+
+cc = meson.get_compiler('c')
+pkg = import('pkgconfig')
+
+conf = configuration_data()
+conf.set_quoted('V4L_UTILS_VERSION', meson.project_version())

meson.build line 22

Quoted 10 lines
meson.build new file +10 -0
+conf.set('PACKAGE_VERSION', meson.project_version())
+
+common_arguments = [
+    '-Wpointer-arith',
+    '-D_GNU_SOURCE',
+    '-I.', # Needed for config.h
+    '-DPROMOTED_MODE_T=int'
+]
+
+v4l2_utils_incdir = include_directories('include', 'lib/include/')

You can remove the / at the end.

Quoted 7 lines
meson.build new file +7 -0
+
+prog_bash = find_program('bash')
+prog_perl = find_program('perl')
+
+dep_libdl = cc.find_library('dl')
+dep_libm = cc.find_library('m')
+dep_librt = cc.find_library('rt')

meson.build line 39

Quoted 10 lines
meson.build new file +10 -0
+dep_threads = dependency('threads')
+
+have_iconv = false
+if cc.has_function('iconv_open')
+    dep_iconv = dependency('', required : false)
+    have_iconv = true
+else
+    dep_iconv = cc.find_library('iconv', required : false)
+    have_iconv = dep_iconv.found()
+endif

I think iconv should be a feature, this way we could explicitly decide to have it or now with -Diconv=disable/disable/auto.

Feature are important for packagers, as they want to decide which deps are included and have the build fail wanted deps is missing. This is something usually very badly implemented in custom autotools scripts.

Quoted 6 lines
meson.build new file +6 -0
+
+if have_iconv
+    conf.set('HAVE_ICONV', 1)
+    iconv_const_test = '''#include <iconv.h>
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+'''

meson.build line 55

Quoted 10 lines
meson.build new file +10 -0
+    if cc.compiles(iconv_const_test, dependencies : dep_iconv)
+        conf.set('ICONV_CONST', '')
+    else
+        conf.set('ICONV_CONST', 'const')
+    endif
+endif
+
+
+# Optional dependencies
+dep_jpeg = dependency('libjpeg', required : false)

Should be a feature.

meson.build line 58

Quoted 3 lines
meson.build new file +3 -0
+if dep_jpeg.found()
+    with_jpeg = true
+    dep_jpeg_priv_libs = '-ljpeg'

Probably imported from autotools, but I don't think you need that, meson generate the .pc files properly, and know the private libs. with_jpeg should go away, if you use a feature, and pass get_option("jpeg") to the required: in dependency() call, then the dep object is sufficient.

meson.build line 61

Quoted 3 lines
meson.build new file +3 -0
+endif
+
+dep_udev = dependency('libudev', required : false)

Should also be a feature.

meson.build line 69

Quoted 8 lines
meson.build new file +8 -0
+if dep_udev.found()
+    with_udev = true
+    with_libdvbv5 = true
+else
+    with_udev = false
+    with_libdvbv5 = false
+    warning('udev library not available')
+endif

And all those with_ variable should go away.

meson.build line 72

Quoted 3 lines
meson.build new file +3 -0
+
+# Found options
+with_v4l_plugins = get_option('v4l-plugins')

You shouldn't hide options, just call get_option when needed.

Quoted 31 lines
meson.build new file +31 -0
+
+c_arguments = []
+cpp_arguments = []
+
+c_arguments += common_arguments
+cpp_arguments += common_arguments
+
+add_project_arguments(c_arguments, language : 'c')
+add_project_arguments(cpp_arguments, language : 'cpp')
+add_project_link_arguments(cpp_arguments, language : 'cpp')
+
+version_h = vcs_tag(command : ['gen-version.sh', meson.build_root()],
+                    input : 'version.h.in',
+                    output : 'version.h',
+                    fallback : meson.project_version())
+
+subdir('lib')
+
+if get_option('v4l-utils')
+    subdir('utils')
+endif
+
+configure_file(output : 'config.h', configuration : conf)
+
+message('')
+message('  jpeg                       @0@'.format(with_jpeg ? 'yes' : 'no' ))
+message('  udev                       @0@'.format(with_udev ? 'yes' : 'no' ))
+message('  libdvbv5                   @0@'.format(with_libdvbv5 ? 'yes' : 'no' ))
+message('  v4l plugins                @0@'.format(with_v4l_plugins ? 'yes' : 'no' ))
+message('  v4l-utils                  @0@'.format(get_option('v4l-utils') ? 'yes' : 'no' ))
+if get_option('v4l-utils')
Quoted 8 lines

meson.build line 107

Quoted 4 lines
meson.build new file +4 -0
+message('  v4l2-compliance-libv4l2    @0@'.format(get_option('v4l2-compliance-libv4l') ? 'yes' : 'no' ))
+message('  v4l2-ctl-libv4l            @0@'.format(get_option('v4l2-ctl-libv4l') ? 'yes' : 'no' ))
+message('  v4l2-ctl-stream-to         @0@'.format(get_option('v4l2-ctl-stream-to') ? 'yes' : 'no' ))
+endif

Custom reporting is no longer recommended, meson have a option driven report (summary). The plus side is that it will be printed at the end properly even if this project is used as subproject.

I didn't know about that, it's nice. The option has been added to meson 0.53 though, which may be a tad too recent ?

Quoted 480 lines
Quoted 480 lines
meson.build new file +1 -0
+message('')
meson_options.txt new file +19 -0
new file mode 100644
index 000000000000..93cc71f1592d
@@ -0,0 +1,19 @@
+option('v4l-utils',
+        type : 'boolean',
+        description : 'Enable v4l-utils')
+
+option('v4l2-compliance-libv4l',
+        type : 'boolean',
+        description : 'Enable use of libv4l in v4l2-compliance')
+
+option('v4l2-ctl-libv4l',
+        type : 'boolean',
+        description : 'Enable use of libv4l in v4l2-ctl')
+
+option('v4l2-ctl-stream-to',
+        type : 'boolean',
+        description : 'Enable use of --stream-to in v4l2-ctl')
+
+option('v4l-plugins',
+        type : 'boolean',
+        description : 'V4L plugin support')
utils/cec-compliance/meson.build new file +39 -0
new file mode 100644
index 000000000000..fd165586fc0d
@@ -0,0 +1,39 @@
+name = 'cec-compliance'
+
+cec_compliance_sources = files(
+    'cec-compliance.cpp',
+    'cec-compliance.h',
+    'cec-test.cpp',
+    'cec-test-adapter.cpp',
+    'cec-test-audio.cpp',
+    'cec-test-power.cpp',
+    'cec-test-fuzzing.cpp',
+)
+
+cec_compliance_sources += version_h
+cec_compliance_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+
+cec_compliance_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_compliance_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_compliance = executable(name,
+                      cec_compliance_sources,
+                      install : true,
+                      dependencies : cec_compliance_deps,
+                      cpp_args : cec_compliance_cpp_args,
+                      include_directories : cec_compliance_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/cec-ctl/meson.build new file +33 -0
new file mode 100644
index 000000000000..5030cfd16de9
@@ -0,0 +1,33 @@
+name = 'cec-ctl'
+
+cec_ctl_sources = files(
+    'cec-ctl.cpp',
+    'cec-pin.cpp',
+    'cec-ctl.h',
+)
+
+cec_ctl_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+cec_ctl_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_ctl_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_ctl = executable(name,
+                     cec_ctl_sources,
+                     install : true,
+                     dependencies : cec_ctl_deps,
+                     cpp_args : cec_ctl_cpp_args,
+		     include_directories : cec_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/cec-follower/meson.build new file +35 -0
new file mode 100644
index 000000000000..bfa707b5d62a
@@ -0,0 +1,35 @@
+name = 'cec-follower'
+
+cec_follower_sources = files(
+    'cec-follower.cpp',
+    'cec-follower.h',
+    'cec-processing.cpp',
+    'cec-tuner.cpp',
+)
+
+cec_follower_sources += version_h
+cec_follower_deps = [
+    dep_libcecutil,
+    dep_librt,
+]
+cec_follower_cpp_args = []
+
+libcecutil_incdir = include_directories('../libcecutil/')
+
+cec_follower_incdir = [
+    v4l2_utils_incdir,
+    libcecutil_incdir,
+]
+
+cec_follower = executable(name,
+                      cec_follower_sources,
+                      install : true,
+                      dependencies : cec_follower_deps,
+                      cpp_args : cec_follower_cpp_args,
+		      include_directories : cec_follower_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/gen_media_bus_format_codes.sh new file +7 -0
new file mode 100644
index 000000000000..18d1e9f3f317
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+src="$1"
+
+sed -e \
+'/#define MEDIA_BUS_FMT/ ! d; s/.*#define //; /FIXED/ d; s/\t.*//; s/.*/ &,/;' \
+${src}
utils/gen_media_bus_format_names.sh new file +7 -0
new file mode 100644
index 000000000000..79cb16756bc3
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+src="$1"
+
+sed -e \
+'/#define MEDIA_BUS_FMT/ ! d; s/.*FMT_//; /FIXED/ d; s/\t.*//; s/.*/{ \"&\", MEDIA_BUS_FMT_& },/;' \
+${src}
utils/ir-ctl/meson.build new file +30 -0
new file mode 100644
index 000000000000..3c0db8aa769a
@@ -0,0 +1,30 @@
+name = 'ir-ctl'
+
+ir_ctl_sources = files(
+    'ir-ctl.c',
+    'ir-encode.c',
+    'ir-encode.h',
+    'toml.c',
+    'toml.h',
+    'keymap.c',
+    'keymap.h',
+    'bpf_encoder.c',
+    'bpf_encoder.h'
+)
+
+ir_ctl_deps = []
+ir_ctl_cpp_args = []
+ir_ctl_incdir = []
+
+ir_ctl = executable(name,
+                    ir_ctl_sources,
+                    install : true,
+                    dependencies : ir_ctl_deps,
+                    cpp_args : ir_ctl_cpp_args,
+		    include_directories : ir_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/libcecutil/meson.build new file +46 -0
new file mode 100644
index 000000000000..097cb274cfa3
@@ -0,0 +1,46 @@
+libcecutil_sources = files(
+    'cec-info.cpp',
+    'cec-log.cpp',
+    'cec-parse.cpp',
+    'cec-info.h',
+    'cec-log.h',
+    'cec-parse.h',
+    'cec-htng.h',
+    'cec-htng-funcs.h',
+)
+
+libcecutil_deps = [
+    dep_libv4lconvert,
+    dep_libdl,
+    dep_threads,
+]
+
+libcecutil_incdir = [
+    utils_common_incdir,
+    v4l2_utils_incdir,
+]
+
+libcecutil_c_args = []
+
+cec_gen_sources = files(
+    '../../include/linux/cec.h',
+    'cec-htng.h',
+    '../../include/linux/cec-funcs.h',
+    'cec-htng-funcs.h',
+)
+
+configure_file(
+    input : 'cec-gen.pl',
+    output : 'cec-gen-dummy.stamp',
+    command: [
+        prog_perl, '@INPUT@', cec_gen_sources, 'utils/libcecutil'
+    ]
+)
+
+libcecutil = static_library('cecutil',
+                         libcecutil_sources,
+                         install : true,
+                         dependencies : libcecutil_deps,
+                         c_args : libcecutil_c_args,
+                         include_directories : libcecutil_incdir)
+dep_libcecutil = declare_dependency(link_with : libcecutil)
utils/media-ctl/meson.build new file +35 -0
new file mode 100644
index 000000000000..258aea7bea3f
@@ -0,0 +1,35 @@
+libmediactl_sources = files(
+    'libmediactl.c',
+    'mediactl-priv.h',
+)
+
+libmediactl_deps = []
+
+libmediactl = static_library('mediactl',
+                             libmediactl_sources,
+                             dependencies : libmediactl_deps)
+
+pkg.generate(
+    name : 'libmediactl',
+    libraries : libmediactl,
+    version : meson.project_version(),
+    description : 'Media controller library')
+
+libv4l2subdev_sources = files('libv4l2subdev.c')
+libv4l2subdev_sources += media_bus_format_names_h
+libv4l2subdev_sources += media_bus_format_codes_h
+
+libv4l2subdev = static_library('v4l2subdev',
+                               libv4l2subdev_sources)
+
+media_ctl_sources = files(
+    'media-ctl.c',
+    'options.c',
+    'options.h',
+    'tools.h',
+)
+
+media_ctl = executable('media-ctl',
+                       media_ctl_sources,
+                       install : true,
+		       link_with : [libmediactl, libv4l2subdev])
utils/meson.build new file +32 -0
new file mode 100644
index 000000000000..d4bb4b50142d
@@ -0,0 +1,32 @@
+utils_common_incdir = include_directories('common')
+
+# Generate targets for media-bus-format-{names,codes}.h
+foreach x: [ 'names', 'codes' ]
+    output_file = 'media-bus-format-@[email protected]'.format(x)
+    input_file = 'gen_media_bus_format_@[email protected]'.format(x)
+
+    target = custom_target(
+        output_file,
+        output : output_file,
+        input : input_file,
+	command : [
+            prog_bash, '@INPUT@', files('../include/linux/media-bus-format.h'),
+        ],
+        capture : true,
+    )
+    set_variable(output_file.underscorify(), target)
+endforeach
+
+# Libraries
+subdir('libcecutil')
+
+# Utils
+subdir('cec-ctl')
+subdir('cec-follower')
+subdir('ir-ctl')
+subdir('media-ctl')
+subdir('v4l2-ctl')
+
+# Compliance tools
+subdir('cec-compliance')
+subdir('v4l2-compliance')
utils/v4l2-compliance/meson.build new file +52 -0
new file mode 100644
index 000000000000..534b7bf4cb4e
@@ -0,0 +1,52 @@
+name = 'v4l2-compliance'
+
+v4l2_compliance_sources = files(
+    'v4l2-compliance.cpp',
+    'v4l2-compliance.h',
+    'v4l2-test-debug.cpp',
+    'v4l2-test-input-output.cpp',
+    'v4l2-test-controls.cpp',
+    'v4l2-test-io-config.cpp',
+    'v4l2-test-formats.cpp',
+    'v4l2-test-buffers.cpp',
+    'v4l2-test-codecs.cpp',
+    'v4l2-test-subdevs.cpp',
+    'v4l2-test-media.cpp',
+    'v4l2-test-colors.cpp',
+    'media-info.cpp',
+    'v4l2-info.cpp',
+)
+
+v4l2_compliance_sources += version_h
+v4l2_compliance_deps = [
+    dep_librt,
+    dep_threads,
+]
+v4l2_compliance_cpp_args = []
+
+if get_option('v4l2-compliance-libv4l')
+    v4l2_compliance_deps += dep_libv4lconvert
+    v4l2_compliance_deps += dep_libv4l2
+else
+    v4l2_compliance_cpp_args += '-DNO_LIBV4L2'
+endif
+
+common_incdir = include_directories('../common')
+
+v4l2_compliance_incdir = [
+    common_incdir,
+    v4l2_utils_incdir,
+]
+
+v4l2_compliance = executable(name,
+                      v4l2_compliance_sources,
+                      install : true,
+                      dependencies : v4l2_compliance_deps,
+                      cpp_args : v4l2_compliance_cpp_args,
+                      include_directories : v4l2_compliance_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
utils/v4l2-ctl/meson.build new file +65 -0
new file mode 100644
index 000000000000..1bbc7fe44313
@@ -0,0 +1,65 @@
+name = 'v4l2-ctl'
+
+v4l2_ctl_sources = files(
+    'v4l2-ctl.cpp',
+    'v4l2-ctl.h',
+    'v4l2-ctl-common.cpp',
+    'v4l2-ctl-tuner.cpp',
+    'v4l2-ctl-io.cpp',
+    'v4l2-ctl-stds.cpp',
+    'v4l2-ctl-vidcap.cpp',
+    'v4l2-ctl-vidout.cpp',
+    'v4l2-ctl-overlay.cpp',
+    'v4l2-ctl-vbi.cpp',
+    'v4l2-ctl-selection.cpp',
+    'v4l2-ctl-misc.cpp',
+    'v4l2-ctl-streaming.cpp',
+    'v4l2-ctl-sdr.cpp',
+    'v4l2-ctl-edid.cpp',
+    'v4l2-ctl-modes.cpp',
+    'v4l2-ctl-subdev.cpp',
+    'v4l2-tpg-colors.c',
+    'v4l2-tpg-core.c',
+    'v4l-stream.c',
+    'v4l2-ctl-meta.cpp',
+    'media-info.cpp',
+    'v4l2-info.cpp',
+    'codec-fwht.c',
+    'codec-v4l2-fwht.c',
+)
+v4l2_ctl_sources += media_bus_format_names_h
+
+v4l2_ctl_deps = [
+    dep_librt,
+    dep_threads,
+]
+v4l2_ctl_cpp_args = []
+
+if get_option('v4l2-ctl-libv4l')
+    v4l2_ctl_deps += dep_libv4lconvert
+    v4l2_ctl_deps += dep_libv4l2
+else
+    v4l2_ctl_cpp_args += '-DNO_LIBV4L2'
+endif
+
+if not get_option('v4l2-ctl-stream-to')
+    v4l2_ctl_cpp_args += '-DNO_STREAM_TO'
+endif
+
+v4l2_ctl_incdir = [
+    utils_common_incdir,
+    v4l2_utils_incdir,
+]
+
+v4l2_ctl = executable(name,
+                      v4l2_ctl_sources,
+                      install : true,
+                      dependencies : v4l2_ctl_deps,
+                      cpp_args : v4l2_ctl_cpp_args,
+		      include_directories : v4l2_ctl_incdir)
+
+manpage = configure_file(
+    input : name + '.1.in',
+    output : name + '.1',
+    install_dir : join_paths(get_option('mandir'), 'man1'),
+    configuration : conf)
version.h.in new file +1 -0
new file mode 100644
index 000000000000..2506ed9bc6cc
@@ -0,0 +1 @@
+#define SHA @VCS_TAG@
Signature · 3 lines
Regards,

Laurent Pinchart
#7 lore raw

Re: [RFC PATCH v4l-utils 1/1] Introduce support for meson building

Quoted 6 lines · Laurent Pinchart
Quoted 3 lines

Custom reporting is no longer recommended, meson have a option driven report (summary). The plus side is that it will be printed at the end properly even if this project is used as subproject.

I didn't know about that, it's nice. The option has been added to meson 0.53 though, which may be a tad too recent ?

Indeed, but be careful with such an argument, since someone could come back and say meson is too early, it's not over 10 years old yet. I think best is too look at how often distro updates this library. If they only update when the entire distro is updated, my recommendation is to use the version that best suite your work. If they tend to backport on stable distro, then maybe it's best to be conservative.

In GStreamer we do both, we stick with older meson in stable release (1.16)
unless there is a bug in meson that caused a bad build. And use the most recent version in development, so that next when distro moves to a new stable, they
have to update meson at the same time, obviously for the benifit of their users. (Also because a some upcoming meson feature are written by GStreamer developers,just to be honnest).

Nicolas

#8 lore raw
In reply to Ezequiel Garcia

Hi Ezequiel,

Quoted 4 lines · Ezequiel Garcia

Here's a first step towards using meson:

https://mesonbuild.com/

Quoted 8 lines

As you can see, this doesn't include all tools and libraries (are there any libv4l1 users?), but otherwise tries to cover as much as possible.

I'm sending this early patch, hoping to get some reviews and possibly some testing.

Let me know what you think.

I like the concept :-) Is there a plan to drop autotools support ?

Quoted 42 lines

Ezequiel Garcia (1):
Add support for meson building

 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in
Signature · 3 lines
Regards,

Laurent Pinchart
#9 lore raw

Hi Ezequiel,

Quoted 9 lines · Laurent Pinchart
Quoted 8 lines · Ezequiel Garcia

Here's a first step towards using meson:

https://mesonbuild.com/

As you can see, this doesn't include all tools and libraries (are there any libv4l1 users?), but otherwise tries to cover as much as possible.

Quoted 6 lines
Quoted 4 lines

I'm sending this early patch, hoping to get some reviews and possibly some testing.

Let me know what you think.

I like the concept :-) Is there a plan to drop autotools support ?

I think it's great. I've toyed with meson in the past and liked it a lot.

Long term, supporting both meson and autotools might be a maintenance burden.

Sean

Quoted 43 lines
Quoted 43 lines

Ezequiel Garcia (1):
Add support for meson building

 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in
#10 lore raw
In reply to Ezequiel Garcia
Quoted 6 lines · Ezequiel Garcia

Here's a first step towards using meson:

https://mesonbuild.com/

As you can see, this doesn't include all tools and libraries (are there any libv4l1 users?),

Probably yes.

but otherwise tries to cover

Quoted 1 line

as much as possible.

Last week I added options to build 32 bit variants of v4l2-ctl and v4l2-compliance, it will be interesting to see how meson does that.

I'm not opposed to changing over to meson, but then the old system has to be removed either at the same time or in a second patch.

Regards,

Hans

Quoted 51 lines

I'm sending this early patch, hoping to get some reviews and possibly some testing.

Let me know what you think.

Thanks,

Ezequiel Garcia (1):
Add support for meson building

 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in
#11 lore raw

Hi Hans,

Quoted 10 lines · Hans Verkuil
Quoted 6 lines · Ezequiel Garcia

Here's a first step towards using meson:

https://mesonbuild.com/

As you can see, this doesn't include all tools and libraries (are there any libv4l1 users?),

Probably yes.

Quoted 9 lines

but otherwise tries to cover

Quoted 1 line

as much as possible.

Last week I added options to build 32 bit variants of v4l2-ctl and v4l2-compliance, it will be interesting to see how meson does that.

I'm not opposed to changing over to meson, but then the old system has to be removed either at the same time or in a second patch.

I think some projects kept autotools for a while until the transition to meson is complete.

Any reason why we'd have to do the transition atomically?

Thanks,
Ezequiel

#12 lore raw
Quoted 19 lines · Ezequiel Garcia

Hi Hans,

Quoted 16 lines · Hans Verkuil
Quoted 6 lines · Ezequiel Garcia

Here's a first step towards using meson:

https://mesonbuild.com/

As you can see, this doesn't include all tools and libraries (are there any libv4l1 users?),

Probably yes.

but otherwise tries to cover

Quoted 1 line

as much as possible.

Last week I added options to build 32 bit variants of v4l2-ctl and v4l2-compliance, it will be interesting to see how meson does that.

Quoted 8 lines
Quoted 3 lines

I'm not opposed to changing over to meson, but then the old system has to be removed either at the same time or in a second patch.

I think some projects kept autotools for a while until the transition to meson is complete.

Any reason why we'd have to do the transition atomically?

Having two (or more) build systems is usually of great pain. In GStreamer we went that route as we had to develop some extra features into Meson to support our much more complex use case. Today, meson is mature enough to allow a quick transition. Of course, having patches merged with few days of delay helps if you have CI and other Bot to update. An atomic transition would cause downtime in that context.

Quoted 4 lines

Thanks,
Ezequiel

#13 lore raw
In reply to Ezequiel Garcia

Em Sun, 15 Mar 2020 17:54:20 -0300 Ezequiel Garcia <[email protected]> escreveu:

Quoted 4 lines

Here's a first step towards using meson:

https://mesonbuild.com/

Quoted 8 lines

As you can see, this doesn't include all tools and libraries (are there any libv4l1 users?), but otherwise tries to cover as much as possible.

I'm sending this early patch, hoping to get some reviews and possibly some testing.

Let me know what you think.

I fail to see why to change it. The autotools-based building system works, and we don't have any bug reports related to it.

Also, we're all familiar to it.

Changing to a new system will not only be extra work from our side, in order to learn how to use it, address any hidden bugs, etc, but also for distro developers as they'll need to change the build dependencies on their packages, as the building system will rely on different toolsets.

Quoted 37 lines

Thanks,

Ezequiel Garcia (1):
Add support for meson building

 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
Quoted 9 lines
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in

Thanks,
Mauro

#14 lore raw

Hi Mauro,

Quoted 17 lines · Mauro Carvalho Chehab

Em Sun, 15 Mar 2020 17:54:20 -0300 Ezequiel Garcia escreveu:

Quoted 4 lines

Here's a first step towards using meson:

https://mesonbuild.com/

Quoted 8 lines

As you can see, this doesn't include all tools and libraries (are there any libv4l1 users?), but otherwise tries to cover as much as possible.

I'm sending this early patch, hoping to get some reviews and possibly some testing.

Let me know what you think.

I fail to see why to change it. The autotools-based building system works, and we don't have any bug reports related to it.

Quoted 6 lines

Also, we're all familiar to it.

Changing to a new system will not only be extra work from our side, in order to learn how to use it, address any hidden bugs, etc, but also for distro developers as they'll need to change the build dependencies on their packages, as the building system will rely on different toolsets.

Changes imply additional work as we need to get used to them, but we need to think about the long term consequences too. meson is much simpler to use than autotools, I think we will benefit from it in the longer term.

Quoted 42 lines
Quoted 42 lines

Ezequiel Garcia (1):
Add support for meson building

 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in
Signature · 3 lines
Regards,

Laurent Pinchart
#15 lore raw
In reply to Mauro Carvalho Chehab
Quoted 19 lines · Mauro Carvalho Chehab

Em Sun, 15 Mar 2020 17:54:20 -0300 Ezequiel Garcia <[email protected]> escreveu:

Quoted 4 lines

Here's a first step towards using meson:

https://mesonbuild.com/

Quoted 8 lines

As you can see, this doesn't include all tools and libraries (are there any libv4l1 users?), but otherwise tries to cover as much as possible.

I'm sending this early patch, hoping to get some reviews and possibly some testing.

Let me know what you think.

I fail to see why to change it. The autotools-based building system works, and we don't have any bug reports related to it.

Quoted 6 lines

Also, we're all familiar to it.

Changing to a new system will not only be extra work from our side, in order to learn how to use it, address any hidden bugs, etc, but also for distro developers as they'll need to change the build dependencies on their packages, as the building system will rely on different toolsets.

Be aware that hundreds of project have made that move already, including very large projects. Distro maintainer knows the drill to move forward. Overall it has been welcome as it reduces the build time on their farm. For those using non-gcc compilers, it has been quite positive as a lot of compiler specific hacks exist per-project with autotools, some project get it right, some don't. With Meson this is unified and solved once correctly.

As this library is always a deps of another project, the move to meson also enables using it as subproject. This can greatly simplify making dedicated build, it will notably make our life easier for CI integration.

Quoted 52 lines
Quoted 39 lines

Thanks,

Ezequiel Garcia (1):
Add support for meson building

 gen-version.sh                      |  36 ++++++++++
 lib/libdvbv5/meson.build            |  87 ++++++++++++++++++++++
 lib/libv4l2/meson.build             |  43 +++++++++++
 lib/libv4lconvert/meson.build       |  79 ++++++++++++++++++++
 lib/meson.build                     |   6 ++
 meson.build                         | 108 ++++++++++++++++++++++++++++
 meson_options.txt                   |  19 +++++
 utils/cec-compliance/meson.build    |  39 ++++++++++
 utils/cec-ctl/meson.build           |  33 +++++++++
 utils/cec-follower/meson.build      |  35 +++++++++
 utils/gen_media_bus_format_codes.sh |   7 ++
 utils/gen_media_bus_format_names.sh |   7 ++
 utils/ir-ctl/meson.build            |  30 ++++++++
 utils/libcecutil/meson.build        |  46 ++++++++++++
 utils/media-ctl/meson.build         |  35 +++++++++
 utils/meson.build                   |  32 +++++++++
 utils/v4l2-compliance/meson.build   |  52 ++++++++++++++
 utils/v4l2-ctl/meson.build          |  65 +++++++++++++++++
 version.h.in                        |   1 +
 19 files changed, 760 insertions(+)
 create mode 100755 gen-version.sh
 create mode 100644 lib/libdvbv5/meson.build
 create mode 100644 lib/libv4l2/meson.build
 create mode 100644 lib/libv4lconvert/meson.build
 create mode 100644 lib/meson.build
 create mode 100644 meson.build
 create mode 100644 meson_options.txt
 create mode 100644 utils/cec-compliance/meson.build
 create mode 100644 utils/cec-ctl/meson.build
 create mode 100644 utils/cec-follower/meson.build
 create mode 100644 utils/gen_media_bus_format_codes.sh
Quoted 9 lines
 create mode 100644 utils/gen_media_bus_format_names.sh
 create mode 100644 utils/ir-ctl/meson.build
 create mode 100644 utils/libcecutil/meson.build
 create mode 100644 utils/media-ctl/meson.build
 create mode 100644 utils/meson.build
 create mode 100644 utils/v4l2-compliance/meson.build
 create mode 100644 utils/v4l2-ctl/meson.build
 create mode 100644 version.h.in

Thanks,
Mauro