1project('phosphor-dbus-interfaces', 'cpp', 2 meson_version: '>= 0.58.0', 3 default_options: [ 4 'buildtype=debugoptimized', 5 'cpp_std=c++20', 6 'warning_level=3', 7 'werror=true', 8 'generate_md=' + (meson.is_subproject() ? 'false' : 'true'), 9 ], 10 version: '1.0.0', 11) 12 13# Get sdbusplus dependency. 14sdbusplus_dep = dependency('sdbusplus', required: false) 15if sdbusplus_dep.found() and sdbusplus_dep.type_name() != 'internal' 16 sdbusplusplus_prog = find_program('sdbus++', native: true) 17 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true) 18else 19 sdbusplus_proj = subproject('sdbusplus', required: true) 20 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep') 21 sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog') 22 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable( 23 'sdbuspp_gen_meson_prog' 24 ) 25endif 26 27# Parse options to determine appropriate subdirectories to support. 28selected_subdirs = [] 29if get_option('data_com_ibm') 30 selected_subdirs += 'com/ibm' 31endif 32if get_option('data_org_freedesktop') 33 selected_subdirs += 'org/freedesktop' 34endif 35if get_option('data_org_open_power') 36 selected_subdirs += 'org/open_power' 37endif 38if get_option('data_xyz_openbmc_project') 39 selected_subdirs += 'xyz/openbmc_project' 40endif 41 42# Install the selected YAML files. 43inst_yaml_dir = get_option('datadir') / 'phosphor-dbus-yaml/yaml' 44foreach d : selected_subdirs 45 install_subdir( 46 'yaml' / d, 47 install_dir: inst_yaml_dir / d, 48 strip_directory: true, 49 ) 50endforeach 51 52# If libphosphor_dbus was not enabled, exit out from here. We installed 53# the YAML which is all we are asked to do. 54if not get_option('libphosphor_dbus') 55 subdir_done() 56endif 57 58generated_sources = [] 59generated_others = [] 60yaml_sources = [] 61 62# Source the generated meson files. 63subdir('gen') 64foreach d : selected_subdirs 65 subdir('gen' / d) 66endforeach 67custom_target( 68 'md', 69 command: 'true', 70 output: 'md', 71 capture: true, 72 depends: generated_others, 73 build_by_default: get_option('generate_md')) 74 75generated_files_headers = [] 76generated_files_cpp = [] 77foreach s : generated_sources 78 foreach f : s.to_list() 79 p = f.full_path() 80 if p.endswith('.hpp') 81 generated_files_headers += f 82 elif p.endswith('.cpp') 83 generated_files_cpp += f 84 else 85 error('Unknown filetype: ' + p) 86 endif 87 endforeach 88endforeach 89 90generated_root = meson.current_build_dir() / 'gen/' 91exclude_cpp = [] 92foreach f : generated_files_cpp 93 exclude_cpp += f.full_path().replace(generated_root, '').strip('/') 94endforeach 95 96# Install the generated header files. 97exclude = exclude_cpp 98foreach o : generated_others 99 foreach f : o.to_list() 100 exclude += f.full_path().replace(generated_root, '').strip('/') 101 endforeach 102endforeach 103install_subdir( 104 generated_root, 105 exclude_files: exclude, 106 install_dir: get_option('includedir'), 107 strip_directory: true, 108) 109 110# Install the generated markdown files. 111exclude = exclude_cpp 112foreach f : generated_files_headers 113 exclude += f.full_path().replace(generated_root, '').strip('/') 114endforeach 115install_subdir( 116 generated_root, 117 exclude_files: exclude, 118 install_dir: get_option('datadir') / 'doc' / meson.project_name(), 119 strip_directory: true, 120) 121 122# Define and build libphosphor_dbus.so from the C++ files. 123libphosphor_dbus = library( 124 'phosphor_dbus', 125 generated_sources, 126 implicit_include_directories: false, 127 include_directories: include_directories('gen'), 128 dependencies: sdbusplus_dep, 129 version: meson.project_version(), 130 install: true, 131) 132 133import('pkgconfig').generate( 134 libphosphor_dbus, 135 name: meson.project_name(), 136 version: meson.project_version(), 137 description: 'Generated sdbusplus bindings for phosphor-dbus-interfaces', 138 variables: ['yamldir=' + '${pc_sysrootdir}${prefix}' / inst_yaml_dir], 139) 140 141phosphor_dbus_interfaces_dep = declare_dependency( 142 sources: generated_files_headers, 143 include_directories: include_directories('gen'), 144 link_with: libphosphor_dbus, 145 dependencies: sdbusplus_dep, 146 variables: ['yamldir=' + meson.project_source_root() / 'yaml'], 147) 148