]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Re-implement dependency generation in perl to increase speed
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 1 Sep 2009 15:05:11 +0000 (15:05 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 1 Sep 2009 15:05:11 +0000 (15:05 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11559 e03df62e-2008-0410-955e-edbf42e46eb7

.Makefile.inc
make/bsd-dep.mk
make/calcdep.pl
make/gnu-dep.mk
make/gnu-real.mk
src/modes/Makefile [deleted file]

index e8bf232b9fc194b451bf81ca3d156ee2e04596e7..1d816a57bc8e0f6e17bc2c194dd351d63d3adbb5 100644 (file)
@@ -128,6 +128,7 @@ clean:
        @rm -f src/inspircd src/modes/modeclasses.a
        @rm -f src/*.so src/modules/*.so src/commands/*.so src/modules/*/*.so
        @rm -f src/*.o src/*/*.o src/modules/*/*.o
+       @rm -f src/.*.d src/*/.*.d src/modules/*/.*.d
        @echo Completed.
 
 modclean:
index 4d2f8e1dc8ef0032064eda7f913c56b6efabc3e0..2e816bdb416c47c7aec83d15d2f2379ecd56e8ab 100644 (file)
@@ -1,10 +1,5 @@
-DFILES != perl -e 'print join " ", grep s/\.cpp/.d/, <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_spanningtree/*.cpp>'
-DFILES += socketengines/$(SOCKETENGINE).d threadengines/threadengine_pthread.d
+DFILES != perl -e 'print join " ", <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_spanningtree/*.cpp>'
+DFILES += socketengines/$(SOCKETENGINE).cpp threadengines/threadengine_pthread.cpp
 
-alldep: $(DFILES)
-
-.SUFFIXES: .d .cpp
-
-.cpp.d:
-       @../make/calcdep.pl $<
-       @echo -n .
+alldep:
+       ../make/calcdep.pl $(DFILES)
index bcbb7cbd04f9c3a8374b56c575673333766efb8a..92d2cc3e07a6622af67a34bc351b16d4ec903c7b 100755 (executable)
@@ -1,25 +1,47 @@
 #!/usr/bin/perl
 use strict;
-BEGIN { push @INC, '..'; }
-use make::configure;
+use warnings;
 
-my $file = shift;
+# This used to be a wrapper around cc -M; however, this is a very slow
+# operation and we don't conditionally include our own files often enough
+# to justify the full preprocesor invocation for all ~200 files.
 
-$file =~ /(.*)\.cpp$/ or die "Cannot process $file";
-my $base = $1;
+my %f2dep;
 
-my $out = "$base.d";
+sub gendep;
+sub gendep {
+       my $f = shift;
+       my $basedir = $f =~ m#(.*)/# ? $1 : '.';
+       return $f2dep{$f} if exists $f2dep{$f};
+       $f2dep{$f} = '';
+       my %dep;
+       open my $in, '<', $f;
+       while (<$in>) {
+               if (/^\s*#\s*include\s*"([^"]+)"/) {
+                       my $inc = $1;
+                       for my $loc ("$basedir/$inc", "../include/$inc") {
+                               next unless -e $loc;
+                               $dep{$loc}++;
+                               $dep{$_}++ for split / /, gendep $loc;
+                       }
+               }
+       }
+       close $in;
+       $f2dep{$f} = join ' ', sort keys %dep;
+       $f2dep{$f};
+}
 
-open IN, '<', $file or die "Could not read $file: $!";
-open OUT, '>', $out or die "Could not write $out: $!";
+for my $file (@ARGV) {
+       next unless $file =~ /cpp$/;
+       gendep $file;
+       my($path,$base) = $file =~ m#^((?:.*/)?)([^/]+)\.cpp#;
+       my $cmd = "$path.$base.d";
+       my $ext = $path eq 'modules/' || $path eq 'commands/' ? '.so' : '.o';
+       my $out = "$path$base$ext";
 
