5 sub commandandcontrol {
6 local ($configdefault, $bIgnoreCmdlineConfig) = @_;
7 local $OPT = {foo => 'bar'};
9 Getopt::Long::Configure('no_bundling', 'no_auto_abbrev',
10 'no_getopt_compat', 'require_order',
11 'ignore_case', 'pass_through',
12 'prefix_pattern=(--|-|\+|\/)'
43 local $argvsize = @ARGV;
45 print "Error -- invalid argument: $ARGV[0]\n";
49 # The first time C&C is called, it is OK to override the default (./bkwconfig.xml)
50 # with a value from the command line.
51 # The second time C&C is called, the repository has been updated and C&C will be passed
52 # <src>/pismere/athena/auth/krb5/windows/build/bkwconfig.xml. That value MUST be used.
53 if ($bIgnoreCmdlineConfig) {$OPT->{config} = $configdefault;}
54 elsif (! exists $OPT->{config}) {$OPT->{config} = $configdefault;}
56 my $configfile = $OPT->{config};
57 my $bOutputCleaned = 0;
59 print "Info -- Reading configuration from $configfile.\n";
61 # Get configuration file:
62 local $xml = new XML::Simple();
63 my $config = $xml->XMLin($configfile);
64 # Set up convenience variables:
65 local $odr = $config->{Config}; ## Options, directories, repository, environment.
67 #while ($v = each %$OPT) {print "$v: $OPT->{$v}\n";}
69 # Scan the configuration for switch definitions:
70 while (($sw, $val) = each %$odr) {
71 next if (! exists $val->{def}); ## ?? Should always exist.
73 # Set/clear environment variables:
75 if ($val->{def}) {$ENV{$sw} = (exists $val->{value}) ? $val->{value} : 1; }
76 else {delete $ENV{$sw}; }
79 # If the switch is in the command line, override the stored value:
80 if (exists $OPT->{$sw}) {
81 if (exists $val->{value}) {
82 $val->{value} = $OPT->{$sw};
86 $val->{def} = $OPT->{$sw}; ## If no<switch>, value will be zero.
89 # If the switch can be negated, test that, too:
90 if ( ! ($val->{def} =~ /A/)) {
91 local $nosw = "no".$sw;
92 if (exists $OPT->{$nosw}) {
97 # For any switch definition with fixed values ("options"), validate:
98 if (exists $val->{options}) {
100 # options can be like value1|syn1 value2|syn2|syn3
101 foreach $option (split(/ /, $val->{options})) {
104 foreach $opt (split(/\|/, $option)) {
105 # opt will be like value2, syn2, syn3
107 $sFirst = $opt; ## Remember the full name of the option.
110 if ($val->{value} =~ /$opt/i) {
111 $val->{value} = $sFirst; ## Save the full name.
117 print "Fatal -- invalid $sw value $val->{value}. Possible values are $val->{options}.\n";
124 # Don't allow /svntag and /svnbranch simultaneously:
125 if ( (length $odr->{svntag}->{value} > 0) &&
126 (length $odr->{svnbranch}->{value} > 0) ) {
127 die "Fatal -- Can't specify both /SVNTAG and /SVNBRANCH.";
136 Usage: $0 [options] NMAKE-options
138 Options are case insensitive.
141 /help /? usage information (what you now see).
142 /config /f path Path to config file. Default is bkwconfig.xml.
143 /srcdir /r dir Source directory to use. Should contain
144 pismere/athena. If cvstag or svntag is null,
145 the directory should be prepopulated.
146 /outdir /o dir Directory to be created where build results will go
147 /repository checkout | co \\ What repository action to take.
148 update | up ) Options are to checkout, update or
149 skip / take no action [skip].
150 /username /u name username used to access svn if checking out.
151 /cvstag /c tag use -r <tag> in cvs command
152 /svnbranch /b tag use /branches/<tag> instead of /trunk.
153 /svntag /s tag use /tags/<tag> instead of /trunk.
154 /debug /d Do debug make instead of release make.
155 /[no]make Control the make step.
156 /clean Build clean target.
157 /[no]package Control the packaging step.
158 /[no]sign Control signing of executable files.
159 /verbose /v Debug mode - verbose output.
160 /logfile /l path Where to write output. Default is bkw.pl.log.
161 /nolog Don't save output.
163 NMAKE-options any options you want to pass to NMAKE, which can be:
164 (note: /nologo is always used)