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', |
| 67 | 'phalerror/create_pel.cpp', |
| 68 | 'phalerror/phal_error.cpp', |
| 69 | ] |
| 70 | extra_dependencies += [ |
| 71 | dependency('libdt-api'), |
| 72 | dependency('fmt'), |
| 73 | cxx.find_library('ekb'), |
| 74 | cxx.find_library('ipl'), |
| 75 | ] |
| 76 | extra_unit_files = [ |
| 77 | 'set-spi-mux.service', |
| 78 | 'phal-reinit-devtree.service', |
| 79 | ] |
Brad Bishop | a5b4b1b | 2020-11-08 12:14:03 -0500 | [diff] [blame] | 80 | unit_subs.set('ENABLE_PHAL_TRUE', '') |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 81 | endif |
| 82 | |
| 83 | executable( |
| 84 | 'openpower-proc-control', |
| 85 | [ |
| 86 | 'cfam_access.cpp', |
| 87 | 'ext_interface.cpp', |
| 88 | 'filedescriptor.cpp', |
| 89 | 'proc_control.cpp', |
| 90 | 'registration.cpp', |
| 91 | 'targeting.cpp', |
| 92 | 'procedures/common/cfam_overrides.cpp', |
| 93 | 'procedures/common/cfam_reset.cpp', |
| 94 | 'procedures/common/enter_mpreboot.cpp', |
| 95 | 'procedures/common/collect_sbe_hb_data.cpp', |
| 96 | ] + extra_sources, |
| 97 | dependencies: [ |
| 98 | dependency('libgpiodcxx'), |
| 99 | cxx.find_library('pdbg'), |
| 100 | dependency('phosphor-dbus-interfaces'), |
| 101 | dependency('phosphor-logging'), |
| 102 | dependency('sdbusplus'), |
| 103 | dependency('threads'), |
Brad Bishop | ce08fb9 | 2020-11-08 09:50:48 -0500 | [diff] [blame] | 104 | ] + extra_dependencies, |
| 105 | install: true |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 106 | ) |
| 107 | |
| 108 | executable( |
| 109 | 'openpower-proc-nmi', |
| 110 | [ |
| 111 | 'nmi_main.cpp', |
| 112 | 'nmi_interface.cpp', |
| 113 | ], |
| 114 | dependencies: [ |
| 115 | cxx.find_library('pdbg'), |
| 116 | dependency('phosphor-dbus-interfaces'), |
| 117 | dependency('phosphor-logging'), |
| 118 | dependency('sdbusplus'), |
Brad Bishop | ce08fb9 | 2020-11-08 09:50:48 -0500 | [diff] [blame] | 119 | ], |
| 120 | install: true |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 121 | ) |
| 122 | |
| 123 | unit_files = [ |
| 124 | 'pcie-poweroff@.service', |
| 125 | 'xyz.openbmc_project.Control.Host.NMI.service', |
| 126 | 'op-stop-instructions@.service', |
| 127 | 'op-cfam-reset.service', |
| 128 | 'op-continue-mpreboot@.service', |
| 129 | 'op-enter-mpreboot@.service', |
| 130 | ] + extra_unit_files |
| 131 | |
| 132 | systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable( |
| 133 | 'systemdsystemunitdir', |
| 134 | define_variable: ['prefix', get_option('prefix')]) |
| 135 | foreach u : unit_files |
| 136 | configure_file( |
| 137 | configuration: unit_subs, |
| 138 | input: u + '.in', |
| 139 | install: true, |
| 140 | install_dir: systemd_system_unit_dir, |
| 141 | output: u |
| 142 | ) |
| 143 | endforeach |
| 144 | |
| 145 | if not get_option('tests').disabled() |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 146 | test( |
| 147 | 'utest', |
| 148 | executable( |
| 149 | 'utest', |
| 150 | 'test/utest.cpp', |
| 151 | 'targeting.cpp', |
| 152 | 'filedescriptor.cpp', |
| 153 | dependencies: [ |
Brad Bishop | 5d482d9 | 2020-11-08 09:45:18 -0500 | [diff] [blame] | 154 | dependency('gtest', main: true), |
Brad Bishop | 919e408 | 2020-10-27 18:55:19 -0400 | [diff] [blame] | 155 | dependency('phosphor-logging'), |
| 156 | ], |
| 157 | implicit_include_directories: false, |
| 158 | include_directories: '.', |
| 159 | ) |
| 160 | ) |
| 161 | endif |