-my $cc_deps = qx($ENV{CC} $ENV{FLAGS} -MM $file);
-$cc_deps =~ s/.*?:\s*//;
-
-my $ext = $file =~ m#(modules|commands)/[^/]+$# ? '.so' : '.o';
-print OUT "$base$ext: $cc_deps";
-print OUT "\t@../make/unit-cc.pl \$(VERBOSE) $file $base$ext\n";
-print OUT "$base.d: $cc_deps";
-print OUT "\t\@\$(VDEP_IN)\n";
-print OUT "\t../make/calcdep.pl $file\n";
-print OUT "\t\@\$(VDEP_OUT)\n";
+       open OUT, '>', $cmd;
+       print OUT "$out: $file $f2dep{$file}\n";
+       print OUT "\t@../make/unit-cc.pl \$(VERBOSE) $file $out\n";
+       print OUT "$cmd: $file $f2dep{$file}\n";
+       print OUT "\t../make/calcdep.pl $file\n";
+}
index f0ebb4d59b26a78c2aa71df970337928eb7c3c19..5cf0927da530ca45a76d734e97bbb46a37f2fb58 100644 (file)
@@ -1,3 +1,4 @@
-VDEP_OUT = echo -n .
-
-include ../make/gnu-real.mk
+CFILES = $(shell perl -e 'print join " ", <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_spanningtree/*.cpp>')
+CFILES += socketengines/$(SOCKETENGINE).cpp threadengines/threadengine_pthread.cpp
+alldep:
+       @../make/calcdep.pl $(CFILES)
index c868aa93386668088a2d125b064dc5adab8609c6..e0a8af68f05e48e7d64e02b8ca0dd795d1758da7 100644 (file)
@@ -8,15 +8,10 @@ CORE_TARGS += modeclasses.a threadengines/threadengine_pthread.o
 CORE_TARGS += socketengines/$(SOCKETENGINE).o
 MOD_TARGS += modules/m_spanningtree.so
 
-DFILES = $(patsubst %.cpp,%.d,$(wildcard *.cpp))
-DFILES += $(patsubst %.cpp,%.d,$(wildcard commands/*.cpp))
-DFILES += $(patsubst %.cpp,%.d,$(wildcard modes/*.cpp))
-DFILES += $(patsubst %.cpp,%.d,$(wildcard modules/*.cpp))
-DFILES += $(patsubst %.cpp,%.d,$(wildcard modules/m_spanningtree/*.cpp))
-DFILES += socketengines/$(SOCKETENGINE).d threadengines/threadengine_pthread.d
+DFILES = $(shell perl -e 'print join " ", grep s!([^/]+)\.cpp!.$$1.d!, <*.cpp>, <commands/*.cpp>, <modes/*.cpp>, <modules/*.cpp>, <modules/m_spanningtree/*.cpp>')
+DFILES += socketengines/.$(SOCKETENGINE).d threadengines/.threadengine_pthread.d
 
 all: inspircd commands modules
-alldep: $(DFILES)
 
 commands: $(CMD_TARGS)
 
@@ -31,7 +26,7 @@ modules/m_spanningtree.so: $(SPANNINGTREE_TARGS)
 inspircd: $(CORE_TARGS)
        $(RUNCC) $(FLAGS) $(CORE_FLAGS) -o inspircd $(LDLIBS) $(CORE_TARGS)
 
-%.d: %.cpp
+.%.d: %.cpp
        @$(VDEP_IN)
        @../make/calcdep.pl $<
        @$(VDEP_OUT)
diff --git a/src/modes/Makefile b/src/modes/Makefile
deleted file mode 100644 (file)
index d2f065d..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-CXXFLAGS = ${FLAGS}
-
-all:
-       @echo "Don't run make here! Run it in the root directory"
-       false
-
-umode_w.o: umode_w.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c umode_w.cpp
-
-umode_o.o: umode_o.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c umode_o.cpp
-
-umode_s.o: umode_s.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c umode_s.cpp
-
-umode_i.o: umode_i.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c umode_i.cpp
-
-cmode_v.o: cmode_v.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c cmode_v.cpp
-
-cmode_t.o: cmode_t.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c cmode_t.cpp
-
-cmode_s.o: cmode_s.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c cmode_s.cpp
-
-cmode_p.o: cmode_p.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c cmode_p.cpp
-
-cmode_o.o: cmode_o.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c cmode_o.cpp
-
-cmode_n.o: cmode_n.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c cmode_n.cpp
-
-cmode_m.o: cmode_m.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c cmode_m.cpp
-
-cmode_l.o: cmode_l.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c cmode_l.cpp
-
-cmode_k.o: cmode_k.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c cmode_k.cpp
-
-cmode_i.o: cmode_i.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c cmode_i.cpp
-
-cmode_h.o: cmode_h.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c cmode_h.cpp
-
-cmode_b.o: cmode_b.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/mode.h
-       $(RUNCC) $(FLAGS) -export-dynamic -c cmode_b.cpp
-
-modeclasses.a: umode_w.o umode_o.o umode_s.o umode_i.o cmode_v.o cmode_t.o cmode_s.o cmode_p.o cmode_o.o cmode_n.o cmode_m.o cmode_l.o cmode_k.o cmode_i.o cmode_h.o cmode_b.o
-       @-rm -rf modeclasses.a
-       @../../make/run-cc.pl ar crs modeclasses.a *.o
-
-clean:
-       @-rm *.o
-       @-rm modeclasses.a
-