more notes on configuration
[buildfarm-client.git] / EximBuild / Options.pm
1
2 package EximBuild::Options;
3
4 =comment
5
6 Copyright (c) 2003-2010, Andrew Dunstan
7 Copyright (c) 2013, Todd Lyons
8
9 See accompanying License file for license details
10
11 =cut 
12
13 # common options code for buildfarm scripts, so it stays in sync
14
15 use strict;
16 use warnings;
17 use Getopt::Long;
18
19 use vars qw(@option_list);
20
21 BEGIN
22 {
23     @option_list =qw(
24       $forcerun $buildconf $keepall $help
25       $quiet $from_source $from_source_clean $testmode
26       $skip_steps $only_steps $override
27       $nosend $nostatus $verbose
28     );
29 }
30
31 use Exporter   ();
32 our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
33
34 use vars qw($VERSION); $VERSION = 'REL_0.1';
35
36 @ISA         = qw(Exporter);
37 @EXPORT      = @option_list;
38 %EXPORT_TAGS = ();
39 @EXPORT_OK   = ();
40
41 our (
42     $forcerun, $buildconf, $keepall,$help,
43     $quiet, $from_source,$from_source_clean, $testmode,
44     $skip_steps,$only_steps, $overrides,
45     $nosend, $nostatus, $verbose,
46 );
47
48 my (%standard_options);
49
50 %standard_options =(
51     'nosend' => \$nosend,
52     'config=s' => \$buildconf,
53     'from-source=s' => \$from_source,
54     'from-source-clean=s' => \$from_source_clean,
55     'force' => \$forcerun,
56     'keepall' => \$keepall,
57     'verbose:i' => \$verbose,
58     'nostatus' => \$nostatus,
59     'test' => \$testmode,
60     'help' => \$help,
61     'quiet' => \$quiet,
62     'skip-steps=s' => \$skip_steps,
63     'only-steps=s' => \$only_steps,
64     'override=s@' => \$overrides,
65 );
66
67 $buildconf = "build-farm.conf"; # default value
68
69 # extra options can be used by a wrapper program, such as
70 # the one that will do the global lock and election, and it will
71 # still have acces to what it needs to do to invoke run_build.
72
73 sub fetch_options
74 {
75     GetOptions(%standard_options, @_)
76       || die "bad command line";
77
78 }
79
80 sub standard_option_list
81 {
82     my @result = ();
83     foreach my $k ( keys %standard_options )
84     {
85         my $vref = $standard_options{$k};
86         next unless defined($$vref);
87         (my $nicekey = $k) =~ s/[=:].*//;
88         push(@result, "--$nicekey");
89         push(@result,$$vref) if $$vref && $k =~ /[:=]/;
90     }
91     return @result;
92 }
93
94 1;