Subversion Repositories DevTools

Rev

Rev 4344 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

########################################################################
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
#
# Module name   : ANDROID.PL
# Module type   : Makefile system
# Compiler(s)   : Perl
# Environment(s): jats
#
# Description:
#       This file provides Toolset initialisation and plugin functions
#       to makelib.pl2
#
# Contents:     Basic (very basic) Android support
#
#............................................................................#

#
#   Globals
#
my $androidBuilder;

##############################################################################
#   ToolsetInit()
#       Runtime initialisation
#
##############################################################################

ToolsetInit();

sub ToolsetInit
{

#.. Toolset configuration
#
    $::ScmToolsetVersion = "1.0.0";               # our version
    $::ScmToolsetGenerate = 0;                    # generate optional

#.. Standard.rul requirements
#
    $s =   'java';          # Assembler source file
    $o =   '';              # Object file
    $a =   'class';         # Library file
    $so =  'jar';           # Shared library
    $exe = '.apk';          # Linked binary images

#.. Toolset specific definitions
#
    Init( "android_sdk" );
    ToolsetDefines( 'ANDROID.DEF' );
#
#.. Locate the AndroidBuilder.pl script
#   This will be delivered by a package
#
    my $program = 'androidBuilder.pl';
    Verbose("Locate extension Program: $program");
    $androidBuilder = ToolExtensionProgram( $program );
    Error( "Tool program(s) required by toolset not found:", $program)
        unless ($androidBuilder);

    ToolsetDefine ('#   Android Builder Support Tool');
    ToolsetDefine ('ANDROIDBUILDER=' . $androidBuilder);

}

########################################################################
#
#   Generate a project from the provided build.xml
#
#   Arguments   : $name             - Base name of the project
#                 $androidxml       - Path to the AndroidManifest.xml file
#                 $pArgs            - Project specific options
#                 $auto_test        - Unit Test Target (optional)
#                 $unit_test        - Unit Test Target (optional)
#                 $pGenerated       - Ref to an array of Generated Files (optional)
#
########################################################################

our $ToolsetPROJECT_type = 'android';
sub ToolsetPROJECT
{
    my( $name, $androidxml ,$pArgs, $auto_test, $unit_test, $pGenerated ) = @_;
    my $io = ToolsetPrinter::New();

    #
    #   Generate the recipe to create the project
    #   Add names of co-generated targets.
    #
    $io->Label( "Build project", $name );
    $io->Entry( "Project_$name",": $androidxml\n", " \\\n", "" , @{$pGenerated} );
    $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,)" );
    $io->Newline();

    #
    #   Generate the recipe to clean the project
    #
    $io->Label( "Clean project", $name );
    $io->PrtLn( "ProjectClean_$name: $androidxml" );
    $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,-clean)" );
    $io->Newline();

    #
    #   Generate the recipe to run unit tests on the project
    #   This is optional
    #
    if ( $auto_test )
    {
        $io->Label( "Auto Test project", $name );
        $io->PrtLn( "ProjectATest_$name: $androidxml" );
        $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,$auto_test)" );
        $io->Newline();
    }

    if ( $unit_test )
    {
        $io->Label( "Unit Test project", $name );
        $io->PrtLn( "ProjectUTest_$name: $androidxml" );
        $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,$unit_test)" );
        $io->Newline();
    }

    #
    #   Generate macro to contain the project invocation
    #   The first argument will be a 'build target' argument
    #
    $io->Label( "Macro to invoke project", $name );
    $io->PrtLn( "define ProjectDefine_$name" );
    $io->PrtLn( "\t\$(GBE_PERL) \$(ANDROIDBUILDER) -f $androidxml -i=\$(PWD)/\$(INTERFACEDIR) -t=\$(GBE_TYPE) -pn=\$(GBE_PBASE) -pv=\$(BUILDVER) @{$pArgs} \$1" );
    $io->PrtLn( "endef");
    $io->Newline();
}

1;