summaryrefslogtreecommitdiffstats
path: root/tools/addtargetdir.pl
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2009-07-12 22:02:09 +0000
committerAndrew Mahone <andrew.mahone@gmail.com>2009-07-12 22:02:09 +0000
commit541072ae5db3c90061ded649b92507c488a8ad9f (patch)
treefbdfe7d34840a5e377fcc8420e5bf7f350e119d9 /tools/addtargetdir.pl
parent672b8b6375198f69c6260dd6e973c7e03c05ff0c (diff)
downloadrockbox-541072ae5db3c90061ded649b92507c488a8ad9f.tar.gz
rockbox-541072ae5db3c90061ded649b92507c488a8ad9f.zip
Rework addtargetdir.pl to also fix prefix generated-file depedencies with the target directory, and simplify the sed expression for mkdepfile.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21826 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/addtargetdir.pl')
-rwxr-xr-xtools/addtargetdir.pl40
1 files changed, 19 insertions, 21 deletions
diff --git a/tools/addtargetdir.pl b/tools/addtargetdir.pl
index 2c08d328dc..6a9a72a878 100755
--- a/tools/addtargetdir.pl
+++ b/tools/addtargetdir.pl
@@ -14,30 +14,28 @@ use File::Basename;
my $rbroot = $ARGV[0];
my $builddir = $ARGV[1];
+undef $/;
-my $target2;
+my $target;
+my $rootlen = length $rbroot;
+my $src;
-for (<STDIN>) {
- if (/^([^:]+): (\S+) (.*)/) {
- my ($target, $src, $rest) = ($1, $2, $3);
- my $dir = dirname $src;
- $dir =~ s/^.*$rbroot//;
- print "$builddir$dir/$target: $src $rest\n";
- }
- elsif (/^([^:]+): \\/) {
- # target and source on different lines
- $target2 = $1;
- }
- elsif ($target2) {
- if (/^\s+([^ ]+) (.*)/) {
- my ($src, $rest) = ($1, $2);
+# Split the input file on any runs of '\' and whitespace.
+for (split(/[\s\\]+/m, <STDIN>)) {
+ /^(\/)?[^:]+(\:)?$/;
+# Save target and continue if this item ends in ':'
+ if (!($2 && ($target=$&))) {
+ $src = $&;
+# If $target is set, prefix it with the target path
+ if ($target) {
my $dir = dirname $src;
- $dir =~ s/^.*$rbroot//;
- print "$builddir$dir/$target2: $src $rest\n";
- $target2 = "";
+ substr($dir, 0, $rootlen) = $builddir;
+ print "\n$dir/$target";
+ $target = "";
+# Otherwise, check for an incomplete path for the source file
+ } elsif (!$1) {
+ $src = "$builddir/$src";
}
- }
- else {
- print $_;
+ print " \\\n $src";
}
}