meson: Fix local build of the settings_gen target

Currently local meson build fails with the following error:
"""
[343/700] Generating settings_manager_hpp with a custom command
FAILED: settings_manager.hpp
<...>/env/bin/python3 ../settings.py -i ../settings_example.yaml
<...>
ModuleNotFoundError: No module named 'sdbusplus'
"""
This is happening because 'settings_manager.mako.hpp' from the
'settings_gen' target refers to python modules from the external
'sdbusplus' project. Therefore in case of a local build it is
necessary to provide search path to the relevant sdbusplus subproject
folder. Fix this with the help of 'PYTHONPATH' environment variable.

Tested:
Both local meson build and Yocto build are finished successfully.

Change-Id: I8ec81edcdeb84c82a315937d3ed31be3dbaa1aa5
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
diff --git a/meson.build b/meson.build
index 37aad32..e8310be 100644
--- a/meson.build
+++ b/meson.build
@@ -12,7 +12,7 @@
 python_prog = find_program('python3', native: true)
 
 # Define dependencies
-sdbusplus_dep = dependency('sdbusplus')
+sdbusplus_dep = dependency('sdbusplus', required : false)
 phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
 phosphor_logging_dep = dependency('phosphor-logging')
 cereal_dep = dependency('cereal', required: false)
@@ -33,6 +33,13 @@
 endif
 
 # Generate settings_manager.hpp
+settings_gen_env = {}
+if not sdbusplus_dep.found()
+    sdbusplus_proj = subproject('sdbusplus')
+    sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
+    settings_gen_env = {'PYTHONPATH': meson.current_source_dir() / 'subprojects' / 'sdbusplus' / 'tools'}
+endif
+
 settings_gen = custom_target(
     'settings_manager.hpp'.underscorify(),
     input: [
@@ -42,6 +49,7 @@
     ],
     output: 'settings_manager.hpp',
     command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@' ],
+    env: settings_gen_env,
 )
 
 # Generate daemon