Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 1 | project('phosphor-dbus-interfaces', 'cpp', |
Patrick Williams | 4b3bc1d | 2021-04-14 15:20:40 -0500 | [diff] [blame] | 2 | meson_version: '>= 0.57.0', |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 3 | default_options: [ |
| 4 | 'buildtype=debugoptimized', |
Patrick Williams | 4b3bc1d | 2021-04-14 15:20:40 -0500 | [diff] [blame] | 5 | 'cpp_std=c++20', |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 6 | 'warning_level=3', |
| 7 | 'werror=true', |
| 8 | ], |
| 9 | version: '1.0.0', |
| 10 | ) |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 11 | |
| 12 | # Get sdbusplus dependency. |
| 13 | sdbusplus_dep = dependency('sdbusplus', required: false) |
| 14 | if sdbusplus_dep.found() |
William A. Kennington III | 8548f03 | 2021-05-14 15:34:01 -0700 | [diff] [blame] | 15 | sdbusplusplus_prog = find_program('sdbus++', native: true) |
| 16 | sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true) |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 17 | else |
| 18 | sdbusplus_proj = subproject('sdbusplus', required: true) |
| 19 | sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep') |
| 20 | sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog') |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 21 | sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable( |
| 22 | 'sdbuspp_gen_meson_prog' |
| 23 | ) |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 24 | endif |
| 25 | |
| 26 | realpath_prog = find_program('realpath') |
| 27 | |
| 28 | # Parse options to determine appropriate subdirectories to support. |
| 29 | selected_subdirs = [] |
| 30 | if get_option('data_com_ibm') |
| 31 | selected_subdirs += 'com/ibm' |
| 32 | endif |
| 33 | if get_option('data_org_open_power') |
| 34 | selected_subdirs += 'org/open_power' |
| 35 | endif |
| 36 | if get_option('data_xyz_openbmc_project') |
| 37 | selected_subdirs += 'xyz/openbmc_project' |
| 38 | endif |
| 39 | |
| 40 | # Install the selected YAML files. |
Patrick Williams | 6f70d9f | 2021-04-15 19:07:19 -0500 | [diff] [blame] | 41 | inst_yaml_dir = get_option('datadir') / 'phosphor-dbus-yaml/yaml' |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 42 | foreach d : selected_subdirs |
| 43 | install_subdir( |
| 44 | d, |
Patrick Williams | 6f70d9f | 2021-04-15 19:07:19 -0500 | [diff] [blame] | 45 | install_dir: inst_yaml_dir / d, |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 46 | strip_directory: true, |
| 47 | ) |
| 48 | endforeach |
| 49 | |
| 50 | # If libphosphor_dbus was not enabled, exit out from here. We installed |
| 51 | # the YAML which is all we are asked to do. |
| 52 | if not get_option('libphosphor_dbus') |
| 53 | subdir_done() |
| 54 | endif |
| 55 | |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 56 | generated_root = meson.current_build_dir() / 'gen' |
| 57 | generated_sources = [] |
| 58 | generated_others = [] |
| 59 | yaml_sources = [] |
| 60 | |
| 61 | # Source the generated meson files. |
| 62 | subdir('gen') |
| 63 | foreach d : selected_subdirs |
| 64 | subdir('gen' / d) |
| 65 | endforeach |
William A. Kennington III | 2600aff | 2021-06-05 12:15:23 -0700 | [diff] [blame] | 66 | custom_target( |
| 67 | 'md', |
| 68 | command: 'true', |
| 69 | output: 'md', |
| 70 | capture: true, |
| 71 | depends: generated_others, |
| 72 | build_by_default: true) |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 73 | |
| 74 | # Parse through the list from sdbus++-gendir and put into sets. |
| 75 | generated_headers = [] |
| 76 | generated_cpp = [] |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 77 | generated_others_files = [] |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 78 | |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 79 | foreach g : generated_sources generated_others |
| 80 | foreach f : g.to_list() |
| 81 | rel_path = run_command( |
| 82 | realpath_prog, |
| 83 | '--relative-to', generated_root, |
| 84 | f.full_path(), |
| 85 | ).stdout().strip().split('\n')[-1] |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 86 | |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 87 | if rel_path.endswith('.hpp') |
| 88 | generated_headers += rel_path |
| 89 | elif rel_path.endswith('.cpp') |
| 90 | generated_cpp += rel_path |
| 91 | else |
| 92 | generated_others_files += rel_path |
| 93 | endif |
| 94 | endforeach |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 95 | endforeach |
| 96 | |
| 97 | # Install the generated header files. |
| 98 | install_subdir( |
| 99 | generated_root, |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 100 | exclude_files: [ generated_cpp, generated_others_files ], |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 101 | install_dir: get_option('includedir'), |
| 102 | strip_directory: true, |
| 103 | ) |
| 104 | |
| 105 | # Install the generated markdown files. |
| 106 | install_subdir( |
| 107 | generated_root, |
| 108 | exclude_files: [ generated_headers, generated_cpp ], |
Patrick Williams | 3230497 | 2020-10-07 10:12:09 -0500 | [diff] [blame] | 109 | install_dir: get_option('datadir') / 'doc' / meson.project_name(), |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 110 | strip_directory: true, |
| 111 | ) |
| 112 | |
| 113 | # Define and build libphosphor_dbus.so from the C++ files. |
| 114 | libphosphor_dbus = library( |
| 115 | 'phosphor_dbus', |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 116 | generated_sources, |
| 117 | include_directories: include_directories('gen'), |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 118 | dependencies: sdbusplus_dep, |
| 119 | version: meson.project_version(), |
| 120 | install: true, |
| 121 | ) |
| 122 | |
| 123 | import('pkgconfig').generate( |
Patrick Williams | aff7017 | 2021-04-15 13:37:25 -0500 | [diff] [blame] | 124 | libphosphor_dbus, |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 125 | name: meson.project_name(), |
| 126 | version: meson.project_version(), |
Patrick Williams | 6f70d9f | 2021-04-15 19:07:19 -0500 | [diff] [blame] | 127 | description: 'Generated sdbusplus bindings for phosphor-dbus-interfaces', |
Patrick Williams | 32fbd5d | 2021-04-21 21:09:09 -0500 | [diff] [blame] | 128 | variables: ['yamldir=' + '${pc_sysrootdir}${prefix}' / inst_yaml_dir], |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 129 | ) |
Patrick Williams | 41a7b45 | 2021-04-15 13:49:06 -0500 | [diff] [blame] | 130 | |
| 131 | phosphor_dbus_interfaces_dep = declare_dependency( |
| 132 | include_directories: include_directories('gen'), |
| 133 | link_with: libphosphor_dbus, |
Patrick Williams | 6f70d9f | 2021-04-15 19:07:19 -0500 | [diff] [blame] | 134 | dependencies: sdbusplus_dep, |
| 135 | variables: ['yamldir=' + meson.project_source_root()], |
Patrick Williams | 41a7b45 | 2021-04-15 13:49:06 -0500 | [diff] [blame] | 136 | ) |