Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 1 | project('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. |
| 18 | sdbusplus_dep = dependency('sdbusplus', required: false) |
| 19 | if sdbusplus_dep.found() |
| 20 | sdbusplusplus_prog = find_program('sdbus++') |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 21 | sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson') |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 22 | else |
| 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') |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 26 | sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable( |
| 27 | 'sdbuspp_gen_meson_prog' |
| 28 | ) |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 29 | endif |
| 30 | |
| 31 | realpath_prog = find_program('realpath') |
| 32 | |
| 33 | # Parse options to determine appropriate subdirectories to support. |
| 34 | selected_subdirs = [] |
| 35 | if get_option('data_com_ibm') |
| 36 | selected_subdirs += 'com/ibm' |
| 37 | endif |
| 38 | if get_option('data_org_open_power') |
| 39 | selected_subdirs += 'org/open_power' |
| 40 | endif |
| 41 | if get_option('data_xyz_openbmc_project') |
| 42 | selected_subdirs += 'xyz/openbmc_project' |
| 43 | endif |
| 44 | |
| 45 | # Install the selected YAML files. |
| 46 | foreach d : selected_subdirs |
| 47 | install_subdir( |
| 48 | d, |
| 49 | install_dir: get_option('datadir') / 'phosphor-dbus-yaml/yaml' / d, |
| 50 | strip_directory: true, |
| 51 | ) |
| 52 | endforeach |
| 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. |
| 56 | if not get_option('libphosphor_dbus') |
| 57 | subdir_done() |
| 58 | endif |
| 59 | |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 60 | generated_root = meson.current_build_dir() / 'gen' |
| 61 | generated_sources = [] |
| 62 | generated_others = [] |
| 63 | yaml_sources = [] |
| 64 | |
| 65 | # Source the generated meson files. |
| 66 | subdir('gen') |
| 67 | foreach d : selected_subdirs |
| 68 | subdir('gen' / d) |
| 69 | endforeach |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 70 | |
| 71 | # Parse through the list from sdbus++-gendir and put into sets. |
| 72 | generated_headers = [] |
| 73 | generated_cpp = [] |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 74 | generated_others_files = [] |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 75 | |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 76 | foreach 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] |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 83 | |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 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 |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 92 | endforeach |
| 93 | |
| 94 | # Install the generated header files. |
| 95 | install_subdir( |
| 96 | generated_root, |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 97 | exclude_files: [ generated_cpp, generated_others_files ], |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 98 | install_dir: get_option('includedir'), |
| 99 | strip_directory: true, |
| 100 | ) |
| 101 | |
| 102 | # Install the generated markdown files. |
| 103 | install_subdir( |
| 104 | generated_root, |
| 105 | exclude_files: [ generated_headers, generated_cpp ], |
Patrick Williams | 3230497 | 2020-10-07 10:12:09 -0500 | [diff] [blame] | 106 | install_dir: get_option('datadir') / 'doc' / meson.project_name(), |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 107 | strip_directory: true, |
| 108 | ) |
| 109 | |
| 110 | # Define and build libphosphor_dbus.so from the C++ files. |
| 111 | libphosphor_dbus = library( |
| 112 | 'phosphor_dbus', |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 113 | generated_sources, |
| 114 | include_directories: include_directories('gen'), |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 115 | dependencies: sdbusplus_dep, |
| 116 | version: meson.project_version(), |
| 117 | install: true, |
| 118 | ) |
| 119 | |
| 120 | import('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 | ) |