Subversion Repositories DevTools

Rev

Rev 6619 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
    #
4344 dpurdie 89
    #   Populate the project for the user
90
    #
91
    ToolsetPROJECTPreBuild (@_);
92
 
93
    #
4324 dpurdie 94
    #   Generate the recipe to create the project
95
    #   Add names of co-generated targets.
96
    #
4344 dpurdie 97
    my $me = MakeEntry::New (*MAKEFILE, 'Project_'.$name );
98
    $me->AddComment ("Build Android Project: $name" );
99
    $me->AddDependancy ( $androidxml );
100
    $me->AddDependancy ( '$(SCM_MAKEFILE)' );
101
    $me->AddDependancy ( @{$pGenerated} );
102
    $me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,)"  );
103
    $me->Print();
4324 dpurdie 104
 
105
    #
106
    #   Generate the recipe to clean the project
107
    #
4344 dpurdie 108
    $me = MakeEntry::New (*MAKEFILE, 'ProjectClean_'.$name );
109
    $me->AddComment ("Clean Android Project: $name" );
110
    $me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,-clean)"  );
111
    $me->Print();
4324 dpurdie 112
 
113
    #
114
    #   Generate the recipe to run unit tests on the project
115
    #   This is optional
116
    #
117
    if ( $auto_test )
118
    {
4344 dpurdie 119
        $me = MakeEntry::New (*MAKEFILE, 'ProjectATest_'.$name );
120
        $me->AddComment ("Auto Test project: $name" );
121
        $me->AddDependancy ( $androidxml );
5411 dpurdie 122
        $me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,'-autotest')"  );
4344 dpurdie 123
        $me->Print();
5411 dpurdie 124
 
125
        #   Flag that we need to post process the test results
126
        #   Under Java the UTF tests MUST be Post processed
127
        $postProcessUnitTest = 1;
128
 
4324 dpurdie 129
    }
130
 
131
    if ( $unit_test )
132
    {
4344 dpurdie 133
        $me = MakeEntry::New (*MAKEFILE, 'ProjectUTest_'.$name );
134
        $me->AddComment ("Unit Test project: $name" );
135
        $me->AddDependancy ( $androidxml );
136
        $me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,$unit_test)"  );
137
        $me->Print();
4324 dpurdie 138
    }
139
 
140
    #
141
    #   Generate macro to contain the project invocation
142
    #   The first argument will be a 'build target' argument
143
    #
4344 dpurdie 144
    my @cmdargs;
145
    push @cmdargs, '$(GBE_PERL)','$(ANDROIDBUILDER)';
146
    push @cmdargs, '-f', $androidxml;
147
    push @cmdargs, '-i=$(PWD)/$(INTERFACEDIR)';
148
    push @cmdargs, '-t=$(GBE_TYPE)';
7579 dpurdie 149
    push @cmdargs, '-pf=$(GBE_PLATFORM)';
150
    push @cmdargs, '-pn=$(GBE_PBASE)', '-pv=$(BUILDVER)';
5448 dpurdie 151
    push @cmdargs, '-hasTests' if ( $auto_test || $unit_test );
7579 dpurdie 152
    push @cmdargs, '$(VERBOSE_OPT)';
4344 dpurdie 153
    push @cmdargs, @{$pArgs}, '$1';
154
 
155
    $me = MakeEntry::New (*MAKEFILE, 'ProjectDefine_'.$name, '--Define' );
156
    $me->AddComment ("Macro to invoke project: $name" );
157
    $me->AddRecipe ( join(' ', @cmdargs)  );
158
    $me->Print();
4324 dpurdie 159
}
160
 
