Build chip data from new JSON format
The chip data XML format has been deprecated and the new JSON format
will be used going forward.
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: I2f44ae7bb921c9ab38c2664ab5cc2a9d6e2fd66a
diff --git a/chip_data/meson.build b/chip_data/meson.build
new file mode 100644
index 0000000..1741447
--- /dev/null
+++ b/chip_data/meson.build
@@ -0,0 +1,51 @@
+#-------------------------------------------------------------------------------
+# Chip Data Files
+#-------------------------------------------------------------------------------
+
+build_cdb = find_program('parse_chip_data.py')
+
+# 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 = {}
+
+chip_config = get_option('chip_config')
+
+if 'p10' in chip_config
+ cdb_files += {'p10_10' : ['chip_data_p10_10.cdb']}
+ cdb_files += {'p10_20' : ['chip_data_p10_20.cdb']}
+endif
+
+if 'explorer' in chip_config
+ cdb_files += {'explorer' : ['chip_data_explorer_11.cdb',
+ 'chip_data_explorer_20.cdb']}
+endif
+
+if 'odyssey' in chip_config
+ cdb_files += {'odyssey' : ['chip_data_odyssey_10.cdb']}
+endif
+
+foreach chip_dir, out_files : cdb_files
+
+ source_dir = meson.current_source_dir() + '/' + chip_dir
+ build_dir = meson.current_build_dir()
+
+ # Get all JSON files in the chip directory. This is a bit of a workaround
+ # because meson does not allow wildcards.
+ json_list = run_command('json_list.sh', source_dir)
+ in_files = json_list.stdout().strip().split('\n')
+
+ custom_target('build_cdb_' + chip_dir, build_by_default : true,
+ input : in_files, output : out_files,
+ command : [ build_cdb, 'bin', source_dir, build_dir ],
+ install : true,
+ install_dir : join_paths(get_option('prefix'),
+ get_option('datadir'),
+ meson.project_name()))
+
+endforeach
+