build: Refactor directory structure to separate headers

This makes the structure similar to other OpenBMC projects.

Change-Id: I5b76fe7439dba9b68244ee1494f2266b6351e498
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include/meson.build b/include/meson.build
new file mode 100644
index 0000000..5d870ac
--- /dev/null
+++ b/include/meson.build
@@ -0,0 +1,44 @@
+stdplus_headers = include_directories('.')
+
+if has_dl
+  install_headers(
+    'stdplus/dl.hpp',
+    subdir: 'stdplus')
+endif
+
+if has_fd
+  install_headers(
+    'stdplus/fd/create.hpp',
+    'stdplus/fd/dupable.hpp',
+    'stdplus/fd/gmock.hpp',
+    'stdplus/fd/impl.hpp',
+    'stdplus/fd/intf.hpp',
+    'stdplus/fd/managed.hpp',
+    'stdplus/fd/mmap.hpp',
+    'stdplus/fd/ops.hpp',
+    subdir: 'stdplus/fd')
+endif
+
+if has_io_uring
+  install_headers(
+    'stdplus/io_uring.hpp',
+    subdir: 'stdplus')
+endif
+
+install_headers(
+  'stdplus/cancel.hpp',
+  'stdplus/exception.hpp',
+  'stdplus/flags.hpp',
+  'stdplus/raw.hpp',
+  'stdplus/signal.hpp',
+  subdir: 'stdplus')
+
+install_headers(
+  'stdplus/handle/copyable.hpp',
+  'stdplus/handle/managed.hpp',
+  subdir: 'stdplus/handle')
+
+install_headers(
+  'stdplus/util/cexec.hpp',
+  'stdplus/util/string.hpp',
+  subdir: 'stdplus/util')
diff --git a/src/stdplus/cancel.hpp b/include/stdplus/cancel.hpp
similarity index 100%
rename from src/stdplus/cancel.hpp
rename to include/stdplus/cancel.hpp
diff --git a/src/stdplus/dl.hpp b/include/stdplus/dl.hpp
similarity index 100%
rename from src/stdplus/dl.hpp
rename to include/stdplus/dl.hpp
diff --git a/src/stdplus/exception.hpp b/include/stdplus/exception.hpp
similarity index 100%
rename from src/stdplus/exception.hpp
rename to include/stdplus/exception.hpp
diff --git a/src/stdplus/fd/create.hpp b/include/stdplus/fd/create.hpp
similarity index 100%
rename from src/stdplus/fd/create.hpp
rename to include/stdplus/fd/create.hpp
diff --git a/src/stdplus/fd/dupable.hpp b/include/stdplus/fd/dupable.hpp
similarity index 100%
rename from src/stdplus/fd/dupable.hpp
rename to include/stdplus/fd/dupable.hpp
diff --git a/src/stdplus/fd/gmock.hpp b/include/stdplus/fd/gmock.hpp
similarity index 100%
rename from src/stdplus/fd/gmock.hpp
rename to include/stdplus/fd/gmock.hpp
diff --git a/src/stdplus/fd/impl.hpp b/include/stdplus/fd/impl.hpp
similarity index 100%
rename from src/stdplus/fd/impl.hpp
rename to include/stdplus/fd/impl.hpp
diff --git a/src/stdplus/fd/intf.hpp b/include/stdplus/fd/intf.hpp
similarity index 100%
rename from src/stdplus/fd/intf.hpp
rename to include/stdplus/fd/intf.hpp
diff --git a/src/stdplus/fd/managed.hpp b/include/stdplus/fd/managed.hpp
similarity index 100%
rename from src/stdplus/fd/managed.hpp
rename to include/stdplus/fd/managed.hpp
diff --git a/src/stdplus/fd/mmap.hpp b/include/stdplus/fd/mmap.hpp
similarity index 100%
rename from src/stdplus/fd/mmap.hpp
rename to include/stdplus/fd/mmap.hpp
diff --git a/src/stdplus/fd/ops.hpp b/include/stdplus/fd/ops.hpp
similarity index 100%
rename from src/stdplus/fd/ops.hpp
rename to include/stdplus/fd/ops.hpp
diff --git a/src/stdplus/flags.hpp b/include/stdplus/flags.hpp
similarity index 100%
rename from src/stdplus/flags.hpp
rename to include/stdplus/flags.hpp
diff --git a/src/stdplus/handle/copyable.hpp b/include/stdplus/handle/copyable.hpp
similarity index 100%
rename from src/stdplus/handle/copyable.hpp
rename to include/stdplus/handle/copyable.hpp
diff --git a/src/stdplus/handle/managed.hpp b/include/stdplus/handle/managed.hpp
similarity index 100%
rename from src/stdplus/handle/managed.hpp
rename to include/stdplus/handle/managed.hpp
diff --git a/src/stdplus/io_uring.hpp b/include/stdplus/io_uring.hpp
similarity index 100%
rename from src/stdplus/io_uring.hpp
rename to include/stdplus/io_uring.hpp
diff --git a/src/stdplus/raw.hpp b/include/stdplus/raw.hpp
similarity index 100%
rename from src/stdplus/raw.hpp
rename to include/stdplus/raw.hpp
diff --git a/src/stdplus/signal.hpp b/include/stdplus/signal.hpp
similarity index 100%
rename from src/stdplus/signal.hpp
rename to include/stdplus/signal.hpp
diff --git a/src/stdplus/util/cexec.hpp b/include/stdplus/util/cexec.hpp
similarity index 100%
rename from src/stdplus/util/cexec.hpp
rename to include/stdplus/util/cexec.hpp
diff --git a/src/stdplus/util/string.hpp b/include/stdplus/util/string.hpp
similarity index 100%
rename from src/stdplus/util/string.hpp
rename to include/stdplus/util/string.hpp
diff --git a/meson.build b/meson.build
index 8e09a59..7d7e0c8 100644
--- a/meson.build
+++ b/meson.build
@@ -10,6 +10,35 @@
     'examples=' + (meson.is_subproject() ? 'false' : 'true'),
   ])
 
