1project( 2 'openpower-occ-control', 'cpp', 3 version : '1.0.0', 4 meson_version: '>=1.1.1', 5 default_options: [ 6 'warning_level=3', 7 'werror=true', 8 'cpp_std=c++23', 9 'buildtype=debugoptimized' 10 ] 11) 12 13cxx = meson.get_compiler('cpp') 14 15conf_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') 23conf_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') 25conf_data.set_quoted('OP_DUMP_OBJ_PATH', get_option('op_dump_obj_path')) 26 27conf_data.set('MAX_CPUS', get_option('max-cpus')) 28conf_data.set('OCC_CPU_TEMP_SENSOR_TYPE', 0xC0) 29conf_data.set('OCC_DIMM_TEMP_SENSOR_TYPE', 0xD0) 30conf_data.set('PS_DERATING_FACTOR', get_option('ps-derating-factor')) 31 32if get_option('i2c-occ').allowed() 33 conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/i2c/drivers/occ-hwmon/') 34 conf_data.set_quoted('DEV_PATH', '/sys/bus/i2c/devices') 35 conf_data.set_quoted('I2C_OCC_DEVICE_NAME', 'p8-occ-hwmon') 36else 37 conf_data.set_quoted('OCC_HWMON_PATH', '/sys/bus/platform/drivers/occ-hwmon/') 38 conf_data.set_quoted('DEV_PATH', '/sys/bus/platform/devices/') 39endif 40 41conf_data.set('I2C_OCC', get_option('i2c-occ').allowed()) 42conf_data.set('READ_OCC_SENSORS', get_option('read-occ-sensors').allowed()) 43conf_data.set('PLDM', get_option('with-host-communication-protocol')=='pldm') 44conf_data.set('POWER10', get_option('power10-support').allowed()) 45 46configure_file(output: 'config.h', 47 configuration: conf_data 48) 49 50install_data('occ-active.sh', 51 install_mode: 'rwxr-xr-x', 52 install_dir: get_option('bindir') 53) 54 55systemd = dependency('systemd') 56systemd_system_unit_dir = systemd.get_variable( 57 'systemdsystemunitdir') 58subdir('service_files') 59 60sdbusplus_dep = dependency('sdbusplus') 61 62python_prog = find_program('python3', required: true) 63 64deps = [] 65sources = [] 66 67cereal_dep = dependency('cereal', required: false) 68has_cereal = cxx.has_header_symbol( 69 'cereal/cereal.hpp', 70 'cereal::specialize', 71 dependencies: cereal_dep, 72 required: false) 73if not has_cereal 74 cereal_opts = import('cmake').subproject_options() 75 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'}) 76 cereal_proj = import('cmake').subproject( 77 'cereal', 78 options: cereal_opts, 79 required: false) 80 assert(cereal_proj.found(), 'cereal is required') 81 cereal_dep = cereal_proj.dependency('cereal') 82endif 83 84nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 85phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 86phosphor_logging_dep = dependency('phosphor-logging') 87sdeventplus_dep = dependency('sdeventplus') 88 89deps += [ 90 cereal_dep, 91 nlohmann_json_dep, 92 phosphor_dbus_interfaces_dep, 93 phosphor_logging_dep, 94 sdbusplus_dep, 95 sdeventplus_dep, 96] 97 98sources += [ 99 'app.cpp', 100 'occ_pass_through.cpp', 101 'occ_manager.cpp', 102 'occ_status.cpp', 103 'occ_device.cpp', 104 'occ_errors.cpp', 105 'occ_ffdc.cpp', 106 'occ_presence.cpp', 107 'occ_command.cpp', 108 'occ_dbus.cpp', 109 'powercap.cpp', 110 'i2c_occ.cpp', 111 'utils.cpp', 112] 113 114if get_option('with-host-communication-protocol')=='pldm' 115 libpldm_dep = dependency('libpldm') 116 deps += [ 117 libpldm_dep, 118 cxx.find_library('pdbg'), 119 cxx.find_library('phal'), 120 ] 121 sources += [ 122 'pldm.cpp', 123 ] 124endif 125 126if get_option('power10-support').allowed() 127 sources += [ 128 'powermode.cpp', 129 ] 130endif 131 132yamldir = get_option('yamldir') 133if yamldir == '' 134 yamldir = meson.project_source_root() / 'example' 135endif 136 137# Generate occ-sensor.hpp. 138occ_sensor_hpp = custom_target( 139 'occ-sensor.hpp', 140 command : [ 141 python_prog, 142 meson.project_source_root() + '/sensor_gen.py', 143 '-i', yamldir, 144 ], 145 output : 'occ-sensor.hpp') 146 sources += [occ_sensor_hpp] 147 148 executable( 149 'openpower-occ-control', 150 sources, 151 include_directories: '.', 152 implicit_include_directories: true, 153 dependencies: deps, 154 install: true, 155 install_dir: get_option('bindir') 156 ) 157 158if not get_option('tests').disabled() 159 subdir('test') 160endif 161