1project( 2 'phosphor-pid-control', 3 'cpp', 4 version: '1.0.0', 5 meson_version: '>=1.1.1', 6 default_options: [ 7 'warning_level=3', 8 'werror=true', 9 'cpp_std=c++23', 10 'b_lto=true', 11 ], 12) 13 14cxx = meson.get_compiler('cpp') 15 16conf_data = configuration_data() 17 18bindir = get_option('prefix') / get_option('bindir') 19conf_data.set('BINDIR', bindir) 20conf_data.set('SYSTEMD_TARGET', get_option('systemd_target')) 21conf_data.set('STRICT_FAILSAFE_PWM', get_option('strict-failsafe-pwm')) 22conf_data.set('OFFLINE_FAILSAFE_PWM', get_option('offline-failsafe-pwm')) 23conf_data.set('UNC_FAILSAFE', get_option('unc-failsafe')) 24conf_data.set( 25 'HANDLE_MISSING_OBJECT_PATHS', 26 get_option('handle-missing-object-paths'), 27) 28 29configure_file(output: 'config.h', configuration: conf_data) 30 31if get_option('oe-sdk').allowed() 32 OECORE_TARGET_SYSROOT = run_command( 33 'sh', 34 '-c', 35 'echo $OECORE_TARGET_SYSROOT', 36 ).stdout().strip() 37 if OECORE_TARGET_SYSROOT == '' 38 error('OECORE_TARGET_SYSROOT must be set with enable oe-sdk') 39 endif 40 message('Enabling OE-SDK at OECORE_TARGET_SYSROOT: ' + OECORE_TARGET_SYSROOT) 41 rpath = ':'.join( 42 [OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'], 43 ) 44 ld_so = run_command( 45 'sh', 46 '-c', 47 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1', 48 ).stdout().strip() 49 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so] 50else 51 dynamic_linker = [] 52endif 53 54systemd = dependency('systemd') 55systemd_system_unit_dir = systemd.get_variable( 56 'systemdsystemunitdir', 57 pkgconfig_define: ['prefix', get_option('prefix')], 58) 59 60configure_file( 61 input: 'phosphor-pid-control.service.in', 62 output: 'phosphor-pid-control.service', 63 configuration: conf_data, 64 install: true, 65 install_dir: systemd_system_unit_dir, 66) 67 68nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 69phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 70phosphor_logging_dep = dependency('phosphor-logging') 71sdbusplus_dep = dependency('sdbusplus') 72libsystemd_dep = dependency('libsystemd') 73ipmid_dep = dependency('libipmid') 74 75 76if cxx.has_header('CLI/CLI.hpp') 77 CLI11_dep = declare_dependency() 78else 79 CLI11_dep = dependency('CLI11') 80endif 81 82deps = [ 83 CLI11_dep, 84 ipmid_dep, 85 libsystemd_dep, 86 nlohmann_json_dep, 87 phosphor_dbus_interfaces_dep, 88 phosphor_logging_dep, 89 sdbusplus_dep, 90] 91 92root_inc = include_directories( 93 '.', 94 'buildjson', 95 'dbus', 96 'errors', 97 'experiments', 98 'ipmi', 99 'notimpl', 100 'pid', 101 'sensors', 102 'sysfs', 103) 104 105setsensor_sources = ['setsensor.cpp'] 106 107libswampd_sources = [ 108 'main.cpp', 109 'util.cpp', 110 'notimpl/readonly.cpp', 111 'notimpl/writeonly.cpp', 112 'dbus/dbusconfiguration.cpp', 113 'dbus/dbusutil.cpp', 114 'dbus/dbushelper.cpp', 115 'dbus/dbuspassiveredundancy.cpp', 116 'dbus/dbuspassive.cpp', 117 'dbus/dbusactiveread.cpp', 118 'dbus/dbuswrite.cpp', 119 'failsafeloggers/builder.cpp', 120 'failsafeloggers/failsafe_logger_utility.cpp', 121 'sysfs/sysfsread.cpp', 122 'sysfs/sysfswrite.cpp', 123 'sysfs/util.cpp', 124 'sensors/pluggable.cpp', 125 'sensors/host.cpp', 126 'sensors/builder.cpp', 127 'sensors/buildjson.cpp', 128 'sensors/manager.cpp', 129 'sensors/build_utils.cpp', 130 'pid/ec/pid.cpp', 131 'pid/ec/logging.cpp', 132 'pid/ec/stepwise.cpp', 133 'pid/fancontroller.cpp', 134 'pid/thermalcontroller.cpp', 135 'pid/pidcontroller.cpp', 136 'pid/stepwisecontroller.cpp', 137 'pid/builder.cpp', 138 'pid/buildjson.cpp', 139 'pid/zone.cpp', 140 'pid/util.cpp', 141 'pid/pidloop.cpp', 142 'pid/tuning.cpp', 143 'buildjson/buildjson.cpp', 144 'experiments/drive.cpp', 145] 146 147libmanualcmds_sources = [ 148 'ipmi/main_ipmi.cpp', 149 'ipmi/manualcmds.cpp', 150 'ipmi/dbus_mode.cpp', 151] 152 153libmanualcmds = library( 154 'manualcmds', 155 libmanualcmds_sources, 156 implicit_include_directories: false, 157 dependencies: deps, 158 version: meson.project_version(), 159 override_options: ['b_lundef=false'], 160 install: true, 161 install_dir: get_option('libdir') / 'ipmid-providers', 162) 163 164executable( 165 'swampd', 166 libswampd_sources, 167 implicit_include_directories: false, 168 include_directories: root_inc, 169 dependencies: deps, 170 install: true, 171 install_dir: get_option('bindir'), 172) 173 174executable( 175 'setsensor', 176 setsensor_sources, 177 implicit_include_directories: true, 178 dependencies: deps, 179 install: true, 180 install_dir: get_option('bindir'), 181) 182 183if get_option('tests').allowed() 184 subdir('test') 185endif 186