blob: ec64ee5a05662205f981b75d44463b75129e8388 [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.
Patrick Williams6f70d9f2021-04-15 19:07:19 -050041inst_yaml_dir = get_option('datadir') / 'phosphor-dbus-yaml/yaml'
Patrick Williams08949432020-06-09 10:22:12 -050042foreach d : selected_subdirs
43 install_subdir(
44 d,
Patrick Williams6f70d9f2021-04-15 19:07:19 -050045 install_dir: inst_yaml_dir / d,
Patrick Williams08949432020-06-09 10:22:12 -050046 strip_directory: true,
47 )
48endforeach
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.
52if not get_option('libphosphor_dbus')
53 subdir_done()
54endif
55
Patrick Williams47f32d12020-06-24 16:13:38 -050056generated_root = meson.current_build_dir() / 'gen'
57generated_sources = []
58generated_others = []
59yaml_sources = []
60
61# Source the generated meson files.
62subdir('gen')
63foreach d : selected_subdirs
64 subdir('gen' / d)
65endforeach
Patrick Williams08949432020-06-09 10:22:12 -050066
67# Parse through the list from sdbus++-gendir and put into sets.
68generated_headers = []
69generated_cpp = []
Patrick Williams47f32d12020-06-24 16:13:38 -050070generated_others_files = []
Patrick Williams08949432020-06-09 10:22:12 -050071
Patrick Williams47f32d12020-06-24 16:13:38 -050072foreach g : generated_sources generated_others
73 foreach f : g.to_list()
74 rel_path = run_command(
75 realpath_prog,
76 '--relative-to', generated_root,
77 f.full_path(),
78 ).stdout().strip().split('\n')[-1]
Patrick Williams08949432020-06-09 10:22:12 -050079
Patrick Williams47f32d12020-06-24 16:13:38 -050080 if rel_path.endswith('.hpp')
81 generated_headers += rel_path
82 elif rel_path.endswith('.cpp')
83 generated_cpp += rel_path
84 else
85 generated_others_files += rel_path
86 endif
87 endforeach
Patrick Williams08949432020-06-09 10:22:12 -050088endforeach
89
90# Install the generated header files.
91install_subdir(
92 generated_root,
Patrick Williams47f32d12020-06-24 16:13:38 -050093 exclude_files: [ generated_cpp, generated_others_files ],
Patrick Williams08949432020-06-09 10:22:12 -050094 install_dir: get_option('includedir'),
95 strip_directory: true,
96)
97
98# Install the generated markdown files.
99install_subdir(
100 generated_root,
101 exclude_files: [ generated_headers, generated_cpp ],
Patrick Williams32304972020-10-07 10:12:09 -0500102 install_dir: get_option('datadir') / 'doc' / meson.project_name(),
Patrick Williams08949432020-06-09 10:22:12 -0500103 strip_directory: true,
104)
105
106# Define and build libphosphor_dbus.so from the C++ files.
107libphosphor_dbus = library(
108 'phosphor_dbus',
Patrick Williams47f32d12020-06-24 16:13:38 -0500109 generated_sources,
110 include_directories: include_directories('gen'),
Patrick Williams08949432020-06-09 10:22:12 -0500111 dependencies: sdbusplus_dep,
112 version: meson.project_version(),
113 install: true,
114)
115
116import('pkgconfig').generate(
Patrick Williamsaff70172021-04-15 13:37:25 -0500117 libphosphor_dbus,
Patrick Williams08949432020-06-09 10:22:12 -0500118 name: meson.project_name(),
119 version: meson.project_version(),
Patrick Williams6f70d9f2021-04-15 19:07:19 -0500120 description: 'Generated sdbusplus bindings for phosphor-dbus-interfaces',
Patrick Williams32fbd5d2021-04-21 21:09:09 -0500121 variables: ['yamldir=' + '${pc_sysrootdir}${prefix}' / inst_yaml_dir],
Patrick Williams08949432020-06-09 10:22:12 -0500122)
Patrick Williams41a7b452021-04-15 13:49:06 -0500123
124phosphor_dbus_interfaces_dep = declare_dependency(
125 include_directories: include_directories('gen'),
126 link_with: libphosphor_dbus,
Patrick Williams6f70d9f2021-04-15 19:07:19 -0500127 dependencies: sdbusplus_dep,
128 variables: ['yamldir=' + meson.project_source_root()],
Patrick Williams41a7b452021-04-15 13:49:06 -0500129)