SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 1 | project( |
| 2 | 'openpower-vpd-parser', |
| 3 | 'c', |
| 4 | 'cpp', |
| 5 | default_options: [ |
Priyanga Ramasamy | 9d14934 | 2020-07-16 23:41:26 +0530 | [diff] [blame] | 6 | 'warning_level=3', |
| 7 | 'werror=true', |
PriyangaRamasamy | f8f9c86 | 2021-02-22 22:53:35 -0600 | [diff] [blame] | 8 | 'cpp_std=c++17', |
PriyangaRamasamy | f272efc | 2021-03-03 23:24:31 -0600 | [diff] [blame] | 9 | 'buildtype=debugoptimized' |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 10 | ], |
| 11 | version: '1.0' |
| 12 | ) |
| 13 | |
Andrew Jeffery | 3aec478 | 2021-06-15 11:45:23 +0930 | [diff] [blame] | 14 | add_global_arguments('-Wno-psabi', language : ['c', 'cpp']) |
| 15 | |
Andrew Jeffery | f395376 | 2021-06-15 11:10:10 +0930 | [diff] [blame] | 16 | # Disable FORTIFY_SOURCE when compiling with no optimization |
| 17 | if(get_option('optimization') == '0') |
| 18 | add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c']) |
| 19 | message('Disabling FORTIFY_SOURCE as optimization is set to 0') |
| 20 | endif |
| 21 | |
| 22 | # Setup googletest before we import any projects that also depend on it to make |
| 23 | # sure we have control over its configuration |
| 24 | build_tests = get_option('tests') |
| 25 | if not build_tests.disabled() |
| 26 | gtest_dep = dependency('gtest', main: true, disabler: true, required: false) |
| 27 | gmock_dep = dependency('gmock', disabler: true, required: false) |
| 28 | if not gtest_dep.found() or not gmock_dep.found() |
| 29 | cmake = import('cmake') |
| 30 | gtest_opts = cmake.subproject_options() |
| 31 | gtest_opts.set_override_option('warning_level', '1') |
| 32 | gtest_opts.set_override_option('werror', 'false') |
| 33 | gtest_proj = cmake.subproject('googletest', |
| 34 | options: gtest_opts, |
| 35 | required: false) |
| 36 | if gtest_proj.found() |
| 37 | gtest_dep = declare_dependency( |
| 38 | dependencies: [ |
| 39 | dependency('threads'), |
| 40 | gtest_proj.dependency('gtest'), |
| 41 | gtest_proj.dependency('gtest_main'), |
| 42 | ] |
| 43 | ) |
| 44 | gmock_dep = gtest_proj.dependency('gmock') |
| 45 | else |
| 46 | assert(not get_option('tests').enabled(), |
| 47 | 'Googletest is required if tests are enabled') |
| 48 | endif |
| 49 | endif |
| 50 | endif |
| 51 | |
Andrew Jeffery | 60b5bd2 | 2021-06-15 10:41:28 +0930 | [diff] [blame] | 52 | phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces', |
| 53 | default_options: [ 'data_com_ibm=true', 'data_org_open_power=true' ], |
| 54 | fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep']) |
| 55 | |
| 56 | phosphor_logging = dependency('phosphor-logging', |
| 57 | default_options: [ 'openpower-pel-extension=enabled' ], |
| 58 | fallback: ['phosphor-logging', 'phosphor_logging_dep']) |
| 59 | |
| 60 | sdbusplus = dependency('sdbusplus', fallback: [ 'sdbusplus', 'sdbusplus_dep' ]) |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 61 | |
Andrew Jeffery | f395376 | 2021-06-15 11:10:10 +0930 | [diff] [blame] | 62 | if not build_tests.disabled() |
| 63 | subdir('test') |
| 64 | endif |
| 65 | |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 66 | compiler = meson.get_compiler('cpp') |
| 67 | python = find_program('python3', required:true) |
| 68 | |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 69 | compiler.has_header('CLI/CLI.hpp') |
| 70 | compiler.has_header('nlohmann/json.hpp') |
PriyangaRamasamy | f8f9c86 | 2021-02-22 22:53:35 -0600 | [diff] [blame] | 71 | |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 72 | configure_file(output: 'config.h', |
| 73 | configuration :{ |
Santosh Puranik | 0246a4d | 2020-11-04 16:57:39 +0530 | [diff] [blame] | 74 | 'INVENTORY_JSON_DEFAULT': '"'+get_option('INVENTORY_JSON_DEFAULT')+'"', |
| 75 | 'VPD_FILES_PATH': '"'+get_option('VPD_FILES_PATH')+'"', |
PriyangaRamasamy | 1f0b1e6 | 2020-02-20 20:48:25 +0530 | [diff] [blame] | 76 | 'INVENTORY_PATH': '"'+get_option('INVENTORY_PATH')+'"', |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 77 | 'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"', |
| 78 | 'INVENTORY_MANAGER_SERVICE': '"'+get_option('INVENTORY_MANAGER_SERVICE')+'"', |
SunnySrivastava1984 | a739259 | 2020-03-09 10:19:33 -0500 | [diff] [blame] | 79 | 'BUSNAME' : '"' + get_option('BUSNAME') + '"', |
| 80 | 'OBJPATH' : '"' + get_option('OBJPATH') + '"', |
| 81 | 'IFACE' : '"' + get_option('IFACE') + '"', |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 82 | 'OBJECT_MAPPER_SERVICE' : '"'+get_option('OBJECT_MAPPER_SERVICE')+'"', |
| 83 | 'OBJECT_MAPPER_OBJECT' : '"'+get_option('OBJECT_MAPPER_OBJECT')+'"', |
| 84 | 'POWER_SUPPLY_TYPE_INTERFACE' : '"'+get_option('POWER_SUPPLY_TYPE_INTERFACE')+'"', |
PriyangaRamasamy | 83a1d5d | 2020-04-30 19:15:43 +0530 | [diff] [blame] | 85 | 'INVENTORY_MANAGER_CACHE' : '"'+get_option('INVENTORY_MANAGER_CACHE')+'"', |
Santosh Puranik | 0246a4d | 2020-11-04 16:57:39 +0530 | [diff] [blame] | 86 | 'INVENTORY_JSON_SYM_LINK': '"'+get_option('INVENTORY_JSON_SYM_LINK')+'"', |
| 87 | 'INVENTORY_JSON_2U': '"'+get_option('INVENTORY_JSON_2U')+'"', |
Santosh Puranik | 4641bff | 2020-11-30 20:26:44 +0530 | [diff] [blame] | 88 | 'INVENTORY_JSON_4U': '"'+get_option('INVENTORY_JSON_4U')+'"', |
PriyangaRamasamy | c0a534f | 2020-08-24 21:29:18 +0530 | [diff] [blame] | 89 | 'INVENTORY_JSON_EVEREST': '"'+get_option('INVENTORY_JSON_EVEREST')+'"', |
Alpana Kumari | f05effd | 2021-04-07 07:32:53 -0500 | [diff] [blame] | 90 | 'DBUS_PROP_JSON': '"'+get_option('DBUS_PROP_JSON')+'"', |
PriyangaRamasamy | c2fe40f | 2021-03-02 06:27:33 -0600 | [diff] [blame] | 91 | 'SYSTEM_JSON' : '"'+get_option('SYSTEM_JSON')+'"', |
PriyangaRamasamy | 8cc5b15 | 2021-06-03 13:05:17 -0500 | [diff] [blame] | 92 | 'BAD_VPD_DIR': '"'+get_option('BAD_VPD_DIR')+'"', |
| 93 | 'FAN_INTERFACE': '"'+get_option('FAN_INTERFACE')+'"' |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 94 | } |
PriyangaRamasamy | 1f0b1e6 | 2020-02-20 20:48:25 +0530 | [diff] [blame] | 95 | ) |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 96 | |
Sunny Srivastava | 6c71c9d | 2021-04-15 04:43:54 -0500 | [diff] [blame] | 97 | common_SOURCES =['common_utility.cpp', |
PriyangaRamasamy | c0a534f | 2020-08-24 21:29:18 +0530 | [diff] [blame] | 98 | 'vpd-parser/parser_factory.cpp', |
| 99 | 'vpd-parser/memory_vpd_parser.cpp', |
| 100 | 'vpd-parser/keyword_vpd_parser.cpp', |
Sunny Srivastava | 6c71c9d | 2021-04-15 04:43:54 -0500 | [diff] [blame] | 101 | 'vpd-parser/ipz_parser.cpp', 'impl.cpp', 'ibm_vpd_utils.cpp', |
PriyangaRamasamy | c0a534f | 2020-08-24 21:29:18 +0530 | [diff] [blame] | 102 | 'vpdecc/vpdecc.c', 'vpdecc/vpdecc_support.c' |
| 103 | ] |
| 104 | |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 105 | if get_option('ibm-parser').enabled() |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 106 | libgpiodcxx = dependency('libgpiodcxx') |
PriyangaRamasamy | c0a534f | 2020-08-24 21:29:18 +0530 | [diff] [blame] | 107 | ibm_read_vpd_SOURCES = ['ibm_vpd_app.cpp' |
| 108 | ]+common_SOURCES |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 109 | |
| 110 | ibm_vpd_exe = executable( |
| 111 | 'ibm-read-vpd', |
| 112 | ibm_read_vpd_SOURCES, |
| 113 | dependencies: [ |
| 114 | sdbusplus, |
| 115 | phosphor_logging, |
Alpana Kumari | 2f79304 | 2020-08-18 05:51:03 -0500 | [diff] [blame] | 116 | libgpiodcxx, |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 117 | ], |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 118 | include_directories : 'vpd-parser/', |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 119 | install: true, |
| 120 | cpp_args : '-DIPZ_PARSER' |
| 121 | ) |
PriyangaRamasamy | 1f0b1e6 | 2020-02-20 20:48:25 +0530 | [diff] [blame] | 122 | |
| 123 | vpd_tool_SOURCES = ['vpd_tool.cpp', |
PriyangaRamasamy | c0a534f | 2020-08-24 21:29:18 +0530 | [diff] [blame] | 124 | 'vpd_tool_impl.cpp', |
| 125 | 'vpd-manager/editor_impl.cpp', |
| 126 | ]+common_SOURCES |
| 127 | |
| 128 | vpd_tool_INCLUDE = include_directories('vpd-parser/', 'vpd-manager') |
PriyangaRamasamy | 1f0b1e6 | 2020-02-20 20:48:25 +0530 | [diff] [blame] | 129 | |
| 130 | vpd_tool_exe = executable( |
| 131 | 'vpd-tool', |
| 132 | vpd_tool_SOURCES, |
| 133 | dependencies: [ |
| 134 | sdbusplus |
| 135 | ], |
PriyangaRamasamy | c0a534f | 2020-08-24 21:29:18 +0530 | [diff] [blame] | 136 | install: true, |
| 137 | include_directories : vpd_tool_INCLUDE |
PriyangaRamasamy | 1f0b1e6 | 2020-02-20 20:48:25 +0530 | [diff] [blame] | 138 | ) |
SunnySrivastava1984 | a739259 | 2020-03-09 10:19:33 -0500 | [diff] [blame] | 139 | if get_option('vpd-manager').enabled() |
| 140 | subdir('vpd-manager') |
| 141 | endif |
| 142 | |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 143 | else |
| 144 | FRUGEN = '$srcdir/extra-properties.py -e' + get_option('FRU_YAML') |
| 145 | PROPGEN = '$srcdir/extra-properties.py -e' + get_option('PROP_YAML') |
| 146 | |
| 147 | src_dir = meson.source_root() |
| 148 | FRU_GEN_SCRIPT = src_dir + '/writefru.py' |
| 149 | FRU_GEN_SCRIPT_FILES = src_dir + '/writefru.yaml' |
| 150 | |
| 151 | PROP_GEN_SCRIPT = src_dir + '/extra-properties.py' |
| 152 | PROP_GEN_SCRIPT_FILES = src_dir + '/extra-properties-example.yaml' |
| 153 | |
| 154 | writefru_hpp = custom_target('writefru.hpp', |
| 155 | command:[python, |
| 156 | FRU_GEN_SCRIPT, |
| 157 | '-i', |
| 158 | get_option('FRU_YAML') |
| 159 | ], |
| 160 | depend_files :['writefru.mako.hpp', |
| 161 | 'writefru.py', |
| 162 | get_option('FRU_YAML') |
| 163 | ], |
| 164 | output:'writefru.hpp' |
| 165 | ) |
| 166 | |
| 167 | extra_properties_gen_hpp = custom_target( |
| 168 | 'extra-properties-gen.hpp', |
| 169 | command:[ |
| 170 | python, |
| 171 | PROP_GEN_SCRIPT, |
| 172 | '-e', |
| 173 | get_option('PROP_YAML') |
| 174 | ], |
| 175 | depend_files : ['extra-properties.mako.hpp', |
| 176 | 'extra-properties.py', |
| 177 | get_option('PROP_YAML') |
| 178 | ], |
| 179 | output:'extra-properties-gen.hpp' |
| 180 | ) |
| 181 | |
| 182 | openpower_read_vpd_SOURCES = ['app.cpp', |
| 183 | 'args.cpp', |
| 184 | 'impl.cpp', |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 185 | 'vpd-parser/ipz_parser.cpp', |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 186 | 'write.cpp', |
Sunny Srivastava | 6c71c9d | 2021-04-15 04:43:54 -0500 | [diff] [blame] | 187 | 'common_utility.cpp', |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 188 | writefru_hpp, |
| 189 | extra_properties_gen_hpp |
| 190 | ] |
| 191 | |
| 192 | openpower_read_vpd_exe= executable( |
| 193 | 'openpower-read-vpd', |
| 194 | openpower_read_vpd_SOURCES, |
| 195 | dependencies: [ |
| 196 | sdbusplus, |
| 197 | phosphor_logging, |
| 198 | ], |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 199 | include_directories : 'vpd-parser/', |
SunnySrivastava1984 | 7ef5442 | 2019-12-03 02:47:37 -0600 | [diff] [blame] | 200 | install: true, |
| 201 | ) |
| 202 | endif |