blob: 0bb8aee62d92ab66298503c655c02dd776c69d74 [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)
26conf_data.set('PS_DERATING_FACTOR', 90)
27
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',
141 'occ_presence.cpp',
142 'occ_command.cpp',
143 'occ_dbus.cpp',
144 'powercap.cpp',
145 'i2c_occ.cpp',
146 'utils.cpp',
147 ]
148
149 if get_option('with-host-communication-protocol')=='pldm'
George Liu9ed399d2021-09-10 13:14:27 +0800150 libpldm_dep = dependency(
151 'libpldm',
152 fallback: ['pldm', 'libpldm_dep'],
153 default_options: ['libpldm-only=enabled', 'oem-ibm=enabled'],
154 )
George Liubddcf852021-09-08 08:46:22 +0800155 deps += [
156 libpldm_dep,
157 ]
158 sources += [
159 'pldm.cpp',
160 ]
161 endif
162
163 if get_option('power10-support').enabled()
164 sources += [
165 'powermode.cpp',
166 ]
167 endif
168
169 yamldir = get_option('yamldir')
170 if yamldir == ''
171 yamldir = meson.project_source_root() / 'example/occ_sensor.yaml'
172 endif
173
174 # Generate occ-sensor.hpp.
175 occ_sensor_hpp = custom_target(
176 'occ-sensor.hpp',
177 command : [
178 python_prog,
179 meson.project_source_root() + '/sensor_gen.py',
180 '-f', meson.project_source_root() / yamldir,
181 '-i', meson.current_build_dir(),
182 ],
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