Subversion Repositories gelsvn

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
107 bj 1
package NMakeWorkspaceCreator;
2
 
3
# ************************************************************
4
# Description   : A NMake Workspace (Makefile) creator
5
# Author        : Chad Elliott
6
# Create Date   : 6/10/2002
7
# ************************************************************
8
 
9
# ************************************************************
10
# Pragmas
11
# ************************************************************
12
 
13
use strict;
14
use File::Basename;
15
 
16
use NMakeProjectCreator;
17
use WorkspaceCreator;
18
 
19
use vars qw(@ISA);
20
@ISA = qw(WorkspaceCreator);
21
 
22
# ************************************************************
23
# Data Section
24
# ************************************************************
25
 
26
my(@targets) = ('CLEAN', 'DEPEND', 'GENERATED', 'REALCLEAN',
27
                '$(CUSTOM_TARGETS)');
28
 
29
# ************************************************************
30
# Subroutine Section
31
# ************************************************************
32
 
33
sub supports_make_coexistence {
34
  #my($self) = shift;
35
  return 1;
36
}
37
 
38
 
39
sub crlf {
40
  my($self) = shift;
41
  return $self->windows_crlf();
42
}
43
 
44
 
45
sub workspace_per_project {
46
  #my($self) = shift;
47
  return 1;
48
}
49
 
50
 
51
sub workspace_file_name {
52
  my($self) = shift;
53
  if ($self->make_coexistence()) {
54
    return $self->get_modified_workspace_name($self->get_workspace_name(),
55
                                              '.nmake');
56
  }
57
  else {
58
    return $self->get_modified_workspace_name('Makefile', '');
59
  }
60
}
61
 
62
 
63
sub pre_workspace {
64
  my($self) = shift;
65
  my($fh)   = shift;
66
  my($crlf) = $self->crlf();
67
 
68
  print $fh '# Microsoft Developer Studio Generated NMAKE File', $crlf,
69
            '#', $crlf,
70
            '# $Id: NMakeWorkspaceCreator.pm 107 2005-09-02 16:42:23Z bj $', $crlf,
71
            '#', $crlf,
72
            '# This file was generated by MPC.  Any changes made directly to', $crlf,
73
            '# this file will be lost the next time it is generated.', $crlf,
74
            '#', $crlf,
75
            '# MPC Command:', $crlf,
76
            "# $0 @ARGV", $crlf,
77
            $crlf;
78
}
79
 
80
 
81
sub write_project_targets {
82
  my($self)     = shift;
83
  my($fh)       = shift;
84
  my($target)   = shift;
85
  my($list)     = shift;
86
  my($crlf)     = $self->crlf();
87
 
88
  foreach my $project (@$list) {
89
    my($dir)    = $self->mpc_dirname($project);
90
    my($chdir)  = 0;
91
    my($back)   = '';
92
 
93
    ## If the directory isn't '.' then we need
94
    ## to figure out how to get back to our starting point
95
    if ($dir ne '.') {
96
      $chdir = 1;
97
      my($count) = ($dir =~ tr/\///);
98
      if ($dir =~ /^\.\.\//) {
99
        $back = ('../' x $count) . basename($self->getcwd());
100
      }
101
      else {
102
        $back = ('../' x ($count + 1));
103
      }
104
    }
105
 
106
    print $fh ($chdir ? "\tcd $dir$crlf" : ''),
107
              "\t\$(MAKE) /f ", basename($project), " $target$crlf",
108
              ($chdir ? "\tcd $back$crlf" : '');
109
  }
110
}
111
 
112
 
113
sub write_comps {
114
  my($self)     = shift;
115
  my($fh)       = shift;
116
  my($projects) = $self->get_projects();
117
  my($pjs)      = $self->get_project_info();
118
  my($trans)    = $self->project_target_translation();
119
  my(%targnum)  = ();
120
  my(@list)     = $self->number_target_deps($projects, $pjs, \%targnum);
121
  my($crlf)     = $self->crlf();
122
  my($default)  = 'Win32 Debug';
123
 
124
  ## Determine the default configuration
125
  foreach my $project (keys %$pjs) {
126
    my($name, $deps, $pguid, @cfgs) = @{$pjs->{$project}};
127
    @cfgs = sort @cfgs;
128
    if (defined $cfgs[0]) {
129
      $default = $cfgs[0];
130
      $default =~ s/(.*)\|(.*)/$2 $1/;
131
      last;
132
    }
133
  }
134
 
135
  ## Print out the content
136
  print $fh '!IF "$(CFG)" == ""', $crlf,
137
            'CFG=', $default, $crlf,
138
            '!MESSAGE No configuration specified. ',
139
            'Defaulting to ', $default, '.', $crlf,
140
            '!ENDIF', $crlf, $crlf,
141
            '!IF "$(CUSTOM_TARGETS)" == ""', $crlf,
142
            'CUSTOM_TARGETS=_EMPTY_TARGET_', $crlf,
143
            '!ENDIF', $crlf;
144
 
145
  ## Print out the "all" target
146
  print $fh $crlf, 'ALL:';
147
  foreach my $project (@list) {
148
    print $fh " $$trans{$project}";
149
  }
150
  print $fh $crlf;
151
 
152
  ## Print out all other targets here
153
  foreach my $target (@targets) {
154
    print $fh $crlf,
155
              $target, ':', $crlf;
156
    $self->write_project_targets($fh, 'CFG="$(CFG)" ' . $target, \@list);
157
  }
158
 
159
  ## Print out each target separately
160
  foreach my $project (@list) {
161
    print $fh $crlf, $$trans{$project}, ':';
162
    if (defined $targnum{$project}) {
163
      foreach my $number (@{$targnum{$project}}) {
164
        print $fh " $$trans{$list[$number]}";
165
      }
166
    }
167
 
168
    print $fh $crlf;
169
    $self->write_project_targets($fh, 'CFG="$(CFG)" ' . 'ALL', [ $project ]);
170
  }
171
 
172
  ## Print out the project_name_list target
173
  print $fh $crlf, "project_name_list:$crlf";
174
  foreach my $project (sort @list) {
175
    print $fh "\t\@echo $$trans{$project}$crlf";
176
  }
177
}
178
 
179
 
180
 
181
1;