ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/TemplateInterface.pm
Revision: 1.6.2.2
Committed: Fri Feb 15 17:30:59 2008 UTC (17 years, 2 months ago) by muzaffar
Content type: text/plain
Branch: forBinLess_SCRAM
CVS Tags: V2_0_2, V2_0_2_relcand1, V2_0_1, V1_2_1b, V1_2_1a, V2_0_1_relcand4, V2_0_1_relcand3, V2_0_1_relcand2, V2_0_1_relcand1, V2_0_0_relcand4, V1_2_3, V2_0_0, V1_2_2, V1_2_2_relcand2, V1_2_2_relcand1, V2_0_0_relcand3, V2_0_0_relcand2, V2_0_0_relcand1, V1_2_1, V1_2_0, V1_2_0-cand11, V1_2_0-cand10, V1_2_0-cand9, V1_2_0-cand8, V1_2_0-cand7, V1_2_0-cand6, V1_2_0-cand5, V1_2_0-cand4, V1_2_0-cand3, V1_2_0-cand2
Branch point for: SCRAM_V2_0
Changes since 1.6.2.1: +2 -3 lines
Log Message:
more cleanup. no more http: protocol used. So no more extra dependency on libwww and uri perl modules

File Contents

# Content
1 #____________________________________________________________________
2 # File: TemplateInterface.pm
3 #____________________________________________________________________
4 #
5 # Author: Shaun Ashby <Shaun.Ashby@cern.ch>
6 # Update: 2004-07-01 14:03:46+0200
7 # Revision: $Id: TemplateInterface.pm,v 1.6.2.1 2008/02/15 14:58:01 muzaffar Exp $
8 #
9 # Copyright: 2004 (C) Shaun Ashby
10 #
11 #--------------------------------------------------------------------
12 package BuildSystem::TemplateInterface;
13 require 5.004;
14 use Exporter;
15 @ISA=qw(Exporter);
16 @EXPORT_OK=qw( );
17
18 sub new()
19 ###############################################################
20 # new #
21 ###############################################################
22 # modified : Thu Jul 1 14:04:01 2004 / SFA #
23 # params : #
24 # : #
25 # function : #
26 # : #
27 ###############################################################
28 {
29 my $proto=shift;
30 my $class=ref($proto) || $proto;
31 my $self={};
32
33 bless $self,$class;
34
35 # Process the environment hash and extract a
36 # list of vars that are needed for building.
37 # NB: This is done once only!
38 my %exportenv;
39 map
40 {
41 if ($_ =~ /^SCRAM/ || $_ =~ /(LOCAL|RELEASE)TOP$/)
42 {
43 $exportenv{$_} = $ENV{$_} if ($_ !~ /^SCRAMRT\_.*$/);
44 }
45 } keys %ENV;
46
47 # Add the environment information to the TEMPLATE_DATA hash:
48 $self->{TEMPLATE_DATA} = { 'environment' => \%exportenv };
49
50 # The filehandle for the generated Makefile:
51 my $makefile="$ENV{LOCALTOP}/$ENV{SCRAM_INTwork}/Makefile";
52
53 if (!-f $makefile)
54 {
55 if (!-f "$ENV{LOCALTOP}/$ENV{SCRAM_CONFIGDIR}/SCRAM/GMake/Makefile")
56 {
57 die "Missing $ENV{LOCALTOP}/$ENV{SCRAM_CONFIGDIR}/SCRAM/GMake/Makefile file.";
58 }
59 use File::Copy;
60 copy("$ENV{LOCALTOP}/$ENV{SCRAM_CONFIGDIR}/SCRAM/GMake/Makefile",$makefile) or die "Copy failed: $!";
61 utime 0,0,$makefile;
62 }
63
64 # Init and pass in the template location:
65 $self->_init(@_);
66 return $self;
67 }
68
69 sub _init()
70 {
71 my $self=shift;
72 my ($templatedir)=@_;
73
74 # Create the new Template object:
75 $self->template_object();
76 return $self;
77 }
78
79 sub template_object()
80 {
81 my $self=shift;
82 require SCRAM::Plugins::BuildRules;
83
84 $self->{TEMPLATE_OBJECT} = SCRAM::Plugins::BuildRules->new();
85 return $self;
86 }
87
88 sub template_data()
89 {
90 my $self=shift;
91 my ($data) = @_;
92
93 # Set the things that we must set. The "branch" data is a
94 # TreeItem object:
95 $self->{TEMPLATE} = $data->template();
96 # Add required data accessed by key:
97 $self->{TEMPLATE_DATA}->{branch} = $data;
98 }
99
100 sub run()
101 {
102 use FileHandle;
103 my $self=shift;
104
105 my $item = $self->{TEMPLATE_DATA}->{branch};
106 my $file = $item->safepath().".mk";
107 if ($item->class() eq "PROJECT")
108 {
109 $file = "$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}/MakeData/${file}";
110 }
111 elsif ($item->publictype())
112 {
113 $file = "$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}/MakeData/DirCache/${file}";
114 $item->{MKDIR}{"$ENV{LOCALTOP}/.SCRAM/$ENV{SCRAM_ARCH}/MakeData/DirCache"}=1;
115 }
116 else
117 {
118 $file = "$ENV{LOCALTOP}/$ENV{SCRAM_INTwork}/MakeData/DirCache/${file}";
119 $item->{MKDIR}{"$ENV{LOCALTOP}/$ENV{SCRAM_INTwork}/MakeData/DirCache"}=1;
120 }
121
122 $self->{MAKEFILEFH} = FileHandle->new();
123 $self->{MAKEFILEFH}->open(">$file");
124 local *FH = $self->{MAKEFILEFH};
125
126 $self->{TEMPLATE_OBJECT}->process($self->{TEMPLATE},
127 $self->{TEMPLATE_DATA},
128 $self->{MAKEFILEFH} )
129 || die "SCRAM: Template error --> ",$self->{TEMPLATE_OBJECT}->error;
130
131 $self->{MAKEFILEFH}->close();
132 }
133
134 1;