1project(
2     'openpower-vpd-parser',
3     'c',
4     'cpp',
5     default_options: [
6     'cpp_std=c++17'
7     ],
8     version: '1.0'
9)
10
11build_tests = get_option('tests')
12
13sdbusplus = dependency('sdbusplus')
14phosphor_logging = dependency('phosphor-logging')
15phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
16
17compiler = meson.get_compiler('cpp')
18python = find_program('python3', required:true)
19
20compiler.has_header('CLI/CLI.hpp')
21compiler.has_header('nlohmann/json.hpp')
22add_global_arguments('-Wno-psabi', language : ['c', 'cpp'])
23configure_file(output: 'config.h',
24                       configuration :{
25                       'INVENTORY_JSON_DEFAULT': '"'+get_option('INVENTORY_JSON_DEFAULT')+'"',
26                       'VPD_FILES_PATH': '"'+get_option('VPD_FILES_PATH')+'"',
27                       'INVENTORY_PATH': '"'+get_option('INVENTORY_PATH')+'"',
28                       'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"',
29                       'INVENTORY_MANAGER_SERVICE': '"'+get_option('INVENTORY_MANAGER_SERVICE')+'"',
30                       'BUSNAME' : '"' + get_option('BUSNAME') + '"',
31                       'OBJPATH' : '"' + get_option('OBJPATH') + '"',
32                       'IFACE' : '"' + get_option('IFACE') + '"',
33                       'OBJECT_MAPPER_SERVICE' : '"'+get_option('OBJECT_MAPPER_SERVICE')+'"',
34                       'OBJECT_MAPPER_OBJECT' : '"'+get_option('OBJECT_MAPPER_OBJECT')+'"',
35                       'POWER_SUPPLY_TYPE_INTERFACE' : '"'+get_option('POWER_SUPPLY_TYPE_INTERFACE')+'"',
36                       'INVENTORY_MANAGER_CACHE' : '"'+get_option('INVENTORY_MANAGER_CACHE')+'"',
37                       'INVENTORY_JSON_SYM_LINK': '"'+get_option('INVENTORY_JSON_SYM_LINK')+'"',
38                       'INVENTORY_JSON_2U': '"'+get_option('INVENTORY_JSON_2U')+'"',
39                       'INVENTORY_JSON_4U': '"'+get_option('INVENTORY_JSON_4U')+'"'
40                       }
41  )
42
43if get_option('ibm-parser').enabled()
44        ibm_read_vpd_SOURCES = ['ibm_vpd_app.cpp',
45                                'vpd-parser/ipz_parser.cpp',
46                                'impl.cpp',
47                                'utils.cpp',
48                                'vpd-parser/keyword_vpd_parser.cpp',
49                                'vpdecc/vpdecc.c',
50                                'vpdecc/vpdecc_support.c',
51                                'vpd-parser/memory_vpd_parser.cpp',
52                                'vpd-parser/parser_factory.cpp'
53                               ]
54
55        ibm_vpd_exe = executable(
56                                'ibm-read-vpd',
57                                ibm_read_vpd_SOURCES,
58                                dependencies: [
59                                        sdbusplus,
60                                        phosphor_logging,
61                                ],
62                                include_directories : 'vpd-parser/',
63                                install: true,
64                                cpp_args : '-DIPZ_PARSER'
65                            )
66
67        vpd_tool_SOURCES = ['vpd_tool.cpp',
68                            'vpd_tool_impl.cpp'
69                           ]
70
71        vpd_tool_exe = executable(
72                                 'vpd-tool',
73                                 vpd_tool_SOURCES,
74                                 dependencies: [
75                                   sdbusplus
76                                   ],
77                                 install: true
78                                 )
79if get_option('vpd-manager').enabled()
80    subdir('vpd-manager')
81endif
82
83else
84        FRUGEN = '$srcdir/extra-properties.py -e' + get_option('FRU_YAML')
85        PROPGEN = '$srcdir/extra-properties.py -e' + get_option('PROP_YAML')
86
87        src_dir = meson.source_root()
88        FRU_GEN_SCRIPT = src_dir + '/writefru.py'
89        FRU_GEN_SCRIPT_FILES = src_dir + '/writefru.yaml'
90
91        PROP_GEN_SCRIPT = src_dir + '/extra-properties.py'
92        PROP_GEN_SCRIPT_FILES = src_dir + '/extra-properties-example.yaml'
93
94        writefru_hpp = custom_target('writefru.hpp',
95                                     command:[python,
96                                              FRU_GEN_SCRIPT,
97                                              '-i',
98                                              get_option('FRU_YAML')
99                                     ],
100                                     depend_files :['writefru.mako.hpp',
101                                                    'writefru.py',
102                                                    get_option('FRU_YAML')
103                                     ],
104                                     output:'writefru.hpp'
105        )
106
107        extra_properties_gen_hpp = custom_target(
108                                        'extra-properties-gen.hpp',
109                                        command:[
110                                                python,
111                                                PROP_GEN_SCRIPT,
112                                                '-e',
113                                                get_option('PROP_YAML')
114                                        ],
115                                        depend_files : ['extra-properties.mako.hpp',
116                                                        'extra-properties.py',
117                                                        get_option('PROP_YAML')
118                                        ],
119                                        output:'extra-properties-gen.hpp'
120        )
121
122        openpower_read_vpd_SOURCES = ['app.cpp',
123                                      'args.cpp',
124                                      'impl.cpp',
125                                      'vpd-parser/ipz_parser.cpp',
126                                      'write.cpp',
127                                      'utils.cpp',
128                                      writefru_hpp,
129                                      extra_properties_gen_hpp
130        ]
131
132        openpower_read_vpd_exe= executable(
133                'openpower-read-vpd',
134                openpower_read_vpd_SOURCES,
135                dependencies: [
136                        sdbusplus,
137                        phosphor_logging,
138                ],
139                include_directories : 'vpd-parser/',
140                install: true,
141        )
142endif
143subdir('test')
144