blob: 6d395edae1223ed7e5d3efbab1461efc88e1acb3 [file] [log] [blame]
George Liubddcf852021-09-08 08:46:22 +08001project(
2 'openpower-occ-control', 'cpp',
3 version : '1.0.0',
Patrick Williams47831f52023-04-12 08:01:05 -05004 meson_version: '>=0.58.0',
George Liubddcf852021-09-08 08:46:22 +08005 default_options: [
6 'warning_level=3',
7 'werror=true',
8 'cpp_std=c++20',
9 'buildtype=debugoptimized'
10 ]
11)
12
Eddie Jamescbad2192021-10-07 09:39:39 -050013cxx = meson.get_compiler('cpp')
14
George Liubddcf852021-09-08 08:46:22 +080015conf_data = configuration_data()
16conf_data.set_quoted('OCC_CONTROL_BUSNAME', 'org.open_power.OCC.Control')
17conf_data.set_quoted('OCC_CONTROL_ROOT', '/org/open_power/control')
18conf_data.set_quoted('OCC_SENSORS_ROOT', '/xyz/openbmc_project/sensors')
19conf_data.set_quoted('CPU_NAME', 'cpu')
20conf_data.set_quoted('OCC_NAME', 'occ')
21conf_data.set_quoted('OCC_MASTER_NAME', 'occ-hwmon.1')
22conf_data.set_quoted('OCC_DEV_PATH', '/dev/occ')
Chris Cain36f9cde2021-11-22 11:18:21 -060023conf_data.set_quoted('CPU_SUBPATH', '/xyz/openbmc_project/inventory/system/chassis/motherboard')
24conf_data.set_quoted('OCC_CONTROL_PERSIST_PATH', '/var/lib/openpower-occ-control')
George Liubddcf852021-09-08 08:46:22 +080025
26conf_data.set('MAX_CPUS', get_option('max-cpus'))
27conf_data.set('OCC_CPU_TEMP_SENSOR_TYPE', 0xC0)
28conf_data.set('OCC_DIMM_TEMP_SENSOR_TYPE', 0xD0)
Eddie James3f710bd2021-10-20 13:40:52 -050029conf_data.set('PS_DERATING_FACTOR', get_option('ps-derating-factor'))
George Liubddcf852021-09-08 08:46:22 +080030
31if get_option('i2c-occ').enabled()
32 conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/i2c/drivers/occ-hwmon/')
33 conf_data.set_quoted('DEV_PATH', '/sys/bus/i2c/devices')
34 conf_data.set_quoted('I2C_OCC_DEVICE_NAME', 'p8-occ-hwmon')
35else
36 conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/platform/drivers/occ-hwmon/')
37 conf_data.set_quoted('DEV_PATH', '/sys/bus/platform/devices/')
38endif
39
40if get_option('install-error-yaml').disabled()
41 conf_data.set('I2C_OCC', get_option('i2c-occ').enabled())
42 conf_data.set('READ_OCC_SENSORS', get_option('read-occ-sensors').enabled())
43 conf_data.set('PLDM', get_option('with-host-communication-protocol')=='pldm')
44 conf_data.set('POWER10', get_option('power10-support').enabled())
45endif
46
47configure_file(output: 'config.h',
48 configuration: conf_data
49)
50
Chris Cain7bd6d142023-01-11 13:41:09 -060051install_data('occ-active.sh',
52 install_mode: 'rwxr-xr-x',
53 install_dir: get_option('bindir')
54)
55
56systemd = dependency('systemd')
57systemd_system_unit_dir = systemd.get_variable(
Patrick Williams47831f52023-04-12 08:01:05 -050058 'systemdsystemunitdir')
Chris Cain7bd6d142023-01-11 13:41:09 -060059subdir('service_files')
60
Patrick Williamse2a58512022-09-13 11:26:57 -050061sdbusplus_dep = dependency('sdbusplus')
George Liubddcf852021-09-08 08:46:22 +080062sdbusplusplus_prog = find_program('sdbus++')
63sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
Patrick Williamse2a58512022-09-13 11:26:57 -050064sdbusplusplus_depfiles = files()
65if sdbusplus_dep.type_name() == 'internal'
66 sdbusplusplus_depfiles = subproject('sdbusplus').get_variable('sdbusplusplus_depfiles')
67endif
68
George Liubddcf852021-09-08 08:46:22 +080069python_prog = find_program('python3', required: true)
70realpath_prog = find_program('realpath')
71
72selected_subdirs = []
73selected_subdirs += 'org/open_power/OCC'
74
75generated_root = meson.current_build_dir() / 'gen'
76generated_others = []
77generated_sources = []
78
79# Source the generated meson files.
80subdir('gen')
81foreach d : selected_subdirs
82 subdir('gen' / d)
83endforeach
84
85# Parse through the list from sdbus++-gendir and put into sets.
86generated_headers = []
87generated_cpp = []
88generated_others_files = []
89
90foreach g : generated_sources generated_others
91 foreach f : g.to_list()
92 rel_path = run_command(
93 realpath_prog,
94 '--relative-to', generated_root,
95 f.full_path(),
96 ).stdout().strip().split('\n')[-1]
97
98 if rel_path.endswith('.hpp')
99 generated_headers += rel_path
100 elif rel_path.endswith('.cpp')
101 generated_cpp += rel_path
102 else
103 generated_others_files += rel_path
104 endif
105 endforeach
106endforeach
107
108deps = []
109sources = []
110if get_option('install-error-yaml').disabled()
George Liu9ed399d2021-09-10 13:14:27 +0800111 sdeventplus_dep = dependency(
112 'sdeventplus',
113 fallback: [
114 'sdeventplus',
115 'sdeventplus_dep'
116 ],
117 )
George Liu9ed399d2021-09-10 13:14:27 +0800118 phosphor_dbus_interfaces_dep = dependency(
119 'phosphor-dbus-interfaces',
120 fallback: [
121 'phosphor-dbus-interfaces',
122 'phosphor_dbus_interfaces_dep'
123 ],
124 )
Patrick Williams18dcfb42023-02-08 09:25:22 -0600125 phosphor_logging_dep = dependency(
126 'phosphor-logging',
127 fallback: [
128 'phosphor-logging',
129 'phosphor_logging_dep'
130 ],
131 )
George Liubddcf852021-09-08 08:46:22 +0800132
Patrick Williamsd86651f2023-02-08 09:31:48 -0600133 if cxx.has_header('nlohmann/json.hpp')
134 nlohmann_json_dep = declare_dependency()
135 else
136 subproject('nlohmann-json')
137 nlohmann_json_dep = declare_dependency(
138 include_directories: [
139 'subprojects/nlohmann-json/single_include',
140 'subprojects/nlohmann-json/single_include/nlohmann',
141 ]
142 )
143 endif
144
George Liubddcf852021-09-08 08:46:22 +0800145 deps += [
Patrick Williamsd86651f2023-02-08 09:31:48 -0600146 nlohmann_json_dep,
147 phosphor_dbus_interfaces_dep,
148 phosphor_logging_dep,
George Liubddcf852021-09-08 08:46:22 +0800149 sdbusplus_dep,
150 sdeventplus_dep,
George Liubddcf852021-09-08 08:46:22 +0800151 ]
152
153 sources += [
154 'app.cpp',
155 'occ_pass_through.cpp',
156 'occ_manager.cpp',
157 'occ_status.cpp',
158 'occ_device.cpp',
159 'occ_errors.cpp',
Eddie James2f9f9bb2021-09-20 14:26:31 -0500160 'occ_ffdc.cpp',
George Liubddcf852021-09-08 08:46:22 +0800161 'occ_presence.cpp',
162 'occ_command.cpp',
163 'occ_dbus.cpp',
164 'powercap.cpp',
165 'i2c_occ.cpp',
166 'utils.cpp',
167 ]
168
169 if get_option('with-host-communication-protocol')=='pldm'
George Liu9ed399d2021-09-10 13:14:27 +0800170 libpldm_dep = dependency(
171 'libpldm',
172 fallback: ['pldm', 'libpldm_dep'],
173 default_options: ['libpldm-only=enabled', 'oem-ibm=enabled'],
174 )
George Liubddcf852021-09-08 08:46:22 +0800175 deps += [
176 libpldm_dep,
Eddie Jamescbad2192021-10-07 09:39:39 -0500177 cxx.find_library('pdbg'),
178 cxx.find_library('phal'),
George Liubddcf852021-09-08 08:46:22 +0800179 ]
180 sources += [
181 'pldm.cpp',
182 ]
183 endif
184
185 if get_option('power10-support').enabled()
186 sources += [
187 'powermode.cpp',
188 ]
189 endif
190
191 yamldir = get_option('yamldir')
192 if yamldir == ''
Eddie James6b234c12021-10-20 16:35:47 -0500193 yamldir = meson.project_source_root() / 'example'
George Liubddcf852021-09-08 08:46:22 +0800194 endif
195
196 # Generate occ-sensor.hpp.
197 occ_sensor_hpp = custom_target(
198 'occ-sensor.hpp',
199 command : [
200 python_prog,
201 meson.project_source_root() + '/sensor_gen.py',
Eddie James6b234c12021-10-20 16:35:47 -0500202 '-i', yamldir,
George Liubddcf852021-09-08 08:46:22 +0800203 ],
204 output : 'occ-sensor.hpp')
205 sources += [occ_sensor_hpp]
206
207 executable(
208 'openpower-occ-control',
209 sources,
210 generated_sources,
211 include_directories: ['.', 'gen'],
212 implicit_include_directories: true,
213 dependencies: deps,
214 install: true,
215 install_dir: get_option('bindir')
216 )
217endif
218
219if not get_option('tests').disabled()
220 subdir('test')
221endif