Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 1 | project( |
George Liu | 690e780 | 2019-08-23 11:04:01 +0800 | [diff] [blame] | 2 | 'phosphor-power', |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 3 | 'cpp', |
| 4 | default_options: [ |
| 5 | 'warning_level=3', |
| 6 | 'werror=true', |
Matthew Barth | d13feab | 2019-12-20 14:09:19 -0600 | [diff] [blame] | 7 | 'cpp_std=c++17', |
Brandon Wyman | 81d6cde | 2021-03-09 16:00:04 -0600 | [diff] [blame] | 8 | 'buildtype=debugoptimized', |
Matthew Barth | d13feab | 2019-12-20 14:09:19 -0600 | [diff] [blame] | 9 | 'prefix=/usr' |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 10 | ], |
| 11 | license: 'Apache-2.0', |
| 12 | version: '1.0', |
| 13 | ) |
| 14 | |
| 15 | build_tests = get_option('tests') |
| 16 | |
Brandon Wyman | dc8e931 | 2020-02-14 17:04:18 -0600 | [diff] [blame] | 17 | if 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] |
| 27 | else |
| 28 | dynamic_linker = [] |
| 29 | endif |
| 30 | |
| 31 | |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 32 | cppfs = meson.get_compiler('cpp').find_library('stdc++fs') |
| 33 | gmock = dependency('gmock', disabler: true, required: build_tests) |
| 34 | gtest = dependency('gtest', main: true, disabler: true, required: build_tests) |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 35 | phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces') |
| 36 | phosphor_logging = dependency('phosphor-logging') |
Lei YU | 43082e7 | 2020-03-09 10:32:48 +0800 | [diff] [blame] | 37 | prog_python = import('python').find_installation('python3') |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 38 | sdbusplus = dependency('sdbusplus') |
| 39 | sdbuspp = find_program('sdbus++') |
| 40 | sdeventplus = dependency('sdeventplus') |
Cheng C Yang | e83604b | 2020-01-09 09:41:47 +0800 | [diff] [blame] | 41 | pthread = dependency('threads') |
Matthew Barth | 7cbc553 | 2020-01-29 15:13:13 -0600 | [diff] [blame] | 42 | stdplus = dependency('stdplus') |
Andrew Geissler | 89283d1 | 2020-05-30 23:17:07 -0500 | [diff] [blame] | 43 | boost = dependency('boost') |
Brandon Wyman | b76ab24 | 2020-09-16 18:06:06 -0500 | [diff] [blame] | 44 | fmt = dependency('fmt') |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 45 | |
Lei YU | bd3bd82 | 2019-10-10 15:28:10 +0800 | [diff] [blame] | 46 | systemd = dependency('systemd') |
| 47 | servicedir = systemd.get_pkgconfig_variable('systemdsystemunitdir') |
| 48 | |
| 49 | services = [ |
Brad Bishop | 1c40f1c | 2020-04-08 19:32:43 -0400 | [diff] [blame] | 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'], |
Lei YU | bd3bd82 | 2019-10-10 15:28:10 +0800 | [diff] [blame] | 58 | ] |
| 59 | |
| 60 | foreach service : services |
Brad Bishop | 1c40f1c | 2020-04-08 19:32:43 -0400 | [diff] [blame] | 61 | if get_option(service[0]) |
| 62 | configure_file(input: 'services/' + service[1], |
| 63 | output: service[1], |
Lei YU | bd3bd82 | 2019-10-10 15:28:10 +0800 | [diff] [blame] | 64 | copy: true, |
| 65 | install_dir: servicedir) |
Brad Bishop | 1c40f1c | 2020-04-08 19:32:43 -0400 | [diff] [blame] | 66 | endif |
Lei YU | bd3bd82 | 2019-10-10 15:28:10 +0800 | [diff] [blame] | 67 | endforeach |
| 68 | |
Andy YF Wang | 40247cc | 2019-09-06 18:30:56 +0800 | [diff] [blame] | 69 | # Get the power sequencer class name |
| 70 | sequencer = get_option('power_sequencer') |
| 71 | if sequencer == 'ucd90160' |
| 72 | sequencer_class = 'UCD90160' |
| 73 | elif sequencer == 'mihawk-cpld' |
| 74 | sequencer_class = 'MihawkCPLD' |
| 75 | else |
| 76 | # power sequencer is incorrect |
| 77 | error('power sequencer is incorrect') |
| 78 | endif |
| 79 | |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 80 | conf = configuration_data() |
| 81 | conf.set_quoted( |
| 82 | 'INPUT_HISTORY_BUSNAME_ROOT', get_option('input-history-busname-root')) |
| 83 | conf.set_quoted( |
| 84 | 'INPUT_HISTORY_SENSOR_ROOT', get_option('input-history-sensor-root')) |
George Liu | 690e780 | 2019-08-23 11:04:01 +0800 | [diff] [blame] | 85 | conf.set_quoted( |
| 86 | 'PSU_JSON_PATH', '/usr/share/phosphor-power/psu.json') |
Andy YF Wang | 40247cc | 2019-09-06 18:30:56 +0800 | [diff] [blame] | 87 | conf.set( |
| 88 | 'SEQUENCER', sequencer_class) |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 89 | conf.set10( |
Andy YF Wang | 40247cc | 2019-09-06 18:30:56 +0800 | [diff] [blame] | 90 | 'DEVICE_ACCESS', get_option('device-access')) |
Brandon Wyman | 1d7a7df | 2020-03-26 10:14:05 -0500 | [diff] [blame] | 91 | conf.set10('IBM_VPD', get_option('ibm-vpd')) |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 92 | |
| 93 | configure_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. |
| 101 | subdir('org/open_power/Witherspoon/Fault') |
| 102 | |
| 103 | libpower = static_library( |
| 104 | 'power', |
| 105 | error_cpp, |
| 106 | error_hpp, |
| 107 | 'gpio.cpp', |
| 108 | 'pmbus.cpp', |
| 109 | 'utility.cpp', |
| 110 | dependencies: [ |
| 111 | cppfs, |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 112 | phosphor_dbus_interfaces, |
| 113 | phosphor_logging, |
| 114 | sdbusplus, |
| 115 | sdeventplus, |
| 116 | ], |
| 117 | ) |
| 118 | |
Lei YU | 7c2fbbb | 2019-11-06 14:56:02 +0800 | [diff] [blame] | 119 | libpower_inc = include_directories('.') |
| 120 | |
Shawn McCarney | 4c94bc7 | 2019-12-13 17:49:31 -0600 | [diff] [blame] | 121 | # Build the tools/i2c sub-directory first. Other sub-directories depend on |
| 122 | # Meson variables defined there. |
| 123 | subdir('tools/i2c') |
| 124 | |
Brad Bishop | 1c40f1c | 2020-04-08 19:32:43 -0400 | [diff] [blame] | 125 | if get_option('regulators') |
| 126 | subdir('phosphor-regulators') |
| 127 | endif |
| 128 | if get_option('sequencer-monitor') |
| 129 | subdir('power-sequencer') |
| 130 | endif |
Jim Wright | 1553cd9 | 2021-03-31 16:11:59 -0500 | [diff] [blame] | 131 | if get_option('sequencer-monitor-ng') |
| 132 | subdir('phosphor-power-sequencer') |
| 133 | endif |
Brad Bishop | 1c40f1c | 2020-04-08 19:32:43 -0400 | [diff] [blame] | 134 | if get_option('supply-monitor') |
| 135 | subdir('power-supply') |
| 136 | endif |
| 137 | if get_option('supply-monitor-ng') |
| 138 | subdir('phosphor-power-supply') |
| 139 | endif |
| 140 | if get_option('utils') |
| 141 | subdir('tools/power-utils') |
| 142 | endif |
Shawn McCarney | ff48143 | 2020-02-13 10:38:44 -0600 | [diff] [blame] | 143 | if get_option('tests').enabled() |
| 144 | subdir('test') |
| 145 | endif |
Brad Bishop | 1c40f1c | 2020-04-08 19:32:43 -0400 | [diff] [blame] | 146 | if get_option('cold-redundancy') |
| 147 | subdir('cold-redundancy') |
| 148 | endif |