+has_dl = false
+if not get_option('dl').disabled()
+  dl_dep = meson.get_compiler('cpp').find_library('dl', required: false)
+  has_dl = meson.get_compiler('cpp').links('''
+    #include <dlfcn.h>
+    int main() { dlopen("", 0); }
+  ''', dependencies: dl_dep)
+endif
+if get_option('dl').enabled() and not has_dl
+  error('libdl support required')
+endif
+
+has_fd = false
+if not get_option('fd').disabled()
+  has_fd = true
+endif
+
+has_io_uring = false
+if not get_option('io_uring').disabled() and has_fd
+  io_uring_dep = dependency('liburing', required: get_option('io_uring'))
+  if io_uring_dep.found()
+    has_io_uring = true
+  endif
+endif
+if get_option('io_uring').enabled() and not has_io_uring
+  error('io_uring support is required')
+endif
+
+subdir('include')
 subdir('src')
 
 build_tests = get_option('tests')
diff --git a/src/stdplus/dl.cpp b/src/dl.cpp
similarity index 100%
rename from src/stdplus/dl.cpp
rename to src/dl.cpp
diff --git a/src/stdplus/exception.cpp b/src/exception.cpp
similarity index 100%
rename from src/stdplus/exception.cpp
rename to src/exception.cpp
diff --git a/src/stdplus/fd/create.cpp b/src/fd/create.cpp
similarity index 100%
rename from src/stdplus/fd/create.cpp
rename to src/fd/create.cpp
diff --git a/src/stdplus/fd/dupable.cpp b/src/fd/dupable.cpp
similarity index 100%
rename from src/stdplus/fd/dupable.cpp
rename to src/fd/dupable.cpp
diff --git a/src/stdplus/fd/impl.cpp b/src/fd/impl.cpp
similarity index 100%
rename from src/stdplus/fd/impl.cpp
rename to src/fd/impl.cpp
diff --git a/src/stdplus/fd/managed.cpp b/src/fd/managed.cpp
similarity index 100%
rename from src/stdplus/fd/managed.cpp
rename to src/fd/managed.cpp
diff --git a/src/stdplus/fd/mmap.cpp b/src/fd/mmap.cpp
similarity index 100%
rename from src/stdplus/fd/mmap.cpp
rename to src/fd/mmap.cpp
diff --git a/src/stdplus/fd/ops.cpp b/src/fd/ops.cpp
similarity index 100%
rename from src/stdplus/fd/ops.cpp
rename to src/fd/ops.cpp
diff --git a/src/stdplus/io_uring.cpp b/src/io_uring.cpp
similarity index 100%
rename from src/stdplus/io_uring.cpp
rename to src/io_uring.cpp
diff --git a/src/meson.build b/src/meson.build
index af7399c..1492655 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,5 +1,3 @@
-stdplus_headers = include_directories('.')
-
 fmt_dep = dependency('fmt', required: false)
 if not fmt_dep.found()
   fmt_opts = import('cmake').subproject_options()
