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 | |
Jayanth Othayoth | 3840547 | 2021-07-26 06:16:44 -0500 | [diff] [blame] | 30 | # Configuration header file(config.h) generation |
| 31 | conf_data = configuration_data() |
| 32 | |
| 33 | conf_data.set_quoted('DEVTREE_EXPORT_FILTER_FILE', get_option('DEVTREE_EXPORT_FILTER_FILE'), |
| 34 | description : 'Path to the phal devtree export filter file' |
| 35 | ) |
| 36 | |
| 37 | conf_data.set_quoted('DEVTREE_EXP_FILE', get_option('DEVTREE_EXP_FILE'), |
| 38 | description : 'Path to the devtree export copy file' |
| 39 | ) |
| 40 | |
| 41 | configure_file(configuration : conf_data, |
| 42 | output : 'config.h' |
| 43 | ) |
| 44 | |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 45 | unit_subs = configuration_data() |
Brad Bishop | a5b4b1b | 2020-11-08 12:14:03 -0500 | [diff] [blame] | 46 | unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir'))) |
| 47 | unit_subs.set('ENABLE_PHAL_TRUE', '#') |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 48 | |
| 49 | if get_option('phal').enabled() and get_option('p9').enabled() |
| 50 | error('phal and p9 cannot be selected at the same time') |
| 51 | endif |
| 52 | |
| 53 | build_p9 = not get_option('p9').disabled() |
| 54 | build_openfsi = not get_option('openfsi').disabled() |
| 55 | build_phal = get_option('phal').enabled() |
| 56 | |
| 57 | if get_option('phal').enabled() and not get_option('p9').disabled() |
| 58 | build_p9 = false |
| 59 | endif |
| 60 | |
| 61 | summary('building p9', build_p9) |
| 62 | summary('building openfsi', build_openfsi) |
| 63 | summary('building phal', build_phal) |
| 64 | |
| 65 | if build_p9 |
| 66 | extra_sources += [ |
| 67 | 'procedures/p9/cleanup_pcie.cpp', |
| 68 | 'procedures/p9/set_sync_fsi_clock_mode.cpp', |
| 69 | 'procedures/p9/start_host.cpp', |
| 70 | 'procedures/p9/start_host_mpreboot.cpp', |
| 71 | ] |
| 72 | endif |
| 73 | if build_openfsi |
| 74 | extra_sources += [ |
| 75 | 'procedures/openfsi/scan.cpp', |
| 76 | ] |
| 77 | endif |
| 78 | if build_phal |
| 79 | extra_sources += [ |
| 80 | 'procedures/phal/start_host.cpp', |
| 81 | 'procedures/phal/set_SPI_mux.cpp', |
Chirag Sharma | a257693 | 2020-12-05 23:17:41 -0600 | [diff] [blame] | 82 | 'procedures/phal/proc_pre_poweroff.cpp', |
Jayanth Othayoth | cf2da1b | 2021-07-29 03:15:20 -0500 | [diff] [blame] | 83 | 'procedures/phal/check_host_running.cpp', |
| 84 | 'procedures/phal/import_devtree.cpp', |
Jayanth Othayoth | 25e39c8 | 2021-07-12 01:00:17 -0500 | [diff] [blame] | 85 | 'extensions/phal/common_utils.cpp', |
Jayanth Othayoth | c3d6b87 | 2021-07-28 05:07:25 -0500 | [diff] [blame] | 86 | 'extensions/phal/pdbg_utils.cpp', |
Jayanth Othayoth | 6552de0 | 2021-07-12 00:55:57 -0500 | [diff] [blame] | 87 | 'extensions/phal/create_pel.cpp', |
| 88 | 'extensions/phal/phal_error.cpp', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 89 | ] |
| 90 | extra_dependencies += [ |
| 91 | dependency('libdt-api'), |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 92 | cxx.find_library('ekb'), |
| 93 | cxx.find_library('ipl'), |
Jayanth Othayoth | 4079f09 | 2021-09-20 07:36:54 -0500 | [diff] [blame^] | 94 | cxx.find_library('phal'), |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 95 | ] |
| 96 | extra_unit_files = [ |
Andrew Geissler | 1dc0829 | 2021-06-22 17:14:54 -0500 | [diff] [blame] | 97 | 'service_files/set-spi-mux.service', |
| 98 | 'service_files/phal-reinit-devtree.service', |
| 99 | 'service_files/proc-pre-poweroff@.service', |
Andrew Geissler | 8e73da0 | 2021-06-23 15:43:21 -0500 | [diff] [blame] | 100 | 'service_files/op-reset-host-check@.service', |
Andrew Geissler | 3292c06 | 2021-06-23 21:11:10 -0500 | [diff] [blame] | 101 | 'service_files/op-reset-host-clear.service', |
Jayanth Othayoth | a089bd2 | 2021-07-30 01:32:31 -0500 | [diff] [blame] | 102 | 'service_files/phal-import-devtree@.service', |
Jayanth Othayoth | 07e9a6a | 2021-07-30 03:52:13 -0500 | [diff] [blame] | 103 | 'service_files/phal-export-devtree@.service', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 104 | ] |
Brad Bishop | a5b4b1b | 2020-11-08 12:14:03 -0500 | [diff] [blame] | 105 | unit_subs.set('ENABLE_PHAL_TRUE', '') |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 106 | endif |
| 107 | |
| 108 | executable( |
| 109 | 'openpower-proc-control', |
| 110 | [ |
| 111 | 'cfam_access.cpp', |
| 112 | 'ext_interface.cpp', |
| 113 | 'filedescriptor.cpp', |
| 114 | 'proc_control.cpp', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 115 | 'targeting.cpp', |
| 116 | 'procedures/common/cfam_overrides.cpp', |
| 117 | 'procedures/common/cfam_reset.cpp', |
| 118 | 'procedures/common/enter_mpreboot.cpp', |
| 119 | 'procedures/common/collect_sbe_hb_data.cpp', |
Jayanth Othayoth | c483181 | 2021-06-08 01:33:40 -0500 | [diff] [blame] | 120 | 'util.cpp', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 121 | ] + extra_sources, |
| 122 | dependencies: [ |
| 123 | dependency('libgpiodcxx'), |
| 124 | cxx.find_library('pdbg'), |
| 125 | dependency('phosphor-dbus-interfaces'), |
| 126 | dependency('phosphor-logging'), |
| 127 | dependency('sdbusplus'), |
| 128 | dependency('threads'), |
Jayanth Othayoth | c483181 | 2021-06-08 01:33:40 -0500 | [diff] [blame] | 129 | dependency('fmt'), |
Brad Bishop | ce08fb9 | 2020-11-08 09:50:48 -0500 | [diff] [blame] | 130 | ] + extra_dependencies, |
| 131 | install: true |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 132 | ) |
| 133 | |
| 134 | executable( |
| 135 | 'openpower-proc-nmi', |
| 136 | [ |
| 137 | 'nmi_main.cpp', |
| 138 | 'nmi_interface.cpp', |
| 139 | ], |
| 140 | dependencies: [ |
| 141 | cxx.find_library('pdbg'), |
| 142 | dependency('phosphor-dbus-interfaces'), |
| 143 | dependency('phosphor-logging'), |
| 144 | dependency('sdbusplus'), |
Brad Bishop | ce08fb9 | 2020-11-08 09:50:48 -0500 | [diff] [blame] | 145 | ], |
| 146 | install: true |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 147 | ) |
| 148 | |
Jayanth Othayoth | 13c57ad | 2021-07-16 06:02:21 -0500 | [diff] [blame] | 149 | if build_phal |
| 150 | executable( |
| 151 | 'phal-export-devtree', |
| 152 | [ |
| 153 | 'extensions/phal/devtree_export.cpp', |
| 154 | 'extensions/phal/fw_update_watch.cpp', |
Jayanth Othayoth | 3840547 | 2021-07-26 06:16:44 -0500 | [diff] [blame] | 155 | 'extensions/phal/pdbg_utils.cpp', |
| 156 | 'extensions/phal/create_pel.cpp', |
| 157 | 'util.cpp', |
Jayanth Othayoth | 13c57ad | 2021-07-16 06:02:21 -0500 | [diff] [blame] | 158 | ], |
| 159 | dependencies: [ |
| 160 | dependency('phosphor-logging'), |
| 161 | dependency('sdbusplus'), |
| 162 | dependency('sdeventplus'), |
| 163 | dependency('fmt'), |
Jayanth Othayoth | 3840547 | 2021-07-26 06:16:44 -0500 | [diff] [blame] | 164 | dependency('phosphor-dbus-interfaces'), |
| 165 | cxx.find_library('pdbg'), |
Jayanth Othayoth | 13c57ad | 2021-07-16 06:02:21 -0500 | [diff] [blame] | 166 | ], |
| 167 | install: true |
| 168 | ) |
| 169 | endif |
| 170 | |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 171 | unit_files = [ |
Andrew Geissler | 1dc0829 | 2021-06-22 17:14:54 -0500 | [diff] [blame] | 172 | 'service_files/pcie-poweroff@.service', |
| 173 | 'service_files/xyz.openbmc_project.Control.Host.NMI.service', |
| 174 | 'service_files/op-stop-instructions@.service', |
| 175 | 'service_files/op-cfam-reset.service', |
| 176 | 'service_files/op-continue-mpreboot@.service', |
| 177 | 'service_files/op-enter-mpreboot@.service', |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 178 | ] + extra_unit_files |
| 179 | |
| 180 | systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable( |
| 181 | 'systemdsystemunitdir', |
| 182 | define_variable: ['prefix', get_option('prefix')]) |
| 183 | foreach u : unit_files |
| 184 | configure_file( |
| 185 | configuration: unit_subs, |
| 186 | input: u + '.in', |
| 187 | install: true, |
| 188 | install_dir: systemd_system_unit_dir, |
Andrew Geissler | 1dc0829 | 2021-06-22 17:14:54 -0500 | [diff] [blame] | 189 | output: '@BASENAME@' |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 190 | ) |
| 191 | endforeach |
| 192 | |
| 193 | if not get_option('tests').disabled() |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 194 | test( |
| 195 | 'utest', |
| 196 | executable( |
| 197 | 'utest', |
| 198 | 'test/utest.cpp', |
| 199 | 'targeting.cpp', |
| 200 | 'filedescriptor.cpp', |
| 201 | dependencies: [ |
Brad Bishop | 5d482d9 | 2020-11-08 09:45:18 -0500 | [diff] [blame] | 202 | dependency('gtest', main: true), |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 203 | dependency('phosphor-logging'), |
| 204 | ], |
| 205 | implicit_include_directories: false, |
| 206 | include_directories: '.', |
| 207 | ) |
| 208 | ) |
| 209 | endif |