3 |
|
#____________________________________________________________________ |
4 |
|
# |
5 |
|
# Author: Shaun Ashby <Shaun.Ashby@cern.ch> |
6 |
– |
# Update: 2004-06-22 14:49:43+0200 |
7 |
– |
# Revision: $Id$ |
8 |
– |
# |
6 |
|
# Copyright: 2004 (C) Shaun Ashby |
7 |
|
# |
8 |
|
#-------------------------------------------------------------------- |
14 |
|
@EXPORT_OK=qw( ); |
15 |
|
|
16 |
|
sub new() |
20 |
– |
############################################################### |
21 |
– |
# new # |
22 |
– |
############################################################### |
23 |
– |
# modified : Tue Jun 22 14:49:46 2004 / SFA # |
24 |
– |
# params : # |
25 |
– |
# : # |
26 |
– |
# function : # |
27 |
– |
# : # |
28 |
– |
############################################################### |
17 |
|
{ |
18 |
|
my $proto=shift; |
19 |
|
my $class=ref($proto) || $proto; |
20 |
|
my $self={ GMAKECMD => '${SCRAM_GMAKE_PATH}gmake', CMDOPTS => ' -r' }; |
21 |
|
bless $self,$class; |
22 |
|
$|=1; |
35 |
– |
|
36 |
– |
# Useful help strings for the options we're supporting: |
37 |
– |
# %help = ( |
38 |
– |
# "s" => " do not print any output", |
39 |
– |
# "j <n>" => " the number of processes to run simultaneously", |
40 |
– |
# "d" => " run gmake in debug mode", |
41 |
– |
# "k" => " continue for as long as possible after an error", |
42 |
– |
# "w" => " print the working directory before and after entering it", |
43 |
– |
# "n" => " print the commands that would be executed but do not run them", |
44 |
– |
# "p" => " print the data base of rules after scanning makefiles, then build as normal" |
45 |
– |
# ); |
46 |
– |
|
47 |
– |
# The options. These are collected in CMDOPTS: |
48 |
– |
my %options = |
49 |
– |
( |
50 |
– |
"make" => sub { }, # dummy so we can use help opt just for MakeInterface |
51 |
– |
"s" => sub { $self->{CMDOPTS}.=" -s" }, |
52 |
– |
"j=i" => sub { $self->{CMDOPTS}.=" -j ".$_[1] }, |
53 |
– |
"d" => sub { $self->{CMDOPTS}.=" -d" }, |
54 |
– |
"k" => sub { $self->{CMDOPTS}.=" -k" }, |
55 |
– |
"printdir" => sub { $self->{CMDOPTS}.=" -w" }, |
56 |
– |
"n" => sub { $self->{CMDOPTS}.=" -n" }, |
57 |
– |
"printdb" => sub { $self->{CMDOPTS}.=" -p" } |
58 |
– |
); |
59 |
– |
|
60 |
– |
Getopt::Long::config qw(default no_ignore_case require_order bundling); |
61 |
– |
|
62 |
– |
if (! Getopt::Long::GetOptions(\%opts, %options)) |
63 |
– |
{ |
64 |
– |
print "SCRAM Warning: Ignoring unknown option.","\n"; |
65 |
– |
exit(1); |
66 |
– |
} |
67 |
– |
|
23 |
|
return $self; |
24 |
|
} |
25 |
|
|
27 |
|
{ |
28 |
|
my $self=shift; |
29 |
|
my ($makefile)=@_; |
75 |
– |
my $PID; |
30 |
|
my $makecmd=$self->{GMAKECMD}.$self->{CMDOPTS}." -f ".$makefile." ".join(" ",@ARGV); |
77 |
– |
|
78 |
– |
# Try without forking: |
31 |
|
exec("$makecmd") || die "SCRAM MakeInterface::exec(): Unable to run gmake ...$!","\n"; |
32 |
|
} |
33 |
|
|