meson: simplify dependencies
Leverage wrapfile `[provide]` directives to simplify the dependency
searching in the meson.build.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ia27d543a9c13b2c6973ab394ed88cd12d93e88a8
diff --git a/meson.build b/meson.build
index 201f0b9..c3ed12c 100644
--- a/meson.build
+++ b/meson.build
@@ -105,23 +105,12 @@
configure_file(output: 'config.h', configuration: conf)
-sdbusplus_dep = dependency('sdbusplus', required: false)
-sdbusplus_proj = dependency('', required: false)
-if not sdbusplus_dep.found() or sdbusplus_dep.type_name() == 'internal'
- sdbusplus_proj = subproject('sdbusplus')
-endif
-if not sdbusplus_dep.found()
- sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
-endif
+sdbusplus_dep = dependency('sdbusplus')
+sdbusplusplus_prog = find_program('sdbus++', native: true)
+sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
-if sdbusplus_proj.found()
- sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog')
- sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
- 'sdbuspp_gen_meson_prog')
-else
- sdbusplusplus_prog = find_program('sdbus++', native: true)
- sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
-endif
+pdi_dep = dependency('phosphor-dbus-interfaces')
+phosphor_logging_dep = dependency('phosphor-logging')
cereal_dep = dependency('cereal', required: false)
has_cereal = cpp.has_header_symbol(
@@ -141,16 +130,10 @@
endif
deps = [
- dependency(
- 'phosphor-dbus-interfaces',
- fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'],
- ),
- dependency(
- 'phosphor-logging',
- fallback: ['phosphor-logging', 'phosphor_logging_dep'],
- ),
- sdbusplus_dep,
cereal_dep,
+ pdi_dep,
+ phosphor_logging_dep,
+ sdbusplus_dep,
]
ssl = dependency('openssl')
diff --git a/subprojects/CLI11.wrap b/subprojects/CLI11.wrap
index e695a9d..2e5a95b 100644
--- a/subprojects/CLI11.wrap
+++ b/subprojects/CLI11.wrap
@@ -1,3 +1,6 @@
[wrap-git]
url = https://github.com/CLIUtils/CLI11.git
revision = HEAD
+
+[provide]
+CLI11 = CLI11_dep
diff --git a/subprojects/phosphor-dbus-interfaces.wrap b/subprojects/phosphor-dbus-interfaces.wrap
index 935a8b2..346aa0c 100644
--- a/subprojects/phosphor-dbus-interfaces.wrap
+++ b/subprojects/phosphor-dbus-interfaces.wrap
@@ -1,3 +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
index a039fcf..71eee8b 100644
--- a/subprojects/phosphor-logging.wrap
+++ b/subprojects/phosphor-logging.wrap
@@ -1,3 +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
index d470130..edd9a31 100644
--- a/subprojects/sdbusplus.wrap
+++ b/subprojects/sdbusplus.wrap
@@ -1,3 +1,7 @@
[wrap-git]
url = https://github.com/openbmc/sdbusplus.git
revision = HEAD
+
+[provide]
+sdbusplus = sdbusplus_dep
+program_names = sdbus++, sdbus++-gen-meson
diff --git a/subprojects/sdeventplus.wrap b/subprojects/sdeventplus.wrap
index 085bb5e..f871ac0 100644
--- a/subprojects/sdeventplus.wrap
+++ b/subprojects/sdeventplus.wrap
@@ -1,3 +1,6 @@
[wrap-git]
url = https://github.com/openbmc/sdeventplus.git
revision = HEAD
+
+[provide]
+sdeventplus = sdeventplus_dep
diff --git a/usb/meson.build b/usb/meson.build
index bb1dc60..da7fc92 100644
--- a/usb/meson.build
+++ b/usb/meson.build
@@ -1,31 +1,17 @@
if cpp.has_header('CLI/CLI.hpp')
CLI11_dep = declare_dependency()
else
- CLI11_dep = dependency(
- 'CLI11',
- fallback: [ 'CLI11', 'CLI11_dep' ],
- )
+ CLI11_dep = dependency('CLI11')
endif
+sdeventplus_dep = dependency('sdeventplus')
+
source = [
'usb_manager_main.cpp',
'usb_manager.cpp',
'../utils.cpp',
]
-sdeventplus_dep = dependency(
- 'sdeventplus',
- fallback: [
- 'sdeventplus',
- 'sdeventplus_dep'
- ],
-)
-
-phosphor_logging_dep = dependency(
- 'phosphor-logging',
- fallback: ['phosphor-logging', 'phosphor_logging_dep'],
-)
-
executable(
'phosphor-usb-code-update',
source,