about summary refs log tree commit diff
path: root/make/lib
diff options
context:
space:
mode:
Diffstat (limited to 'make/lib')
-rw-r--r--make/lib/compile-c.sh1
-rw-r--r--make/lib/default.nix19
-rw-r--r--make/lib/find-includes.pl19
-rw-r--r--make/lib/find-includes.sh20
4 files changed, 31 insertions, 28 deletions
diff --git a/make/lib/compile-c.sh b/make/lib/compile-c.sh
index 3558dd89ead4..04d2595def24 100644
--- a/make/lib/compile-c.sh
+++ b/make/lib/compile-c.sh
@@ -70,4 +70,5 @@ fi
 
 mkdir $out
 test "$prefix" && cd $prefix
+ls -l
 gcc -Wall $cFlags -c $mainName -o $out/$mainName.o
diff --git a/make/lib/default.nix b/make/lib/default.nix
index a9b17d2ced77..b2f26a936785 100644
--- a/make/lib/default.nix
+++ b/make/lib/default.nix
@@ -14,11 +14,13 @@ rec {
     builder = ./compile-c.sh;
     localIncludes =
       if localIncludes == "auto" then
-        import (findIncludes {
-          main = toString main;
-          hack = __currentTime;
-          inherit cFlags;
-        })
+        dependencyClosure {
+          scanner = main:
+            import (findIncludes {
+              inherit main;
+            });
+          startSet = [main];
+        }
       else
         localIncludes;
     inherit main;
@@ -36,10 +38,11 @@ rec {
   };
   */
 
-  findIncludes = {main, hack, cFlags ? ""}: stdenv.mkDerivation {
+  findIncludes = {main}: stdenv.mkDerivation {
     name = "find-includes";
-    builder = ./find-includes.sh;
-    inherit main hack cFlags;
+    realBuilder = pkgs.perl ~ "bin/perl";
+    args = [ ./find-includes.pl ];
+    inherit main;
   };
   
   link = {objects, programName ? "program", libraries ? []}: stdenv.mkDerivation {
diff --git a/make/lib/find-includes.pl b/make/lib/find-includes.pl
new file mode 100644
index 000000000000..f4f1f43239f3
--- /dev/null
+++ b/make/lib/find-includes.pl
@@ -0,0 +1,19 @@
+use strict;
+
+my $root = $ENV{"main"};
+my $out = $ENV{"out"};
+
+open OUT, ">$out" or die "$!";
+print OUT "[\n";
+
+open IN, "<$root" or die "$!";
+while (<IN>) {
+    if (/^\#include\s+\"(.*)\"/) {
+        print "DEP $1\n";
+        print OUT "\"$1\"\n";
+    }
+}
+close IN;
+
+print OUT "]\n";
+close OUT;
diff --git a/make/lib/find-includes.sh b/make/lib/find-includes.sh
deleted file mode 100644
index 4824207c2917..000000000000
--- a/make/lib/find-includes.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-. $stdenv/setup
-
-echo "finding includes of \`$(basename $main)'..."
-
-makefile=$NIX_BUILD_TOP/makefile
-
-mainDir=$(dirname $main)
-(cd $mainDir && gcc $cFlags -MM $(basename $main) -MF $makefile) || false
-
-echo "[" >$out
-
-while read line; do
-    line=$(echo "$line" | sed 's/.*://')
-    for i in $line; do
-        fullPath=$(readlink -f $mainDir/$i)
-        echo "  [ $fullPath \"$i\" ]" >>$out
-    done
-done < $makefile
-
-echo "]" >>$out