Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4324 dpurdie 1
########################################################################
2
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
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;
24
 
25
##############################################################################
26
#   ToolsetInit()
27
#       Runtime initialisation
28
#
29
##############################################################################
30
 
31
ToolsetInit();
32
 
33
sub ToolsetInit
34
{
35
 
36
#.. Toolset configuration
37
#
38
    $::ScmToolsetVersion = "1.0.0";               # our version
39
    $::ScmToolsetGenerate = 0;                    # generate optional
40
 
41
#.. Standard.rul requirements
42
#
4344 dpurdie 43
    $::s =   'java';          # Assembler source file
44
    $::o =   '';              # Object file
45
    $::a =   'class';         # Library file
46
    $::so =  'jar';           # Shared library
47
    $::exe = '.apk';          # Linked binary images
4324 dpurdie 48
 
49
#.. Toolset specific definitions
50
#
51
    Init( "android_sdk" );
52
    ToolsetDefines( 'ANDROID.DEF' );
53
#
54
#.. Locate the AndroidBuilder.pl script
55
#   This will be delivered by a package
56
#
4362 dpurdie 57
    my $program = 'AndroidBuilder.pl';
4324 dpurdie 58
    Verbose("Locate extension Program: $program");
59
    $androidBuilder = ToolExtensionProgram( $program );
60
    Error( "Tool program(s) required by toolset not found:", $program)
61
        unless ($androidBuilder);
62
 
63
    ToolsetDefine ('#   Android Builder Support Tool');
64
    ToolsetDefine ('ANDROIDBUILDER=' . $androidBuilder);
65
 
66
}
67
 
68
########################################################################
69
#
70
#   Generate a project from the provided build.xml
71
#
72
#   Arguments   : $name             - Base name of the project
73
#                 $androidxml       - Path to the AndroidManifest.xml file
74
#                 $pArgs            - Project specific options
75
#                 $auto_test        - Unit Test Target (optional)
76
#                 $unit_test        - Unit Test Target (optional)
77
#                 $pGenerated       - Ref to an array of Generated Files (optional)
78
#
79
########################################################################
80
 
81
our $ToolsetPROJECT_type = 'android';
82
sub ToolsetPROJECT
83
{
84
    my( $name, $androidxml ,$pArgs, $auto_test, $unit_test, $pGenerated ) = @_;
85
 
86
    #
4949 dpurdie 87
    #   Kludge Alert
88
    #       The AndroidStudioBuilder needs to target platform
89
    #       The AndroidBuilder cannot handle this argument
90
    #       Luckily the AndroidStudioBuilder builds under windows
91
    #       and the AndroidBuilder under unix 
92
    #
93
    if ($::GBE_HOSTMACH eq 'win32')
94
    {
95
        push @{$pArgs}, '-pf', $::ScmPlatform;
96
    }
97
 
98
    #
4344 dpurdie 99
    #   Populate the project for the user
100
    #
101
    ToolsetPROJECTPreBuild (@_);
102
 
103
    #
4324 dpurdie 104
    #   Generate the recipe to create the project
105
    #   Add names of co-generated targets.
106
    #
4344 dpurdie 107
    my $me = MakeEntry::New (*MAKEFILE, 'Project_'.$name );
108
    $me->AddComment ("Build Android Project: $name" );
109
    $me->AddDependancy ( $androidxml );
110
    $me->AddDependancy ( '$(SCM_MAKEFILE)' );
111
    $me->AddDependancy ( @{$pGenerated} );
112
    $me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,)"  );
113
    $me->Print();
4324 dpurdie 114
 
115
    #
116
    #   Generate the recipe to clean the project
117
    #
4344 dpurdie 118
    $me = MakeEntry::New (*MAKEFILE, 'ProjectClean_'.$name );
119
    $me->AddComment ("Clean Android Project: $name" );
120
    $me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,-clean)"  );
121
    $me->Print();
4324 dpurdie 122
 
123
    #
124
    #   Generate the recipe to run unit tests on the project
125
    #   This is optional
126
    #
127
    if ( $auto_test )
128
    {
4344 dpurdie 129
        $me = MakeEntry::New (*MAKEFILE, 'ProjectATest_'.$name );
130
        $me->AddComment ("Auto Test project: $name" );
131
        $me->AddDependancy ( $androidxml );
132
        $me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,$auto_test)"  );
133
        $me->Print();
4324 dpurdie 134
    }
135
 
136
    if ( $unit_test )
137
    {
4344 dpurdie 138
        $me = MakeEntry::New (*MAKEFILE, 'ProjectUTest_'.$name );
139
        $me->AddComment ("Unit Test project: $name" );
140
        $me->AddDependancy ( $androidxml );
141
        $me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,$unit_test)"  );
142
        $me->Print();
4324 dpurdie 143
    }
144
 
145
    #
146
    #   Generate macro to contain the project invocation
147
    #   The first argument will be a 'build target' argument
148
    #
4344 dpurdie 149
    my @cmdargs;
150
    push @cmdargs, '$(GBE_PERL)','$(ANDROIDBUILDER)';
151
    push @cmdargs, '-f', $androidxml;
152
    push @cmdargs, '-i=$(PWD)/$(INTERFACEDIR)';
153
    push @cmdargs, '-t=$(GBE_TYPE)';
154
    push @cmdargs, '-pn=$(GBE_PBASE) -pv=$(BUILDVER)';
155
    push @cmdargs, @{$pArgs}, '$1';
156
 
157
    $me = MakeEntry::New (*MAKEFILE, 'ProjectDefine_'.$name, '--Define' );
158
    $me->AddComment ("Macro to invoke project: $name" );
159
    $me->AddRecipe ( join(' ', @cmdargs)  );
160
    $me->Print();
4324 dpurdie 161
}
162
 
4344 dpurdie 163
#-------------------------------------------------------------------------------
164
# Function        : ToolsetPROJECTPreBuild 
165
#
166
# Description     : This ANDROID Specific operation is used to perform some of the 
167
#                   build opertaions at 'build' time. These include:
168
#                       - Verify that required packages are available
169
#                       - Populate the targets 'libs' directory so that the user can
170
#                         develop with the external dependencies in place 
171
#
172
# Inputs          : $name             - Base name of the project
173
#                   $androidxml       - Path to the AndroidManifest.xml file
174
#                   $pArgs            - Project specific options
175
#                   $auto_test        - Unit Test Target (optional)
176
#                   $unit_test        - Unit Test Target (optional)
177
#                   $pGenerated       - Ref to an array of Generated Files (optional)
178
#
179
# Returns         : Nothing
180
#
181
sub ToolsetPROJECTPreBuild
182
{
183
    my( $name, $androidxml ,$pArgs, $auto_test, $unit_test, $pGenerated ) = @_;
184
 
185
    #
186
    #   Invoke the androidBuilder in a mode so that it will populate the Eclipse project
187
    #   in a suitable manner.
188
    #
189
    #   In the build phase there is no 'debug' or 'production' phase
190
    #   Assume debug - if it needs to be determined
191
    #
4949 dpurdie 192
 
4344 dpurdie 193
    EnvImport( "GBE_PERL" );
194
    System ( '--NoShell', '--Exit', $::GBE_PERL, $androidBuilder, 
195
             '-f', $androidxml,
196
             '-i', catdir( $::ScmRoot, $::ScmInterface),
197
             '-t', 'D',
198
             '-pn', $::Pbase,
199
             '-pv', $::ScmBuildVersionFull,
4362 dpurdie 200
             '-populate',
201
             @{$pArgs}
4344 dpurdie 202
           );
203
}
204
 
205
 
4324 dpurdie 206
1;
207