Build Chip Data binary files from XML
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: Ifee9e2f5ec1fc639ceb4bc2bd5b53d8b3c4177d8
diff --git a/meson.build b/meson.build
index 9453bbc..b429dd8 100644
--- a/meson.build
+++ b/meson.build
@@ -1,3 +1,4 @@
+# OpenBMC openpower-libhei project, see README.md for details.
project('openpower-libhei', 'cpp',
version: '0.1', meson_version: '>=0.50.0',
default_options: [
@@ -7,6 +8,10 @@
'cpp_args=-Wno-unused-parameter'
])
+#-------------------------------------------------------------------------------
+# libhei library
+#-------------------------------------------------------------------------------
+
incdir = include_directories('src')
libhei_src = [
@@ -46,8 +51,19 @@
filebase : 'hei',
description : 'Openpower Hardware Error Isolator')
+#-------------------------------------------------------------------------------
+# Chip Data Files
+#-------------------------------------------------------------------------------
+
+subdir('xml')
+
+#-------------------------------------------------------------------------------
+# Test
+#-------------------------------------------------------------------------------
+
build_tests = get_option('tests')
if not build_tests.disabled()
subdir('test')
endif
+
diff --git a/xml/build_chip_data_binary b/xml/build_chip_data_binary
index 6eb76ee..aa82ea3 100755
--- a/xml/build_chip_data_binary
+++ b/xml/build_chip_data_binary
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use warnings;
use strict;
@@ -28,7 +28,6 @@
# This is a map of all currently supported models/ECs and their IDs.
my $SUPPORTED_MODEL_EC =
{
- SAMPLE_10 => 0xdeadbeef, # Sample binary for libhei
EXPLORER_10 => 0x160D2000, # Explorer Chip DD1.0
P10_10 => 0x120DA049, # P10 Chip DD1.0
};
diff --git a/xml/meson.build b/xml/meson.build
new file mode 100644
index 0000000..23a9ca0
--- /dev/null
+++ b/xml/meson.build
@@ -0,0 +1,45 @@
+#-------------------------------------------------------------------------------
+# Chip Data Files
+#-------------------------------------------------------------------------------
+
+build_cdb = find_program('build_chip_data_binary')
+
+# The key for each entry in this dictionary is a subdirectory containing XML for
+# a chip model. The value for each entry contains the expected output files that
+# will be produced for each chip model. It is important to note that the script
+# will generate all output files, regardless of what is listed, when the script
+# is run. However, this list must be kept in sync with the expected output so
+# that meson will know to run the script when an output file has changed or is
+# missing.
+cdb_files = {
+ 'p10' :
+ [
+ 'chip_data_p10_10.cdb',
+ ],
+
+ 'explorer' :
+ [
+ 'chip_data_explorer_10.cdb',
+ ],
+}
+
+foreach chip_dir, out_files : cdb_files
+
+ source_dir = meson.current_source_dir() + '/' + chip_dir
+ build_dir = meson.current_build_dir()
+
+ # Get all XML files in the chip directory. This is a bit of a workaround
+ # because meson does not allow wildcards.
+ xml_list = run_command('xml_list.sh', source_dir)
+ in_files = xml_list.stdout().strip().split('\n')
+
+ custom_target('build_cdb_' + chip_dir, build_by_default : true,
+ input : in_files, output : out_files,
+ command : [ build_cdb, '-i', source_dir, '-o', build_dir ],
+ install : true,
+ install_dir : join_paths(get_option('prefix'),
+ get_option('datadir'),
+ meson.project_name()))
+
+endforeach
+
diff --git a/xml/xml_list.sh b/xml/xml_list.sh
new file mode 100755
index 0000000..ca598cc
--- /dev/null
+++ b/xml/xml_list.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Verify input.
+if [ ! -d "$1" ]; then
+ echo "Invalid directory: $1" 1>&2
+ exit 1
+fi
+
+# Simply list out all of the XML files in the given directory.
+for i in "$1"/*.xml; do
+ if [ -f "$i" ]; then
+ echo "$i"
+ fi
+done
+