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') |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 45 | libgpiodcxx = dependency('libgpiodcxx') |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 46 | |
Lei YU | bd3bd82 | 2019-10-10 15:28:10 +0800 | [diff] [blame] | 47 | systemd = dependency('systemd') |
| 48 | servicedir = systemd.get_pkgconfig_variable('systemdsystemunitdir') |
| 49 | |
| 50 | services = [ |
Brad Bishop | 1c40f1c | 2020-04-08 19:32:43 -0400 | [diff] [blame] | 51 | ['supply-monitor', 'power-supply-monitor@.service'], |
| 52 | ['sequencer-monitor', 'pseq-monitor-pgood.service'], |
| 53 | ['sequencer-monitor', 'pseq-monitor.service'], |
| 54 | ['supply-monitor-ng', 'phosphor-psu-monitor.service'], |
| 55 | ['regulators', 'phosphor-regulators.service'], |
| 56 | ['regulators', 'phosphor-regulators-config.service'], |
| 57 | ['regulators', 'phosphor-regulators-monitor-enable.service'], |
| 58 | ['regulators', 'phosphor-regulators-monitor-disable.service'], |
Lei YU | bd3bd82 | 2019-10-10 15:28:10 +0800 | [diff] [blame] | 59 | ] |
| 60 | |
| 61 | foreach service : services |
Brad Bishop | 1c40f1c | 2020-04-08 19:32:43 -0400 | [diff] [blame] | 62 | if get_option(service[0]) |
| 63 | configure_file(input: 'services/' + service[1], |
| 64 | output: service[1], |
Lei YU | bd3bd82 | 2019-10-10 15:28:10 +0800 | [diff] [blame] | 65 | copy: true, |
| 66 | install_dir: servicedir) |
Brad Bishop | 1c40f1c | 2020-04-08 19:32:43 -0400 | [diff] [blame] | 67 | endif |
Lei YU | bd3bd82 | 2019-10-10 15:28:10 +0800 | [diff] [blame] | 68 | endforeach |
| 69 | |
Andy YF Wang | 40247cc | 2019-09-06 18:30:56 +0800 | [diff] [blame] | 70 | # Get the power sequencer class name |
| 71 | sequencer = get_option('power_sequencer') |
| 72 | if sequencer == 'ucd90160' |
| 73 | sequencer_class = 'UCD90160' |
| 74 | elif sequencer == 'mihawk-cpld' |
| 75 | sequencer_class = 'MihawkCPLD' |
| 76 | else |
| 77 | # power sequencer is incorrect |
| 78 | error('power sequencer is incorrect') |
| 79 | endif |
| 80 | |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 81 | conf = configuration_data() |
| 82 | conf.set_quoted( |
| 83 | 'INPUT_HISTORY_BUSNAME_ROOT', get_option('input-history-busname-root')) |
| 84 | conf.set_quoted( |
| 85 | 'INPUT_HISTORY_SENSOR_ROOT', get_option('input-history-sensor-root')) |
George Liu | 690e780 | 2019-08-23 11:04:01 +0800 | [diff] [blame] | 86 | conf.set_quoted( |
| 87 | 'PSU_JSON_PATH', '/usr/share/phosphor-power/psu.json') |
Andy YF Wang | 40247cc | 2019-09-06 18:30:56 +0800 | [diff] [blame] | 88 | conf.set( |
| 89 | 'SEQUENCER', sequencer_class) |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 90 | conf.set10( |
Andy YF Wang | 40247cc | 2019-09-06 18:30:56 +0800 | [diff] [blame] | 91 | 'DEVICE_ACCESS', get_option('device-access')) |
Brandon Wyman | 1d7a7df | 2020-03-26 10:14:05 -0500 | [diff] [blame] | 92 | conf.set10('IBM_VPD', get_option('ibm-vpd')) |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 93 | |
| 94 | configure_file(output: 'config.h', configuration: conf) |
| 95 | |
| 96 | # Ensure the generated header here winds up in the correct path in the build |
| 97 | # tree such that it actually get used and doesn't get found in the sysroot |
| 98 | # somewhere. Meson doesn't allow path elements (rightfully so) when specifying |
| 99 | # the output filename of a target definition so the target must be defined in |
| 100 | # the directory where the artifacts need to be placed. Do that now, because |
| 101 | # the generated source (cpp) is needed to define the library target. |
| 102 | subdir('org/open_power/Witherspoon/Fault') |
| 103 | |
| 104 | libpower = static_library( |
| 105 | 'power', |
| 106 | error_cpp, |
| 107 | error_hpp, |
| 108 | 'gpio.cpp', |
| 109 | 'pmbus.cpp', |
| 110 | 'utility.cpp', |
| 111 | dependencies: [ |
| 112 | cppfs, |
Brad Bishop | 39b370a | 2019-09-02 02:37:32 -0400 | [diff] [blame] | 113 | phosphor_dbus_interfaces, |
| 114 | phosphor_logging, |
| 115 | sdbusplus, |
| 116 | sdeventplus, |
| 117 | ], |
| 118 | ) |
| 119 | |
Lei YU | 7c2fbbb | 2019-11-06 14:56:02 +0800 | [diff] [blame] | 120 | libpower_inc = include_directories('.') |
| 121 | |
Shawn McCarney | 4c94bc7 | 2019-12-13 17:49:31 -0600 | [diff] [blame] | 122 | # Build the tools/i2c sub-directory first. Other sub-directories depend on |
| 123 | # Meson variables defined there. |
| 124 | subdir('tools/i2c') |
| 125 | |
Brad Bishop | 1c40f1c | 2020-04-08 19:32:43 -0400 | [diff] [blame] | 126 | if get_option('regulators') |
| 127 | subdir('phosphor-regulators') |
| 128 | endif |
| 129 | if get_option('sequencer-monitor') |
| 130 | subdir('power-sequencer') |
| 131 | endif |
Jim Wright | 1553cd9 | 2021-03-31 16:11:59 -0500 | [diff] [blame] | 132 | if get_option('sequencer-monitor-ng') |
| 133 | subdir('phosphor-power-sequencer') |
| 134 | endif |
Brad Bishop | 1c40f1c | 2020-04-08 19:32:43 -0400 | [diff] [blame] | 135 | if get_option('supply-monitor') |
| 136 | subdir('power-supply') |
| 137 | endif |
| 138 | if get_option('supply-monitor-ng') |
| 139 | subdir('phosphor-power-supply') |
| 140 | endif |
| 141 | if get_option('utils') |
| 142 | subdir('tools/power-utils') |
| 143 | endif |
Shawn McCarney | ff48143 | 2020-02-13 10:38:44 -0600 | [diff] [blame] | 144 | if get_option('tests').enabled() |
| 145 | subdir('test') |
| 146 | endif |
Brad Bishop | 1c40f1c | 2020-04-08 19:32:43 -0400 | [diff] [blame] | 147 | if get_option('cold-redundancy') |
| 148 | subdir('cold-redundancy') |
| 149 | endif |