| 227 |
dpurdie |
1 |
#..
|
| 6177 |
dpurdie |
2 |
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
|
| 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" );
|
| 6177 |
dpurdie |
92 |
ToolsetDefine ( "" );
|
| 227 |
dpurdie |
93 |
|
| 6177 |
dpurdie |
94 |
#
|
|
|
95 |
# Examine the dependent packages looking for a package that provides
|
|
|
96 |
# 'ant' toolset information. If found the provided ANT will be used
|
|
|
97 |
# in place of the default ant
|
|
|
98 |
#
|
|
|
99 |
if (testToolInfo('ant'))
|
|
|
100 |
{
|
|
|
101 |
my $antTool = getToolInfo('ant', 'JAVA_VERSION');
|
|
|
102 |
my $antHome = catdir($antTool->{PKGBASE}, $antTool->{TOOLROOT});
|
|
|
103 |
my $antVersion = $antTool->{PKGENTRY}->getVersion();
|
|
|
104 |
|
|
|
105 |
#
|
|
|
106 |
# Validate the required version of Java for the tool
|
|
|
107 |
# Assume JAVA_VERSION is of the form JAVA_HOME_1_6 and
|
|
|
108 |
# that we can do a crude string comparison
|
|
|
109 |
#
|
|
|
110 |
my $javaVersion = $antTool->{JAVA_VERSION};
|
| 6619 |
dpurdie |
111 |
if (("JAVA_HOME_$nice_ver" cmp $javaVersion) < 0 )
|
| 6177 |
dpurdie |
112 |
{
|
|
|
113 |
Error ("The version of Java required by the ant package is not suitable",
|
|
|
114 |
"The ant plugin requires: $javaVersion",
|
|
|
115 |
"This package is building for: JAVA_HOME_$nice_ver"
|
|
|
116 |
);
|
|
|
117 |
}
|
|
|
118 |
$ENV{JAVA_HOME}=$ENV{$javaVersion};
|
|
|
119 |
|
|
|
120 |
ToolsetDefine ( '#.. Specify the ANT_HOME provided by the package' );
|
|
|
121 |
ToolsetDefine ( '#' );
|
|
|
122 |
ToolsetDefine ( "ANT_HOME = $antHome" );
|
|
|
123 |
ToolsetDefine ( "ANT_TITLE=, Ant $antVersion" );
|
|
|
124 |
ToolsetDefine ( '' );
|
|
|
125 |
}
|
|
|
126 |
|
| 227 |
dpurdie |
127 |
#.. Toolset specific definitions
|
|
|
128 |
#
|
|
|
129 |
Init( "java_sdk" );
|
|
|
130 |
ToolsetDefines( 'JAVA.DEF' );
|
|
|
131 |
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
########################################################################
|
|
|
135 |
#
|
|
|
136 |
# Generate a project from the provided build.xml
|
|
|
137 |
# This is aimed at Java
|
|
|
138 |
#
|
|
|
139 |
# Arguments : $name - Base name of the project
|
|
|
140 |
# $buildxml - Path to the build.xml file
|
|
|
141 |
# $pArgs - Project specific options
|
|
|
142 |
# $auto_test - Unit Test Target (optional)
|
|
|
143 |
# $unit_test - Unit Test Target (optional)
|
|
|
144 |
# $pGenerated - Ref to an array of Generated Files (optional)
|
|
|
145 |
#
|
|
|
146 |
########################################################################
|
|
|
147 |
|
|
|
148 |
our $ToolsetPROJECT_type = 'ant';
|
|
|
149 |
sub ToolsetPROJECT
|
|
|
150 |
{
|
|
|
151 |
my( $name, $buildxml ,$pArgs, $auto_test, $unit_test, $pGenerated ) = @_;
|
| 241 |
dpurdie |
152 |
my $cmd = '$(ANT) $(ANT_VERBOSE)';
|
| 227 |
dpurdie |
153 |
my $io = ToolsetPrinter::New();
|
|
|
154 |
|
|
|
155 |
#
|
|
|
156 |
# Generate the recipe to create the project
|
|
|
157 |
# Add names of co-generated targets.
|
|
|
158 |
#
|
|
|
159 |
$io->Label( "Build project", $name );
|
|
|
160 |
$io->Entry( "Project_$name",": $buildxml\n", " \\\n", "" , @{$pGenerated} );
|
| 6177 |
dpurdie |
161 |
$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)" );
|
| 227 |
dpurdie |
162 |
$io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,)" );
|
|
|
163 |
$io->Newline();
|
|
|
164 |
|
|
|
165 |
#
|
|
|
166 |
# Generate the recipe to clean the project
|
|
|
167 |
#
|
|
|
168 |
$io->Label( "Clean project", $name );
|
|
|
169 |
$io->PrtLn( "ProjectClean_$name: $buildxml" );
|
|
|
170 |
$io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,clean)" );
|
|
|
171 |
$io->Newline();
|
|
|
172 |
|
|
|
173 |
#
|
|
|
174 |
# Generate the recipe to run unit tests on the project
|
|
|
175 |
# This is optional
|
|
|
176 |
#
|
|
|
177 |
if ( $auto_test )
|
|
|
178 |
{
|
| 4778 |
dpurdie |
179 |
# Flag that we need to post process the test results
|
|
|
180 |
# Under Java the UTF tests MUST be Post processed
|
|
|
181 |
$postProcessUnitTest = 1;
|
|
|
182 |
|
| 227 |
dpurdie |
183 |
$io->Label( "Auto Test project", $name );
|
|
|
184 |
$io->PrtLn( "ProjectATest_$name: $buildxml" );
|
|
|
185 |
$io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,$auto_test)" );
|
|
|
186 |
$io->Newline();
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
if ( $unit_test )
|
|
|
190 |
{
|
|
|
191 |
$io->Label( "Unit Test project", $name );
|
|
|
192 |
$io->PrtLn( "ProjectUTest_$name: $buildxml" );
|
|
|
193 |
$io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,$unit_test)" );
|
|
|
194 |
$io->Newline();
|
|
|
195 |
}
|
|
|
196 |
|
|
|
197 |
#
|
|
|
198 |
# Generate macro to contain the project invocation
|
|
|
199 |
# The first argument will be a 'build target' argument
|
|
|
200 |
#
|
|
|
201 |
$io->Label( "Macro to invoke project", $name );
|
|
|
202 |
$io->PrtLn( "define ProjectDefine_$name" );
|
| 6294 |
dpurdie |
203 |
$io->PrtLn( "\t$cmd -f $buildxml -DINTERFACEDIR=\$(abspath \$(INTERFACEDIR)) -DGBE_TYPE=\$(GBE_TYPE) @{$pArgs} \$1" );
|
| 227 |
dpurdie |
204 |
$io->PrtLn( "endef");
|
|
|
205 |
$io->Newline();
|
|
|
206 |
}
|
|
|
207 |
|
| 4778 |
dpurdie |
208 |
#-------------------------------------------------------------------------------
|
|
|
209 |
# Function : ToolsetPostprocess
|
|
|
210 |
#
|
|
|
211 |
# Description : Last chance by the toolset to perform processing
|
|
|
212 |
# All Directives have been processed
|
|
|
213 |
#
|
|
|
214 |
# If the Java Project has indicated that it has an automated unit test
|
|
|
215 |
# then we need to post process the results
|
|
|
216 |
#
|
|
|
217 |
# Inputs : None
|
|
|
218 |
#
|
|
|
219 |
# Returns :
|
|
|
220 |
#
|
|
|
221 |
|
|
|
222 |
sub ToolsetPostprocess
|
|
|
223 |
{
|
|
|
224 |
if ($postProcessUnitTest)
|
|
|
225 |
{
|
|
|
226 |
MakeHeader ("Automated tests Post Processing");
|
|
|
227 |
|
|
|
228 |
# Extend the list of Post Unit Tests recipes that are run
|
|
|
229 |
my $recipeName = 'post_utf_processing';
|
|
|
230 |
ToolsetAddUnitTestPostProcess($recipeName);
|
|
|
231 |
|
|
|
232 |
#
|
|
|
233 |
# Create the Post Unit Test Recipe
|
|
|
234 |
#
|
| 4781 |
dpurdie |
235 |
my $me = MakeEntry::New (*MAKEFILE, $recipeName, '--Phony' );
|
|
|
236 |
|
|
|
237 |
# Insert test EnvVars
|
|
|
238 |
# In the Java toolset these are not as useful in a Jats RunTest
|
|
|
239 |
$me->AddDefn('export GBE_UTFNAME', 'junit4Test');
|
|
|
240 |
$me->AddDefn('export GBE_UTFUID', '$(MAKEFILEUID)' . '_' . '1');
|
| 4996 |
dpurdie |
241 |
$me->AddDefn('export GBE_UTFFILE','$(UTFDIR_PKG)/$(GBE_PLATFORM)-$(GBE_TYPE)-$(GBE_UTFUID)' . '.xml');
|
| 6619 |
dpurdie |
242 |
$me->AddDefn('export GBE_UTFTEST','TEST-$(GBE_UTFNAME)-$(GBE_TYPE)-$(GBE_UTFUID)' );
|
| 4781 |
dpurdie |
243 |
|
| 4889 |
dpurdie |
244 |
$me->SectionIfDef ('UTF_POSTPROCESS');
|
| 4781 |
dpurdie |
245 |
$me->AddRecipe ( [
|
|
|
246 |
'$(GBE_PERL) -Mjats_runutf -e processUtf -- ',
|
|
|
247 |
'$(VERBOSE_OPT)',
|
| 6898 |
dpurdie |
248 |
'-filter=junit',
|
|
|
249 |
'-arg=pattern=TEST-*.xml',
|
| 4781 |
dpurdie |
250 |
'-root=$(GBE_ROOT_ABS)',
|
|
|
251 |
'-target=$(GBE_PLATFORM)',
|
|
|
252 |
'-pkgdir=$(PKGDIR)',
|
|
|
253 |
'-local=$(LOCALDIR)',
|
|
|
254 |
'-interface=$(INTERFACEDIR)'
|
|
|
255 |
]);
|
| 4778 |
dpurdie |
256 |
$me->Print();
|
|
|
257 |
|
|
|
258 |
# Clean up files that look like Junit output files
|
|
|
259 |
ToolsetGenerate( 'TEST-*.xml' );
|
|
|
260 |
}
|
|
|
261 |
}
|
|
|
262 |
|
| 227 |
dpurdie |
263 |
1;
|
|
|
264 |
|