Subversion Repositories DevTools

Rev

Rev 227 | Rev 261 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
#..
2
# Copyright (C) 1998-2005 ERG Transit Systems, All rights reserved
3
#
4
# Module name   : JAVA
5
# Module type   : Makefile system
6
# Compiler(s)   : None
7
# Environment(s): All
8
#
9
# Description:
10
#       This file provides Toolset initialisation and plugin functions
11
#       to makelib.pl2
12
#
13
# Contents:     Basic (very basic) Java support
14
#
15
# Revision History:
16
#       15-Jul-05   DDP     Created
17
#............................................................................#
18
 
19
##############################################################################
20
#   ToolsetInit()
21
#       Runtime initialisation
22
#
23
##############################################################################
24
 
25
ToolsetInit();
26
 
27
sub ToolsetInit
28
{
29
    my( @args ) = @ScmToolsetArgs;             # Toolset arguments
30
    my( $version, $product, @defines, @dirs, @flags );
31
 
32
    #
33
    #   If the user doesn't specify a version, then force a known version
34
    #   1.4 may not be the current flavor, but it was when this was done!
35
    #
36
    $version = 1.4;
37
 
38
#.. Parse arguments
39
#
40
    Debug( "JAVA(@args)\n" );
41
 
42
    foreach $_ ( @args ) {
43
        if (/^--Version=(.*)/) {                # Compiler version
44
            $version = "$1";
45
        } else {
46
            Message( "JAVA: unknown toolset argument $_ -- ignored\n" );
47
        }
48
    }
49
 
50
#.. Parse Platform Arguments
51
#
52
    my( @args ) = @ScmPlatformArgs;             # Platform arguments
53
    foreach $_ ( @args ) {
54
        if (/^--product=(.*)/) {                # GBE product
55
            $product = $1;
56
 
57
        } elsif (/^--Version=(.*)/) {
58
            $version = $1;
59
 
60
        } else {
61
            Message( "JAVA: unknown platform argument $_ -- ignored\n" );
62
        }
63
    }
64
 
65
#.. Toolset configuration
66
#
67
    $::ScmToolsetVersion = "1.0.0";               # our version
68
    $::ScmToolsetGenerate = 0;                    # generate optional
69
    $::ScmToolsetIFLAG3 = 1;                      # supports IFLAG3
70
 
71
#.. Standard.rul requirements
72
#
73
    $s =   'java';          # Assembler source file
74
    $o =   '';              # Object file
75
    $a =   'class';         # Library file
76
    $so =  '';              # Shared library
77
    $exe = '.jar';          # Linked binary images
78
 
79
#.. Pass version information in
80
#
81
    Error ("Java Version has not been set") unless $version;
82
    my $nice_ver = $version;
83
    $nice_ver =~ s~\.~_~g;
84
 
85
    ToolsetDefine ( "\n#..    Specify the version of JAVA to use and the EnvVar that specifies it" );
86
    ToolsetDefine ( "#" );
87
    ToolsetDefine ( "JAVA_VER = $version" );
88
    ToolsetDefine ( "JAVA_HOME_VAR = JAVA_HOME_$nice_ver" );
89
    ToolsetDefine ( "\n" );
90
 
91
#.. Toolset specific definitions
92
#
93
    Init( "java_sdk" );
94
    ToolsetDefines( 'JAVA.DEF' );
95
 
96
}
97
 
98
########################################################################
99
#
100
#   Generate a project from the provided build.xml
101
#   This is aimed at Java
102
#
103
#   Arguments   : $name             - Base name of the project
104
#                 $buildxml         - Path to the build.xml file
105
#                 $pArgs            - Project specific options
106
#                 $auto_test        - Unit Test Target (optional)
107
#                 $unit_test        - Unit Test Target (optional)
108
#                 $pGenerated       - Ref to an array of Generated Files (optional)
109
#
110
########################################################################
111
 
112
our $ToolsetPROJECT_type = 'ant';
113
sub ToolsetPROJECT
114
{
115
    my( $name, $buildxml ,$pArgs, $auto_test, $unit_test, $pGenerated ) = @_;
241 dpurdie 116
    my $cmd = '$(ANT) $(ANT_VERBOSE)';
227 dpurdie 117
    my $io = ToolsetPrinter::New();
118
 
119
    #
120
    #   Generate the recipe to create the project
121
    #   Add names of co-generated targets.
122
    #
123
    $io->Label( "Build project", $name );
124
    $io->Entry( "Project_$name",": $buildxml\n", " \\\n", "" , @{$pGenerated} );
125
    $io->PrtLn( "\t\$(XX_PRE)grep \'includeAntRuntime[ \t]*=[ \t]*\"off\"\' $buildxml || (echo ANT build file MUST specify includeAntRuntime=\"off\" with each javac command; exit 1)" );
126
    $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,)" );
127
    $io->Newline();
128
 
129
    #
130
    #   Generate the recipe to clean the project
131
    #
132
    $io->Label( "Clean project", $name );
133
    $io->PrtLn( "ProjectClean_$name: $buildxml" );
134
    $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,clean)" );
135
    $io->Newline();
136
 
137
    #
138
    #   Generate the recipe to run unit tests on the project
139
    #   This is optional
140
    #
141
    if ( $auto_test )
142
    {
143
        $io->Label( "Auto Test project", $name );
144
        $io->PrtLn( "ProjectATest_$name: $buildxml" );
145
        $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,$auto_test)" );
146
        $io->Newline();
147
    }
148
 
149
    if ( $unit_test )
150
    {
151
        $io->Label( "Unit Test project", $name );
152
        $io->PrtLn( "ProjectUTest_$name: $buildxml" );
153
        $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,$unit_test)" );
154
        $io->Newline();
155
    }
156
 
157
    #
158
    #   Generate macro to contain the project invocation
159
    #   The first argument will be a 'build target' argument
160
    #
161
    $io->Label( "Macro to invoke project", $name );
162
    $io->PrtLn( "define ProjectDefine_$name" );
163
    $io->PrtLn( "\t$cmd -f $buildxml -DINTERFACEDIR=\$(PWD)/\$(INTERFACEDIR) -DGBE_TYPE=\$(GBE_TYPE) @{$pArgs} \$1" );
164
    $io->PrtLn( "endef");
165
    $io->Newline();
166
}
167
 
168
1;
169