summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-08-02 22:07:30 +0200
committerMichael Stahl <mstahl@redhat.com>2012-08-02 22:12:07 +0200
commitb4d5eebfdd095a75966f2fa0997817d3441a3b80 (patch)
tree7a28bd3808489026a851f51777088d0a24f401d7 /solenv
parentebd2bfa2e748d9efa4ee759f5b9003d9e470d752 (diff)
filter-showIncludes: convert to AWK
Change-Id: Iedc315550f4eafdf1612bc390044a4b1b0c8e80b
Diffstat (limited to 'solenv')
-rwxr-xr-xsolenv/gbuild/filter-showIncludes.pl85
-rw-r--r--solenv/gbuild/platform/WNT_INTEL_MSC.mk2
-rwxr-xr-xsolenv/gbuild/platform/filter-showIncludes.awk91
3 files changed, 92 insertions, 86 deletions
diff --git a/solenv/gbuild/filter-showIncludes.pl b/solenv/gbuild/filter-showIncludes.pl
deleted file mode 100755
index 1ed3679b14e8..000000000000
--- a/solenv/gbuild/filter-showIncludes.pl
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/env perl
-#
-# filter-showIncludes.pl depfile.d objfile.o orginal.cxx
-#
-# Create dependency information from the output of cl.exe's showInclude. It
-# needs additional information - the output name to which to write, objfile
-# that depends on the includes, and the original file name.
-#
-# It also consolidates the file names to a canonical form, and filters out
-# duplicates.
-#
-# LGPL v3 / GPL v3 / MPL 1.1
-#
-# Original author: Jan Holesovsky <kendy@suse.cz>
-
-use File::Basename;
-use File::Copy;
-use File::Temp qw/tempfile/;
-
-my $outfile = $ARGV[0];
-my $objfile = $ARGV[1];
-my $srcfile = $ARGV[2];
-if ( !defined $outfile || !defined $objfile || !defined $srcfile ) {
- die "Not enough parameters to create dependencies.";
-}
-
-my $showincludes_prefix = $ENV{'SHOWINCLUDES_PREFIX'};
-if ( !defined( $showincludes_prefix ) || $showincludes_prefix eq "" ) {
- $showincludes_prefix = 'Note: including file:';
-}
-
-my ($OUT, $tmp_filename) = tempfile( 'showIncludesXXXXXX', DIR => dirname( $outfile ) ) or die "Cannot create a temp file.";
-
-print $OUT "$objfile: \\\n $srcfile";
-
-my %seen;
-my $first_line = 1;
-while ( <STDIN> ) {
- if ( /^$showincludes_prefix/ ) {
- s/^$showincludes_prefix\s*//;
- s/\r$//;
-
- chomp;
- s/\\/\//g;
-
-
- # skip system headers, i.e. everything not under source or build dirs
- if ( /$ENV{'SRCDIR'}|$ENV{'OUTDIR'}|$ENV{'WORKDIR'}/ )
- {
-
- # X: -> /cygdrive/x/
- s/^(.):/\/cygdrive\/\l\1/;
-
- s/ /\\ /g;
-
- if ( !defined $seen{$_} ) {
- $seen{$_} = 1;
- print $OUT " \\\n $_";
- }
- }
- }
- else {
- # skip the first line, it always just duplicates what is being
- # compiled
- print unless ( $first_line );
- }
- $first_line = 0;
-}
-
-print $OUT "\n";
-
-# fdo#40099 if header.h does not exist, it will simply be considered out of
-# date and any targets that use it as a prerequisite will be updated,
-# which avoid misery when the header is deliberately deleted and removed
-# as an include
-# see http://www.makelinux.net/make3/make3-CHP-8-SECT-3
-foreach my $key ( keys %seen ) {
- print $OUT "\n$key:\n";
-}
-
-close( $OUT ) or die "Cannot close $tmp_filename.";
-
-move( $tmp_filename, $outfile ) or die "Cannot move $tmp_filename to $outfile.";
-
-# vim: shiftwidth=4 softtabstop=4 expandtab:
diff --git a/solenv/gbuild/platform/WNT_INTEL_MSC.mk b/solenv/gbuild/platform/WNT_INTEL_MSC.mk
index 9519a482c423..a060cc8f048f 100644
--- a/solenv/gbuild/platform/WNT_INTEL_MSC.mk
+++ b/solenv/gbuild/platform/WNT_INTEL_MSC.mk
@@ -228,7 +228,7 @@ gb_COMPILERNOOPTFLAGS := -Od
ifeq ($(gb_FULLDEPS),$(true))
gb_COMPILERDEPFLAGS := -showIncludes
define gb_create_deps
-| $(GBUILDDIR)/filter-showIncludes.pl $(1) $(2) $(3); exit $${PIPESTATUS[0]}
+| $(GBUILDDIR)/platform/filter-showIncludes.awk -vdepfile=$(1) -vobjectfile=$(2) -vsourcefile=$(3); exit $${PIPESTATUS[0]}
endef
else
gb_COMPILERDEPFLAGS :=
diff --git a/solenv/gbuild/platform/filter-showIncludes.awk b/solenv/gbuild/platform/filter-showIncludes.awk
new file mode 100755
index 000000000000..9d94f3b546bf
--- /dev/null
+++ b/solenv/gbuild/platform/filter-showIncludes.awk
@@ -0,0 +1,91 @@
+#!/usr/bin/gawk -f
+# -*- tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+# Create dependency information from the output of cl.exe's showInclude. It
+# needs additional information - the output name to which to write, objfile
+# that depends on the includes, and the original file name.
+# For best results all arguments should be absolute paths.
+#
+# It also consolidates the file names to a canonical form, and filters out
+# duplicates.
+#
+# based on filter-showInclude.pl by Jan Holesovsky <kendy@suse.cz>
+
+BEGIN {
+ if (!depfile || !objectfile || !sourcefile) {
+ print "usage: filter-showIncludes.awk -vdepfile=depfile.d " \
+ "-vobjectfile=objfile.o -vsourcefile=source.cxx" > "/dev/stderr"
+ exit 1
+ }
+ tempfile = depfile ".tmp"
+ print objectfile " : \\\n " sourcefile " \\" > tempfile
+
+ showincludes_prefix = ENVIRON["SHOWINCLUDES_PREFIX"];
+ if (!showincludes_prefix) {
+ showincludes_prefix = "Note: including file:"
+ }
+ regex = "^ *" showincludes_prefix " *"
+ pattern = "/" regex "/"
+
+ # to match especially drive letters in whitelist case insensitive
+ IGNORECASE = 1
+ whitelist = \
+ "^(" ENVIRON["SRCDIR"] "|" ENVIRON["OUTDIR"] "|" ENVIRON["WORKDIR"] ")"
+ firstline = 1
+}
+
+{
+ if ($0 ~ regex) {
+ sub(regex, "")
+ gsub(/\\/, "/")
+ gsub(/ /, "\\ ")
+ if ($0 ~ whitelist) { # filter out system headers
+ if (!($0 in incfiles)) {
+ incfiles[$0]
+ print " " $0 " \\" > tempfile
+ }
+ }
+ } else {
+ # because MSVC stupidly prints the include files on stderr, it's
+ # necessary to forward everything that isn't matched by the pattern
+ # so users get to see compiler errros
+ if (firstline) { # ignore the line that just prints name of sourcefile
+ firstline = 0
+ } else {
+ print $0 > "/dev/stderr"
+ }
+ }
+}
+
+END {
+ if (!tempfile) {
+ exit 1
+ }
+ print "" > tempfile
+
+ # fdo#40099 if header.h does not exist, it will simply be considered out of
+ # date and any targets that use it as a prerequisite will be updated,
+ # which avoid misery when the header is deliberately deleted and removed
+ # as an include
+ # see http://www.makelinux.net/make3/make3-CHP-8-SECT-3
+ for (file in incfiles) {
+ print file " :\n" > tempfile
+ }
+
+ close(tempfile)
+ movecmd = "mv " tempfile " " depfile
+ ret = system(movecmd)
+ if (ret) {
+ print "ERROR: " movecmd " FAILED with status " ret > "/dev/stderr"
+ exit ret
+ }
+}
+
+# vim: set noet sw=4 ts=4: