From 121bcb38f29409f10de63a68d86620c4beb75c97 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Wed, 9 Apr 2014 00:18:03 -0400 Subject: [PATCH] opcodes2c.pl: Add command line options Argument 1 is opcodes list filename Argument 2 is the output directory. These arguments are necessary if we want to generate the C source files and headers in a separate build directory. --- src/common/opcodes2c.pl | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/common/opcodes2c.pl b/src/common/opcodes2c.pl index 2bc822a..15213a4 100755 --- a/src/common/opcodes2c.pl +++ b/src/common/opcodes2c.pl @@ -5,11 +5,32 @@ # # This file is released under the GPLv2 -open INST_DEF, ">instructions_8051.h" or die "Error creating : $!\n"; -open INST_IMP, ">instructions_8051.c" or die "Error creating : $!\n"; -open OPCODELST, "opcodes.lst" or die "Error opening : $!\n"; -open OPCODES_DEF, ">opcodes.h" or die "Error creating : $!\n"; -open OPCODES_IMP, ">opcodes.c" or die "Error creating : $!\n"; +# Arg1: opcodes list filename +# Arg2: output directory + +if (($#ARGV + 1) < 2) { + die "Missing arguments.\n"; +} + +my $opcodes_lst_filename = $ARGV[0]; +my $builddir = $ARGV[1]; + +open OPCODELST, $opcodes_lst_filename or die "Error opening " . + $opcodes_lst_filename . " : $!\n"; + +my $file; + +$file = $builddir . "/instructions_8051.h"; +open INST_DEF, ">" . $file or die "Error creating <" . $file . "> : $!\n"; + +$file = $builddir . "/instructions_8051.c"; +open INST_IMP, ">" . $file or die "Error creating <" . $file . "> : $!\n"; + +$file = $builddir . "/opcodes.h"; +open OPCODES_DEF, ">" . $file or die "Error creating <" . $file . "> : $!\n"; + +$file = $builddir . "/opcodes.c"; +open OPCODES_IMP, ">" . $file or die "Error creating <" . $file . "> : $!\n"; # Write GPL license # Argument 0 is file descriptor -- 2.20.1