blob: e6b6c6c824bc0f1e5cd91fbcd6899f3d910f1898 [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
13conf_data = configuration_data()
14conf_data.set_quoted('OCC_CONTROL_BUSNAME', 'org.open_power.OCC.Control')
15conf_data.set_quoted('OCC_CONTROL_ROOT', '/org/open_power/control')
16conf_data.set_quoted('OCC_SENSORS_ROOT', '/xyz/openbmc_project/sensors')
17conf_data.set_quoted('CPU_NAME', 'cpu')
18conf_data.set_quoted('OCC_NAME', 'occ')
19conf_data.set_quoted('OCC_MASTER_NAME', 'occ-hwmon.1')
20conf_data.set_quoted('OCC_DEV_PATH', '/dev/occ')
21conf_data.set_quoted('CPU_SUBPATH', '/xyz/openbmc_project/inventory/system/chassis/motherboard')
22
23conf_data.set('MAX_CPUS', get_option('max-cpus'))
24conf_data.set('OCC_CPU_TEMP_SENSOR_TYPE', 0xC0)
25conf_data.set('OCC_DIMM_TEMP_SENSOR_TYPE', 0xD0)
Eddie James3f710bd2021-10-20 13:40:52 -050026conf_data.set('PS_DERATING_FACTOR', get_option('ps-derating-factor'))
George Liubddcf852021-09-08 08:46:22 +080027
28if get_option('i2c-occ').enabled()
29 conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/i2c/drivers/occ-hwmon/')
30 conf_data.set_quoted('DEV_PATH', '/sys/bus/i2c/devices')
31 conf_data.set_quoted('I2C_OCC_DEVICE_NAME', 'p8-occ-hwmon')
32else
33 conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/platform/drivers/occ-hwmon/')
34 conf_data.set_quoted('DEV_PATH', '/sys/bus/platform/devices/')
35endif
36
37if get_option('install-error-yaml').disabled()
38 conf_data.set('I2C_OCC', get_option('i2c-occ').enabled())
39 conf_data.set('READ_OCC_SENSORS', get_option('read-occ-sensors').enabled())
40 conf_data.set('PLDM', get_option('with-host-communication-protocol')=='pldm')
41 conf_data.set('POWER10', get_option('power10-support').enabled())
42endif
43
44configure_file(output: 'config.h',
45 configuration: conf_data
46)
47
48sdbusplusplus_prog = find_program('sdbus++')
49sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
50python_prog = find_program('python3', required: true)
51realpath_prog = find_program('realpath')
52
53selected_subdirs = []
54selected_subdirs += 'org/open_power/OCC'
55
56generated_root = meson.current_build_dir() / 'gen'
57generated_others = []
58generated_sources = []
59
60# Source the generated meson files.
61subdir('gen')
62foreach d : selected_subdirs
63 subdir('gen' / d)
64endforeach
65
66# Parse through the list from sdbus++-gendir and put into sets.
67generated_headers = []
68generated_cpp = []
69generated_others_files = []
70
71foreach g : generated_sources generated_others
72 foreach f : g.to_list()
73 rel_path = run_command(
74 realpath_prog,
75 '--relative-to', generated_root,
76 f.full_path(),
77 ).stdout().strip().split('\n')[-1]
78
79 if rel_path.endswith('.hpp')
80 generated_headers += rel_path
81 elif rel_path.endswith('.cpp')
82 generated_cpp += rel_path
83 else
84 generated_others_files += rel_path
85 endif
86 endforeach
87endforeach
88
89deps = []
90sources = []
91if get_option('install-error-yaml').disabled()
92 sdbusplus_dep = dependency('sdbusplus')
George Liu9ed399d2021-09-10 13:14:27 +080093 if sdbusplus_dep.found()
94 sdbusplusplus_prog = find_program('sdbus++')
95 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
96 else
97 sdbusplus_proj = subproject('sdbusplus', required: true)
98 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
99 sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog')
100 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable(
101 'sdbuspp_gen_meson_prog'
102 )
103 endif
104
105 sdeventplus_dep = dependency(
106 'sdeventplus',
107 fallback: [
108 'sdeventplus',
109 'sdeventplus_dep'
110 ],
111 )
112 phosphor_logging_dep = dependency(
113 'phosphor-logging',
114 fallback: [
115 'phosphor-logging',
116 'phosphor_logging_dep'
117 ],
118 )
119 phosphor_dbus_interfaces_dep = dependency(
120 'phosphor-dbus-interfaces',
121 fallback: [
122 'phosphor-dbus-interfaces',
123 'phosphor_dbus_interfaces_dep'
124 ],
125 )
George Liubddcf852021-09-08 08:46:22 +0800126
127 deps += [
128 sdbusplus_dep,
129 sdeventplus_dep,
130 phosphor_logging_dep,
131 phosphor_dbus_interfaces_dep,
132 ]
133
134 sources += [
135 'app.cpp',
136 'occ_pass_through.cpp',
137 'occ_manager.cpp',
138 'occ_status.cpp',
139 'occ_device.cpp',
140 'occ_errors.cpp',
Eddie James2f9f9bb2021-09-20 14:26:31 -0500141 'occ_ffdc.cpp',
George Liubddcf852021-09-08 08:46:22 +0800142 'occ_presence.cpp',
143 'occ_command.cpp',
144 'occ_dbus.cpp',
145 'powercap.cpp',
146 'i2c_occ.cpp',
147 'utils.cpp',
148 ]
149
150 if get_option('with-host-communication-protocol')=='pldm'
George Liu9ed399d2021-09-10 13:14:27 +0800151 libpldm_dep = dependency(
152 'libpldm',
153 fallback: ['pldm', 'libpldm_dep'],
154 default_options: ['libpldm-only=enabled', 'oem-ibm=enabled'],
155 )
George Liubddcf852021-09-08 08:46:22 +0800156 deps += [
157 libpldm_dep,
158 ]
159 sources += [
160 'pldm.cpp',
161 ]
162 endif
163
164 if get_option('power10-support').enabled()
165 sources += [
166 'powermode.cpp',
167 ]
168 endif
169
170 yamldir = get_option('yamldir')
171 if yamldir == ''
Eddie James6b234c12021-10-20 16:35:47 -0500172 yamldir = meson.project_source_root() / 'example'
George Liubddcf852021-09-08 08:46:22 +0800173 endif
174
175 # Generate occ-sensor.hpp.
176 occ_sensor_hpp = custom_target(
177 'occ-sensor.hpp',
178 command : [
179 python_prog,
180 meson.project_source_root() + '/sensor_gen.py',
Eddie James6b234c12021-10-20 16:35:47 -0500181 '-i', yamldir,
George Liubddcf852021-09-08 08:46:22 +0800182 ],
183 output : 'occ-sensor.hpp')
184 sources += [occ_sensor_hpp]
185
186 executable(
187 'openpower-occ-control',
188 sources,
189 generated_sources,
190 include_directories: ['.', 'gen'],
191 implicit_include_directories: true,
192 dependencies: deps,
193 install: true,
194 install_dir: get_option('bindir')
195 )
196endif
197
198if not get_option('tests').disabled()
199 subdir('test')
200endif