meson: improve subproject builds
Add meson subproject wrapfiles for all the openbmc projects we utilize
and fix the missing dependency for cereal. There is still a missing
dependency for the `ldap.h` that prevents a full wrap-based build.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: If3a5836c3ff9a34d5624c60ac00c8fd46bfba20b
diff --git a/.gitignore b/.gitignore
index 7cc63e3..33981e7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,8 @@
+# Meson ignores.
+build*/
+subprojects/*
+!subprojects/*.wrap
+
# Template from
# https://github.com/github/gitignore/blob/master/Autotools.gitignore
diff --git a/meson.build b/meson.build
index 7ebdc4d..7cb6227 100644
--- a/meson.build
+++ b/meson.build
@@ -59,25 +59,31 @@
conf_header = configure_file(output: 'config.h',
configuration: conf_data)
-phosphor_dbus_interfaces_dep = dependency(
- 'phosphor-dbus-interfaces',
- fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'],
-)
-
-sdbusplus_dep = dependency(
- 'sdbusplus',
- fallback: ['sdbusplus', 'sdbusplus_dep'],
-)
-
-phosphor_logging_dep = dependency(
- 'phosphor-logging',
- fallback: ['phosphor-logging', 'phosphor_logging_dep'],
-)
-
+phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
+sdbusplus_dep = dependency('sdbusplus')
+phosphor_logging_dep = dependency('phosphor-logging')
systemd_dep = dependency('systemd')
cpp = meson.get_compiler('cpp')
+# Get Cereal dependency.
+cereal_dep = dependency('cereal', required: false)
+has_cereal = cpp.has_header_symbol(
+ 'cereal/cereal.hpp',
+ 'cereal::specialize',
+ dependencies: cereal_dep,
+ required: false)
+if not has_cereal
+ cereal_opts = import('cmake').subproject_options()
+ cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
+ cereal_proj = import('cmake').subproject(
+ 'cereal',
+ options: cereal_opts,
+ required: false)
+ assert(cereal_proj.found(), 'cereal is required')
+ cereal_dep = cereal_proj.dependency('cereal')
+endif
+
user_manager_src = [
'mainapp.cpp',
'user_mgr.cpp',
diff --git a/phosphor-ldap-mapper/meson.build b/phosphor-ldap-mapper/meson.build
index d2f4c50..a3a027e 100644
--- a/phosphor-ldap-mapper/meson.build
+++ b/phosphor-ldap-mapper/meson.build
@@ -1,4 +1,5 @@
phosphor_ldap_mapper_deps = [
+ cereal_dep,
phosphor_dbus_interfaces_dep,
phosphor_logging_dep,
sdbusplus_dep,
diff --git a/subprojects/cereal.wrap b/subprojects/cereal.wrap
new file mode 100644
index 0000000..a4cb7ec
--- /dev/null
+++ b/subprojects/cereal.wrap
@@ -0,0 +1,4 @@
+[wrap-git]
+url = https://github.com/USCiLab/cereal.git
+revision = HEAD
+# need at least for C++20 fixes 3e4d1b84cab4891368d2179a61a7ba06a5693e7f
diff --git a/subprojects/phosphor-dbus-interfaces.wrap b/subprojects/phosphor-dbus-interfaces.wrap
new file mode 100644
index 0000000..346aa0c
--- /dev/null
+++ b/subprojects/phosphor-dbus-interfaces.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-dbus-interfaces.git
+revision = HEAD
+
+[provide]
+phosphor-dbus-interfaces = phosphor_dbus_interfaces_dep
diff --git a/subprojects/phosphor-logging.wrap b/subprojects/phosphor-logging.wrap
new file mode 100644
index 0000000..71eee8b
--- /dev/null
+++ b/subprojects/phosphor-logging.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-logging.git
+revision = HEAD
+
+[provide]
+phosphor-logging = phosphor_logging_dep
diff --git a/subprojects/sdbusplus.wrap b/subprojects/sdbusplus.wrap
new file mode 100644
index 0000000..7b076d0
--- /dev/null
+++ b/subprojects/sdbusplus.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/sdbusplus.git
+revision = HEAD
+
+[provide]
+sdbusplus = sdbusplus_dep