summaryrefslogtreecommitdiff
path: root/cesar/common
diff options
context:
space:
mode:
authorschodet2009-12-02 15:35:12 +0000
committerschodet2009-12-02 15:35:12 +0000
commitf016529d66f0be45dad551546a3206bdcd36b414 (patch)
tree0f2ff9ff82af6b015608b7d1d96a70d1b8592d6e /cesar/common
parent9da793e0a1168e978b7baf7a2351ce14587052d7 (diff)
cesar/common/tools: add build information to rom files, closes #806
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6515 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/common')
-rwxr-xr-xcesar/common/tools/bin2rom23
-rwxr-xr-xcesar/common/tools/build-info83
2 files changed, 105 insertions, 1 deletions
diff --git a/cesar/common/tools/bin2rom b/cesar/common/tools/bin2rom
index d799426fc1..a5321a6d77 100755
--- a/cesar/common/tools/bin2rom
+++ b/cesar/common/tools/bin2rom
@@ -4,8 +4,17 @@
#
use strict;
use warnings;
+use Getopt::Long qw(:config no_ignore_case bundling);
use Pod::Usage;
+# Option parsing.
+my $help;
+my $build_info = 1;
+GetOptions (
+ 'help|h' => \$help,
+ 'build-info!' => \$build_info,
+) or pod2usage (2);
+pod2usage (1) if $help;
@ARGV == 0 or pod2usage (2);
# Convert from big to little endian.
@@ -16,6 +25,14 @@ while (my $n = sysread (STDIN, $_, 1024))
}
die $! if $!;
+# Append build info.
+if ($build_info)
+{
+ use File::Basename qw/dirname/;
+ my $exe = dirname ($0) . '/build-info';
+ system ($exe, '-b');
+}
+
__END__
=head1 NAME
@@ -24,7 +41,11 @@ bin2rom - Convert from binary format to ROM format
=head1 SYNOPSIS
-bin2rom < input.bin > output.rom
+bin2rom [options] < input.bin > output.rom
+
+ Options:
+ -h, --help brief help message
+ --no-build-info do not append build info
=cut
diff --git a/cesar/common/tools/build-info b/cesar/common/tools/build-info
new file mode 100755
index 0000000000..20334ec9c5
--- /dev/null
+++ b/cesar/common/tools/build-info
@@ -0,0 +1,83 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Getopt::Long qw(:config no_ignore_case bundling);
+use Pod::Usage;
+
+# Option parsing.
+my $help;
+my @info;
+my $tag = 1;
+my $blank = 0;
+GetOptions (
+ 'help|h' => \$help,
+ 'info|i=s' => \@info,
+ 'tag!' => \$tag,
+ 'blank-lines|b:9' => \$blank,
+) or pod2usage (2);
+pod2usage (1) if $help;
+@ARGV == 0 or pod2usage (2);
+
+# Define available information.
+
+my %info = (
+ project => \&info_project,
+ version => \&info_version,
+);
+
+# Get project directory.
+sub info_project
+{
+ use Cwd;
+ my @dir = split '/', getcwd ();
+ my @project;
+ # Iteratively remove a directory part to find root.
+ do
+ {
+ @dir or die "cannot find the base directory.\n";
+ unshift @project, pop @dir;
+ } while (!-r join ('/', @dir) . '/common/make/top.mk');
+ return join ('/', @project);
+}
+
+# Get git version.
+sub info_version
+{
+ my $version = qx/git describe --always/
+ or die "cannot get version.\n";
+ chomp $version;
+ return $version;
+}
+
+# Check --info parameter.
+@info = sort keys %info unless @info;
+pod2usage ("unknown info requested.\n") if grep { !exists $info{$_} } @info;
+
+# Output.
+print "\n" x $blank;
+for my $info (@info)
+{
+ my $text = $info{$info} ();
+ my $itag = '';
+ ($itag = "$info: ") =~ s/(\b[a-z])/\u$1/g if $tag;
+ print "$itag$text\n";
+}
+
+__END__
+
+=head1 NAME
+
+build-info - print build information
+
+=head1 SYNOPSIS
+
+build-info [options]
+
+ Options:
+ -h, --help brief help message
+ -i, --info=INFO include specified INFO
+ --no-tag do not print information tag
+ -b, --blank-lines[=N] prepend N blank lines (default: 9)
+
+=cut
+