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