From c6c7ed99996e6eb8f346c4bef3ad9ee8a31c498a Mon Sep 17 00:00:00 2001 From: Junichi Kajiwara Date: Mon, 13 Jul 2015 05:42:15 +0000 Subject: [PATCH 1/2] Fix support clang when we use autotools --- bin/qrintf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/qrintf b/bin/qrintf index 4b91eff..87f2095 100755 --- a/bin/qrintf +++ b/bin/qrintf @@ -62,11 +62,16 @@ if (basename($cc) =~ m{^g(?:cc|\+\+)}) { # splice "-o fn" from ARGV my $output_fn; + my $coption; + for (my $i = 0; $i < @ARGV;) { if ($i + 1 < @ARGV && $ARGV[$i] eq '-o') { $output_fn = $ARGV[$i + 1]; splice @ARGV, $i, 2; } else { + if ($i + 1 < @ARGV && $ARGV[$i] eq '-c') { + $coption = 1; + } ++$i; } } @@ -78,6 +83,10 @@ if (basename($cc) =~ m{^g(?:cc|\+\+)}) { && -e $ARGV[$i] # is a file && get_preprocessed_fn($ARGV[$i]) # is a file that is recognized as a source file ) { + if($ARGV[$i] =~ /\.c$/ && !defined $output_fn && defined $coption) { + $output_fn = $ARGV[$i]; + $output_fn =~ s/\.c$/\.o/; + } push @files, splice @ARGV, $i, 1; } else { ++$i; From 5c03e4863abec2f5ca859a40ada3ab06bb82ad31 Mon Sep 17 00:00:00 2001 From: Junichi Kajiwara Date: Wed, 15 Jul 2015 01:01:22 +0900 Subject: [PATCH 2/2] to work with -c foo.c bar.c --- bin/qrintf | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/bin/qrintf b/bin/qrintf index 87f2095..39234ce 100755 --- a/bin/qrintf +++ b/bin/qrintf @@ -69,8 +69,8 @@ if (basename($cc) =~ m{^g(?:cc|\+\+)}) { $output_fn = $ARGV[$i + 1]; splice @ARGV, $i, 2; } else { - if ($i + 1 < @ARGV && $ARGV[$i] eq '-c') { - $coption = 1; + if ($i < @ARGV && $ARGV[$i] eq '-c') { + $coption = 1; } ++$i; } @@ -78,15 +78,15 @@ if (basename($cc) =~ m{^g(?:cc|\+\+)}) { # splice the filenames from ARGV my @files; + my %tmp_fn_to_obj_fn; + for (my $i = 0; $i < @ARGV;) { if ($ARGV[$i] !~ /^-/s # does not start with '-' && -e $ARGV[$i] # is a file && get_preprocessed_fn($ARGV[$i]) # is a file that is recognized as a source file ) { - if($ARGV[$i] =~ /\.c$/ && !defined $output_fn && defined $coption) { - $output_fn = $ARGV[$i]; - $output_fn =~ s/\.c$/\.o/; - } + $tmp_fn_to_obj_fn{$ARGV[$i]} = get_preprocessed_fn($ARGV[$i]) + if !defined $output_fn && defined $coption; push @files, splice @ARGV, $i, 1; } else { ++$i; @@ -112,6 +112,17 @@ if (basename($cc) =~ m{^g(?:cc|\+\+)}) { push @ARGV, '-o', $output_fn if defined $output_fn; run_cmd($cc, @ARGV); + #print $output_fn, $coption; + if(!defined $output_fn && defined $coption) { + while (my ($key, $value) = each(%tmp_fn_to_obj_fn)){ + $key =~ /\.([^\.]+)$/s; + my $dest_fn = $`; + $value =~ /\.([^\.]+)$/s; + my $src_fn = $`; + run_cmd("mv", "$src_fn.o", "$dest_fn.o"); + run_cmd("rm", $value); + } + } exit 0; }