From 2918662767f2c2694e6ccf94e1aff38bdc4aa167 Mon Sep 17 00:00:00 2001 From: Alex Lin Date: Wed, 7 Sep 2016 09:33:03 -0500 Subject: [PATCH] Create a trick-config script #298 Created trick-config that can print the version, installation prefix, and compile and link flags that Trick defines. --- bin/trick-config | 76 ++++++++++++++++++++++++++++++ share/trick/makefiles/Makefile.sim | 5 ++ 2 files changed, 81 insertions(+) create mode 100755 bin/trick-config diff --git a/bin/trick-config b/bin/trick-config new file mode 100755 index 00000000..29e3a21d --- /dev/null +++ b/bin/trick-config @@ -0,0 +1,76 @@ +#!/usr/bin/perl + +use File::Basename ; +use Cwd 'abs_path'; +use Getopt::Long ; +use strict; + +# read the trick_ver.txt file and print the trick version +sub print_version() { + my @all_lines ; + my $file_contents ; + my ($current_version) ; + my $trick_ver_txt = "$ENV{TRICK_HOME}/share/trick/trick_ver.txt" ; + open FILE, "$trick_ver_txt" or die "$0: Couldn't find $trick_ver_txt\n" ; + @all_lines = ; + close FILE ; + $file_contents = join "" , @all_lines ; + ($current_version) = $file_contents =~ /current_version\s*=\s*"([^"]+)"/ ; + print "$current_version\n" ; +} + +# print the prefix which is also TRICK_HOME +sub print_prefix() { + print "$ENV{TRICK_HOME}\n" ; +} + +# Run a special rule in Makefile.sim that prints the value of the environment variable we request +sub print_makefile_var($) { + open(README, "make -f $ENV{TRICK_HOME}/share/trick/makefiles/Makefile.sim print-@_ | ") or + die "Couldn't fork $!\n" ; + while () { + /=(.*)/ && print "$1\n" ; + } + close(README) ; +} + +sub print_usage() { + print "\ +Usage: trick-config