Update meson and subprojects

Few changes related to meson:
- GTest and boost were updated.
- Boost is now built locally in case it is not installed on system.
- Minor meson.build refactor.

Testing done:
- local build is working fine, when subprojects are not installed on the
  system,
- local build is working fine, when subprojects are installed on the
  system,
- yocto build is working fine.

Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: Ib62092946d6ffafb1884d1ba3eab97bed243dd12
diff --git a/.gitignore b/.gitignore
index d5e4365..d5005aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -114,6 +114,8 @@
 ### Meson ###
 # subproject directories
 /subprojects/*
+!/subprojects/packagefiles/
+!/subprojects/boost.wrap
 !/subprojects/googletest.wrap
 !/subprojects/nlohmann.wrap
 !/subprojects/phosphor-logging.wrap
diff --git a/meson.build b/meson.build
index 993f100..5e4fa20 100644
--- a/meson.build
+++ b/meson.build
@@ -5,9 +5,6 @@
     default_options: [
         'buildtype=debugoptimized',
         'cpp_std=c++20',
-        # TODO: Without RTTI telemetry does not build using Boost 1.74.0
-        # https://github.com/chriskohlhoff/asio/issues/533
-        #'cpp_rtti=false',
         'warning_level=3',
         'werror=true',
         'b_lto=true',
@@ -15,40 +12,31 @@
     license: 'Apache-2.0',
 )
 
-summary({'Fast build with link-time optimizer disabled':
-            not get_option('b_lto')}, section: 'General')
-
-cpp = meson.get_compiler('cpp')
+cxx = meson.get_compiler('cpp')
 add_project_arguments(
-    cpp.get_supported_arguments([
+    cxx.get_supported_arguments([
         '-DBOOST_ASIO_DISABLE_THREADS',
         '-DBOOST_ALL_NO_LIB',
         '-DBOOST_SYSTEM_NO_DEPRECATED',
         '-DBOOST_ASIO_NO_DEPRECATED',
         '-DBOOST_NO_RTTI',
         '-DBOOST_NO_TYPEID',
-        # TODO: Removed below arg after upgrade to Boost 1.75
-        '-DBOOST_ALLOW_DEPRECATED_HEADERS',
         '-Wno-unused-parameter',
     ]),
     language: 'cpp'
 )
 
-boost = dependency(
-    'boost',
-    version: '>=1.74.0',
-    required: false,
-    modules: ['coroutine'])
-assert(boost.found(),
-       'Missing Boost 1.74.0 or higher, as WA you can set BOOST_ROOT ' +
-       'environemt to point at boost build. To build a boost you can use ' +
-       'script ./scripts/boost_build_1.74.0.sh')
+boost_version = '>=1.79.0'
+boost_modules = ['coroutine', 'context']
+boost = dependency('boost',
+    version: boost_version, 
+    modules: boost_modules)
 
 phosphor_logging = dependency('phosphor-logging')
 sdbusplus = dependency('sdbusplus')
 systemd = dependency('systemd')
 
-if cpp.has_header('nlohmann/json.hpp')
+if cxx.has_header('nlohmann/json.hpp')
     nlohmann_json = declare_dependency()
 else
     nlohmann_json = dependency('nlohmann_json')
diff --git a/subprojects/boost.wrap b/subprojects/boost.wrap
new file mode 100644
index 0000000..b10bf3d
--- /dev/null
+++ b/subprojects/boost.wrap
@@ -0,0 +1,10 @@
+[wrap-file]
+source_url = https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.bz2
+source_hash = 1e19565d82e43bc59209a168f5ac899d3ba471d55c7610c677d4ccf2c9c500c0
+source_filename = boost_1_80_0.tar.bz2
+
+directory = boost_1_80_0
+patch_directory = boost
+
+[provide]
+boost = boost_dep
diff --git a/subprojects/googletest.wrap b/subprojects/googletest.wrap
index f22e2fa..56da9ef 100644
--- a/subprojects/googletest.wrap
+++ b/subprojects/googletest.wrap
@@ -1,3 +1,3 @@
 [wrap-git]
 url = https://github.com/google/googletest
-revision = e2239ee6043f73722e7aa812a459f54a28552929
+revision = HEAD
diff --git a/subprojects/packagefiles/boost/meson.build b/subprojects/packagefiles/boost/meson.build
new file mode 100644
index 0000000..dab33f3
--- /dev/null
+++ b/subprojects/packagefiles/boost/meson.build
@@ -0,0 +1,29 @@
+project('boost', 'cpp',
+         version: '1.80.0',
+         meson_version: '>=0.56.0')
+
+cxx = meson.get_compiler('cpp')
+
+build_dir = join_paths(meson.current_source_dir(), 'build')
+r = run_command('[','!','-d', build_dir, ']', check: false)
+if r.returncode() == 0
+      r = run_command('./bootstrap.sh', '--with-libraries=coroutine', check: true)
+      r = run_command('./b2', 'install','--prefix=build', check: true)
+endif
+
+include_dir = join_paths('build', 'include')
+lib_dir = join_paths(meson.current_source_dir(), 'build', 'lib')
+
+custom_dep = declare_dependency(
+      link_args: ['-L' + lib_dir, '-Wl,-rpath-link,' + lib_dir])
+
+boost_inc = include_directories(include_dir, is_system:true)
+boost_dep = declare_dependency(
+       include_directories: boost_inc,
+       dependencies: [
+            cxx.find_library('boost_context', dirs: lib_dir, static: true),
+            cxx.find_library('boost_coroutine', dirs: lib_dir, static: true),
+            custom_dep
+      ])
+
+meson.override_dependency('boost', boost_dep)