meson: add subproject support
Enable building the repository outside of an OpenBMC Docker container or
SDK by leveraging meson subproject support. Copy wrap files from
elsewhere in the organization and update the meson dependencies for some
missing dependencies.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I9f2cdc310cbee3fd4ee911cca5e339c4e1ebb94f
diff --git a/.gitignore b/.gitignore
index 1ee84da..64bb464 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
+build*/
+subprojects/*
+!subprojects/*.wrap
*.sw*
diff --git a/meson.build b/meson.build
index ec7bb65..e4fc256 100644
--- a/meson.build
+++ b/meson.build
@@ -12,6 +12,8 @@
meson_version: '>=0.58.0',
)
+cxx = meson.get_compiler('cpp')
+
build_tests = get_option('tests')
libevdev = dependency('libevdev')
@@ -22,6 +24,24 @@
sdbusplus = dependency('sdbusplus')
systemd = dependency('systemd')
+if cxx.has_header('nlohmann/json.hpp')
+ nlohmann_json_dep = declare_dependency()
+else
+ subproject('nlohmann', required: false)
+ nlohmann_json_dep = declare_dependency(
+ include_directories: [
+ 'subprojects/nlohmann-json/single_include',
+ 'subprojects/nlohmann-json/single_include/nlohmann',
+ ]
+ )
+endif
+
+if cxx.has_header('CLI/CLI.hpp')
+ cli11_dep = declare_dependency()
+else
+ cli11_dep = dependency('CLI11')
+endif
+
boost_args = ['-DBOOST_ASIO_DISABLE_THREADS',
'-DBOOST_ERROR_CODE_HEADER_ONLY',
'-DBOOST_SYSTEM_NO_DEPRECATED']
@@ -125,9 +145,11 @@
'gpioMonMain.cpp',
'gpioMon.cpp',
dependencies: [
+ cli11_dep,
+ libgpiod,
+ nlohmann_json_dep,
phosphor_logging,
sdbusplus,
- libgpiod,
],
cpp_args: boost_args,
install: true,
diff --git a/subprojects/CLI11.wrap b/subprojects/CLI11.wrap
new file mode 100644
index 0000000..2e5a95b
--- /dev/null
+++ b/subprojects/CLI11.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/CLIUtils/CLI11.git
+revision = HEAD
+
+[provide]
+CLI11 = CLI11_dep
diff --git a/subprojects/libgpiod.wrap b/subprojects/libgpiod.wrap
new file mode 100644
index 0000000..f650e74
--- /dev/null
+++ b/subprojects/libgpiod.wrap
@@ -0,0 +1,13 @@
+[wrap-file]
+directory = libgpiod-1.6.3
+source_url = https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/snapshot/libgpiod-1.6.3.tar.gz
+source_filename = libgpiod-1.6.3.tar.gz
+source_hash = eb446070be1444fd7d32d32bbca53c2f3bbb0a21193db86198cf6050b7a28441
+patch_filename = libgpiod_1.6.3-1_patch.zip
+patch_url = https://wrapdb.mesonbuild.com/v2/libgpiod_1.6.3-1/get_patch
+patch_hash = 76821c637073679a88f77593c6f7ce65b4b5abf8c998f823fffa13918c8761df
+
+[provide]
+libgpiod = gpiod_dep
+libgpiodcxx = gpiodcxx_dep
+
diff --git a/subprojects/nlohmann-json.wrap b/subprojects/nlohmann-json.wrap
new file mode 100644
index 0000000..a77b7c9
--- /dev/null
+++ b/subprojects/nlohmann-json.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+revision = b3e5cb7f20dcc5c806e418df34324eca60d17d4e
+url = https://github.com/nlohmann/json.git
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
diff --git a/test/meson.build b/test/meson.build
index c71f83a..c725739 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -9,6 +9,7 @@
gmock,
gtest,
libevdev,
+ sdbusplus,
],
implicit_include_directories: false,
include_directories: '..',