Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 1 | project('phosphor-dbus-interfaces', 'cpp', |
William A. Kennington III | d2180a9 | 2021-05-14 15:34:44 -0700 | [diff] [blame] | 2 | meson_version: '>= 0.58.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', |
William A. Kennington III | 7189200 | 2021-05-14 16:09:53 -0700 | [diff] [blame] | 8 | 'generate_md=' + (meson.is_subproject() ? 'false' : 'true'), |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 9 | ], |
| 10 | version: '1.0.0', |
| 11 | ) |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 12 | |
| 13 | # Get sdbusplus dependency. |
| 14 | sdbusplus_dep = dependency('sdbusplus', required: false) |
William A. Kennington III | 0e6cea8 | 2021-06-17 22:35:57 -0700 | [diff] [blame] | 15 | if sdbusplus_dep.found() and sdbusplus_dep.type_name() != 'internal' |
William A. Kennington III | 8548f03 | 2021-05-14 15:34:01 -0700 | [diff] [blame] | 16 | sdbusplusplus_prog = find_program('sdbus++', native: true) |
| 17 | sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true) |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 18 | else |
| 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') |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 22 | sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable( |
| 23 | 'sdbuspp_gen_meson_prog' |
| 24 | ) |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 25 | endif |
| 26 | |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 27 | # Parse options to determine appropriate subdirectories to support. |
| 28 | selected_subdirs = [] |
| 29 | if get_option('data_com_ibm') |
| 30 | selected_subdirs += 'com/ibm' |
| 31 | endif |
| 32 | if get_option('data_org_open_power') |
| 33 | selected_subdirs += 'org/open_power' |
| 34 | endif |
| 35 | if get_option('data_xyz_openbmc_project') |
| 36 | selected_subdirs += 'xyz/openbmc_project' |
| 37 | endif |
| 38 | |
| 39 | # Install the selected YAML files. |
Patrick Williams | 6f70d9f | 2021-04-15 19:07:19 -0500 | [diff] [blame] | 40 | inst_yaml_dir = get_option('datadir') / 'phosphor-dbus-yaml/yaml' |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 41 | foreach d : selected_subdirs |
| 42 | install_subdir( |
William A. Kennington III | b1b4d26 | 2021-06-05 12:22:23 -0700 | [diff] [blame] | 43 | 'yaml' / d, |
Patrick Williams | 6f70d9f | 2021-04-15 19:07:19 -0500 | [diff] [blame] | 44 | install_dir: inst_yaml_dir / d, |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 45 | strip_directory: true, |
| 46 | ) |
| 47 | endforeach |
| 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. |
| 51 | if not get_option('libphosphor_dbus') |
| 52 | subdir_done() |
| 53 | endif |
| 54 | |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 55 | generated_sources = [] |
| 56 | generated_others = [] |
| 57 | yaml_sources = [] |
| 58 | |
| 59 | # Source the generated meson files. |
| 60 | subdir('gen') |
| 61 | foreach d : selected_subdirs |
| 62 | subdir('gen' / d) |
| 63 | endforeach |
William A. Kennington III | 2600aff | 2021-06-05 12:15:23 -0700 | [diff] [blame] | 64 | custom_target( |
| 65 | 'md', |
| 66 | command: 'true', |
| 67 | output: 'md', |
| 68 | capture: true, |
| 69 | depends: generated_others, |
William A. Kennington III | 7189200 | 2021-05-14 16:09:53 -0700 | [diff] [blame] | 70 | build_by_default: get_option('generate_md')) |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 71 | |
William A. Kennington III | d2180a9 | 2021-05-14 15:34:44 -0700 | [diff] [blame] | 72 | generated_files_headers = [] |
| 73 | generated_files_cpp = [] |
| 74 | foreach 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 |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 81 | else |
William A. Kennington III | d2180a9 | 2021-05-14 15:34:44 -0700 | [diff] [blame] | 82 | error('Unknown filetype: ' + p) |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 83 | endif |
| 84 | endforeach |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 85 | endforeach |
| 86 | |
William A. Kennington III | d2180a9 | 2021-05-14 15:34:44 -0700 | [diff] [blame] | 87 | generated_root = meson.current_build_dir() / 'gen/' |
| 88 | exclude_cpp = [] |
| 89 | foreach f : generated_files_cpp |
| 90 | exclude_cpp += f.full_path().replace(generated_root, '') |
| 91 | endforeach |
| 92 | |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 93 | # Install the generated header files. |
William A. Kennington III | d2180a9 | 2021-05-14 15:34:44 -0700 | [diff] [blame] | 94 | exclude = exclude_cpp |
| 95 | foreach o : generated_others |
| 96 | foreach f : o.to_list() |
| 97 | exclude += f.full_path().replace(generated_root, '') |
| 98 | endforeach |
| 99 | endforeach |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 100 | install_subdir( |
| 101 | generated_root, |
William A. Kennington III | d2180a9 | 2021-05-14 15:34:44 -0700 | [diff] [blame] | 102 | exclude_files: exclude, |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 103 | install_dir: get_option('includedir'), |
| 104 | strip_directory: true, |
| 105 | ) |
| 106 | |
| 107 | # Install the generated markdown files. |
William A. Kennington III | d2180a9 | 2021-05-14 15:34:44 -0700 | [diff] [blame] | 108 | exclude = exclude_cpp |
| 109 | foreach f : generated_files_headers |
| 110 | exclude += f.full_path().replace(generated_root, '') |
| 111 | endforeach |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 112 | install_subdir( |
| 113 | generated_root, |
William A. Kennington III | d2180a9 | 2021-05-14 15:34:44 -0700 | [diff] [blame] | 114 | exclude_files: exclude, |
Patrick Williams | 3230497 | 2020-10-07 10:12:09 -0500 | [diff] [blame] | 115 | install_dir: get_option('datadir') / 'doc' / meson.project_name(), |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 116 | strip_directory: true, |
| 117 | ) |
| 118 | |
| 119 | # Define and build libphosphor_dbus.so from the C++ files. |
| 120 | libphosphor_dbus = library( |
| 121 | 'phosphor_dbus', |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 122 | generated_sources, |
William A. Kennington III | db24111 | 2021-05-14 15:35:48 -0700 | [diff] [blame] | 123 | implicit_include_directories: false, |
Patrick Williams | 47f32d1 | 2020-06-24 16:13:38 -0500 | [diff] [blame] | 124 | include_directories: include_directories('gen'), |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 125 | dependencies: sdbusplus_dep, |
| 126 | version: meson.project_version(), |
| 127 | install: true, |
| 128 | ) |
| 129 | |
| 130 | import('pkgconfig').generate( |
Patrick Williams | aff7017 | 2021-04-15 13:37:25 -0500 | [diff] [blame] | 131 | libphosphor_dbus, |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 132 | name: meson.project_name(), |
| 133 | version: meson.project_version(), |
Patrick Williams | 6f70d9f | 2021-04-15 19:07:19 -0500 | [diff] [blame] | 134 | description: 'Generated sdbusplus bindings for phosphor-dbus-interfaces', |
Patrick Williams | 32fbd5d | 2021-04-21 21:09:09 -0500 | [diff] [blame] | 135 | variables: ['yamldir=' + '${pc_sysrootdir}${prefix}' / inst_yaml_dir], |
Patrick Williams | 0894943 | 2020-06-09 10:22:12 -0500 | [diff] [blame] | 136 | ) |
Patrick Williams | 41a7b45 | 2021-04-15 13:49:06 -0500 | [diff] [blame] | 137 | |
| 138 | phosphor_dbus_interfaces_dep = declare_dependency( |
William A. Kennington III | 795b437 | 2021-05-14 15:37:47 -0700 | [diff] [blame] | 139 | sources: generated_files_headers, |
Patrick Williams | 41a7b45 | 2021-04-15 13:49:06 -0500 | [diff] [blame] | 140 | include_directories: include_directories('gen'), |
| 141 | link_with: libphosphor_dbus, |
Patrick Williams | 6f70d9f | 2021-04-15 19:07:19 -0500 | [diff] [blame] | 142 | dependencies: sdbusplus_dep, |
William A. Kennington III | b1b4d26 | 2021-06-05 12:22:23 -0700 | [diff] [blame] | 143 | variables: ['yamldir=' + meson.project_source_root() / 'yaml'], |
Patrick Williams | 41a7b45 | 2021-04-15 13:49:06 -0500 | [diff] [blame] | 144 | ) |