@@ -20,79 +18,39 @@
 ]
 
 stdplus_srcs = [
-  'stdplus/exception.cpp',
-  'stdplus/signal.cpp',
+  'exception.cpp',
+  'signal.cpp',
 ]
 
-has_dl = false
-if not get_option('dl').disabled()
-  dl_dep = meson.get_compiler('cpp').find_library('dl', required: false)
-  has_dl = meson.get_compiler('cpp').links('''
-    #include <dlfcn.h>
-    int main() { dlopen("", 0); }
-  ''', dependencies: dl_dep)
-endif
 if has_dl
   stdplus_deps += [
     dl_dep,
   ]
 
   stdplus_srcs += [
-    'stdplus/dl.cpp',
+    'dl.cpp',
   ]
-
-  install_headers(
-    'stdplus/dl.hpp',
-    subdir: 'stdplus')
-elif get_option('dl').enabled()
-  error('libdl support required')
 endif
 
-has_fd = false
-if not get_option('fd').disabled()
-  has_fd = true
-
+if has_fd
   stdplus_srcs += [
-    'stdplus/fd/create.cpp',
-    'stdplus/fd/dupable.cpp',
-    'stdplus/fd/impl.cpp',
-    'stdplus/fd/managed.cpp',
-    'stdplus/fd/mmap.cpp',
-    'stdplus/fd/ops.cpp',
+    'fd/create.cpp',
+    'fd/dupable.cpp',
+    'fd/impl.cpp',
+    'fd/managed.cpp',
+    'fd/mmap.cpp',
+    'fd/ops.cpp',
   ]
-
-  install_headers(
-    'stdplus/fd/create.hpp',
-    'stdplus/fd/dupable.hpp',
-    'stdplus/fd/gmock.hpp',
-    'stdplus/fd/impl.hpp',
-    'stdplus/fd/intf.hpp',
-    'stdplus/fd/managed.hpp',
-    'stdplus/fd/mmap.hpp',
-    'stdplus/fd/ops.hpp',
-    subdir: 'stdplus/fd')
-elif get_option('fd').enabled()
-  error('File descriptor support required')
 endif
 
-io_uring_dep = dependency('liburing', required: get_option('io_uring'))
-has_io_uring = false
-if not get_option('io_uring').disabled() and has_fd and io_uring_dep.found()
-  has_io_uring = true
-
+if has_io_uring
   stdplus_deps += [
     io_uring_dep,
   ]
 
   stdplus_srcs += [
-    'stdplus/io_uring.cpp',
+    'io_uring.cpp',
   ]
-
-  install_headers(
-    'stdplus/io_uring.hpp',
-    subdir: 'stdplus')
-elif get_option('io_uring').enabled()
-  error('File descriptor support required')
 endif
 
 stdplus_lib = library(
@@ -121,21 +79,3 @@
   description: 'C++ helper utilities',
   version: meson.project_version(),
   requires: stdplus_reqs)
-
-install_headers(
-  'stdplus/cancel.hpp',
-  'stdplus/exception.hpp',
-  'stdplus/flags.hpp',
-  'stdplus/raw.hpp',
-  'stdplus/signal.hpp',
-  subdir: 'stdplus')
-
-install_headers(
-  'stdplus/handle/copyable.hpp',
-  'stdplus/handle/managed.hpp',
-  subdir: 'stdplus/handle')
-
-install_headers(
-  'stdplus/util/cexec.hpp',
-  'stdplus/util/string.hpp',
-  subdir: 'stdplus/util')
diff --git a/src/stdplus/signal.cpp b/src/signal.cpp
similarity index 100%
rename from src/stdplus/signal.cpp
rename to src/signal.cpp