blob: 4b356c7383fd343c9089cb4e7db61a1d14116d00 [file] [log] [blame]
Brad Bishop39b370a2019-09-02 02:37:32 -04001project(
George Liu690e7802019-08-23 11:04:01 +08002 'phosphor-power',
Brad Bishop39b370a2019-09-02 02:37:32 -04003 'cpp',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Matthew Barthd13feab2019-12-20 14:09:19 -06007 'cpp_std=c++17',
Brandon Wyman81d6cde2021-03-09 16:00:04 -06008 'buildtype=debugoptimized',
Matthew Barthd13feab2019-12-20 14:09:19 -06009 'prefix=/usr'
Brad Bishop39b370a2019-09-02 02:37:32 -040010 ],
11 license: 'Apache-2.0',
12 version: '1.0',
13)
14
15build_tests = get_option('tests')
16
Brandon Wymandc8e9312020-02-14 17:04:18 -060017if 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
Brad Bishop39b370a2019-09-02 02:37:32 -040032cppfs = 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)
Brad Bishop39b370a2019-09-02 02:37:32 -040035phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
36phosphor_logging = dependency('phosphor-logging')
Lei YU43082e72020-03-09 10:32:48 +080037prog_python = import('python').find_installation('python3')
Brad Bishop39b370a2019-09-02 02:37:32 -040038sdbusplus = dependency('sdbusplus')
39sdbuspp = find_program('sdbus++')
40sdeventplus = dependency('sdeventplus')
Cheng C Yange83604b2020-01-09 09:41:47 +080041pthread = dependency('threads')
Matthew Barth7cbc5532020-01-29 15:13:13 -060042stdplus = dependency('stdplus')
Andrew Geissler89283d12020-05-30 23:17:07 -050043boost = dependency('boost')
Brandon Wymanb76ab242020-09-16 18:06:06 -050044fmt = dependency('fmt')
Brad Bishop39b370a2019-09-02 02:37:32 -040045
Lei YUbd3bd822019-10-10 15:28:10 +080046systemd = dependency('systemd')
47servicedir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
48
49services = [
Brad Bishop1c40f1c2020-04-08 19:32:43 -040050 ['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 YUbd3bd822019-10-10 15:28:10 +080058]
59
60foreach service : services
Brad Bishop1c40f1c2020-04-08 19:32:43 -040061 if get_option(service[0])
62 configure_file(input: 'services/' + service[1],
63 output: service[1],
Lei YUbd3bd822019-10-10 15:28:10 +080064 copy: true,
65 install_dir: servicedir)
Brad Bishop1c40f1c2020-04-08 19:32:43 -040066 endif
Lei YUbd3bd822019-10-10 15:28:10 +080067endforeach
68
Andy YF Wang40247cc2019-09-06 18:30:56 +080069# 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
Brad Bishop39b370a2019-09-02 02:37:32 -040080conf = 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'))
George Liu690e7802019-08-23 11:04:01 +080085conf.set_quoted(
86 'PSU_JSON_PATH', '/usr/share/phosphor-power/psu.json')
Andy YF Wang40247cc2019-09-06 18:30:56 +080087conf.set(
88 'SEQUENCER', sequencer_class)
Brad Bishop39b370a2019-09-02 02:37:32 -040089conf.set10(
Andy YF Wang40247cc2019-09-06 18:30:56 +080090 'DEVICE_ACCESS', get_option('device-access'))
Brandon Wyman1d7a7df2020-03-26 10:14:05 -050091conf.set10('IBM_VPD', get_option('ibm-vpd'))
Brad Bishop39b370a2019-09-02 02:37:32 -040092
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,
Brad Bishop39b370a2019-09-02 02:37:32 -0400112 phosphor_dbus_interfaces,
113 phosphor_logging,
114 sdbusplus,
115 sdeventplus,
116 ],
117)
118
Lei YU7c2fbbb2019-11-06 14:56:02 +0800119libpower_inc = include_directories('.')
120
Shawn McCarney4c94bc72019-12-13 17:49:31 -0600121# Build the tools/i2c sub-directory first. Other sub-directories depend on
122# Meson variables defined there.
123subdir('tools/i2c')
124
Brad Bishop1c40f1c2020-04-08 19:32:43 -0400125if get_option('regulators')
126 subdir('phosphor-regulators')
127endif
128if get_option('sequencer-monitor')
129 subdir('power-sequencer')
130endif
Jim Wright1553cd92021-03-31 16:11:59 -0500131if get_option('sequencer-monitor-ng')
132 subdir('phosphor-power-sequencer')
133endif
Brad Bishop1c40f1c2020-04-08 19:32:43 -0400134if get_option('supply-monitor')
135 subdir('power-supply')
136endif
137if get_option('supply-monitor-ng')
138 subdir('phosphor-power-supply')
139endif
140if get_option('utils')
141 subdir('tools/power-utils')
142endif
Shawn McCarneyff481432020-02-13 10:38:44 -0600143if get_option('tests').enabled()
144 subdir('test')
145endif
Brad Bishop1c40f1c2020-04-08 19:32:43 -0400146if get_option('cold-redundancy')
147 subdir('cold-redundancy')
148endif