Wed Jun 9 07:35:19 UTC 2010 Johnny Willemsen <jwillemsen@remedy.nl>
[MPC.git] / modules / GHSProjectCreator.pm
blobcec75cf9425108080d9325656746c1463df5cacd
1 package GHSProjectCreator;
3 # ************************************************************
4 # Description : A GHS project creator for version 4.x.
5 # By default, this module assumes Multi will
6 # be used on Windows. If it is not, you must
7 # set the MPC_GHS_UNIX environment variable.
8 # Author : Chad Elliott
9 # Create Date : 4/19/2002
10 # ************************************************************
12 # ************************************************************
13 # Pragmas
14 # ************************************************************
16 use strict;
18 use ProjectCreator;
19 use GHSPropertyBase;
21 use vars qw(@ISA);
22 @ISA = qw(GHSPropertyBase ProjectCreator);
24 # ************************************************************
25 # Data Section
26 # ************************************************************
28 my $startre;
30 # ************************************************************
31 # Subroutine Section
32 # ************************************************************
34 sub convert_slashes {
35 return (defined $ENV{$GHSPropertyBase::ghsunix} ? 0 : 1);
39 sub case_insensitive {
40 return (defined $ENV{$GHSPropertyBase::ghsunix} ? 0 : 1);
44 sub use_win_compatibility_commands {
45 return (defined $ENV{$GHSPropertyBase::ghsunix} ? 0 : 1);
49 sub post_file_creation {
50 my $self = shift;
52 ## These special files are only used if it is a custom only project or
53 ## there are no source files in the project.
54 if ((defined $self->get_assignment('custom_only') ||
55 !defined $self->get_assignment('source_files')) &&
56 defined $self->get_assignment('custom_types')) {
57 my $fh = new FileHandle();
58 if (open($fh, '>.custom_build_rule')) {
59 print $fh ".empty_html_file\n";
60 close($fh);
62 if (open($fh, '>.empty_html_file')) {
63 close($fh);
68 sub compare_output {
69 #my $self = shift;
70 return 1;
74 sub project_file_extension {
75 #my $self = shift;
76 return '.gpj';
80 sub fill_value {
81 my($self, $name) = @_;
82 my $value;
84 if (!defined $startre) {
85 $startre = $self->escape_regex_special($self->getstartdir());
88 ## The Green Hills project format is strange and needs all paths
89 ## relative to the top directory, no matter where the source files
90 ## reside. The template uses reltop_ in front of the real project
91 ## settings, so we get the value of the real keyword and then do some
92 ## adjusting to get it relative to the top directory.
93 if ($name =~ /^reltop_(\w+)/) {
94 $value = $self->relative($self->get_assignment($1));
95 if (defined $value) {
96 my $part = $self->getcwd();
97 $part =~ s/^$startre[\/]?//;
98 if ($part ne '') {
99 if ($value eq '.') {
100 $value = $part;
102 else {
103 $value = $part . '/' . $value;
108 elsif ($name eq 'reltop') {
109 $value = $self->getcwd();
110 $value =~ s/^$startre[\/]?//;
111 $value = '.' if ($value eq '');
113 elsif ($name eq 'slash') {
114 ## We need to override the slash value so that we can give the right
115 ## value for Windows or UNIX.
116 $value = (defined $ENV{$GHSPropertyBase::ghsunix} ? '/' : '\\');
118 elsif ($name eq 'postmkdir') {
119 ## If we're on Windows, we need an "or" command that will reset the
120 ## errorlevel so that a mkdir on a directory that already exists
121 ## doesn't cause the build to cease.
122 $value = ' || type nul' if (!defined $ENV{$GHSPropertyBase::ghsunix});
125 return $value;
128 sub get_dll_exe_template_input_file {
129 #my $self = shift;
130 return 'ghsdllexe';
134 sub get_lib_exe_template_input_file {
135 #my $self = shift;
136 return 'ghslibexe';
140 sub get_lib_template_input_file {
141 #my $self = shift;
142 return 'ghslib';
146 sub get_dll_template_input_file {
147 #my $self = shift;
148 return 'ghsdll';