Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 1 | project( |
| 2 | 'openpower-proc-control', |
| 3 | 'cpp', |
| 4 | default_options: [ |
| 5 | 'warning_level=3', |
| 6 | 'werror=true', |
Brad Bishop | f38b35e | 2020-11-08 10:42:34 -0500 | [diff] [blame] | 7 | 'cpp_std=c++17', |
| 8 | 'buildtype=debugoptimized', |
| 9 | 'b_ndebug=if-release', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 10 | ], |
| 11 | license: 'Apache-2.0', |
| 12 | version: '1.0', |
| 13 | ) |
| 14 | add_project_arguments('-Wno-psabi', language: 'cpp') |
| 15 | |
Brad Bishop | f38b35e | 2020-11-08 10:42:34 -0500 | [diff] [blame] | 16 | if get_option('cpp_std') != 'c++17' |
| 17 | error('This project requires c++17') |
| 18 | endif |
| 19 | |
| 20 | if(get_option('buildtype') == 'minsize') |
| 21 | add_project_arguments('-DNDEBUG', language : 'cpp') |
| 22 | endif |
| 23 | |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 24 | cxx = meson.get_compiler('cpp') |
| 25 | |
| 26 | extra_sources = [] |
| 27 | extra_dependencies = [] |
| 28 | extra_unit_files = [] |
| 29 | |
| 30 | unit_subs = configuration_data() |
Brad Bishop | a5b4b1b | 2020-11-08 12:14:03 -0500 | [diff] [blame] | 31 | unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir'))) |
| 32 | unit_subs.set('ENABLE_PHAL_TRUE', '#') |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 33 | |
| 34 | if get_option('phal').enabled() and get_option('p9').enabled() |
| 35 | error('phal and p9 cannot be selected at the same time') |
| 36 | endif |
| 37 | |
| 38 | build_p9 = not get_option('p9').disabled() |
| 39 | build_openfsi = not get_option('openfsi').disabled() |
| 40 | build_phal = get_option('phal').enabled() |
| 41 | |
| 42 | if get_option('phal').enabled() and not get_option('p9').disabled() |
| 43 | build_p9 = false |
| 44 | endif |
| 45 | |
| 46 | summary('building p9', build_p9) |
| 47 | summary('building openfsi', build_openfsi) |
| 48 | summary('building phal', build_phal) |
| 49 | |
| 50 | if build_p9 |
| 51 | extra_sources += [ |
| 52 | 'procedures/p9/cleanup_pcie.cpp', |
| 53 | 'procedures/p9/set_sync_fsi_clock_mode.cpp', |
| 54 | 'procedures/p9/start_host.cpp', |
| 55 | 'procedures/p9/start_host_mpreboot.cpp', |
| 56 | ] |
| 57 | endif |
| 58 | if build_openfsi |
| 59 | extra_sources += [ |
| 60 | 'procedures/openfsi/scan.cpp', |
| 61 | ] |
| 62 | endif |
| 63 | if build_phal |
| 64 | extra_sources += [ |
| 65 | 'procedures/phal/start_host.cpp', |
| 66 | 'procedures/phal/set_SPI_mux.cpp', |
Chirag Sharma | a257693 | 2020-12-05 23:17:41 -0600 | [diff] [blame] | 67 | 'procedures/phal/proc_pre_poweroff.cpp', |
| 68 | 'procedures/phal/common_utils.cpp', |
Andrew Geissler | 65c0101 | 2021-06-15 14:03:34 -0500 | [diff] [blame] | 69 | 'procedures/phal/check_host_running.cpp', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 70 | 'phalerror/create_pel.cpp', |
| 71 | 'phalerror/phal_error.cpp', |
| 72 | ] |
| 73 | extra_dependencies += [ |
| 74 | dependency('libdt-api'), |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 75 | cxx.find_library('ekb'), |
| 76 | cxx.find_library('ipl'), |
| 77 | ] |
| 78 | extra_unit_files = [ |
Andrew Geissler | 1dc0829 | 2021-06-22 17:14:54 -0500 | [diff] [blame] | 79 | 'service_files/set-spi-mux.service', |
| 80 | 'service_files/phal-reinit-devtree.service', |
| 81 | 'service_files/proc-pre-poweroff@.service', |
Andrew Geissler | 8e73da0 | 2021-06-23 15:43:21 -0500 | [diff] [blame] | 82 | 'service_files/op-reset-host-check@.service', |
Andrew Geissler | 3292c06 | 2021-06-23 21:11:10 -0500 | [diff] [blame^] | 83 | 'service_files/op-reset-host-clear.service', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 84 | ] |
Brad Bishop | a5b4b1b | 2020-11-08 12:14:03 -0500 | [diff] [blame] | 85 | unit_subs.set('ENABLE_PHAL_TRUE', '') |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 86 | endif |
| 87 | |
| 88 | executable( |
| 89 | 'openpower-proc-control', |
| 90 | [ |
| 91 | 'cfam_access.cpp', |
| 92 | 'ext_interface.cpp', |
| 93 | 'filedescriptor.cpp', |
| 94 | 'proc_control.cpp', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 95 | 'targeting.cpp', |
| 96 | 'procedures/common/cfam_overrides.cpp', |
| 97 | 'procedures/common/cfam_reset.cpp', |
| 98 | 'procedures/common/enter_mpreboot.cpp', |
| 99 | 'procedures/common/collect_sbe_hb_data.cpp', |
Jayanth Othayoth | c483181 | 2021-06-08 01:33:40 -0500 | [diff] [blame] | 100 | 'util.cpp', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 101 | ] + extra_sources, |
| 102 | dependencies: [ |
| 103 | dependency('libgpiodcxx'), |
| 104 | cxx.find_library('pdbg'), |
| 105 | dependency('phosphor-dbus-interfaces'), |
| 106 | dependency('phosphor-logging'), |
| 107 | dependency('sdbusplus'), |
| 108 | dependency('threads'), |
Jayanth Othayoth | c483181 | 2021-06-08 01:33:40 -0500 | [diff] [blame] | 109 | dependency('fmt'), |
Brad Bishop | ce08fb9 | 2020-11-08 09:50:48 -0500 | [diff] [blame] | 110 | ] + extra_dependencies, |
| 111 | install: true |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 112 | ) |
| 113 | |
| 114 | executable( |
| 115 | 'openpower-proc-nmi', |
| 116 | [ |
| 117 | 'nmi_main.cpp', |
| 118 | 'nmi_interface.cpp', |
| 119 | ], |
| 120 | dependencies: [ |
| 121 | cxx.find_library('pdbg'), |
| 122 | dependency('phosphor-dbus-interfaces'), |
| 123 | dependency('phosphor-logging'), |
| 124 | dependency('sdbusplus'), |
Brad Bishop | ce08fb9 | 2020-11-08 09:50:48 -0500 | [diff] [blame] | 125 | ], |
| 126 | install: true |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 127 | ) |
| 128 | |
| 129 | unit_files = [ |
Andrew Geissler | 1dc0829 | 2021-06-22 17:14:54 -0500 | [diff] [blame] | 130 | 'service_files/pcie-poweroff@.service', |
| 131 | 'service_files/xyz.openbmc_project.Control.Host.NMI.service', |
| 132 | 'service_files/op-stop-instructions@.service', |
| 133 | 'service_files/op-cfam-reset.service', |
| 134 | 'service_files/op-continue-mpreboot@.service', |
| 135 | 'service_files/op-enter-mpreboot@.service', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 136 | ] + extra_unit_files |
| 137 | |
| 138 | systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable( |
| 139 | 'systemdsystemunitdir', |
| 140 | define_variable: ['prefix', get_option('prefix')]) |
| 141 | foreach u : unit_files |
| 142 | configure_file( |
| 143 | configuration: unit_subs, |
| 144 | input: u + '.in', |
| 145 | install: true, |
| 146 | install_dir: systemd_system_unit_dir, |
Andrew Geissler | 1dc0829 | 2021-06-22 17:14:54 -0500 | [diff] [blame] | 147 | output: '@BASENAME@' |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 148 | ) |
| 149 | endforeach |
| 150 | |
| 151 | if not get_option('tests').disabled() |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 152 | test( |
| 153 | 'utest', |
| 154 | executable( |
| 155 | 'utest', |
| 156 | 'test/utest.cpp', |
| 157 | 'targeting.cpp', |
| 158 | 'filedescriptor.cpp', |
| 159 | dependencies: [ |
Brad Bishop | 5d482d9 | 2020-11-08 09:45:18 -0500 | [diff] [blame] | 160 | dependency('gtest', main: true), |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 161 | dependency('phosphor-logging'), |
| 162 | ], |
| 163 | implicit_include_directories: false, |
| 164 | include_directories: '.', |
| 165 | ) |
| 166 | ) |
| 167 | endif |