mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-01 02:26:58 +03:00
6807b4208a
NetSurf includes are now done with ""s and other system includes with <>s as C intended. The scandeps tool has been updated to only look for ""ed includes, and to verify that the files exist in the tree before adding them to the dependency lines. The depend rule has therefore been augmented to make sure the autogenerated files are built before it is run. This is untested under self-hosted RISC OS builds. All else tested and works. svn path=/trunk/netsurf/; revision=3307
46 lines
923 B
Perl
Executable File
46 lines
923 B
Perl
Executable File
#!/usr/bin/perl -W
|
|
|
|
%include = ();
|
|
|
|
die "Usage: scandeps object_dirs -- sources" if (@ARGV < 3);
|
|
|
|
@objdirs = ();
|
|
while (($z = shift @ARGV) ne "--") {
|
|
push @objdirs, $z;
|
|
}
|
|
|
|
# scan all files for relevant #include lines
|
|
foreach my $file (@ARGV) {
|
|
open FILE, "<$file" or die "Failed to open $file: $!";
|
|
while (my $line = <FILE>) {
|
|
if ($line =~ m|#include "([^"]+)"|) {
|
|
$include{$file}{$1} = 1 if (-e $1);
|
|
}
|
|
}
|
|
close FILE;
|
|
}
|
|
|
|
# output dependencies
|
|
foreach my $file (@ARGV) {
|
|
next unless $file =~ m|([^/]+)[.]c$|;
|
|
%deps = ();
|
|
search_deps($file);
|
|
foreach my $z (@objdirs) {
|
|
print "$z/$1.o ";
|
|
}
|
|
print ": $file ";
|
|
foreach my $z (sort keys %deps) { print "$z " }
|
|
print "\n";
|
|
}
|
|
|
|
|
|
sub search_deps {
|
|
my $file = shift;
|
|
return unless exists $include{$file};
|
|
foreach my $z (keys %{$include{$file}}) {
|
|
next if exists $deps{$z};
|
|
$deps{$z} = 1;
|
|
search_deps($z);
|
|
}
|
|
}
|