2 eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}'
3 & eval 'exec perl -w -S $0 $argv:q'
6 # ******************************************************************
9 # Description: Combined multiple dsw's into a single dsw
10 # ******************************************************************
12 # ******************************************************************
14 # ******************************************************************
20 # ******************************************************************
22 # ******************************************************************
26 # ******************************************************************
28 # ******************************************************************
32 print STDERR
"$str\n" if (defined $str);
33 print STDERR
"Combine DSW v$version\n",
34 "Usage: ", basename
($0),
35 " [-u] <output file> <input files...>\n\n",
36 "-u Each input file will be removed after successful ",
38 "NOTE: This script will work for vcw's too.\n\n",
39 "Combine multiple dsw's into a single dsw. You can use ",
41 "dynamic projects and then generate static projects using ",
43 "-name_modifier and -apply_project options together. You ",
44 "can then run this\n",
45 "script to combine the workspaces into one.\n";
49 # ******************************************************************
51 # ******************************************************************
57 for(my $i = 0; $i <= $#ARGV; $i++) {
64 usageAndExit
("Unknown option: $arg");
68 if (!defined $output) {
77 ## Print the usage if there is no output file provided or there isn't at
78 ## least two input files.
79 usageAndExit
() if (!defined $output ||
80 !defined $input[0] || !defined $input[1]);
82 my $tmp = "$output.$$.tmp";
83 my $oh = new FileHandle
();
85 if (open($oh, ">$tmp")) {
87 for(my $i = 0; $i <= $#input; ++$i) {
88 ## We only want to take the global settings from the last input file.
89 my $input = $input[$i];
90 my $global = ($i == $#input);
92 ## Read in the input file and write out the parts that are common
93 ## between multiple workspace files (but only on the first input
94 ## file). After that, write out the project information from each
96 my $fh = new FileHandle
();
97 if (open($fh, $input)) {
100 if (/Microsoft\s+(Developer\s+Studio|eMbedded\s+Visual)/) {
101 ## We only want to print out the identifier from the first
112 elsif ($in_global && /^[#]{79,}/) {
117 ## Only print out the line if it's not part of the global
118 ## settings (unless this is the last input file).
119 print $oh $_ if (!$in_global || ($global && $in_global));
125 print STDERR
"ERROR: Unable to open '$input' for reading\n";
131 ## If the user wants us to remove the input files after successfully
132 ## combining them, then do so here.
133 unlink(@input) if ($unlink);
135 ## We have written the new workspace to a temporary file to allow an
136 ## input file to be the same as an output file. Once we're done, we
137 ## need to move it to it's correct output name.
139 rename($tmp, $output);
142 print STDERR
"ERROR: Unable to open '$tmp' for writing\n";