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