blob: 345b84b284125df13dc6a4ab7a909e7097dfb57a [file] [log] [blame]
SunnySrivastava19847ef54422019-12-03 02:47:37 -06001project(
2 'openpower-vpd-parser',
3 'c',
4 'cpp',
5 default_options: [
Priyanga Ramasamy9d149342020-07-16 23:41:26 +05306 'warning_level=3',
7 'werror=true',
PriyangaRamasamyf8f9c862021-02-22 22:53:35 -06008 'cpp_std=c++17',
PriyangaRamasamyf272efc2021-03-03 23:24:31 -06009 'buildtype=debugoptimized'
SunnySrivastava19847ef54422019-12-03 02:47:37 -060010 ],
11 version: '1.0'
12)
13
14build_tests = get_option('tests')
15
Andrew Jeffery3aec4782021-06-15 11:45:23 +093016add_global_arguments('-Wno-psabi', language : ['c', 'cpp'])
17
SunnySrivastava19847ef54422019-12-03 02:47:37 -060018sdbusplus = dependency('sdbusplus')
19phosphor_logging = dependency('phosphor-logging')
SunnySrivastava198497f8df02020-05-30 12:05:53 -050020phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
SunnySrivastava19847ef54422019-12-03 02:47:37 -060021
22compiler = meson.get_compiler('cpp')
23python = find_program('python3', required:true)
24
SunnySrivastava19847ef54422019-12-03 02:47:37 -060025compiler.has_header('CLI/CLI.hpp')
26compiler.has_header('nlohmann/json.hpp')
PriyangaRamasamyf8f9c862021-02-22 22:53:35 -060027
28# Disable FORTIFY_SOURCE when compiling with no optimization
29if(get_option('optimization') == '0')
30 add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c'])
31 message('Disabling FORTIFY_SOURCE as optimization is set to 0')
32endif
33
SunnySrivastava19847ef54422019-12-03 02:47:37 -060034configure_file(output: 'config.h',
35 configuration :{
Santosh Puranik0246a4d2020-11-04 16:57:39 +053036 'INVENTORY_JSON_DEFAULT': '"'+get_option('INVENTORY_JSON_DEFAULT')+'"',
37 'VPD_FILES_PATH': '"'+get_option('VPD_FILES_PATH')+'"',
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +053038 'INVENTORY_PATH': '"'+get_option('INVENTORY_PATH')+'"',
SunnySrivastava198443306542020-04-01 02:50:20 -050039 'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"',
40 'INVENTORY_MANAGER_SERVICE': '"'+get_option('INVENTORY_MANAGER_SERVICE')+'"',
SunnySrivastava1984a7392592020-03-09 10:19:33 -050041 'BUSNAME' : '"' + get_option('BUSNAME') + '"',
42 'OBJPATH' : '"' + get_option('OBJPATH') + '"',
43 'IFACE' : '"' + get_option('IFACE') + '"',
SunnySrivastava198443306542020-04-01 02:50:20 -050044 'OBJECT_MAPPER_SERVICE' : '"'+get_option('OBJECT_MAPPER_SERVICE')+'"',
45 'OBJECT_MAPPER_OBJECT' : '"'+get_option('OBJECT_MAPPER_OBJECT')+'"',
46 'POWER_SUPPLY_TYPE_INTERFACE' : '"'+get_option('POWER_SUPPLY_TYPE_INTERFACE')+'"',
PriyangaRamasamy83a1d5d2020-04-30 19:15:43 +053047 'INVENTORY_MANAGER_CACHE' : '"'+get_option('INVENTORY_MANAGER_CACHE')+'"',
Santosh Puranik0246a4d2020-11-04 16:57:39 +053048 'INVENTORY_JSON_SYM_LINK': '"'+get_option('INVENTORY_JSON_SYM_LINK')+'"',
49 'INVENTORY_JSON_2U': '"'+get_option('INVENTORY_JSON_2U')+'"',
Santosh Puranik4641bff2020-11-30 20:26:44 +053050 'INVENTORY_JSON_4U': '"'+get_option('INVENTORY_JSON_4U')+'"',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +053051 'INVENTORY_JSON_EVEREST': '"'+get_option('INVENTORY_JSON_EVEREST')+'"',
Alpana Kumarif05effd2021-04-07 07:32:53 -050052 'DBUS_PROP_JSON': '"'+get_option('DBUS_PROP_JSON')+'"',
PriyangaRamasamyc2fe40f2021-03-02 06:27:33 -060053 'SYSTEM_JSON' : '"'+get_option('SYSTEM_JSON')+'"',
54 'BAD_VPD_DIR': '"'+get_option('BAD_VPD_DIR')+'"'
SunnySrivastava19847ef54422019-12-03 02:47:37 -060055 }
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +053056 )
SunnySrivastava198443306542020-04-01 02:50:20 -050057
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -050058common_SOURCES =['common_utility.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +053059'vpd-parser/parser_factory.cpp',
60 'vpd-parser/memory_vpd_parser.cpp',
61 'vpd-parser/keyword_vpd_parser.cpp',
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -050062 'vpd-parser/ipz_parser.cpp', 'impl.cpp', 'ibm_vpd_utils.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +053063 'vpdecc/vpdecc.c', 'vpdecc/vpdecc_support.c'
64]
65
SunnySrivastava198443306542020-04-01 02:50:20 -050066if get_option('ibm-parser').enabled()
Alpana Kumari2f793042020-08-18 05:51:03 -050067 libgpiodcxx = dependency('libgpiodcxx')
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +053068 ibm_read_vpd_SOURCES = ['ibm_vpd_app.cpp'
69 ]+common_SOURCES
SunnySrivastava19847ef54422019-12-03 02:47:37 -060070
71 ibm_vpd_exe = executable(
72 'ibm-read-vpd',
73 ibm_read_vpd_SOURCES,
74 dependencies: [
75 sdbusplus,
76 phosphor_logging,
Alpana Kumari2f793042020-08-18 05:51:03 -050077 libgpiodcxx,
SunnySrivastava19847ef54422019-12-03 02:47:37 -060078 ],
SunnySrivastava1984e12b1812020-05-26 02:23:11 -050079 include_directories : 'vpd-parser/',
SunnySrivastava19847ef54422019-12-03 02:47:37 -060080 install: true,
81 cpp_args : '-DIPZ_PARSER'
82 )
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +053083
84 vpd_tool_SOURCES = ['vpd_tool.cpp',
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +053085 'vpd_tool_impl.cpp',
86 'vpd-manager/editor_impl.cpp',
87 ]+common_SOURCES
88
89 vpd_tool_INCLUDE = include_directories('vpd-parser/', 'vpd-manager')
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +053090
91 vpd_tool_exe = executable(
92 'vpd-tool',
93 vpd_tool_SOURCES,
94 dependencies: [
95 sdbusplus
96 ],
PriyangaRamasamyc0a534f2020-08-24 21:29:18 +053097 install: true,
98 include_directories : vpd_tool_INCLUDE
PriyangaRamasamy1f0b1e62020-02-20 20:48:25 +053099 )
SunnySrivastava1984a7392592020-03-09 10:19:33 -0500100if get_option('vpd-manager').enabled()
101 subdir('vpd-manager')
102endif
103
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600104else
105 FRUGEN = '$srcdir/extra-properties.py -e' + get_option('FRU_YAML')
106 PROPGEN = '$srcdir/extra-properties.py -e' + get_option('PROP_YAML')
107
108 src_dir = meson.source_root()
109 FRU_GEN_SCRIPT = src_dir + '/writefru.py'
110 FRU_GEN_SCRIPT_FILES = src_dir + '/writefru.yaml'
111
112 PROP_GEN_SCRIPT = src_dir + '/extra-properties.py'
113 PROP_GEN_SCRIPT_FILES = src_dir + '/extra-properties-example.yaml'
114
115 writefru_hpp = custom_target('writefru.hpp',
116 command:[python,
117 FRU_GEN_SCRIPT,
118 '-i',
119 get_option('FRU_YAML')
120 ],
121 depend_files :['writefru.mako.hpp',
122 'writefru.py',
123 get_option('FRU_YAML')
124 ],
125 output:'writefru.hpp'
126 )
127
128 extra_properties_gen_hpp = custom_target(
129 'extra-properties-gen.hpp',
130 command:[
131 python,
132 PROP_GEN_SCRIPT,
133 '-e',
134 get_option('PROP_YAML')
135 ],
136 depend_files : ['extra-properties.mako.hpp',
137 'extra-properties.py',
138 get_option('PROP_YAML')
139 ],
140 output:'extra-properties-gen.hpp'
141 )
142
143 openpower_read_vpd_SOURCES = ['app.cpp',
144 'args.cpp',
145 'impl.cpp',
SunnySrivastava1984e12b1812020-05-26 02:23:11 -0500146 'vpd-parser/ipz_parser.cpp',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600147 'write.cpp',
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -0500148 'common_utility.cpp',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600149 writefru_hpp,
150 extra_properties_gen_hpp
151 ]
152
153 openpower_read_vpd_exe= executable(
154 'openpower-read-vpd',
155 openpower_read_vpd_SOURCES,
156 dependencies: [
157 sdbusplus,
158 phosphor_logging,
159 ],
SunnySrivastava1984e12b1812020-05-26 02:23:11 -0500160 include_directories : 'vpd-parser/',
SunnySrivastava19847ef54422019-12-03 02:47:37 -0600161 install: true,
162 )
163endif
164subdir('test')