comparison g23m/system/busyb/tools/make_dep.pl @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 #!perl
2
3 # mk_dep example/out/obj/lib/util/obj/util.dep
4 # util.o: example/src/util/util.c example/src/inc/util.h
5 # util.obj util.d: example/src/util/util.c example/src/inc/util.h
6 # example/out/obj/lib/util/obj/util.obj example/out/obj/lib/util/obj/util.d: example/src/util/util.c example/src/inc/util.h
7
8 my $dep_file=$ARGV[0];
9 my $obj_file=$ARGV[0];
10 my $d_file=$ARGV[0];
11
12 # construct the object file name (replace .d with .obj)
13 $obj_file =~ s/\.dep\b/.obj/;
14
15 # construct the .d file name (replace .dep with .d)
16 $d_file =~ s/\.dep\b/.d/;
17
18
19 unless (-s $dep_file) {
20 unlink $d_file;
21 unlink $dep_file;
22 die "Abort: Empty dependency file >> $dep_file <<, did the source file parse correctly ?\n"
23 }
24
25 # open the files
26 open (DEP,$dep_file)||die "can't open file\n";
27 open (DFILE,">$d_file")||die "can't open file\n";
28
29 #parse the dependency file
30 while ($line=<DEP>) {
31 # find object filename (.o) and replace it with new full
32 # object and dependency file names (.obj, .d)
33 $line =~ s/(\w+\.o)/$obj_file $d_file/;
34
35 # cope with CPP error, it sometimes appends a \ to the filename
36 # it even sometimes creates solitary \ characters
37 $line =~ s/\\([ \t]+)/$1/g;
38
39 # cyclic (henn and egg) dependency between .d files and generated files
40 # e.g msconst.cdg/rv_swe.h must be handled by busyb.pl
41 # $line =~ s/(\s)(\w+.cdg|[pPmM]_\w+.((h)|(val)))\b/$1$gen_cdginc_dir\/$2/g;
42 # $line =~ s/(\s)(rv_swe.h)\b/$1$gen_cfginc_dir\/$2/g;
43 # $line =~ s/(\s)(\w+.cfg)\b/$1$gen_cfginc_dir\/$2/g;
44
45 print DFILE $line;
46 }
47
48 close DFILE;
49 close DEP;
50
51 unlink $dep_file;