Add subproject wrap files

As a start on getting the repo to build standalone outside of a docker
or bitbake environment, add meson wrap files for most of its
dependencies.

A subproject is still needed for pdbg.  It will take a bit more work as
a subprojects/packagefiles/pdbg/meson.build has to be created for it.

Tested:
Meson gets past these dependencies and then fails on pdbg.

Change-Id: I7379d1feafd00d42f3d38ba08aac6267f9eca76b
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/.gitignore b/.gitignore
index 46d951a..2fcd898 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
 # meson
 /build
 /builddir
+subprojects/*
+!subprojects/*.wrap
+!subprojects/packagefiles
diff --git a/meson.build b/meson.build
index be48e54..35aeae9 100644
--- a/meson.build
+++ b/meson.build
@@ -140,6 +140,33 @@
     unit_subs.set('ENABLE_PHAL_TRUE', '')
 endif
 
+libgpiodcxx_dep = dependency('libgpiodcxx', default_options: ['bindings=cxx'])
+sdbusplus_dep = dependency('sdbusplus')
+sdeventplus_dep = dependency('sdeventplus')
+pdi_dep = dependency('phosphor-dbus-interfaces')
+phosphor_logging_dep = dependency('phosphor-logging')
+
+gtest = dependency('gtest', main: true, disabler: true, required: false, include_type: 'system')
+if get_option('tests').allowed()
+    if not gtest.found()
+        gtest_proj = import('cmake').subproject('gtest', required: false)
+        if gtest_proj.found()
+            gtest = declare_dependency(
+                dependencies: [
+                    dependency('threads'),
+                    gtest_proj.dependency('gtest'),
+                    gtest_proj.dependency('gtest_main'),
+                ]
+            )
+        else
+            assert(
+                not get_option('tests').enabled(),
+                'Googletest is required if tests are enabled'
+            )
+        endif
+    endif
+endif
+
 executable(
     'openpower-proc-control',
     [
@@ -154,11 +181,11 @@
         'util.cpp',
     ] + extra_sources,
     dependencies: [
-        dependency('libgpiodcxx'),
+        libgpiodcxx_dep,
         cxx.find_library('pdbg'),
-        dependency('phosphor-dbus-interfaces'),
-        dependency('phosphor-logging'),
-        dependency('sdbusplus'),
+        pdi_dep,
+        phosphor_logging_dep,
+        sdbusplus_dep,
         dependency('threads'),
         dependency('fmt'),
     ] + extra_dependencies,
@@ -173,9 +200,9 @@
     ],
     dependencies: [
         cxx.find_library('pdbg'),
-        dependency('phosphor-dbus-interfaces'),
-        dependency('phosphor-logging'),
-        dependency('sdbusplus'),
+        pdi_dep,
+        phosphor_logging_dep,
+        sdbusplus_dep,
    ],
    install: true
 )
@@ -191,11 +218,10 @@
             'util.cpp',
         ],
         dependencies: [
-            dependency('phosphor-logging'),
-            dependency('sdbusplus'),
-            dependency('sdeventplus'),
-            dependency('fmt'),
-            dependency('phosphor-dbus-interfaces'),
+            phosphor_logging_dep,
+            sdbusplus_dep,
+            sdeventplus_dep,
+            pdi_dep,
             cxx.find_library('pdbg'),
             cxx.find_library('phal'),
        ],
@@ -215,9 +241,9 @@
              cxx.find_library('pdbg'),
              cxx.find_library('phal'),
              dependency('libdt-api'),
-             dependency('phosphor-logging'),
-             dependency('sdbusplus'),
-             dependency('sdeventplus'),
+             phosphor_logging_dep,
+             sdbusplus_dep,
+             sdeventplus_dep,
        ],
        install: true
 )
@@ -254,7 +280,7 @@
             'targeting.cpp',
             'filedescriptor.cpp',
             dependencies: [
-                dependency('gtest', main: true),
+                gtest,
                 dependency('phosphor-logging'),
             ],
             implicit_include_directories: false,
diff --git a/subprojects/gtest.wrap b/subprojects/gtest.wrap
new file mode 100644
index 0000000..b39fa59
--- /dev/null
+++ b/subprojects/gtest.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+revision = HEAD
+url = https://github.com/google/googletest.git
diff --git a/subprojects/libgpiod.wrap b/subprojects/libgpiod.wrap
new file mode 100644
index 0000000..3a92657
--- /dev/null
+++ b/subprojects/libgpiod.wrap
@@ -0,0 +1,14 @@
+[wrap-file]
+directory = libgpiod-1.6.5
+source_url = https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/snapshot/libgpiod-1.6.5.tar.gz
+source_filename = libgpiod-1.6.5.tar.gz
+source_hash = 1473d3035b506065393a4569763cf6b5c98e59c8f865326374ebadffa2578f3a
+patch_filename = libgpiod_1.6.5-1_patch.zip
+patch_url = https://wrapdb.mesonbuild.com/v2/libgpiod_1.6.5-1/get_patch
+patch_hash = a8ee005ecaeaf9d4382d196a1b82e808e72b750f6b8cf61b84f7ccee134b8d4f
+source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/libgpiod_1.6.5-1/libgpiod-1.6.5.tar.gz
+wrapdb_version = 1.6.5-1
+
+[provide]
+libgpiod = gpiod_dep
+libgpiodcxx = gpiodcxx_dep
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..edd9a31
--- /dev/null
+++ b/subprojects/sdbusplus.wrap
@@ -0,0 +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
new file mode 100644
index 0000000..f871ac0
--- /dev/null
+++ b/subprojects/sdeventplus.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/sdeventplus.git
+revision = HEAD
+
+[provide]
+sdeventplus = sdeventplus_dep