4344 dpurdie 161
#-------------------------------------------------------------------------------
162
# Function        : ToolsetPROJECTPreBuild 
163
#
164
# Description     : This ANDROID Specific operation is used to perform some of the 
165
#                   build opertaions at 'build' time. These include:
166
#                       - Verify that required packages are available
167
#                       - Populate the targets 'libs' directory so that the user can
168
#                         develop with the external dependencies in place 
169
#
170
# Inputs          : $name             - Base name of the project
171
#                   $androidxml       - Path to the AndroidManifest.xml file
172
#                   $pArgs            - Project specific options
173
#                   $auto_test        - Unit Test Target (optional)
174
#                   $unit_test        - Unit Test Target (optional)
175
#                   $pGenerated       - Ref to an array of Generated Files (optional)
176
#
177
# Returns         : Nothing
178
#
179
sub ToolsetPROJECTPreBuild
180
{
6353 dpurdie 181
    my( $name, $androidxml ,$pArgs, $auto_test, $unit_test, $pGenerated, $project ) = @_;
4344 dpurdie 182
 
183
    #
6353 dpurdie 184
    #   Determine the populate mode
185
    #   Used to limit the shared libraries that are included
186
    #   In populate mode may have both -tD and -tP
187
    #       Need -tD last for backward compatability
188
    #
189
    my @tArgs;
190
    if (exists $project->{Prod} && $project->{Prod}) {
191
        push @tArgs, '-t=P';
192
    } elsif (exists $project->{Debug} && $project->{Debug}) {
193
        push @tArgs, '-t=D';
194
    } else {
195
        push @tArgs, '-t=P', '-t=D';
196
    }
197
 
198
    #
4344 dpurdie 199
    #   Invoke the androidBuilder in a mode so that it will populate the Eclipse project
200
    #   in a suitable manner.
201
    #
202
    EnvImport( "GBE_PERL" );
203
    System ( '--NoShell', '--Exit', $::GBE_PERL, $androidBuilder, 
204
             '-f', $androidxml,
205
             '-i', catdir( $::ScmRoot, $::ScmInterface),
6353 dpurdie 206
             @tArgs,
7579 dpurdie 207
             '-pf', $::ScmPlatform,
4344 dpurdie 208
             '-pn', $::Pbase,
209
             '-pv', $::ScmBuildVersionFull,
4362 dpurdie 210
             '-populate',
211
             @{$pArgs}
4344 dpurdie 212
           );
213
}
214
 
5411 dpurdie 215
#-------------------------------------------------------------------------------
216
# Function        : ToolsetPostprocess 
217
#
218
# Description     : Last chance by the toolset to perform processing
219
#                   All Directives have been processed
220
#
221
#                   If the Project has indicated that it has an automated unit test
222
#                   then we need to post process the results
223
#
224
# Inputs          : None
225
#
226
# Returns         : 
227
#
4344 dpurdie 228
 
5411 dpurdie 229
sub ToolsetPostprocess
230
{
231
    if ($postProcessUnitTest)
232
    {
233
        MakeHeader ("Automated tests Post Processing");
234
 
235
        #   Extend the list of Post Unit Tests recipes that are run
236
        my $recipeName = 'post_utf_processing';
237
        ToolsetAddUnitTestPostProcess($recipeName);
238
 
239
        #
240
        #   Create the Post Unit Test Recipe
241
        #
242
        my $me = MakeEntry::New (*MAKEFILE, $recipeName, '--Phony' );
243
 
244
        #   Insert test EnvVars
245
        #       In the Java toolset these are not as useful in a Jats RunTest
246
        $me->AddDefn('export GBE_UTFNAME', 'AndroidStudioTest');
247
        $me->AddDefn('export GBE_UTFUID', '$(MAKEFILEUID)' . '_' . '1');
248
        $me->AddDefn('export GBE_UTFFILE','$(UTFDIR_PKG)/$(GBE_PLATFORM)-$(GBE_TYPE)-$(GBE_UTFUID)' . '.xml');
6619 dpurdie 249
        $me->AddDefn('export GBE_UTFTEST','TEST-$(GBE_UTFNAME)-$(GBE_TYPE)-$(GBE_UTFUID)' );
5411 dpurdie 250
 
251
        $me->SectionIfDef ('UTF_POSTPROCESS');
252
        $me->AddRecipe  ( [
253
                           '$(GBE_PERL) -Mjats_runutf -e processUtf -- ',
254
                           '$(VERBOSE_OPT)',
255
                           '-filter=androidStudio',
256
                           '-root=$(GBE_ROOT_ABS)',
257
                           '-target=$(GBE_PLATFORM)', 
258
                           '-pkgdir=$(PKGDIR)',
259
                           '-local=$(LOCALDIR)',
260
                           '-interface=$(INTERFACEDIR)' 
261
                          ]);
262
        $me->Print();
263
 
264
        #   Clean up files that look like Junit output files
265
        ToolsetGenerate( 'TEST-*.xml' );
266
    }
267
}
268
 
269
 
4324 dpurdie 270
1;
271