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_open_power') 33 selected_subdirs += 'org/open_power' 34endif 35if get_option('data_xyz_openbmc_project') 36 selected_subdirs += 'xyz/openbmc_project' 37endif 38 39# Install the selected YAML files. 40inst_yaml_dir = get_option('datadir') / 'phosphor-dbus-yaml/yaml' 41foreach d : selected_subdirs 42 install_subdir( 43 'yaml' / d, 44 install_dir: inst_yaml_dir / d, 45 strip_directory: true, 46 ) 47endforeach 48 49# If libphosphor_dbus was not enabled, exit out from here. We installed 50# the YAML which is all we are asked to do. 51if not get_option('libphosphor_dbus') 52 subdir_done() 53endif 54 55generated_sources = [] 56generated_others = [] 57yaml_sources = [] 58 59# Source the generated meson files. 60subdir('gen') 61foreach d : selected_subdirs 62 subdir('gen' / d) 63endforeach 64custom_target( 65 'md', 66 command: 'true', 67 output: 'md', 68 capture: true, 69 depends: generated_others, 70 build_by_default: get_option('generate_md')) 71 72generated_files_headers = [] 73generated_files_cpp = [] 74foreach s : generated_sources 75 foreach f : s.to_list() 76 p = f.full_path() 77 if p.endswith('.hpp') 78 generated_files_headers += f 79 elif p.endswith('.cpp') 80 generated_files_cpp += f 81 else 82 error('Unknown filetype: ' + p) 83 endif 84 endforeach 85endforeach 86 87generated_root = meson.current_build_dir() / 'gen/' 88exclude_cpp = [] 89foreach f : generated_files_cpp 90 exclude_cpp += f.full_path().replace(generated_root, '') 91endforeach 92 93# Install the generated header files. 94exclude = exclude_cpp 95foreach o : generated_others 96 foreach f : o.to_list() 97 exclude += f.full_path().replace(generated_root, '') 98 endforeach 99endforeach 100install_subdir( 101 generated_root, 102 exclude_files: exclude, 103 install_dir: get_option('includedir'), 104 strip_directory: true, 105) 106 107# Install the generated markdown files. 108exclude = exclude_cpp 109foreach f : generated_files_headers 110 exclude += f.full_path().replace(generated_root, '') 111endforeach 112install_subdir( 113 generated_root, 114 exclude_files: exclude, 115 install_dir: get_option('datadir') / 'doc' / meson.project_name(), 116 strip_directory: true, 117) 118 119# Define and build libphosphor_dbus.so from the C++ files. 120libphosphor_dbus = library( 121 'phosphor_dbus', 122 generated_sources, 123 implicit_include_directories: false, 124 include_directories: include_directories('gen'), 125 dependencies: sdbusplus_dep, 126 version: meson.project_version(), 127 install: true, 128) 129 130import('pkgconfig').generate( 131 libphosphor_dbus, 132 name: meson.project_name(), 133 version: meson.project_version(), 134 description: 'Generated sdbusplus bindings for phosphor-dbus-interfaces', 135 variables: ['yamldir=' + '${pc_sysrootdir}${prefix}' / inst_yaml_dir], 136) 137 138phosphor_dbus_interfaces_dep = declare_dependency( 139 sources: generated_files_headers, 140 include_directories: include_directories('gen'), 141 link_with: libphosphor_dbus, 142 dependencies: sdbusplus_dep, 143 variables: ['yamldir=' + meson.project_source_root() / 'yaml'], 144) 145