blob: 856123b71bd9f5207f9cc1e571fc6713b828ed9f [file] [log] [blame]
Patrick Williams08949432020-06-09 10:22:12 -05001project('phosphor-dbus-interfaces', 'cpp',
William A. Kennington IIId2180a92021-05-14 15:34:44 -07002 meson_version: '>= 0.58.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',
William A. Kennington III71892002021-05-14 16:09:53 -07008 'generate_md=' + (meson.is_subproject() ? 'false' : 'true'),
Patrick Williams08949432020-06-09 10:22:12 -05009 ],
10 version: '1.0.0',
11)
Patrick Williams08949432020-06-09 10:22:12 -050012
13# Get sdbusplus dependency.
14sdbusplus_dep = dependency('sdbusplus', required: false)
William A. Kennington III0e6cea82021-06-17 22:35:57 -070015if sdbusplus_dep.found() and sdbusplus_dep.type_name() != 'internal'
William A. Kennington III8548f032021-05-14 15:34:01 -070016 sdbusplusplus_prog = find_program('sdbus++', native: true)
17 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
Patrick Williams08949432020-06-09 10:22:12 -050018else
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 Williams47f32d12020-06-24 16:13:38 -050022 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
23 'sdbuspp_gen_meson_prog'
24 )
Patrick Williams08949432020-06-09 10:22:12 -050025endif
26
Patrick Williams08949432020-06-09 10:22:12 -050027# Parse options to determine appropriate subdirectories to support.
28selected_subdirs = []
29if get_option('data_com_ibm')
30 selected_subdirs += 'com/ibm'
31endif
Jason M. Bills36ed8ad2021-11-16 11:22:42 -080032if get_option('data_com_intel')
33 selected_subdirs += 'com/intel'
34endif
Shawn McCarney54ed0a12021-12-08 11:14:46 -060035if get_option('data_org_freedesktop')
36 selected_subdirs += 'org/freedesktop'
37endif
Patrick Williams08949432020-06-09 10:22:12 -050038if 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.
Patrick Williams6f70d9f2021-04-15 19:07:19 -050046inst_yaml_dir = get_option('datadir') / 'phosphor-dbus-yaml/yaml'
Patrick Williams08949432020-06-09 10:22:12 -050047foreach d : selected_subdirs
48 install_subdir(
William A. Kennington IIIb1b4d262021-06-05 12:22:23 -070049 'yaml' / d,
Patrick Williams6f70d9f2021-04-15 19:07:19 -050050 install_dir: inst_yaml_dir / d,
Patrick Williams08949432020-06-09 10:22:12 -050051 strip_directory: true,
52 )
53endforeach
54
55# If libphosphor_dbus was not enabled, exit out from here. We installed
56# the YAML which is all we are asked to do.
57if not get_option('libphosphor_dbus')
58 subdir_done()
59endif
60
Patrick Williams47f32d12020-06-24 16:13:38 -050061generated_sources = []
62generated_others = []
63yaml_sources = []
64
65# Source the generated meson files.
66subdir('gen')
67foreach d : selected_subdirs
68 subdir('gen' / d)
69endforeach
William A. Kennington III2600aff2021-06-05 12:15:23 -070070custom_target(
71 'md',
72 command: 'true',
73 output: 'md',
74 capture: true,
75 depends: generated_others,
William A. Kennington III71892002021-05-14 16:09:53 -070076 build_by_default: get_option('generate_md'))
Patrick Williams08949432020-06-09 10:22:12 -050077
William A. Kennington IIId2180a92021-05-14 15:34:44 -070078generated_files_headers = []
79generated_files_cpp = []
80foreach s : generated_sources
81 foreach f : s.to_list()
82 p = f.full_path()
83 if p.endswith('.hpp')
84 generated_files_headers += f
85 elif p.endswith('.cpp')
86 generated_files_cpp += f
Patrick Williams47f32d12020-06-24 16:13:38 -050087 else
William A. Kennington IIId2180a92021-05-14 15:34:44 -070088 error('Unknown filetype: ' + p)
Patrick Williams47f32d12020-06-24 16:13:38 -050089 endif
90 endforeach
Patrick Williams08949432020-06-09 10:22:12 -050091endforeach
92
William A. Kennington IIId2180a92021-05-14 15:34:44 -070093generated_root = meson.current_build_dir() / 'gen/'
94exclude_cpp = []
95foreach f : generated_files_cpp
Jonathan Doman90116922021-11-01 17:26:07 -070096 exclude_cpp += f.full_path().replace(generated_root, '').strip('/')
William A. Kennington IIId2180a92021-05-14 15:34:44 -070097endforeach
98
Patrick Williams08949432020-06-09 10:22:12 -050099# Install the generated header files.
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700100exclude = exclude_cpp
101foreach o : generated_others
102 foreach f : o.to_list()
Jonathan Doman90116922021-11-01 17:26:07 -0700103 exclude += f.full_path().replace(generated_root, '').strip('/')
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700104 endforeach
105endforeach
Patrick Williams08949432020-06-09 10:22:12 -0500106install_subdir(
107 generated_root,
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700108 exclude_files: exclude,
Patrick Williams08949432020-06-09 10:22:12 -0500109 install_dir: get_option('includedir'),
110 strip_directory: true,
111)
112
113# Install the generated markdown files.
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700114exclude = exclude_cpp
115foreach f : generated_files_headers
Jonathan Doman90116922021-11-01 17:26:07 -0700116 exclude += f.full_path().replace(generated_root, '').strip('/')
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700117endforeach
Patrick Williams08949432020-06-09 10:22:12 -0500118install_subdir(
119 generated_root,
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700120 exclude_files: exclude,
Patrick Williams32304972020-10-07 10:12:09 -0500121 install_dir: get_option('datadir') / 'doc' / meson.project_name(),
Patrick Williams08949432020-06-09 10:22:12 -0500122 strip_directory: true,
123)
124
125# Define and build libphosphor_dbus.so from the C++ files.
126libphosphor_dbus = library(
127 'phosphor_dbus',
Patrick Williams47f32d12020-06-24 16:13:38 -0500128 generated_sources,
William A. Kennington IIIdb241112021-05-14 15:35:48 -0700129 implicit_include_directories: false,
Patrick Williams47f32d12020-06-24 16:13:38 -0500130 include_directories: include_directories('gen'),
Patrick Williams08949432020-06-09 10:22:12 -0500131 dependencies: sdbusplus_dep,
132 version: meson.project_version(),
133 install: true,
134)
135
136import('pkgconfig').generate(
Patrick Williamsaff70172021-04-15 13:37:25 -0500137 libphosphor_dbus,
Patrick Williams08949432020-06-09 10:22:12 -0500138 name: meson.project_name(),
139 version: meson.project_version(),
Patrick Williams6f70d9f2021-04-15 19:07:19 -0500140 description: 'Generated sdbusplus bindings for phosphor-dbus-interfaces',
Patrick Williams32fbd5d2021-04-21 21:09:09 -0500141 variables: ['yamldir=' + '${pc_sysrootdir}${prefix}' / inst_yaml_dir],
Patrick Williams08949432020-06-09 10:22:12 -0500142)
Patrick Williams41a7b452021-04-15 13:49:06 -0500143
144phosphor_dbus_interfaces_dep = declare_dependency(
William A. Kennington III795b4372021-05-14 15:37:47 -0700145 sources: generated_files_headers,
Patrick Williams41a7b452021-04-15 13:49:06 -0500146 include_directories: include_directories('gen'),
147 link_with: libphosphor_dbus,
Patrick Williams6f70d9f2021-04-15 19:07:19 -0500148 dependencies: sdbusplus_dep,
William A. Kennington IIIb1b4d262021-06-05 12:22:23 -0700149 variables: ['yamldir=' + meson.project_source_root() / 'yaml'],
Patrick Williams41a7b452021-04-15 13:49:06 -0500150)