blob: 2e9f09d367ad54c2157430b85cf02b9b1ad7578c [file] [log] [blame]
Patrick Williams08949432020-06-09 10:22:12 -05001project('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.
18sdbusplus_dep = dependency('sdbusplus', required: false)
19if sdbusplus_dep.found()
20 sdbusplusplus_prog = find_program('sdbus++')
Patrick Williams47f32d12020-06-24 16:13:38 -050021 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
Patrick Williams08949432020-06-09 10:22:12 -050022else
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 Williams47f32d12020-06-24 16:13:38 -050026 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
27 'sdbuspp_gen_meson_prog'
28 )
Patrick Williams08949432020-06-09 10:22:12 -050029endif
30
31realpath_prog = find_program('realpath')
32
33# Parse options to determine appropriate subdirectories to support.
34selected_subdirs = []
35if get_option('data_com_ibm')
36 selected_subdirs += 'com/ibm'
37endif
38if get_option('data_org_open_power')
39 selected_subdirs += 'org/open_power'
40endif
41if get_option('data_xyz_openbmc_project')
42 selected_subdirs += 'xyz/openbmc_project'
43endif
44
45# Install the selected YAML files.
46foreach d : selected_subdirs
47 install_subdir(
48 d,
49 install_dir: get_option('datadir') / 'phosphor-dbus-yaml/yaml' / d,
50 strip_directory: true,
51 )
52endforeach
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.
56if not get_option('libphosphor_dbus')
57 subdir_done()
58endif
59
Patrick Williams47f32d12020-06-24 16:13:38 -050060generated_root = meson.current_build_dir() / 'gen'
61generated_sources = []
62generated_others = []
63yaml_sources = []
64
65# Source the generated meson files.
66subdir('gen')
67foreach d : selected_subdirs
68 subdir('gen' / d)
69endforeach
Patrick Williams08949432020-06-09 10:22:12 -050070
71# Parse through the list from sdbus++-gendir and put into sets.
72generated_headers = []
73generated_cpp = []
Patrick Williams47f32d12020-06-24 16:13:38 -050074generated_others_files = []
Patrick Williams08949432020-06-09 10:22:12 -050075
Patrick Williams47f32d12020-06-24 16:13:38 -050076foreach 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 Williams08949432020-06-09 10:22:12 -050083
Patrick Williams47f32d12020-06-24 16:13:38 -050084 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 Williams08949432020-06-09 10:22:12 -050092endforeach
93
94# Install the generated header files.
95install_subdir(
96 generated_root,
Patrick Williams47f32d12020-06-24 16:13:38 -050097 exclude_files: [ generated_cpp, generated_others_files ],
Patrick Williams08949432020-06-09 10:22:12 -050098 install_dir: get_option('includedir'),
99 strip_directory: true,
100)
101
102# Install the generated markdown files.
103install_subdir(
104 generated_root,
105 exclude_files: [ generated_headers, generated_cpp ],
Patrick Williams32304972020-10-07 10:12:09 -0500106 install_dir: get_option('datadir') / 'doc' / meson.project_name(),
Patrick Williams08949432020-06-09 10:22:12 -0500107 strip_directory: true,
108)
109
110# Define and build libphosphor_dbus.so from the C++ files.
111libphosphor_dbus = library(
112 'phosphor_dbus',
Patrick Williams47f32d12020-06-24 16:13:38 -0500113 generated_sources,
114 include_directories: include_directories('gen'),
Patrick Williams08949432020-06-09 10:22:12 -0500115 dependencies: sdbusplus_dep,
116 version: meson.project_version(),
117 install: true,
118)
119
120import('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)