1a081956fSMike Cappsproject( 2a081956fSMike Capps 'phosphor-fan-presence', 3a081956fSMike Capps 'cpp', 4a081956fSMike Capps default_options: [ 5a081956fSMike Capps 'warning_level=3', 6a081956fSMike Capps 'werror=true', 7*2fbbae69SPatrick Williams 'cpp_std=c++23', 8a081956fSMike Capps 'buildtype=debugoptimized', 9a081956fSMike Capps 'prefix=/usr' 10a081956fSMike Capps ], 11a081956fSMike Capps license: 'Apache-2.0', 12a081956fSMike Capps version: '1.0', 13*2fbbae69SPatrick Williams meson_version: '>=1.1.1', 14a081956fSMike Capps) 15a081956fSMike Capps 16a081956fSMike Cappspython_prog = find_program('python3', native: true) 17a081956fSMike Capps 18a081956fSMike Cappscpp = meson.get_compiler('cpp') 19a081956fSMike Capps 20a081956fSMike Cappscli11_dep = dependency('cli11', required: false) 21a081956fSMike Capps 22a081956fSMike Cappsif not meson.get_compiler('cpp').has_header_symbol( 23a081956fSMike Capps 'CLI/CLI.hpp', 24a081956fSMike Capps 'CLI::App', 25a081956fSMike Capps dependencies: cli11_dep, 26a081956fSMike Capps required: false) 27a081956fSMike Capps cli11_proj = subproject('cli11', required:false) 28a081956fSMike Capps assert(cli11_proj.found(), 'CLI11 is required') 29a081956fSMike Capps cli11_dep = cli11_proj.get_variable('CLI11_dep') 30a081956fSMike Cappsendif 31a081956fSMike Capps 32a081956fSMike Cappsfmt_dep = dependency('fmt') 33a081956fSMike Cappsjson_dep = declare_dependency() 34a081956fSMike Capps 35a081956fSMike Cappsphosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 36a081956fSMike Cappsphosphor_logging_dep = dependency('phosphor-logging') 37a081956fSMike Cappssdbusplus_dep = dependency('sdbusplus') 38a081956fSMike Cappssdeventplus_dep = dependency('sdeventplus') 39a081956fSMike Cappsstdplus_dep = dependency('stdplus') 40a081956fSMike Cappssystemd_dep = dependency('systemd') 41a081956fSMike Capps 42a081956fSMike Cappsif(get_option('tests').enabled()) 43a081956fSMike Capps gmock_dep = dependency('gmock', disabler: true) 44a081956fSMike Capps gtest_dep = dependency('gtest', main: true, disabler: true, required: false) 45a081956fSMike Capps 46a081956fSMike Capps if not gtest_dep.found() or not gmock_dep.found() 47a081956fSMike Capps gtest_proj = import('cmake').subproject('googletest', required: false) 48a081956fSMike Capps if gtest_proj.found() 49a081956fSMike Capps gtest_dep = declare_dependency( 50a081956fSMike Capps dependencies: [ 51a081956fSMike Capps dependency('threads'), 52a081956fSMike Capps gtest_proj.dependency('gtest'), 53a081956fSMike Capps gtest_proj.dependency('gtest_main'), 54a081956fSMike Capps ] 55a081956fSMike Capps ) 56a081956fSMike Capps gmock_dep = gtest_proj.dependency('gmock') 57a081956fSMike Capps else 58a081956fSMike Capps assert( 59a081956fSMike Capps not get_option('tests').enabled(), 60a081956fSMike Capps 'Googletest is required if tests are enabled' 61a081956fSMike Capps ) 62a081956fSMike Capps endif 63a081956fSMike Capps endif 64a081956fSMike Capps subdir('test') 65a081956fSMike Cappsendif 66a081956fSMike Capps 67a081956fSMike Capps 68a081956fSMike Cappsservicedir = systemd_dep.get_variable('systemdsystemunitdir') 69a081956fSMike Cappsusr_share_dir = '/usr/share/phosphor-fan-presence' 70a081956fSMike Capps 71a081956fSMike Cappsconf = configuration_data() 72a081956fSMike Capps 73a081956fSMike Capps# Control 74a081956fSMike Cappsconf.set_quoted( 75a081956fSMike Capps 'CONTROL_PERSIST_ROOT_PATH', get_option('control-persist-root-path')) 76a081956fSMike Cappsconf.set_quoted( 77a081956fSMike Capps 'CONTROL_PERSIST_ROOT_PATH', get_option('control-persist-root-path')) 78a081956fSMike Cappsconf.set_quoted( 79a081956fSMike Capps 'FAN_DEF_YAML_FILE', get_option('fan-def-yaml-file')) 80a081956fSMike Cappsconf.set_quoted( 81a081956fSMike Capps 'FAN_ZONE_YAML_FILE', get_option('fan-zone-yaml-file')) 82a081956fSMike Cappsconf.set_quoted( 83a081956fSMike Capps 'ZONE_EVENTS_YAML_FILE', get_option('zone-events-yaml-file')) 84a081956fSMike Cappsconf.set_quoted( 85a081956fSMike Capps 'ZONE_CONDITIONS_YAML_FILE', get_option('zone-conditions-yaml-file')) 86a081956fSMike Capps 87a081956fSMike Capps# Fan control can be in YAML mode when everything else is in JSON mode 88a081956fSMike Cappscontrol_conf_type = 'yaml' 89a081956fSMike Cappsif get_option('json-config').enabled() and get_option('json-control').enabled() 90a081956fSMike Capps control_conf_type = 'json' 91a081956fSMike Cappsendif 92a081956fSMike Capps 93bf8e56f6SMike Capps# Monitor 94bf8e56f6SMike Cappsconf.set( 95bf8e56f6SMike Capps 'NUM_MONITOR_LOG_ENTRIES', get_option('num-monitor-log-entries')) 96bf8e56f6SMike Cappsconf.set_quoted( 97bf8e56f6SMike Capps 'FAN_MONITOR_YAML_FILE', get_option('fan-monitor-yaml-file')) 98751c8bebSChau Lyconf.set('DELAY_HOST_CONTROL', get_option('delay-host-control')) 99fce14908SChau Lyif get_option('monitor-use-host-state').enabled() 100fce14908SChau Ly conf.set('MONITOR_USE_HOST_STATE', '') 101fce14908SChau Lyendif 102bf8e56f6SMike Capps 103a081956fSMike Capps# JSON-or-YAML (all programs) 104a081956fSMike Cappsif get_option('json-config').enabled() 105a081956fSMike Capps conf.set('PRESENCE_USE_JSON', '') 106a081956fSMike Capps if control_conf_type == 'json' 107a081956fSMike Capps conf.set('CONTROL_USE_JSON', '') 108a081956fSMike Capps endif 109a081956fSMike Capps conf.set('MONITOR_USE_JSON', '') 110a081956fSMike Capps 111a081956fSMike Capps if not cpp.has_header('nlohmann/json.hpp') 112a081956fSMike Capps json_dep = dependency('nlohmann_json') 113a081956fSMike Capps endif 114a081956fSMike Capps conf_type = 'json' 115a081956fSMike Cappselse 116a081956fSMike Capps conf_type = 'yaml' 117a081956fSMike Cappsendif 118a081956fSMike Capps 119bf8e56f6SMike Capps# Sensor Monitor 120bf8e56f6SMike Cappsconf.set_quoted('SENSOR_MONITOR_PERSIST_ROOT_PATH', 121bf8e56f6SMike Capps get_option('sensor-monitor-persist-root-path')) 122a081956fSMike Capps 123b7dd3e22SMatt Spinlerif get_option('use-host-power-state').enabled() 124a081956fSMike Capps conf.set('ENABLE_HOST_STATE', '') 125a081956fSMike Cappsendif 126a081956fSMike Capps 127a081956fSMike Cappsconf.set( 128a081956fSMike Capps 'SHUTDOWN_ALARM_HARD_SHUTDOWN_DELAY_MS', get_option('sensor-monitor-hard-shutdown-delay')) 129a081956fSMike Cappsconf.set( 130a081956fSMike Capps 'SHUTDOWN_ALARM_SOFT_SHUTDOWN_DELAY_MS', get_option('sensor-monitor-soft-shutdown-delay')) 131a081956fSMike Capps 132bf8e56f6SMike Capps# Presence 133bf8e56f6SMike Cappsconf.set( 134bf8e56f6SMike Capps 'NUM_PRESENCE_LOG_ENTRIES', get_option('num-presence-log-entries')) 135bf8e56f6SMike Cappsconf.set_quoted( 136bf8e56f6SMike Capps 'PRESENCE_YAML_FILE', get_option('presence-config')) 137bf8e56f6SMike Capps 138a081956fSMike Cappsconfigure_file(output: 'config.h', configuration: conf) 139a081956fSMike Capps 140a081956fSMike Capps# Service: [name,[svcfiles]] 141a081956fSMike Cappsservices = [] 142a081956fSMike Capps 143a081956fSMike Cappsif get_option('control-service').enabled() 144a081956fSMike Capps subdir('control') 145a081956fSMike Capps service_files = ['phosphor-fan-control@.service'] 146a081956fSMike Capps if control_conf_type == 'yaml' 147a081956fSMike Capps service_files += 'phosphor-fan-control-init@.service' 148a081956fSMike Capps endif 149a081956fSMike Capps services += [['control', service_files]] 150a081956fSMike Cappsendif 151a081956fSMike Capps 152a081956fSMike Cappsif get_option('monitor-service').enabled() 153a081956fSMike Capps subdir('monitor') 154a081956fSMike Capps service_files = ['phosphor-fan-monitor@.service'] 155a081956fSMike Capps if not get_option('json-config').enabled() 156a081956fSMike Capps service_files += 'phosphor-fan-monitor-init@.service' 157a081956fSMike Capps endif 158a081956fSMike Capps services += [['monitor', service_files]] 159a081956fSMike Cappsendif 160a081956fSMike Capps 161a081956fSMike Cappsif get_option('cooling-type-service').enabled() 162a081956fSMike Capps libevdev_dep = dependency('libevdev') 163a081956fSMike Capps subdir('cooling-type') 164a081956fSMike Cappsendif 165a081956fSMike Capps 166a081956fSMike Cappsif get_option('presence-service').enabled() 167a081956fSMike Capps libevdev_dep = dependency('libevdev') 168a081956fSMike Capps subdir('presence') 169a081956fSMike Capps services += [['presence', ['phosphor-fan-presence-tach@.service']]] 170a081956fSMike Cappsendif 171a081956fSMike Capps 172a081956fSMike Cappsif get_option('sensor-monitor-service').enabled() 173a081956fSMike Capps subdir('sensor-monitor') 174a081956fSMike Capps install_data('sensor-monitor/service_files/sensor-monitor.service', 175a081956fSMike Capps install_dir: servicedir) 176a081956fSMike Cappsendif 177a081956fSMike Capps 178a081956fSMike Cappsforeach service : services 179a081956fSMike Capps this_conf_type = conf_type 180a081956fSMike Capps 181a081956fSMike Capps if service[0] == 'control' 182a081956fSMike Capps this_conf_type = control_conf_type 183a081956fSMike Capps endif 184a081956fSMike Capps 185a081956fSMike Capps foreach service_file : service[1] 186a081956fSMike Capps install_data(service[0] / 'service_files' / this_conf_type / service_file, 187a081956fSMike Capps install_dir: servicedir) 188a081956fSMike Capps endforeach 189a081956fSMike Capps 190a081956fSMike Capps if this_conf_type == 'json' 191a081956fSMike Capps fs = import('fs') 192a081956fSMike Capps dir = meson.current_source_dir() / service[0] / 'config_files' / get_option('machine-name') 193a081956fSMike Capps if fs.is_dir(dir) 194a081956fSMike Capps install_subdir(service[0] / 'config_files' / get_option('machine-name'), 195a081956fSMike Capps install_dir: usr_share_dir / service[0], 196a081956fSMike Capps strip_directory: true) 197a081956fSMike Capps endif 198a081956fSMike Capps endif 199a081956fSMike Cappsendforeach 200a081956fSMike Capps 201