Subversion Repositories DevTools

Rev

Rev 4362 | Details | Compare with Previous | 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
    #
4344 dpurdie 87
    #   Populate the project for the user
88
    #
89
    ToolsetPROJECTPreBuild (@_);
90
 
91
    #
4324 dpurdie 92
    #   Generate the recipe to create the project
93
    #   Add names of co-generated targets.
94
    #
4344 dpurdie 95
    my $me = MakeEntry::New (*MAKEFILE, 'Project_'.$name );
96
    $me->AddComment ("Build Android Project: $name" );
97
    $me->AddDependancy ( $androidxml );
98
    $me->AddDependancy ( '$(SCM_MAKEFILE)' );
99
    $me->AddDependancy ( @{$pGenerated} );
100
    $me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,)"  );
101
    $me->Print();
4324 dpurdie 102
 
103
    #
104
    #   Generate the recipe to clean the project
105
    #
4344 dpurdie 106
    $me = MakeEntry::New (*MAKEFILE, 'ProjectClean_'.$name );
107
    $me->AddComment ("Clean Android Project: $name" );
108
    $me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,-clean)"  );
109
    $me->Print();
4324 dpurdie 110
 
111
    #
112
    #   Generate the recipe to run unit tests on the project
113
    #   This is optional
114
    #
115
    if ( $auto_test )
116
    {
4344 dpurdie 117
        $me = MakeEntry::New (*MAKEFILE, 'ProjectATest_'.$name );
118
        $me->AddComment ("Auto Test project: $name" );
119
        $me->AddDependancy ( $androidxml );
120
        $me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,$auto_test)"  );
121
        $me->Print();
4324 dpurdie 122
    }
123
 
124
    if ( $unit_test )
125
    {
4344 dpurdie 126
        $me = MakeEntry::New (*MAKEFILE, 'ProjectUTest_'.$name );
127
        $me->AddComment ("Unit Test project: $name" );
128
        $me->AddDependancy ( $androidxml );
129
        $me->AddRecipe ( "\$(XX_PRE)\$(call ProjectDefine_$name,$unit_test)"  );
130
        $me->Print();
4324 dpurdie 131
    }
132
 
133
    #
134
    #   Generate macro to contain the project invocation
135
    #   The first argument will be a 'build target' argument
136
    #
4344 dpurdie 137
    my @cmdargs;
138
    push @cmdargs, '$(GBE_PERL)','$(ANDROIDBUILDER)';
139
    push @cmdargs, '-f', $androidxml;
140
    push @cmdargs, '-i=$(PWD)/$(INTERFACEDIR)';
141
    push @cmdargs, '-t=$(GBE_TYPE)';
142
    push @cmdargs, '-pn=$(GBE_PBASE) -pv=$(BUILDVER)';
143
    push @cmdargs, @{$pArgs}, '$1';
144
 
145
    $me = MakeEntry::New (*MAKEFILE, 'ProjectDefine_'.$name, '--Define' );
146
    $me->AddComment ("Macro to invoke project: $name" );
147
    $me->AddRecipe ( join(' ', @cmdargs)  );
148
    $me->Print();
4324 dpurdie 149
}
150
 
4344 dpurdie 151
#-------------------------------------------------------------------------------
152
# Function        : ToolsetPROJECTPreBuild 
153
#
154
# Description     : This ANDROID Specific operation is used to perform some of the 
155
#                   build opertaions at 'build' time. These include:
156
#                       - Verify that required packages are available
157
#                       - Populate the targets 'libs' directory so that the user can
158
#                         develop with the external dependencies in place 
159
#
160
# Inputs          : $name             - Base name of the project
161
#                   $androidxml       - Path to the AndroidManifest.xml file
162
#                   $pArgs            - Project specific options
163
#                   $auto_test        - Unit Test Target (optional)
164
#                   $unit_test        - Unit Test Target (optional)
165
#                   $pGenerated       - Ref to an array of Generated Files (optional)
166
#
167
# Returns         : Nothing
168
#
169
sub ToolsetPROJECTPreBuild
170
{
171
    my( $name, $androidxml ,$pArgs, $auto_test, $unit_test, $pGenerated ) = @_;
172
 
173
    #
174
    #   Invoke the androidBuilder in a mode so that it will populate the Eclipse project
175
    #   in a suitable manner.
176
    #
177
    #   In the build phase there is no 'debug' or 'production' phase
178
    #   Assume debug - if it needs to be determined
179
    #
180
    EnvImport( "GBE_PERL" );
181
    System ( '--NoShell', '--Exit', $::GBE_PERL, $androidBuilder, 
182
             '-f', $androidxml,
183
             '-i', catdir( $::ScmRoot, $::ScmInterface),
184
             '-t', 'D',
185
             '-pn', $::Pbase,
186
             '-pv', $::ScmBuildVersionFull,
4362 dpurdie 187
             '-populate',
188
             @{$pArgs}
4344 dpurdie 189
           );
190
}
191
 
192
 
4324 dpurdie 193
1;
194