1project('phosphor-dbus-interfaces', 'cpp', 2 meson_version: '>= 0.54.1', 3 default_options: [ 4 'buildtype=debugoptimized', 5 'cpp_std=c++17', 6 'warning_level=3', 7 'werror=true', 8 ], 9 version: '1.0.0', 10) 11# meson_version >= 0.54.1 is necessary because that is the first place meson 12# generates unique object filenames for two files with the same `basename`. 13# Many sdbus++ generated files have `basename` collisions because they are 14# named like `.../server.cpp`. Prior to this version, meson would create a 15# ninja recipe for a single `server.o` file. 16 17# Get sdbusplus dependency. 18sdbusplus_dep = dependency('sdbusplus', required: false) 19if sdbusplus_dep.found() 20 sdbusplusplus_prog = find_program('sdbus++') 21 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson') 22else 23 sdbusplus_proj = subproject('sdbusplus', required: true) 24 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep') 25 sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog') 26 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable( 27 'sdbuspp_gen_meson_prog' 28 ) 29endif 30 31realpath_prog = find_program('realpath') 32 33# Parse options to determine appropriate subdirectories to support. 34selected_subdirs = [] 35if get_option('data_com_ibm') 36 selected_subdirs += 'com/ibm' 37endif 38if get_option('data_org_open_power') 39 selected_subdirs += 'org/open_power' 40endif 41if get_option('data_xyz_openbmc_project') 42 selected_subdirs += 'xyz/openbmc_project' 43endif 44 45# Install the selected YAML files. 46foreach d : selected_subdirs 47 install_subdir( 48 d, 49 install_dir: get_option('datadir') / 'phosphor-dbus-yaml/yaml' / d, 50 strip_directory: true, 51 ) 52endforeach 53 54# If libphosphor_dbus was not enabled, exit out from here. We installed 55# the YAML which is all we are asked to do. 56if not get_option('libphosphor_dbus') 57 subdir_done() 58endif 59 60generated_root = meson.current_build_dir() / 'gen' 61generated_sources = [] 62generated_others = [] 63yaml_sources = [] 64 65# Source the generated meson files. 66subdir('gen') 67foreach d : selected_subdirs 68 subdir('gen' / d) 69endforeach 70 71# Parse through the list from sdbus++-gendir and put into sets. 72generated_headers = [] 73generated_cpp = [] 74generated_others_files = [] 75 76foreach g : generated_sources generated_others 77 foreach f : g.to_list() 78 rel_path = run_command( 79 realpath_prog, 80 '--relative-to', generated_root, 81 f.full_path(), 82 ).stdout().strip().split('\n')[-1] 83 84 if rel_path.endswith('.hpp') 85 generated_headers += rel_path 86 elif rel_path.endswith('.cpp') 87 generated_cpp += rel_path 88 else 89 generated_others_files += rel_path 90 endif 91 endforeach 92endforeach 93 94# Install the generated header files. 95install_subdir( 96 generated_root, 97 exclude_files: [ generated_cpp, generated_others_files ], 98 install_dir: get_option('includedir'), 99 strip_directory: true, 100) 101 102# Install the generated markdown files. 103install_subdir( 104 generated_root, 105 exclude_files: [ generated_headers, generated_cpp ], 106 install_dir: get_option('datadir') / 'doc' / meson.project_name(), 107 strip_directory: true, 108) 109 110# Define and build libphosphor_dbus.so from the C++ files. 111libphosphor_dbus = library( 112 'phosphor_dbus', 113 generated_sources, 114 include_directories: include_directories('gen'), 115 dependencies: sdbusplus_dep, 116 version: meson.project_version(), 117 install: true, 118) 119 120import('pkgconfig').generate( 121 libraries: libphosphor_dbus, 122 name: meson.project_name(), 123 version: meson.project_version(), 124 description: 'Generated sdbusplus bindings for phosphor-dbus-interfaces' 125) 126