Subversion Repositories DevTools

Rev

Rev 4889 | Rev 5411 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
#..
2
# Copyright (C) 1998-2005 ERG Transit Systems, All rights reserved
3
#
4
# Module name   : JAVA
5
# Module type   : Makefile system
6
# Compiler(s)   : None
7
# Environment(s): All
8
#
9
# Description:
10
#       This file provides Toolset initialisation and plugin functions
11
#       to makelib.pl2
12
#
13
# Contents:     Basic (very basic) Java support
14
#
15
#............................................................................#
16
 
4778 dpurdie 17
#   Local varables
18
#
19
my  $postProcessUnitTest = 0;
20
 
227 dpurdie 21
##############################################################################
22
#   ToolsetInit()
23
#       Runtime initialisation
24
#
25
##############################################################################
26
 
27
ToolsetInit();
28
 
29
sub ToolsetInit
30
{
31
    my( @args ) = @ScmToolsetArgs;             # Toolset arguments
32
    my( $version, $product, @defines, @dirs, @flags );
33
 
34
    #
35
    #   If the user doesn't specify a version, then force a known version
36
    #   1.4 may not be the current flavor, but it was when this was done!
37
    #
38
    $version = 1.4;
39
 
40
#.. Parse arguments
41
#
42
    Debug( "JAVA(@args)\n" );
43
 
44
    foreach $_ ( @args ) {
45
        if (/^--Version=(.*)/) {                # Compiler version
46
            $version = "$1";
47
        } else {
48
            Message( "JAVA: unknown toolset argument $_ -- ignored\n" );
49
        }
50
    }
51
 
52
#.. Parse Platform Arguments
53
#
261 dpurdie 54
    @args = @ScmPlatformArgs;                   # Platform arguments
227 dpurdie 55
    foreach $_ ( @args ) {
56
        if (/^--product=(.*)/) {                # GBE product
57
            $product = $1;
58
 
59
        } elsif (/^--Version=(.*)/) {
60
            $version = $1;
61
 
62
        } else {
63
            Message( "JAVA: unknown platform argument $_ -- ignored\n" );
64
        }
65
    }
66
 
67
#.. Toolset configuration
68
#
69
    $::ScmToolsetVersion = "1.0.0";               # our version
70
    $::ScmToolsetGenerate = 0;                    # generate optional
71
 
72
#.. Standard.rul requirements
73
#
74
    $s =   'java';          # Assembler source file
75
    $o =   '';              # Object file
76
    $a =   'class';         # Library file
77
    $so =  '';              # Shared library
78
    $exe = '.jar';          # Linked binary images
79
 
80
#.. Pass version information in
81
#
82
    Error ("Java Version has not been set") unless $version;
83
    my $nice_ver = $version;
84
    $nice_ver =~ s~\.~_~g;
85
 
86
    ToolsetDefine ( "\n#..    Specify the version of JAVA to use and the EnvVar that specifies it" );
87
    ToolsetDefine ( "#" );
88
    ToolsetDefine ( "JAVA_VER = $version" );
89
    ToolsetDefine ( "JAVA_HOME_VAR = JAVA_HOME_$nice_ver" );
90
    ToolsetDefine ( "\n" );
91
 
92
#.. Toolset specific definitions
93
#
94
    Init( "java_sdk" );
95
    ToolsetDefines( 'JAVA.DEF' );
96
 
97
}
98
 
99
########################################################################
100
#
101
#   Generate a project from the provided build.xml
102
#   This is aimed at Java
103
#
104
#   Arguments   : $name             - Base name of the project
105
#                 $buildxml         - Path to the build.xml file
106
#                 $pArgs            - Project specific options
107
#                 $auto_test        - Unit Test Target (optional)
108
#                 $unit_test        - Unit Test Target (optional)
109
#                 $pGenerated       - Ref to an array of Generated Files (optional)
110
#
111
########################################################################
112
 
113
our $ToolsetPROJECT_type = 'ant';
114
sub ToolsetPROJECT
115
{
116
    my( $name, $buildxml ,$pArgs, $auto_test, $unit_test, $pGenerated ) = @_;
241 dpurdie 117
    my $cmd = '$(ANT) $(ANT_VERBOSE)';
227 dpurdie 118
    my $io = ToolsetPrinter::New();
119
 
120
    #
121
    #   Generate the recipe to create the project
122
    #   Add names of co-generated targets.
123
    #
124
    $io->Label( "Build project", $name );
125
    $io->Entry( "Project_$name",": $buildxml\n", " \\\n", "" , @{$pGenerated} );
126
    $io->PrtLn( "\t\$(XX_PRE)grep \'includeAntRuntime[ \t]*=[ \t]*\"off\"\' $buildxml || (echo ANT build file MUST specify includeAntRuntime=\"off\" with each javac command; exit 1)" );
127
    $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,)" );
