blob: 8bba3392e5332e4d30848abeb1537b2aaa402a2e [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 Williams08949432020-06-09 10:22:12 -050016
Patrick Williams08949432020-06-09 10:22:12 -050017# Parse options to determine appropriate subdirectories to support.
18selected_subdirs = []
19if get_option('data_com_ibm')
20 selected_subdirs += 'com/ibm'
21endif
Jason M. Bills36ed8ad2021-11-16 11:22:42 -080022if get_option('data_com_intel')
23 selected_subdirs += 'com/intel'
24endif
John Edward Broadbent2b2784a2022-02-03 19:54:34 -080025if get_option('data_com_google')
26 selected_subdirs += 'com/google'
27endif
Shawn McCarney54ed0a12021-12-08 11:14:46 -060028if get_option('data_org_freedesktop')
29 selected_subdirs += 'org/freedesktop'
30endif
Patrick Williams08949432020-06-09 10:22:12 -050031if get_option('data_org_open_power')
32 selected_subdirs += 'org/open_power'
33endif
34if get_option('data_xyz_openbmc_project')
35 selected_subdirs += 'xyz/openbmc_project'
36endif
37
38# Install the selected YAML files.
Patrick Williams6f70d9f2021-04-15 19:07:19 -050039inst_yaml_dir = get_option('datadir') / 'phosphor-dbus-yaml/yaml'
Patrick Williams08949432020-06-09 10:22:12 -050040foreach d : selected_subdirs
41 install_subdir(
William A. Kennington IIIb1b4d262021-06-05 12:22:23 -070042 'yaml' / d,
Patrick Williams6f70d9f2021-04-15 19:07:19 -050043 install_dir: inst_yaml_dir / d,
Patrick Williams08949432020-06-09 10:22:12 -050044 strip_directory: true,
45 )
46endforeach
47
48# If libphosphor_dbus was not enabled, exit out from here. We installed
49# the YAML which is all we are asked to do.
50if not get_option('libphosphor_dbus')
51 subdir_done()
52endif
53
Patrick Williams47f32d12020-06-24 16:13:38 -050054generated_sources = []
55generated_others = []
56yaml_sources = []
57
58# Source the generated meson files.
59subdir('gen')
60foreach d : selected_subdirs
61 subdir('gen' / d)
62endforeach
William A. Kennington III2600aff2021-06-05 12:15:23 -070063custom_target(
64 'md',
65 command: 'true',
66 output: 'md',
67 capture: true,
68 depends: generated_others,
William A. Kennington III71892002021-05-14 16:09:53 -070069 build_by_default: get_option('generate_md'))
Patrick Williams08949432020-06-09 10:22:12 -050070
William A. Kennington IIId2180a92021-05-14 15:34:44 -070071generated_files_headers = []
72generated_files_cpp = []
73foreach s : generated_sources
74 foreach f : s.to_list()
75 p = f.full_path()
76 if p.endswith('.hpp')
77 generated_files_headers += f
78 elif p.endswith('.cpp')
79 generated_files_cpp += f
Patrick Williams47f32d12020-06-24 16:13:38 -050080 else
William A. Kennington IIId2180a92021-05-14 15:34:44 -070081 error('Unknown filetype: ' + p)
Patrick Williams47f32d12020-06-24 16:13:38 -050082 endif
83 endforeach
Patrick Williams08949432020-06-09 10:22:12 -050084endforeach
85
William A. Kennington IIId2180a92021-05-14 15:34:44 -070086generated_root = meson.current_build_dir() / 'gen/'
87exclude_cpp = []
88foreach f : generated_files_cpp
Jonathan Doman90116922021-11-01 17:26:07 -070089 exclude_cpp += f.full_path().replace(generated_root, '').strip('/')
William A. Kennington IIId2180a92021-05-14 15:34:44 -070090endforeach
91
Patrick Williams08949432020-06-09 10:22:12 -050092# Install the generated header files.
William A. Kennington IIId2180a92021-05-14 15:34:44 -070093exclude = exclude_cpp
94foreach o : generated_others
95 foreach f : o.to_list()
Jonathan Doman90116922021-11-01 17:26:07 -070096 exclude += f.full_path().replace(generated_root, '').strip('/')
William A. Kennington IIId2180a92021-05-14 15:34:44 -070097 endforeach
98endforeach
Patrick Williams08949432020-06-09 10:22:12 -050099install_subdir(
100 generated_root,
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700101 exclude_files: exclude,
Patrick Williams08949432020-06-09 10:22:12 -0500102 install_dir: get_option('includedir'),
103 strip_directory: true,
104)
105
106# Install the generated markdown files.
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700107exclude = exclude_cpp
108foreach f : generated_files_headers
Jonathan Doman90116922021-11-01 17:26:07 -0700109 exclude += f.full_path().replace(generated_root, '').strip('/')
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700110endforeach
Patrick Williams08949432020-06-09 10:22:12 -0500111install_subdir(
112 generated_root,
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700113 exclude_files: exclude,
Patrick Williams32304972020-10-07 10:12:09 -0500114 install_dir: get_option('datadir') / 'doc' / meson.project_name(),
Patrick Williams08949432020-06-09 10:22:12 -0500115 strip_directory: true,
116)
117
118# Define and build libphosphor_dbus.so from the C++ files.
119libphosphor_dbus = library(
120 'phosphor_dbus',
Patrick Williams47f32d12020-06-24 16:13:38 -0500121 generated_sources,
William A. Kennington IIIdb241112021-05-14 15:35:48 -0700122 implicit_include_directories: false,
Patrick Williams47f32d12020-06-24 16:13:38 -0500123 include_directories: include_directories('gen'),
Patrick Williams08949432020-06-09 10:22:12 -0500124 dependencies: sdbusplus_dep,
125 version: meson.project_version(),
126 install: true,
127)
128
129import('pkgconfig').generate(
Patrick Williamsaff70172021-04-15 13:37:25 -0500130 libphosphor_dbus,
Patrick Williams08949432020-06-09 10:22:12 -0500131 name: meson.project_name(),
132 version: meson.project_version(),
Patrick Williams6f70d9f2021-04-15 19:07:19 -0500133 description: 'Generated sdbusplus bindings for phosphor-dbus-interfaces',
Patrick Williams32fbd5d2021-04-21 21:09:09 -0500134 variables: ['yamldir=' + '${pc_sysrootdir}${prefix}' / inst_yaml_dir],
Patrick Williams08949432020-06-09 10:22:12 -0500135)
Patrick Williams41a7b452021-04-15 13:49:06 -0500136
137phosphor_dbus_interfaces_dep = declare_dependency(
William A. Kennington III795b4372021-05-14 15:37:47 -0700138 sources: generated_files_headers,
Patrick Williams41a7b452021-04-15 13:49:06 -0500139 include_directories: include_directories('gen'),
140 link_with: libphosphor_dbus,
Patrick Williams6f70d9f2021-04-15 19:07:19 -0500141 dependencies: sdbusplus_dep,
William A. Kennington IIIb1b4d262021-06-05 12:22:23 -0700142 variables: ['yamldir=' + meson.project_source_root() / 'yaml'],
Patrick Williams41a7b452021-04-15 13:49:06 -0500143)