blob: 8dc550cfe1dab2d96f8200ad3bb9cc3435a1e346 [file] [log] [blame]
Patrick Williams08949432020-06-09 10:22:12 -05001project('phosphor-dbus-interfaces', 'cpp',
Patrick Williams4b3bc1d2021-04-14 15:20:40 -05002 meson_version: '>= 0.57.0',
Patrick Williams08949432020-06-09 10:22:12 -05003 default_options: [
4 'buildtype=debugoptimized',
Patrick Williams4b3bc1d2021-04-14 15:20:40 -05005 'cpp_std=c++20',
Patrick Williams08949432020-06-09 10:22:12 -05006 'warning_level=3',
7 'werror=true',
8 ],
9 version: '1.0.0',
10)
Patrick Williams08949432020-06-09 10:22:12 -050011
12# Get sdbusplus dependency.
13sdbusplus_dep = dependency('sdbusplus', required: false)
14if sdbusplus_dep.found()
15 sdbusplusplus_prog = find_program('sdbus++')
Patrick Williams47f32d12020-06-24 16:13:38 -050016 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
Patrick Williams08949432020-06-09 10:22:12 -050017else
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 Williams47f32d12020-06-24 16:13:38 -050021 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
22 'sdbuspp_gen_meson_prog'
23 )
Patrick Williams08949432020-06-09 10:22:12 -050024endif
25
26realpath_prog = find_program('realpath')
27
28# Parse options to determine appropriate subdirectories to support.
29selected_subdirs = []
30if get_option('data_com_ibm')
31 selected_subdirs += 'com/ibm'
32endif
33if get_option('data_org_open_power')
34 selected_subdirs += 'org/open_power'
35endif
36if get_option('data_xyz_openbmc_project')
37 selected_subdirs += 'xyz/openbmc_project'
38endif
39
40# Install the selected YAML files.
41foreach d : selected_subdirs
42 install_subdir(
43 d,
44 install_dir: get_option('datadir') / 'phosphor-dbus-yaml/yaml' / d,
45 strip_directory: true,
46 )
47endforeach
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.
51if not get_option('libphosphor_dbus')
52 subdir_done()
53endif
54
Patrick Williams47f32d12020-06-24 16:13:38 -050055generated_root = meson.current_build_dir() / 'gen'
56generated_sources = []
57generated_others = []
58yaml_sources = []
59
60# Source the generated meson files.
61subdir('gen')
62foreach d : selected_subdirs
63 subdir('gen' / d)
64endforeach
Patrick Williams08949432020-06-09 10:22:12 -050065
66# Parse through the list from sdbus++-gendir and put into sets.
67generated_headers = []
68generated_cpp = []
Patrick Williams47f32d12020-06-24 16:13:38 -050069generated_others_files = []
Patrick Williams08949432020-06-09 10:22:12 -050070
Patrick Williams47f32d12020-06-24 16:13:38 -050071foreach g : generated_sources generated_others
72 foreach f : g.to_list()
73 rel_path = run_command(
74 realpath_prog,
75 '--relative-to', generated_root,
76 f.full_path(),
77 ).stdout().strip().split('\n')[-1]
Patrick Williams08949432020-06-09 10:22:12 -050078
Patrick Williams47f32d12020-06-24 16:13:38 -050079 if rel_path.endswith('.hpp')
80 generated_headers += rel_path
81 elif rel_path.endswith('.cpp')
82 generated_cpp += rel_path
83 else
84 generated_others_files += rel_path
85 endif
86 endforeach
Patrick Williams08949432020-06-09 10:22:12 -050087endforeach
88
89# Install the generated header files.
90install_subdir(
91 generated_root,
Patrick Williams47f32d12020-06-24 16:13:38 -050092 exclude_files: [ generated_cpp, generated_others_files ],
Patrick Williams08949432020-06-09 10:22:12 -050093 install_dir: get_option('includedir'),
94 strip_directory: true,
95)
96
97# Install the generated markdown files.
98install_subdir(
99 generated_root,
100 exclude_files: [ generated_headers, generated_cpp ],
Patrick Williams32304972020-10-07 10:12:09 -0500101 install_dir: get_option('datadir') / 'doc' / meson.project_name(),
Patrick Williams08949432020-06-09 10:22:12 -0500102 strip_directory: true,
103)
104
105# Define and build libphosphor_dbus.so from the C++ files.
106libphosphor_dbus = library(
107 'phosphor_dbus',
Patrick Williams47f32d12020-06-24 16:13:38 -0500108 generated_sources,
109 include_directories: include_directories('gen'),
Patrick Williams08949432020-06-09 10:22:12 -0500110 dependencies: sdbusplus_dep,
111 version: meson.project_version(),
112 install: true,
113)
114
115import('pkgconfig').generate(
Patrick Williamsaff70172021-04-15 13:37:25 -0500116 libphosphor_dbus,
Patrick Williams08949432020-06-09 10:22:12 -0500117 name: meson.project_name(),
118 version: meson.project_version(),
119 description: 'Generated sdbusplus bindings for phosphor-dbus-interfaces'
120)