Module: sip-router
Branch: master
Commit: e8b64a9db7487233e6ddea10ea7b504e0a4484f6
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e8b64a9…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Aug 30 13:28:17 2010 +0200
doc: dump_*.pl: support for gcc 4.5
- support for gcc 4.5 (gcc 4.5 will produce the translation unit
dump file in the same directory as the output file, while older
versions will always write it in the current directory).
- be more verbose on gcc error (display the complete gcc command line)
- cleanup temporary files even in the error case
---
doc/scripts/cdefs2doc/dump_cfg_defs.pl | 17 ++++++++++++++---
doc/scripts/cdefs2doc/dump_rpcs.pl | 17 ++++++++++++++---
doc/scripts/cdefs2doc/dump_selects.pl | 17 ++++++++++++++---
3 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/doc/scripts/cdefs2doc/dump_cfg_defs.pl
b/doc/scripts/cdefs2doc/dump_cfg_defs.pl
index 48e199b..ebf14af 100755
--- a/doc/scripts/cdefs2doc/dump_cfg_defs.pl
+++ b/doc/scripts/cdefs2doc/dump_cfg_defs.pl
@@ -228,9 +228,20 @@ if (! defined $opt_is_tu){
# => we have to create one
$src_fname=basename($file);
$tmp_file = "/tmp/" . mktemp ("dump_translation_unit_XXXXXX");
- system("$gcc -fdump-translation-unit $c_defs -c $file -o $tmp_file.o && \
- mv \"$src_fname\".001t.tu $tmp_file") == 0 or
- die "$gcc failed to generate a translation unit dump from $file";
+ # Note: gcc < 4.5 will produce the translation unit dump in a file in
+ # the current directory. gcc 4.5 will write it in the same directory as
+ # the output file.
+ system("$gcc -fdump-translation-unit $c_defs -c $file -o $tmp_file") == 0
+ or die "$gcc -fdump-translation-unit $c_defs -c $file -o $tmp_file" .
+ " failed to generate a translation unit dump from $file";
+ if (system("if [ -f \"$src_fname\".001t.tu ]; then \
+ mv \"$src_fname\".001t.tu $tmp_file; \
+ else mv /tmp/\"$src_fname\".001t.tu $tmp_file; fi ") != 0) {
+ unlink($tmp_file, "$tmp_file.o");
+ die "could not find the gcc translation unit dump file" .
+ " ($src_fname.001t.tu) neither in the current directory" .
+ " or /tmp";
+ };
$tu=GCC::TranslationUnit::Parser->parsefile($tmp_file);
print(STDERR "src name $src_fname\n") if $dbg;
unlink($tmp_file, "$tmp_file.o");
diff --git a/doc/scripts/cdefs2doc/dump_rpcs.pl b/doc/scripts/cdefs2doc/dump_rpcs.pl
index 706ec80..63c222e 100755
--- a/doc/scripts/cdefs2doc/dump_rpcs.pl
+++ b/doc/scripts/cdefs2doc/dump_rpcs.pl
@@ -221,9 +221,20 @@ if (! defined $opt_is_tu){
# => we have to create one
$src_fname=basename($file);
$tmp_file = "/tmp/" . mktemp ("dump_translation_unit_XXXXXX");
- system("$gcc -fdump-translation-unit $c_defs -c $file -o $tmp_file && \
- mv \"$src_fname\".001t.tu $tmp_file") == 0 or
- die "$gcc failed to generate a translation unit dump from $file";
+ # Note: gcc < 4.5 will produce the translation unit dump in a file in
+ # the current directory. gcc 4.5 will write it in the same directory as
+ # the output file.
+ system("$gcc -fdump-translation-unit $c_defs -c $file -o $tmp_file") == 0
+ or die "$gcc -fdump-translation-unit $c_defs -c $file -o $tmp_file" .
+ " failed to generate a translation unit dump from $file";
+ if (system("if [ -f \"$src_fname\".001t.tu ]; then \
+ mv \"$src_fname\".001t.tu $tmp_file; \
+ else mv /tmp/\"$src_fname\".001t.tu $tmp_file; fi ") != 0) {
+ unlink($tmp_file, "$tmp_file.o");
+ die "could not find the gcc translation unit dump file" .
+ " ($src_fname.001t.tu) neither in the current directory" .
+ " or /tmp";
+ };
$tu=GCC::TranslationUnit::Parser->parsefile($tmp_file);
print(STDERR "src name $src_fname\n") if $dbg;
unlink($tmp_file, "$tmp_file.o");
diff --git a/doc/scripts/cdefs2doc/dump_selects.pl
b/doc/scripts/cdefs2doc/dump_selects.pl
index aea0018..76aa5d9 100755
--- a/doc/scripts/cdefs2doc/dump_selects.pl
+++ b/doc/scripts/cdefs2doc/dump_selects.pl
@@ -391,9 +391,20 @@ sub process_file
# => we have to create one
$src_fname=basename($file);
$tmp_file = "/tmp/" . mktemp ("dump_translation_unit_XXXXXX");
- system("$gcc -fdump-translation-unit $c_defs -c $file -o $tmp_file && \
- mv \"$src_fname\".001t.tu $tmp_file") == 0 or
- die "$gcc failed to generate a translation unit dump from $file";
+ # Note: gcc < 4.5 will produce the translation unit dump in a file in
+ # the current directory. gcc 4.5 will write it in the same directory as
+ # the output file.
+ system("$gcc -fdump-translation-unit $c_defs -c $file -o $tmp_file") == 0
+ or die "$gcc -fdump-translation-unit $c_defs -c $file -o $tmp_file" .
+ " failed to generate a translation unit dump from $file";
+ if (system("if [ -f \"$src_fname\".001t.tu ]; then \
+ mv \"$src_fname\".001t.tu $tmp_file; \
+ else mv /tmp/\"$src_fname\".001t.tu $tmp_file; fi ") != 0) {
+ unlink($tmp_file, "$tmp_file.o");
+ die "could not find the gcc translation unit dump file" .
+ " ($src_fname.001t.tu) neither in the current directory" .
+ " or /tmp";
+ };
$tu=GCC::TranslationUnit::Parser->parsefile($tmp_file);
print(STDERR "src name $src_fname\n") if $dbg;
unlink($tmp_file, "$tmp_file.o");