1project( 2 'phosphor-power', 3 'cpp', 4 default_options: [ 5 'warning_level=3', 6 'werror=true', 7 'cpp_std=c++17', 8 'buildtype=debugoptimized', 9 'prefix=/usr' 10 ], 11 license: 'Apache-2.0', 12 version: '1.0', 13) 14 15build_tests = get_option('tests') 16 17if get_option('oe-sdk').enabled() 18 # Setup OE SYSROOT 19 OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip() 20 if OECORE_TARGET_SYSROOT == '' 21 error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.') 22 endif 23 message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT) 24 rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib']) 25 ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip() 26 dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so] 27else 28 dynamic_linker = [] 29endif 30 31 32cppfs = meson.get_compiler('cpp').find_library('stdc++fs') 33gmock = dependency('gmock', disabler: true, required: build_tests) 34gtest = dependency('gtest', main: true, disabler: true, required: build_tests) 35phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces') 36phosphor_logging = dependency('phosphor-logging') 37prog_python = import('python').find_installation('python3') 38sdbusplus = dependency('sdbusplus') 39sdbuspp = find_program('sdbus++') 40sdeventplus = dependency('sdeventplus') 41pthread = dependency('threads') 42stdplus = dependency('stdplus') 43boost = dependency('boost') 44fmt = dependency('fmt') 45 46systemd = dependency('systemd') 47servicedir = systemd.get_pkgconfig_variable('systemdsystemunitdir') 48 49services = [ 50 ['supply-monitor', 'power-supply-monitor@.service'], 51 ['sequencer-monitor', 'pseq-monitor-pgood.service'], 52 ['sequencer-monitor', 'pseq-monitor.service'], 53 ['supply-monitor-ng', 'phosphor-psu-monitor.service'], 54 ['regulators', 'phosphor-regulators.service'], 55 ['regulators', 'phosphor-regulators-config.service'], 56 ['regulators', 'phosphor-regulators-monitor-enable.service'], 57 ['regulators', 'phosphor-regulators-monitor-disable.service'], 58] 59 60foreach service : services 61 if get_option(service[0]) 62 configure_file(input: 'services/' + service[1], 63 output: service[1], 64 copy: true, 65 install_dir: servicedir) 66 endif 67endforeach 68 69# Get the power sequencer class name 70sequencer = get_option('power_sequencer') 71if sequencer == 'ucd90160' 72 sequencer_class = 'UCD90160' 73elif sequencer == 'mihawk-cpld' 74 sequencer_class = 'MihawkCPLD' 75else 76 # power sequencer is incorrect 77 error('power sequencer is incorrect') 78endif 79 80conf = configuration_data() 81conf.set_quoted( 82 'INPUT_HISTORY_BUSNAME_ROOT', get_option('input-history-busname-root')) 83conf.set_quoted( 84 'INPUT_HISTORY_SENSOR_ROOT', get_option('input-history-sensor-root')) 85conf.set_quoted( 86 'PSU_JSON_PATH', '/usr/share/phosphor-power/psu.json') 87conf.set( 88 'SEQUENCER', sequencer_class) 89conf.set10( 90 'DEVICE_ACCESS', get_option('device-access')) 91conf.set10('IBM_VPD', get_option('ibm-vpd')) 92 93configure_file(output: 'config.h', configuration: conf) 94 95# Ensure the generated header here winds up in the correct path in the build 96# tree such that it actually get used and doesn't get found in the sysroot 97# somewhere. Meson doesn't allow path elements (rightfully so) when specifying 98# the output filename of a target definition so the target must be defined in 99# the directory where the artifacts need to be placed. Do that now, because 100# the generated source (cpp) is needed to define the library target. 101subdir('org/open_power/Witherspoon/Fault') 102 103libpower = static_library( 104 'power', 105 error_cpp, 106 error_hpp, 107 'gpio.cpp', 108 'pmbus.cpp', 109 'utility.cpp', 110 dependencies: [ 111 cppfs, 112 phosphor_dbus_interfaces, 113 phosphor_logging, 114 sdbusplus, 115 sdeventplus, 116 ], 117) 118 119libpower_inc = include_directories('.') 120 121# Build the tools/i2c sub-directory first. Other sub-directories depend on 122# Meson variables defined there. 123subdir('tools/i2c') 124 125if get_option('regulators') 126 subdir('phosphor-regulators') 127endif 128if get_option('sequencer-monitor') 129 subdir('power-sequencer') 130endif 131if get_option('supply-monitor') 132 subdir('power-supply') 133endif 134if get_option('supply-monitor-ng') 135 subdir('phosphor-power-supply') 136endif 137if get_option('utils') 138 subdir('tools/power-utils') 139endif 140if get_option('tests').enabled() 141 subdir('test') 142endif 143if get_option('cold-redundancy') 144 subdir('cold-redundancy') 145endif 146