summaryrefslogtreecommitdiff
path: root/tests/use-as-subproject
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2021-05-05 12:16:20 +0100
committerSimon McVittie <smcv@collabora.com>2022-02-18 10:42:55 +0000
commit19279812409265b2bb86edf465d47c529ed9226d (patch)
tree18c076e6f65c553e5aafe15c138de545124da0e9 /tests/use-as-subproject
parent43c2d32d7f03ce502c248ff6575c1ce5e205ecd5 (diff)
downloadbubblewrap-19279812409265b2bb86edf465d47c529ed9226d.tar.gz
Add a Meson build system
This allows bwrap to be built as a subproject in larger Meson projects. When built as a subproject, we install into the --libexecdir and require a program prefix to be specified: for example, Flatpak would use program_prefix=flatpak- to get /usr/libexec/flatpak-bwrap. Verified to be backwards-compatible as far as Meson 0.49.0 (Debian 9 backports). Loosely based on previous work by Jussi Pakkanen (see #133). Differences between the Autotools and Meson builds: The Meson build requires a version of libcap that has pkg-config metadata (introduced in libcap 2.23, in 2013). The Meson build has no equivalent of --with-priv-mode=setuid. On distributions like Debian <= 10 and RHEL <= 7 that require a setuid bwrap executable, the sysadmin or distribution packaging will need to set the correct permissions on the bwrap executable; Debian already did this via packaging rather than the upstream build system. The Meson build supports being used as a subproject, and there is CI for this. It automatically disables shell completions and man pages, moves the bubblewrap executable to ${libexecdir}, and renames the bubblewrap executable according to a program_prefix option that the caller must specify (for example, Flatpak would use -Dprogram_prefix=flatpak- to get /usr/libexec/flatpak-bwrap). See the tests/use-as-subproject/ directory for an example. Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'tests/use-as-subproject')
-rw-r--r--tests/use-as-subproject/.gitignore2
-rw-r--r--tests/use-as-subproject/README3
-rw-r--r--tests/use-as-subproject/config.h1
-rw-r--r--tests/use-as-subproject/dummy-config.h.in1
-rw-r--r--tests/use-as-subproject/meson.build19
5 files changed, 26 insertions, 0 deletions
diff --git a/tests/use-as-subproject/.gitignore b/tests/use-as-subproject/.gitignore
new file mode 100644
index 0000000..371a7d9
--- /dev/null
+++ b/tests/use-as-subproject/.gitignore
@@ -0,0 +1,2 @@
+/_build/
+/subprojects/
diff --git a/tests/use-as-subproject/README b/tests/use-as-subproject/README
new file mode 100644
index 0000000..97d2e88
--- /dev/null
+++ b/tests/use-as-subproject/README
@@ -0,0 +1,3 @@
+This is a simple example of a project that uses bubblewrap as a
+subproject. The intention is that if this project can successfully build
+bubblewrap as a subproject, then so could Flatpak.
diff --git a/tests/use-as-subproject/config.h b/tests/use-as-subproject/config.h
new file mode 100644
index 0000000..4a99af4
--- /dev/null
+++ b/tests/use-as-subproject/config.h
@@ -0,0 +1 @@
+#error Should not use superproject config.h to compile bubblewrap
diff --git a/tests/use-as-subproject/dummy-config.h.in b/tests/use-as-subproject/dummy-config.h.in
new file mode 100644
index 0000000..1d1e56a
--- /dev/null
+++ b/tests/use-as-subproject/dummy-config.h.in
@@ -0,0 +1 @@
+#error Should not use superproject generated config.h to compile bubblewrap
diff --git a/tests/use-as-subproject/meson.build b/tests/use-as-subproject/meson.build
new file mode 100644
index 0000000..802fd61
--- /dev/null
+++ b/tests/use-as-subproject/meson.build
@@ -0,0 +1,19 @@
+project(
+ 'use-bubblewrap-as-subproject',
+ 'c',
+ version : '0',
+ meson_version : '>=0.49.0',
+)
+
+configure_file(
+ output : 'config.h',
+ input : 'dummy-config.h.in',
+ configuration : configuration_data(),
+)
+
+subproject(
+ 'bubblewrap',
+ default_options : [
+ 'program_prefix=not-flatpak-',
+ ],
+)