128
    $io->Newline();
129
 
130
    #
131
    #   Generate the recipe to clean the project
132
    #
133
    $io->Label( "Clean project", $name );
134
    $io->PrtLn( "ProjectClean_$name: $buildxml" );
135
    $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,clean)" );
136
    $io->Newline();
137
 
138
    #
139
    #   Generate the recipe to run unit tests on the project
140
    #   This is optional
141
    #
142
    if ( $auto_test )
143
    {
4778 dpurdie 144
        #   Flag that we need to post process the test results
145
        #   Under Java the UTF tests MUST be Post processed
146
        $postProcessUnitTest = 1;
147
 
227 dpurdie 148
        $io->Label( "Auto Test project", $name );
149
        $io->PrtLn( "ProjectATest_$name: $buildxml" );
150
        $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,$auto_test)" );
151
        $io->Newline();
152
    }
153
 
154
    if ( $unit_test )
155
    {
156
        $io->Label( "Unit Test project", $name );
157
        $io->PrtLn( "ProjectUTest_$name: $buildxml" );
158
        $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,$unit_test)" );
159
        $io->Newline();
160
    }
161
 
162
    #
163
    #   Generate macro to contain the project invocation
164
    #   The first argument will be a 'build target' argument
165
    #
166
    $io->Label( "Macro to invoke project", $name );
167
    $io->PrtLn( "define ProjectDefine_$name" );
168
    $io->PrtLn( "\t$cmd -f $buildxml -DINTERFACEDIR=\$(PWD)/\$(INTERFACEDIR) -DGBE_TYPE=\$(GBE_TYPE) @{$pArgs} \$1" );
169
    $io->PrtLn( "endef");
170
    $io->Newline();
171
}
172
 
4778 dpurdie 173
#-------------------------------------------------------------------------------
174
# Function        : ToolsetPostprocess 
175
#
176
# Description     : Last chance by the toolset to perform processing
177
#                   All Directives have been processed
178
#
179
#                   If the Java Project has indicated that it has an automated unit test
180
#                   then we need to post process the results
181
#
182
# Inputs          : None
183
#
184
# Returns         : 
185
#
186
 
187
sub ToolsetPostprocess
188
{
189
    if ($postProcessUnitTest)
190
    {
191
        MakeHeader ("Automated tests Post Processing");
192
 
193
        #   Extend the list of Post Unit Tests recipes that are run
194
        my $recipeName = 'post_utf_processing';
195
        ToolsetAddUnitTestPostProcess($recipeName);
196
 
197
        #
198
        #   Create the Post Unit Test Recipe
199
        #
4781 dpurdie 200
        my $me = MakeEntry::New (*MAKEFILE, $recipeName, '--Phony' );
201
 
202
        #   Insert test EnvVars
203
        #       In the Java toolset these are not as useful in a Jats RunTest
204
        $me->AddDefn('export GBE_UTFNAME', 'junit4Test');
205
        $me->AddDefn('export GBE_UTFUID', '$(MAKEFILEUID)' . '_' . '1');
4996 dpurdie 206
        $me->AddDefn('export GBE_UTFFILE','$(UTFDIR_PKG)/$(GBE_PLATFORM)-$(GBE_TYPE)-$(GBE_UTFUID)' . '.xml');
4781 dpurdie 207
 
4889 dpurdie 208
        $me->SectionIfDef ('UTF_POSTPROCESS');
4781 dpurdie 209
        $me->AddRecipe  ( [
210
                           '$(GBE_PERL) -Mjats_runutf -e processUtf -- ',
211
                           '$(VERBOSE_OPT)',
4787 dpurdie 212
                           '-filter=ant',
4781 dpurdie 213
                           '-root=$(GBE_ROOT_ABS)',
214
                           '-target=$(GBE_PLATFORM)', 
215
                           '-pkgdir=$(PKGDIR)',
216
                           '-local=$(LOCALDIR)',
217
                           '-interface=$(INTERFACEDIR)' 
218
                          ]);
4778 dpurdie 219
        $me->Print();
220
 
221
        #   Clean up files that look like Junit output files
222
        ToolsetGenerate( 'TEST-*.xml' );
223
    }
224
}
225
 
227 dpurdie 226
1;
227