Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
227 dpurdie 1
#..
5709 dpurdie 2
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
227 dpurdie 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
#
5411 dpurdie 69
    $::ScmToolsetVersion = "1.0.0";                 # our version
70
    $::ScmToolsetGenerate = 0;                      # generate optional
71
    $::ScmToolsetProperties{'AutoUnitTests'} = 1;   # Supports AutoUnit Tests in MakeProject
72
    $::ScmToolsetProperties{'UnitTests'} = 1;       # Supports Manual Unit Tests in MakeProject
227 dpurdie 73
 
74
#.. Standard.rul requirements
75
#
76
    $s =   'java';          # Assembler source file
77
    $o =   '';              # Object file
78
    $a =   'class';         # Library file
79
    $so =  '';              # Shared library
80
    $exe = '.jar';          # Linked binary images
81
 
82
#.. Pass version information in
83
#
84
    Error ("Java Version has not been set") unless $version;
85
    my $nice_ver = $version;
86
    $nice_ver =~ s~\.~_~g;
87
 
88
    ToolsetDefine ( "\n#..    Specify the version of JAVA to use and the EnvVar that specifies it" );
89
    ToolsetDefine ( "#" );
90
    ToolsetDefine ( "JAVA_VER = $version" );
91
    ToolsetDefine ( "JAVA_HOME_VAR = JAVA_HOME_$nice_ver" );
92
    ToolsetDefine ( "\n" );
93
 
94
#.. Toolset specific definitions
95
#
96
    Init( "java_sdk" );
97
    ToolsetDefines( 'JAVA.DEF' );
98
 
99
}
100
 
101
########################################################################
102
#
103
#   Generate a project from the provided build.xml
104
#   This is aimed at Java
105
#
106
#   Arguments   : $name             - Base name of the project
107
#                 $buildxml         - Path to the build.xml file
108
#                 $pArgs            - Project specific options
109
#                 $auto_test        - Unit Test Target (optional)
110
#                 $unit_test        - Unit Test Target (optional)
111
#                 $pGenerated       - Ref to an array of Generated Files (optional)
112
#
113
########################################################################
114
 
115
our $ToolsetPROJECT_type = 'ant';
116
sub ToolsetPROJECT
117
{
118
    my( $name, $buildxml ,$pArgs, $auto_test, $unit_test, $pGenerated ) = @_;
241 dpurdie 119
    my $cmd = '$(ANT) $(ANT_VERBOSE)';
227 dpurdie 120
    my $io = ToolsetPrinter::New();
121
 
122
    #
123
    #   Generate the recipe to create the project
124
    #   Add names of co-generated targets.
125
    #
126
    $io->Label( "Build project", $name );
127
    $io->Entry( "Project_$name",": $buildxml\n", " \\\n", "" , @{$pGenerated} );
128
    $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)" );
129
    $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,)" );
130
    $io->Newline();
131
 
132
    #
133
    #   Generate the recipe to clean the project
134
    #
135
    $io->Label( "Clean project", $name );
136
    $io->PrtLn( "ProjectClean_$name: $buildxml" );
137
    $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,clean)" );
138
    $io->Newline();
139
 
140
    #
141
    #   Generate the recipe to run unit tests on the project
142
    #   This is optional
143
    #
144
    if ( $auto_test )
145
    {
4778 dpurdie 146
        #   Flag that we need to post process the test results
147
        #   Under Java the UTF tests MUST be Post processed
148
        $postProcessUnitTest = 1;
149
 
227 dpurdie 150
        $io->Label( "Auto Test project", $name );
151
        $io->PrtLn( "ProjectATest_$name: $buildxml" );
152
        $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,$auto_test)" );
153
        $io->Newline();
154
    }
155
 
156
    if ( $unit_test )
157
    {
158
        $io->Label( "Unit Test project", $name );
159
        $io->PrtLn( "ProjectUTest_$name: $buildxml" );
160
        $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,$unit_test)" );
161
        $io->Newline();
162
    }
163
 
164
    #
165
    #   Generate macro to contain the project invocation
166
    #   The first argument will be a 'build target' argument
167
    #
168
    $io->Label( "Macro to invoke project", $name );
169
    $io->PrtLn( "define ProjectDefine_$name" );
170
    $io->PrtLn( "\t$cmd -f $buildxml -DINTERFACEDIR=\$(PWD)/\$(INTERFACEDIR) -DGBE_TYPE=\$(GBE_TYPE) @{$pArgs} \$1" );
171
    $io->PrtLn( "endef");
172
    $io->Newline();
173
}
174
 
4778 dpurdie 175
#-------------------------------------------------------------------------------
176
# Function        : ToolsetPostprocess 
177
#
178
# Description     : Last chance by the toolset to perform processing
179
#                   All Directives have been processed
180
#
181
#                   If the Java Project has indicated that it has an automated unit test
182
#                   then we need to post process the results
183
#
184
# Inputs          : None
185
#
186
# Returns         : 
187
#
188
 
189
sub ToolsetPostprocess
190
{
191
    if ($postProcessUnitTest)
192
    {
193
        MakeHeader ("Automated tests Post Processing");
194
 
195
        #   Extend the list of Post Unit Tests recipes that are run
196
        my $recipeName = 'post_utf_processing';
197
        ToolsetAddUnitTestPostProcess($recipeName);
198
 
199
        #
200
        #   Create the Post Unit Test Recipe
201
        #
4781 dpurdie 202
        my $me = MakeEntry::New (*MAKEFILE, $recipeName, '--Phony' );
203
 
204
        #   Insert test EnvVars
205
        #       In the Java toolset these are not as useful in a Jats RunTest
206
        $me->AddDefn('export GBE_UTFNAME', 'junit4Test');
207
        $me->AddDefn('export GBE_UTFUID', '$(MAKEFILEUID)' . '_' . '1');
4996 dpurdie 208
        $me->AddDefn('export GBE_UTFFILE','$(UTFDIR_PKG)/$(GBE_PLATFORM)-$(GBE_TYPE)-$(GBE_UTFUID)' . '.xml');
4781 dpurdie 209
 
4889 dpurdie 210
        $me->SectionIfDef ('UTF_POSTPROCESS');
4781 dpurdie 211
        $me->AddRecipe  ( [
212
                           '$(GBE_PERL) -Mjats_runutf -e processUtf -- ',
213
                           '$(VERBOSE_OPT)',
4787 dpurdie 214
                           '-filter=ant',
4781 dpurdie 215
                           '-root=$(GBE_ROOT_ABS)',
216
                           '-target=$(GBE_PLATFORM)', 
217
                           '-pkgdir=$(PKGDIR)',
218
                           '-local=$(LOCALDIR)',
219
                           '-interface=$(INTERFACEDIR)' 
220
                          ]);
4778 dpurdie 221
        $me->Print();
222
 
223
        #   Clean up files that look like Junit output files
224
        ToolsetGenerate( 'TEST-*.xml' );
225
    }
226
}
227
 
227 dpurdie 228
1;
229