blob: 843a9a76bd0664ce7a367e86e32ebe845d4e6e9b [file] [log] [blame]
George Liubddcf852021-09-08 08:46:22 +08001project(
2 'openpower-occ-control', 'cpp',
3 version : '1.0.0',
4 meson_version: '>=0.57.0',
5 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
51sdbusplusplus_prog = find_program('sdbus++')
52sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
53python_prog = find_program('python3', required: true)
54realpath_prog = find_program('realpath')
55
56selected_subdirs = []
57selected_subdirs += 'org/open_power/OCC'
58
59generated_root = meson.current_build_dir() / 'gen'
60generated_others = []
61generated_sources = []
62
63# Source the generated meson files.
64subdir('gen')
65foreach d : selected_subdirs
66 subdir('gen' / d)
67endforeach
68
69# Parse through the list from sdbus++-gendir and put into sets.
70generated_headers = []
71generated_cpp = []
72generated_others_files = []
73
74foreach g : generated_sources generated_others
75 foreach f : g.to_list()
76 rel_path = run_command(
77 realpath_prog,
78 '--relative-to', generated_root,
79 f.full_path(),
80 ).stdout().strip().split('\n')[-1]
81
82 if rel_path.endswith('.hpp')
83 generated_headers += rel_path
84 elif rel_path.endswith('.cpp')
85 generated_cpp += rel_path
86 else
87 generated_others_files += rel_path
88 endif
89 endforeach
90endforeach
91
92deps = []
93sources = []
94if get_option('install-error-yaml').disabled()
95 sdbusplus_dep = dependency('sdbusplus')
George Liu9ed399d2021-09-10 13:14:27 +080096 if sdbusplus_dep.found()
97 sdbusplusplus_prog = find_program('sdbus++')
98 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
99 else
100 sdbusplus_proj = subproject('sdbusplus', required: true)
101 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
102 sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog')
103 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
104 'sdbuspp_gen_meson_prog'
105 )
106 endif
107
108 sdeventplus_dep = dependency(
109 'sdeventplus',
110 fallback: [
111 'sdeventplus',
112 'sdeventplus_dep'
113 ],
114 )
115 phosphor_logging_dep = dependency(
116 'phosphor-logging',
117 fallback: [
118 'phosphor-logging',
119 'phosphor_logging_dep'
120 ],
121 )
122 phosphor_dbus_interfaces_dep = dependency(
123 'phosphor-dbus-interfaces',
124 fallback: [
125 'phosphor-dbus-interfaces',
126 'phosphor_dbus_interfaces_dep'
127 ],
128 )
George Liubddcf852021-09-08 08:46:22 +0800129
130 deps += [
131 sdbusplus_dep,
132 sdeventplus_dep,
133 phosphor_logging_dep,
134 phosphor_dbus_interfaces_dep,
135 ]
136
137 sources += [
138 'app.cpp',
139 'occ_pass_through.cpp',
140 'occ_manager.cpp',
141 'occ_status.cpp',
142 'occ_device.cpp',
143 'occ_errors.cpp',
Eddie James2f9f9bb2021-09-20 14:26:31 -0500144 'occ_ffdc.cpp',
George Liubddcf852021-09-08 08:46:22 +0800145 'occ_presence.cpp',
146 'occ_command.cpp',
147 'occ_dbus.cpp',
148 'powercap.cpp',
149 'i2c_occ.cpp',
150 'utils.cpp',
151 ]
152
153 if get_option('with-host-communication-protocol')=='pldm'
George Liu9ed399d2021-09-10 13:14:27 +0800154 libpldm_dep = dependency(
155 'libpldm',
156 fallback: ['pldm', 'libpldm_dep'],
157 default_options: ['libpldm-only=enabled', 'oem-ibm=enabled'],
158 )
George Liubddcf852021-09-08 08:46:22 +0800159 deps += [
160 libpldm_dep,
Eddie Jamescbad2192021-10-07 09:39:39 -0500161 cxx.find_library('pdbg'),
162 cxx.find_library('phal'),
George Liubddcf852021-09-08 08:46:22 +0800163 ]
164 sources += [
165 'pldm.cpp',
166 ]
167 endif
168
169 if get_option('power10-support').enabled()
170 sources += [
171 'powermode.cpp',
172 ]
173 endif
174
175 yamldir = get_option('yamldir')
176 if yamldir == ''
Eddie James6b234c12021-10-20 16:35:47 -0500177 yamldir = meson.project_source_root() / 'example'
George Liubddcf852021-09-08 08:46:22 +0800178 endif
179
180 # Generate occ-sensor.hpp.
181 occ_sensor_hpp = custom_target(
182 'occ-sensor.hpp',
183 command : [
184 python_prog,
185 meson.project_source_root() + '/sensor_gen.py',
Eddie James6b234c12021-10-20 16:35:47 -0500186 '-i', yamldir,
George Liubddcf852021-09-08 08:46:22 +0800187 ],
188 output : 'occ-sensor.hpp')
189 sources += [occ_sensor_hpp]
190
191 executable(
192 'openpower-occ-control',
193 sources,
194 generated_sources,
195 include_directories: ['.', 'gen'],
196 implicit_include_directories: true,
197 dependencies: deps,
198 install: true,
199 install_dir: get_option('bindir')
200 )
201endif
202
203if not get_option('tests').disabled()
204 subdir('test')
205endif