blob: 74c088a3a9f64a07ac3d4392e11fcf5cd40e7be9 [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
32if get_option('data_org_open_power')
33 selected_subdirs += 'org/open_power'
34endif
35if get_option('data_xyz_openbmc_project')
36 selected_subdirs += 'xyz/openbmc_project'
37endif
38
39# Install the selected YAML files.
Patrick Williams6f70d9f2021-04-15 19:07:19 -050040inst_yaml_dir = get_option('datadir') / 'phosphor-dbus-yaml/yaml'
Patrick Williams08949432020-06-09 10:22:12 -050041foreach d : selected_subdirs
42 install_subdir(
William A. Kennington IIIb1b4d262021-06-05 12:22:23 -070043 'yaml' / d,
Patrick Williams6f70d9f2021-04-15 19:07:19 -050044 install_dir: inst_yaml_dir / d,
Patrick Williams08949432020-06-09 10:22:12 -050045 strip_directory: true,
46 )
47endforeach
48
49# If libphosphor_dbus was not enabled, exit out from here. We installed
50# the YAML which is all we are asked to do.
51if not get_option('libphosphor_dbus')
52 subdir_done()
53endif
54
Patrick Williams47f32d12020-06-24 16:13:38 -050055generated_sources = []
56generated_others = []
57yaml_sources = []
58
59# Source the generated meson files.
60subdir('gen')
61foreach d : selected_subdirs
62 subdir('gen' / d)
63endforeach
William A. Kennington III2600aff2021-06-05 12:15:23 -070064custom_target(
65 'md',
66 command: 'true',
67 output: 'md',
68 capture: true,
69 depends: generated_others,
William A. Kennington III71892002021-05-14 16:09:53 -070070 build_by_default: get_option('generate_md'))
Patrick Williams08949432020-06-09 10:22:12 -050071
William A. Kennington IIId2180a92021-05-14 15:34:44 -070072generated_files_headers = []
73generated_files_cpp = []
74foreach s : generated_sources
75 foreach f : s.to_list()
76 p = f.full_path()
77 if p.endswith('.hpp')
78 generated_files_headers += f
79 elif p.endswith('.cpp')
80 generated_files_cpp += f
Patrick Williams47f32d12020-06-24 16:13:38 -050081 else
William A. Kennington IIId2180a92021-05-14 15:34:44 -070082 error('Unknown filetype: ' + p)
Patrick Williams47f32d12020-06-24 16:13:38 -050083 endif
84 endforeach
Patrick Williams08949432020-06-09 10:22:12 -050085endforeach
86
William A. Kennington IIId2180a92021-05-14 15:34:44 -070087generated_root = meson.current_build_dir() / 'gen/'
88exclude_cpp = []
89foreach f : generated_files_cpp
90 exclude_cpp += f.full_path().replace(generated_root, '')
91endforeach
92
Patrick Williams08949432020-06-09 10:22:12 -050093# Install the generated header files.
William A. Kennington IIId2180a92021-05-14 15:34:44 -070094exclude = exclude_cpp
95foreach o : generated_others
96 foreach f : o.to_list()
97 exclude += f.full_path().replace(generated_root, '')
98 endforeach
99endforeach
Patrick Williams08949432020-06-09 10:22:12 -0500100install_subdir(
101 generated_root,
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700102 exclude_files: exclude,
Patrick Williams08949432020-06-09 10:22:12 -0500103 install_dir: get_option('includedir'),
104 strip_directory: true,
105)
106
107# Install the generated markdown files.
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700108exclude = exclude_cpp
109foreach f : generated_files_headers
110 exclude += f.full_path().replace(generated_root, '')
111endforeach
Patrick Williams08949432020-06-09 10:22:12 -0500112install_subdir(
113 generated_root,
William A. Kennington IIId2180a92021-05-14 15:34:44 -0700114 exclude_files: exclude,
Patrick Williams32304972020-10-07 10:12:09 -0500115 install_dir: get_option('datadir') / 'doc' / meson.project_name(),
Patrick Williams08949432020-06-09 10:22:12 -0500116 strip_directory: true,
117)
118
119# Define and build libphosphor_dbus.so from the C++ files.
120libphosphor_dbus = library(
121 'phosphor_dbus',
Patrick Williams47f32d12020-06-24 16:13:38 -0500122 generated_sources,
William A. Kennington IIIdb241112021-05-14 15:35:48 -0700123 implicit_include_directories: false,
Patrick Williams47f32d12020-06-24 16:13:38 -0500124 include_directories: include_directories('gen'),
Patrick Williams08949432020-06-09 10:22:12 -0500125 dependencies: sdbusplus_dep,
126 version: meson.project_version(),
127 install: true,
128)
129
130import('pkgconfig').generate(
Patrick Williamsaff70172021-04-15 13:37:25 -0500131 libphosphor_dbus,
Patrick Williams08949432020-06-09 10:22:12 -0500132 name: meson.project_name(),
133 version: meson.project_version(),
Patrick Williams6f70d9f2021-04-15 19:07:19 -0500134 description: 'Generated sdbusplus bindings for phosphor-dbus-interfaces',
Patrick Williams32fbd5d2021-04-21 21:09:09 -0500135 variables: ['yamldir=' + '${pc_sysrootdir}${prefix}' / inst_yaml_dir],
Patrick Williams08949432020-06-09 10:22:12 -0500136)
Patrick Williams41a7b452021-04-15 13:49:06 -0500137
138phosphor_dbus_interfaces_dep = declare_dependency(
William A. Kennington III795b4372021-05-14 15:37:47 -0700139 sources: generated_files_headers,
Patrick Williams41a7b452021-04-15 13:49:06 -0500140 include_directories: include_directories('gen'),
141 link_with: libphosphor_dbus,
Patrick Williams6f70d9f2021-04-15 19:07:19 -0500142 dependencies: sdbusplus_dep,
William A. Kennington IIIb1b4d262021-06-05 12:22:23 -0700143 variables: ['yamldir=' + meson.project_source_root() / 'yaml'],
Patrick Williams41a7b452021-04-15 13:49:06 -0500144)