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