| 4324 |
dpurdie |
1 |
########################################################################
|
| 6177 |
dpurdie |
2 |
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
|
| 4324 |
dpurdie |
3 |
#
|
|
|
4 |
# Module name : ANDROID.PL
|
|
|
5 |
# Module type : Makefile system
|
|
|
6 |
# Compiler(s) : Perl
|
|
|
7 |
# Environment(s): jats
|
|
|
8 |
#
|
|
|
9 |
# Description:
|
|
|
10 |
# This file provides Toolset initialisation and plugin functions
|
|
|
11 |
# to makelib.pl2
|
|
|
12 |
#
|
|
|
13 |
# Contents: Basic (very basic) Android support
|
|
|
14 |
#
|
|
|
15 |
#............................................................................#
|
|
|
16 |
|
| 4344 |
dpurdie |
17 |
use strict;
|
|
|
18 |
use warnings;
|
|
|
19 |
|
| 4324 |
dpurdie |
20 |
#
|
|
|
21 |
# Globals
|
|
|
22 |
#
|
|
|
23 |
my $androidBuilder;
|
| 5411 |
dpurdie |
24 |
my $postProcessUnitTest = 0;
|
| 4324 |
dpurdie |
25 |
|
|
|
26 |
##############################################################################
|
|
|
27 |
# ToolsetInit()
|
|
|
28 |
# Runtime initialisation
|
|
|
29 |
#
|
|
|
30 |
##############################################################################
|
|
|
31 |
|
|
|
32 |
ToolsetInit();
|
|
|
33 |
|
|
|
34 |
sub ToolsetInit
|
|
|
35 |
{
|
|
|
36 |
|
|
|
37 |
#.. Toolset configuration
|
|
|
38 |
#
|
| 5411 |
dpurdie |
39 |
$::ScmToolsetVersion = "1.0.0"; # our version
|
|
|
40 |
$::ScmToolsetGenerate = 0; # generate optional
|
|
|
41 |
$::ScmToolsetProperties{'AutoUnitTests'} = 1; # Supports AutoUnit Tests
|
| 4324 |
dpurdie |
42 |
|
|
|
43 |
#.. Standard.rul requirements
|
|
|
44 |
#
|
| 4344 |
dpurdie |
45 |
$::s = 'java'; # Assembler source file
|
|
|
46 |
$::o = ''; # Object file
|
|
|
47 |
$::a = 'class'; # Library file
|
|
|
48 |
$::so = 'jar'; # Shared library
|
|
|
49 |
$::exe = '.apk'; # Linked binary images
|
| 4324 |
dpurdie |
50 |
|
|
|
51 |
#.. Toolset specific definitions
|
|
|
52 |
#
|
|
|
53 |
Init( "android_sdk" );
|
|
|
54 |
ToolsetDefines( 'ANDROID.DEF' );
|
|
|
55 |
#
|
|
|
56 |
#.. Locate the AndroidBuilder.pl script
|
|
|
57 |
# This will be delivered by a package
|
|
|
58 |
#
|
| 4362 |
dpurdie |
59 |
my $program = 'AndroidBuilder.pl';
|
| 4324 |
dpurdie |
60 |
Verbose("Locate extension Program: $program");
|
|
|
61 |
$androidBuilder = ToolExtensionProgram( $program );
|
|
|
62 |
Error( "Tool program(s) required by toolset not found:", $program)
|
|
|
63 |
unless ($androidBuilder);
|
|
|
64 |
|
|
|
65 |
ToolsetDefine ('# Android Builder Support Tool');
|
|
|
66 |
ToolsetDefine ('ANDROIDBUILDER=' . $androidBuilder);
|
|
|
67 |
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
########################################################################
|
|
|
71 |
#
|
|
|
72 |
# Generate a project from the provided build.xml
|
|
|
73 |
#
|
|
|
74 |
# Arguments : $name - Base name of the project
|
|
|
75 |
# $androidxml - Path to the AndroidManifest.xml file
|
|
|
76 |
# $pArgs - Project specific options
|
|
|
77 |
# $auto_test - Unit Test Target (optional)
|
|
|
78 |
# $unit_test - Unit Test Target (optional)
|
|
|
79 |
# $pGenerated - Ref to an array of Generated Files (optional)
|
|
|
80 |
#
|
|
|
81 |
########################################################################
|
|
|
82 |
|
|
|
83 |
our $ToolsetPROJECT_type = 'android';
|
|
|
84 |
sub ToolsetPROJECT
|
|
|
85 |
{
|
|
|
86 |
my( $name, $androidxml ,$pArgs, $auto_test, $unit_test, $pGenerated ) = @_;
|
|
|
87 |
|
|
|
88 |
#
|
| 4949 |
dpurdie |
89 |
# Kludge Alert
|
|
|
90 |
# The AndroidStudioBuilder needs to target platform
|
|
|
91 |
# The AndroidBuilder cannot handle this argument
|
|
|
92 |
# Luckily the AndroidStudioBuilder builds under windows
|
|
|
93 |
# and the AndroidBuilder under unix
|
|
|
94 |
#
|
|
|
95 |
if ($::GBE_HOSTMACH eq 'win32')
|
|
|
96 |
{
|
|
|
97 |
push @{$pArgs}, '-pf', $::ScmPlatform;
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
#
|
| 4344 |
dpurdie |
101 |
# Populate the project for the user
|
|
|
102 |
#
|
|
|
103 |
ToolsetPROJECTPreBuild (@_);
|
|
|
104 |
|
|
|
105 |
#
|
| 4324 |
dpurdie |
106 |
# Generate the recipe to create the project
|
|
|
107 |
# Add names of co-generated targets.
|
|
|
108 |
#
|
| 4344 |
dpurdie |
109 |
my $me = MakeEntry::New (*MAKEFILE, 'Project_'.$name );
|
|
|
110 |
$me->AddComment ("Build Android Project: $name" );
|
|
|
111 |
$me->AddDependancy ( $androidxml );
|
|
|
112 |
$me->AddDependancy ( '$(SCM_MAKEFILE)' );
|
|
|
113 |
$me->AddDependancy ( @{$pGenerated} );
|
|
|
114 |
$me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,)" );
|
|
|
115 |
$me->Print();
|
| 4324 |
dpurdie |
116 |
|
|
|
117 |
#
|
|
|
118 |
# Generate the recipe to clean the project
|
|
|
119 |
#
|
| 4344 |
dpurdie |
120 |
$me = MakeEntry::New (*MAKEFILE, 'ProjectClean_'.$name );
|
|
|
121 |
$me->AddComment ("Clean Android Project: $name" );
|
|
|
122 |
$me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,-clean)" );
|
|
|
123 |
$me->Print();
|
| 4324 |
dpurdie |
124 |
|
|
|
125 |
#
|
|
|
126 |
# Generate the recipe to run unit tests on the project
|
|
|
127 |
# This is optional
|
|
|
128 |
#
|
|
|
129 |
if ( $auto_test )
|
|
|
130 |
{
|
| 4344 |
dpurdie |
131 |
$me = MakeEntry::New (*MAKEFILE, 'ProjectATest_'.$name );
|
|
|
132 |
$me->AddComment ("Auto Test project: $name" );
|
|
|
133 |
$me->AddDependancy ( $androidxml );
|
| 5411 |
dpurdie |
134 |
$me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,'-autotest')" );
|
| 4344 |
dpurdie |
135 |
$me->Print();
|
| 5411 |
dpurdie |
136 |
|
|
|
137 |
# Flag that we need to post process the test results
|
|
|
138 |
# Under Java the UTF tests MUST be Post processed
|
|
|
139 |
$postProcessUnitTest = 1;
|
|
|
140 |
|
| 4324 |
dpurdie |
141 |
}
|
|
|
142 |
|
|
|
143 |
if ( $unit_test )
|
|
|
144 |
{
|
| 4344 |
dpurdie |
145 |
$me = MakeEntry::New (*MAKEFILE, 'ProjectUTest_'.$name );
|
|
|
146 |
$me->AddComment ("Unit Test project: $name" );
|
|
|
147 |
$me->AddDependancy ( $androidxml );
|
|
|
148 |
$me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,$unit_test)" );
|
|
|
149 |
$me->Print();
|
| 4324 |
dpurdie |
150 |
}
|
|
|
151 |
|
|
|
152 |
#
|
|
|
153 |
# Generate macro to contain the project invocation
|
|
|
154 |
# The first argument will be a 'build target' argument
|
|
|
155 |
#
|
| 4344 |
dpurdie |
156 |
my @cmdargs;
|
|
|
157 |
push @cmdargs, '$(GBE_PERL)','$(ANDROIDBUILDER)';
|
|
|
158 |
push @cmdargs, '-f', $androidxml;
|
|
|
159 |
push @cmdargs, '-i=$(PWD)/$(INTERFACEDIR)';
|
|
|
160 |
push @cmdargs, '-t=$(GBE_TYPE)';
|
|
|
161 |
push @cmdargs, '-pn=$(GBE_PBASE) -pv=$(BUILDVER)';
|
| 5448 |
dpurdie |
162 |
push @cmdargs, '-hasTests' if ( $auto_test || $unit_test );
|
| 4344 |
dpurdie |
163 |
push @cmdargs, @{$pArgs}, '$1';
|
|
|
164 |
|
|
|
165 |
$me = MakeEntry::New (*MAKEFILE, 'ProjectDefine_'.$name, '--Define' );
|
|
|
166 |
$me->AddComment ("Macro to invoke project: $name" );
|
|
|
167 |
$me->AddRecipe ( join(' ', @cmdargs) );
|
|
|
168 |
$me->Print();
|
| 4324 |
dpurdie |
169 |
}
|
|
|
170 |
|
| 4344 |
dpurdie |
171 |
#-------------------------------------------------------------------------------
|
|
|
172 |
# Function : ToolsetPROJECTPreBuild
|
|
|
173 |
#
|
|
|
174 |
# Description : This ANDROID Specific operation is used to perform some of the
|
|
|
175 |
# build opertaions at 'build' time. These include:
|
|
|
176 |
# - Verify that required packages are available
|
|
|
177 |
# - Populate the targets 'libs' directory so that the user can
|
|
|
178 |
# develop with the external dependencies in place
|
|
|
179 |
#
|
|
|
180 |
# Inputs : $name - Base name of the project
|
|
|
181 |
# $androidxml - Path to the AndroidManifest.xml file
|
|
|
182 |
# $pArgs - Project specific options
|
|
|
183 |
# $auto_test - Unit Test Target (optional)
|
|
|
184 |
# $unit_test - Unit Test Target (optional)
|
|
|
185 |
# $pGenerated - Ref to an array of Generated Files (optional)
|
|
|
186 |
#
|
|
|
187 |
# Returns : Nothing
|
|
|
188 |
#
|
|
|
189 |
sub ToolsetPROJECTPreBuild
|
|
|
190 |
{
|
| 6353 |
dpurdie |
191 |
my( $name, $androidxml ,$pArgs, $auto_test, $unit_test, $pGenerated, $project ) = @_;
|
| 4344 |
dpurdie |
192 |
|
|
|
193 |
#
|
| 6353 |
dpurdie |
194 |
# Determine the populate mode
|
|
|
195 |
# Used to limit the shared libraries that are included
|
|
|
196 |
# In populate mode may have both -tD and -tP
|
|
|
197 |
# Need -tD last for backward compatability
|
|
|
198 |
#
|
|
|
199 |
my @tArgs;
|
|
|
200 |
if (exists $project->{Prod} && $project->{Prod}) {
|
|
|
201 |
push @tArgs, '-t=P';
|
|
|
202 |
} elsif (exists $project->{Debug} && $project->{Debug}) {
|
|
|
203 |
push @tArgs, '-t=D';
|
|
|
204 |
} else {
|
|
|
205 |
push @tArgs, '-t=P', '-t=D';
|
|
|
206 |
}
|
|
|
207 |
|
|
|
208 |
#
|
| 4344 |
dpurdie |
209 |
# Invoke the androidBuilder in a mode so that it will populate the Eclipse project
|
|
|
210 |
# in a suitable manner.
|
|
|
211 |
#
|
|
|
212 |
EnvImport( "GBE_PERL" );
|
|
|
213 |
System ( '--NoShell', '--Exit', $::GBE_PERL, $androidBuilder,
|
|
|
214 |
'-f', $androidxml,
|
|
|
215 |
'-i', catdir( $::ScmRoot, $::ScmInterface),
|
| 6353 |
dpurdie |
216 |
@tArgs,
|
| 4344 |
dpurdie |
217 |
'-pn', $::Pbase,
|
|
|
218 |
'-pv', $::ScmBuildVersionFull,
|
| 4362 |
dpurdie |
219 |
'-populate',
|
|
|
220 |
@{$pArgs}
|
| 4344 |
dpurdie |
221 |
);
|
|
|
222 |
}
|
|
|
223 |
|
| 5411 |
dpurdie |
224 |
#-------------------------------------------------------------------------------
|
|
|
225 |
# Function : ToolsetPostprocess
|
|
|
226 |
#
|
|
|
227 |
# Description : Last chance by the toolset to perform processing
|
|
|
228 |
# All Directives have been processed
|
|
|
229 |
#
|
|
|
230 |
# If the Project has indicated that it has an automated unit test
|
|
|
231 |
# then we need to post process the results
|
|
|
232 |
#
|
|
|
233 |
# Inputs : None
|
|
|
234 |
#
|
|
|
235 |
# Returns :
|
|
|
236 |
#
|
| 4344 |
dpurdie |
237 |
|
| 5411 |
dpurdie |
238 |
sub ToolsetPostprocess
|
|
|
239 |
{
|
|
|
240 |
if ($postProcessUnitTest)
|
|
|
241 |
{
|
|
|
242 |
MakeHeader ("Automated tests Post Processing");
|
|
|
243 |
|
|
|
244 |
# Extend the list of Post Unit Tests recipes that are run
|
|
|
245 |
my $recipeName = 'post_utf_processing';
|
|
|
246 |
ToolsetAddUnitTestPostProcess($recipeName);
|
|
|
247 |
|
|
|
248 |
#
|
|
|
249 |
# Create the Post Unit Test Recipe
|
|
|
250 |
#
|
|
|
251 |
my $me = MakeEntry::New (*MAKEFILE, $recipeName, '--Phony' );
|
|
|
252 |
|
|
|
253 |
# Insert test EnvVars
|
|
|
254 |
# In the Java toolset these are not as useful in a Jats RunTest
|
|
|
255 |
$me->AddDefn('export GBE_UTFNAME', 'AndroidStudioTest');
|
|
|
256 |
$me->AddDefn('export GBE_UTFUID', '$(MAKEFILEUID)' . '_' . '1');
|
|
|
257 |
$me->AddDefn('export GBE_UTFFILE','$(UTFDIR_PKG)/$(GBE_PLATFORM)-$(GBE_TYPE)-$(GBE_UTFUID)' . '.xml');
|
| 6619 |
dpurdie |
258 |
$me->AddDefn('export GBE_UTFTEST','TEST-$(GBE_UTFNAME)-$(GBE_TYPE)-$(GBE_UTFUID)' );
|
| 5411 |
dpurdie |
259 |
|
|
|
260 |
$me->SectionIfDef ('UTF_POSTPROCESS');
|
|
|
261 |
$me->AddRecipe ( [
|
|
|
262 |
'$(GBE_PERL) -Mjats_runutf -e processUtf -- ',
|
|
|
263 |
'$(VERBOSE_OPT)',
|
|
|
264 |
'-filter=androidStudio',
|
|
|
265 |
'-root=$(GBE_ROOT_ABS)',
|
|
|
266 |
'-target=$(GBE_PLATFORM)',
|
|
|
267 |
'-pkgdir=$(PKGDIR)',
|
|
|
268 |
'-local=$(LOCALDIR)',
|
|
|
269 |
'-interface=$(INTERFACEDIR)'
|
|
|
270 |
]);
|
|
|
271 |
$me->Print();
|
|
|
272 |
|
|
|
273 |
# Clean up files that look like Junit output files
|
|
|
274 |
ToolsetGenerate( 'TEST-*.xml' );
|
|
|
275 |
}
|
|
|
276 |
}
|
|
|
277 |
|
|
|
278 |
|
| 4324 |
dpurdie |
279 |
1;
|
|
|
280 |
|