FreeCalypso > hg > leo2moko-debug
comparison g23m/system/busyb/tools/make_cfg.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 -w | |
2 use strict; | |
3 | |
4 # import some modules | |
5 use File::Spec; | |
6 use File::Copy; | |
7 use File::Glob ':glob'; | |
8 use File::Compare; | |
9 use File::stat; | |
10 | |
11 if (@ARGV != 3) { | |
12 print "usage: make_cfg <ssa_script> <outputDir> <hw_config>\n"; | |
13 print "example: make_cfg ../ssa/system/update_exported_makefiles.pl ../__out__/ssa_config GPRS_DSAMPLE_AMR_NW4\n"; | |
14 exit; | |
15 } | |
16 | |
17 my $script; | |
18 my $scriptDir; | |
19 my $outDir; | |
20 my $config=$ARGV[2]; | |
21 | |
22 # find the perl script | |
23 (-e $ARGV[0]) || die "Script $ARGV[0] could not be found!"; | |
24 ($_,$scriptDir,$script) = File::Spec->splitpath($ARGV[0]); | |
25 #print "$scriptDir\n"; | |
26 | |
27 # calculate outputdir relative to script dir, so we don't need to CD back | |
28 $outDir = calcRelativePathFromLocation($ARGV[1], $scriptDir); | |
29 #print "$outDir\n"; | |
30 | |
31 # cd into the script directory and call it | |
32 chdir($scriptDir) || die "Can't cd to $scriptDir: $!\n"; | |
33 | |
34 # delete gen_cfg_values.mak to force re-generation | |
35 (-e "gen_cfg_values.mak") && unlink("gen_cfg_values.mak"); | |
36 | |
37 # call the script | |
38 system ("perl $script $config") && die "Can't call $script: $!\n"; | |
39 | |
40 # copy all cfg files | |
41 my @cfgFiles = bsd_glob("config/*.cfg"); | |
42 | |
43 foreach (@cfgFiles) { | |
44 my ($drive,$directories,$file) = File::Spec->splitpath($_); | |
45 if(compare("$directories$file","$outDir/$file") != 0) | |
46 { | |
47 print "Copying $_ to $outDir !\n"; | |
48 copy($_,$outDir ) || die "Could not copy $_ to $outDir: $!\n"; | |
49 } | |
50 } | |
51 | |
52 # move rv_swe.h to assure that this one is used | |
53 my $rvFile = "../Riviera/rv/rv_swe.h"; | |
54 my $newRvFile = "$outDir/rv_swe.h"; | |
55 | |
56 if(compare($rvFile,$newRvFile) != 0) | |
57 { | |
58 print "Copying $rvFile to $outDir !\n"; | |
59 copy($rvFile, $outDir ) || die "Could not copy $rvFile to $outDir: $!\n"; | |
60 } | |
61 | |
62 # if rv_swe.h in SSA has been created - remove it | |
63 if(-w $rvFile) { | |
64 print "Deleting $rvFile !\n"; | |
65 unlink($rvFile) || die "Could not delete $rvFile: $!\n"; | |
66 } | |
67 | |
68 # if the file is older than the script (thanks to ABC) touch it; | |
69 if (stat($newRvFile)->mtime < stat($script)->mtime) { | |
70 my $now = time; | |
71 utime ($now, $now, $newRvFile) ; | |
72 } | |
73 | |
74 | |
75 ######################################################## | |
76 # correct obscure behavior of File::Spec->abs2rel, | |
77 # which inserts a drive letter befor a relative path !!! | |
78 # | |
79 sub calcRelativePathFromLocation | |
80 { | |
81 my ($drive,$directories,$file); | |
82 | |
83 ($drive,$directories,$file) = File::Spec->splitpath( File::Spec->abs2rel ($_[0], $_[1]) ); | |
84 | |
85 return File::Spec->catpath("",$directories,$file); | |
86 } | |
87 ######################################################## |