diff options
author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2017-02-06 07:35:32 -0600 |
---|---|---|
committer | Deepak Kodihalli <dkodihal@in.ibm.com> | 2017-02-14 12:42:39 -0600 |
commit | cd6d2416f02125819605f1274c7cf50c59d6ee2a (patch) | |
tree | 6de8da6b28f7a1359539bc3d0a0bb88626ebd49e | |
parent | 4cf89a1022508ff2419f451de7ca0ed270e202ed (diff) | |
download | openpower-vpd-parser-cd6d2416f02125819605f1274c7cf50c59d6ee2a.tar.gz openpower-vpd-parser-cd6d2416f02125819605f1274c7cf50c59d6ee2a.zip |
build : provide FRU yaml as configurable input
In preparation for the openpower-vpd-parser recipe, make it possible to
provide the FRU data YAML file as a build-configurable input.
Use writefru.yaml as default.
Change-Id: I32dba99bcb6c8dd4da259f907b0499b3192cc412
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rwxr-xr-x | writefru.py | 19 |
3 files changed, 21 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am index 7ece020..8065a48 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,7 +19,7 @@ EXTRA_DIST = \ $(REQ_SCRIPT) \ $(REQ_SCRIPT_FILES) writefru.hpp: ${REQ_SCRIPT} ${REQ_SCRIPT_FILES} - $(AM_V_GEN)$(PYTHON) ${REQ_SCRIPT} + $(AM_V_GEN)@FRUGEN@ sbin_PROGRAMS = openpower-read-vpd openpower_read_vpd_SOURCES = \ diff --git a/configure.ac b/configure.ac index 2cb5d9d..aca5495 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,10 @@ AS_IF([test "x$enable_oe_sdk" == "xyes"], AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) ) +AS_IF([test "x$FRU_YAML" == "x"], [FRU_YAML="writefru.yaml"]) +FRUGEN="$PYTHON $srcdir/writefru.py -i $FRU_YAML" +AC_SUBST(FRUGEN) + AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile test/Makefile]) AC_OUTPUT diff --git a/writefru.py b/writefru.py index 97418ca..eb5d5b8 100755 --- a/writefru.py +++ b/writefru.py @@ -3,10 +3,18 @@ import os import yaml from mako.template import Template +import argparse -if __name__ == '__main__': - script_dir = os.path.dirname(os.path.realpath(__file__)) - with open(os.path.join(script_dir, 'writefru.yaml'), 'r') as fd: +def main(): + parser = argparse.ArgumentParser( + description="OpenPOWER FRU VPD parser and code generator") + + parser.add_argument( + '-i', '--inventory_yaml', dest='inventory_yaml', + default='writefru.yaml', help='input inventory yaml file to parse') + args = parser.parse_args() + + with open(os.path.join(script_dir, args.inventory_yaml), 'r') as fd: yamlDict = yaml.safe_load(fd) # Render the mako template @@ -16,3 +24,8 @@ if __name__ == '__main__': fd.write( t.render( fruDict=yamlDict)) + + +if __name__ == '__main__': + script_dir = os.path.dirname(os.path.realpath(__file__)) + main() |