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