blob: 70cd52acce8a5209b31c050e01aa7c47fbbd0c1c [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
Patrick Williams69292c22022-03-23 15:46:40 -050013sdbusplus_dep = dependency('sdbusplus')
14sdbusplusplus_prog = find_program('sdbus++', native: true)
15sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson', native: true)
Patrick Williams11335242022-09-12 06:11:41 -050016sdbusplusplus_depfiles = files()
17if sdbusplus_dep.type_name() == 'internal'
18 sdbusplusplus_depfiles = subproject('sdbusplus').get_variable('sdbusplusplus_depfiles')
19endif
Patrick Williams08949432020-06-09 10:22:12 -050020
Patrick Williams08949432020-06-09 10:22:12 -050021# Parse options to determine appropriate subdirectories to support.
22selected_subdirs = []
23if get_option('data_com_ibm')
24 selected_subdirs += 'com/ibm'
25endif
Jason M. Bills36ed8ad2021-11-16 11:22:42 -080026if get_option('data_com_intel')
27 selected_subdirs += 'com/intel'
28endif
John Edward Broadbent2b2784a2022-02-03 19:54:34 -080029if get_option('data_com_google')
30 selected_subdirs += 'com/google'
31endif
Shawn McCarney54ed0a12021-12-08 11:14:46 -060032if get_option('data_org_freedesktop')
33 selected_subdirs += 'org/freedesktop'
34endif
Patrick Williams08949432020-06-09 10:22:12 -050035if get_option('data_org_open_power')
36 selected_subdirs += 'org/open_power'
37endif
38if get_option('data_xyz_openbmc_project')
39 selected_subdirs += 'xyz/openbmc_project'
40endif
41
42# Install the selected YAML files.
Patrick Williams6f70d9f2021-04-15 19:07:19 -050043inst_yaml_dir = get_option('datadir') / 'phosphor-dbus-yaml/yaml'
Patrick Williams08949432020-06-09 10:22:12 -050044foreach d : selected_subdirs
45 install_subdir(
William A. Kennington IIIb1b4d262021-06-05 12:22:23 -070046 'yaml' / d,
Patrick Williams6f70d9f2021-04-15 19:07:19 -050047 install_dir: inst_yaml_dir / d,
Patrick Williams08949432020-06-09 10:22:12 -050048 strip_directory: true,
49 )
50endforeach
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.
54if not get_option('libphosphor_dbus')
55 subdir_done()
56endif
57
Patrick Williams47f32d12020-06-24 16:13:38 -050058generated_sources = []
59generated_others = []
60yaml_sources = []
61
62# Source the generated meson files.
63subdir('gen')
64foreach d : selected_subdirs
65 subdir('gen' / d)
66endforeach
William A. Kennington III2600aff2021-06-05 12:15:23 -070067custom_target(
68 'md',
69 command: 'true',
70 output: 'md',
71 capture: true,
72 depends: generated_others,
William A. Kennington III71892002021-05-14 16:09:53 -070073 build_by_default: get_option('generate_md'))
Patrick Williams08949432020-06-09 10:22:12 -050074
William A. Kennington IIId2180a92021-05-14 15:34:44 -070075generated_files_headers = []
76generated_files_cpp = []
77foreach 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 Williams47f32d12020-06-24 16:13:38 -050084 else
William A. Kennington IIId2180a92021-05-14 15:34:44 -070085 error('Unknown filetype: ' + p)
Patrick Williams47f32d12020-06-24 16:13:38 -050086 endif
87 endforeach
Patrick Williams08949432020-06-09 10:22:12 -050088endforeach
89
William A. Kennington IIId2180a92021-05-14 15:34:44 -070090generated_root = meson.current_build_dir() / 'gen/'
91exclude_cpp = []
92foreach f : generated_files_cpp
Jonathan Doman90116922021-11-01 17:26:07 -070093 exclude_cpp += f.full_path().replace(generated_root, '').strip('/')
William A. Kennington IIId2180a92021-05-14 15:34:44 -070094endforeach
95
Patrick Williams08949432020-06-09 10:22:12 -050096# Install the generated header files.
William A. Kennington IIId2180a92021-05-14 15:34:44 -070097exclude = exclude_cpp
98foreach o : generated_others
99 foreach f : o.to_list()
Jonathan Doman90116922021-11-01 17:26:07 -0700100 exclude += f.full_path().replace(generated_root, '').strip('/')
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700101 endforeach
102endforeach
Patrick Williams08949432020-06-09 10:22:12 -0500103install_subdir(
104 generated_root,
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700105 exclude_files: exclude,
Patrick Williams08949432020-06-09 10:22:12 -0500106 install_dir: get_option('includedir'),
107 strip_directory: true,
108)
109
110# Install the generated markdown files.
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700111exclude = exclude_cpp
112foreach f : generated_files_headers
Jonathan Doman90116922021-11-01 17:26:07 -0700113 exclude += f.full_path().replace(generated_root, '').strip('/')
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700114endforeach
Patrick Williams08949432020-06-09 10:22:12 -0500115install_subdir(
116 generated_root,
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700117 exclude_files: exclude,
Patrick Williams32304972020-10-07 10:12:09 -0500118 install_dir: get_option('datadir') / 'doc' / meson.project_name(),
Patrick Williams08949432020-06-09 10:22:12 -0500119 strip_directory: true,
120)
121
122# Define and build libphosphor_dbus.so from the C++ files.
123libphosphor_dbus = library(
124 'phosphor_dbus',
Patrick Williams47f32d12020-06-24 16:13:38 -0500125 generated_sources,
William A. Kennington IIIdb241112021-05-14 15:35:48 -0700126 implicit_include_directories: false,
Patrick Williams47f32d12020-06-24 16:13:38 -0500127 include_directories: include_directories('gen'),
Patrick Williams08949432020-06-09 10:22:12 -0500128 dependencies: sdbusplus_dep,
129 version: meson.project_version(),
130 install: true,
131)
132
133import('pkgconfig').generate(
Patrick Williamsaff70172021-04-15 13:37:25 -0500134 libphosphor_dbus,
Patrick Williams08949432020-06-09 10:22:12 -0500135 name: meson.project_name(),
136 version: meson.project_version(),
Patrick Williams6f70d9f2021-04-15 19:07:19 -0500137 description: 'Generated sdbusplus bindings for phosphor-dbus-interfaces',
Patrick Williams32fbd5d2021-04-21 21:09:09 -0500138 variables: ['yamldir=' + '${pc_sysrootdir}${prefix}' / inst_yaml_dir],
Patrick Williams08949432020-06-09 10:22:12 -0500139)
Patrick Williams41a7b452021-04-15 13:49:06 -0500140
141phosphor_dbus_interfaces_dep = declare_dependency(
William A. Kennington III795b4372021-05-14 15:37:47 -0700142 sources: generated_files_headers,
Patrick Williams41a7b452021-04-15 13:49:06 -0500143 include_directories: include_directories('gen'),
144 link_with: libphosphor_dbus,
Patrick Williams6f70d9f2021-04-15 19:07:19 -0500145 dependencies: sdbusplus_dep,
William A. Kennington IIIb1b4d262021-06-05 12:22:23 -0700146 variables: ['yamldir=' + meson.project_source_root() / 'yaml'],
Patrick Williams41a7b452021-04-15 13:49:06 -0500147)