blob: 25b66435ad2f26008fe8472eab3f167250c810fa [file] [log] [blame]
George Liubddcf852021-09-08 08:46:22 +08001project(
2 'openpower-occ-control', 'cpp',
3 version : '1.0.0',
Patrick Williams50cfb702023-07-12 11:15:24 -05004 meson_version: '>=1.1.1',
George Liubddcf852021-09-08 08:46:22 +08005 default_options: [
6 'warning_level=3',
7 'werror=true',
Patrick Williams50cfb702023-07-12 11:15:24 -05008 'cpp_std=c++23',
George Liubddcf852021-09-08 08:46:22 +08009 '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
Patrick Williams9bec8af2023-09-07 14:02:27 -050040conf_data.set('I2C_OCC', get_option('i2c-occ').enabled())
41conf_data.set('READ_OCC_SENSORS', get_option('read-occ-sensors').enabled())
42conf_data.set('PLDM', get_option('with-host-communication-protocol')=='pldm')
43conf_data.set('POWER10', get_option('power10-support').enabled())
George Liubddcf852021-09-08 08:46:22 +080044
45configure_file(output: 'config.h',
46 configuration: conf_data
47)
48
Chris Cain7bd6d142023-01-11 13:41:09 -060049install_data('occ-active.sh',
50 install_mode: 'rwxr-xr-x',
51 install_dir: get_option('bindir')
52)
53
54systemd = dependency('systemd')
55systemd_system_unit_dir = systemd.get_variable(
Patrick Williams47831f52023-04-12 08:01:05 -050056 'systemdsystemunitdir')
Chris Cain7bd6d142023-01-11 13:41:09 -060057subdir('service_files')
58
Patrick Williamse2a58512022-09-13 11:26:57 -050059sdbusplus_dep = dependency('sdbusplus')
Patrick Williamse2a58512022-09-13 11:26:57 -050060
George Liubddcf852021-09-08 08:46:22 +080061python_prog = find_program('python3', required: true)
George Liubddcf852021-09-08 08:46:22 +080062
63deps = []
64sources = []
Patrick Williams9bec8af2023-09-07 14:02:27 -050065
66sdeventplus_dep = dependency(
67 'sdeventplus',
68 fallback: [
George Liu9ed399d2021-09-10 13:14:27 +080069 'sdeventplus',
Patrick Williams9bec8af2023-09-07 14:02:27 -050070 'sdeventplus_dep'
71 ],
72)
73phosphor_dbus_interfaces_dep = dependency(
74 'phosphor-dbus-interfaces',
75 fallback: [
George Liu9ed399d2021-09-10 13:14:27 +080076 'phosphor-dbus-interfaces',
Patrick Williams9bec8af2023-09-07 14:02:27 -050077 'phosphor_dbus_interfaces_dep'
78 ],
79)
80phosphor_logging_dep = dependency(
81 'phosphor-logging',
82 fallback: [
Patrick Williams18dcfb42023-02-08 09:25:22 -060083 'phosphor-logging',
Patrick Williams9bec8af2023-09-07 14:02:27 -050084 'phosphor_logging_dep'
85 ],
86)
87
88if cxx.has_header('nlohmann/json.hpp')
89 nlohmann_json_dep = declare_dependency()
90else
91 subproject('nlohmann-json')
92 nlohmann_json_dep = declare_dependency(
93 include_directories: [
94 'subprojects/nlohmann-json/single_include',
95 'subprojects/nlohmann-json/single_include/nlohmann',
96 ]
Patrick Williams18dcfb42023-02-08 09:25:22 -060097 )
Patrick Williams9bec8af2023-09-07 14:02:27 -050098endif
George Liubddcf852021-09-08 08:46:22 +080099
Patrick Williams9bec8af2023-09-07 14:02:27 -0500100deps += [
101 nlohmann_json_dep,
102 phosphor_dbus_interfaces_dep,
103 phosphor_logging_dep,
104 sdbusplus_dep,
105 sdeventplus_dep,
106]
Patrick Williamsd86651f2023-02-08 09:31:48 -0600107
Patrick Williams9bec8af2023-09-07 14:02:27 -0500108sources += [
109 'app.cpp',
110 'occ_pass_through.cpp',
111 'occ_manager.cpp',
112 'occ_status.cpp',
113 'occ_device.cpp',
114 'occ_errors.cpp',
115 'occ_ffdc.cpp',
116 'occ_presence.cpp',
117 'occ_command.cpp',
118 'occ_dbus.cpp',
119 'powercap.cpp',
120 'i2c_occ.cpp',
121 'utils.cpp',
122]
123
124if get_option('with-host-communication-protocol')=='pldm'
125 libpldm_dep = dependency(
126 'libpldm',
127 fallback: ['pldm', 'libpldm_dep'],
128 default_options: ['libpldm-only=enabled', 'oem-ibm=enabled'],
129 )
George Liubddcf852021-09-08 08:46:22 +0800130 deps += [
Patrick Williams9bec8af2023-09-07 14:02:27 -0500131 libpldm_dep,
132 cxx.find_library('pdbg'),
133 cxx.find_library('phal'),
George Liubddcf852021-09-08 08:46:22 +0800134 ]
George Liubddcf852021-09-08 08:46:22 +0800135 sources += [
Patrick Williams9bec8af2023-09-07 14:02:27 -0500136 'pldm.cpp',
George Liubddcf852021-09-08 08:46:22 +0800137 ]
Patrick Williams9bec8af2023-09-07 14:02:27 -0500138endif
George Liubddcf852021-09-08 08:46:22 +0800139
Patrick Williams9bec8af2023-09-07 14:02:27 -0500140if get_option('power10-support').enabled()
141 sources += [
142 'powermode.cpp',
143 ]
144endif
George Liubddcf852021-09-08 08:46:22 +0800145
Patrick Williams9bec8af2023-09-07 14:02:27 -0500146yamldir = get_option('yamldir')
147if yamldir == ''
148 yamldir = meson.project_source_root() / 'example'
149endif
George Liubddcf852021-09-08 08:46:22 +0800150
Patrick Williams9bec8af2023-09-07 14:02:27 -0500151# Generate occ-sensor.hpp.
152occ_sensor_hpp = custom_target(
153 'occ-sensor.hpp',
154 command : [
155 python_prog,
156 meson.project_source_root() + '/sensor_gen.py',
157 '-i', yamldir,
158 ],
159 output : 'occ-sensor.hpp')
George Liubddcf852021-09-08 08:46:22 +0800160 sources += [occ_sensor_hpp]
161
162 executable(
163 'openpower-occ-control',
164 sources,
Patrick Williamsd8aab2a2023-04-21 11:15:54 -0500165 include_directories: '.',
George Liubddcf852021-09-08 08:46:22 +0800166 implicit_include_directories: true,
167 dependencies: deps,
168 install: true,
169 install_dir: get_option('bindir')
170 )
George Liubddcf852021-09-08 08:46:22 +0800171
172if not get_option('tests').disabled()
173 subdir('test')
174endif