Subversion Repositories DevTools

Rev

Go to most recent revision | Details | 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
#
261 dpurdie 52
    @args = @ScmPlatformArgs;                   # Platform arguments
227 dpurdie 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
 
70
#.. Standard.rul requirements
71
#
72
    $s =   'java';          # Assembler source file
73
    $o =   '';              # Object file
74
    $a =   'class';         # Library file
75
    $so =  '';              # Shared library
76
    $exe = '.jar';          # Linked binary images
77
 
78
#.. Pass version information in
79
#
80
    Error ("Java Version has not been set") unless $version;
81
    my $nice_ver = $version;
82
    $nice_ver =~ s~\.~_~g;
83
 
84
    ToolsetDefine ( "\n#..    Specify the version of JAVA to use and the EnvVar that specifies it" );
85
    ToolsetDefine ( "#" );
86
    ToolsetDefine ( "JAVA_VER = $version" );
87
    ToolsetDefine ( "JAVA_HOME_VAR = JAVA_HOME_$nice_ver" );
88
    ToolsetDefine ( "\n" );
89
 
90
#.. Toolset specific definitions
91
#
92
    Init( "java_sdk" );
93
    ToolsetDefines( 'JAVA.DEF' );
94
 
95
}
96
 
97
########################################################################
98
#
99
#   Generate a project from the provided build.xml
100
#   This is aimed at Java
101
#
102
#   Arguments   : $name             - Base name of the project
103
#                 $buildxml         - Path to the build.xml file
104
#                 $pArgs            - Project specific options
105
#                 $auto_test        - Unit Test Target (optional)
106
#                 $unit_test        - Unit Test Target (optional)
107
#                 $pGenerated       - Ref to an array of Generated Files (optional)
108
#
109
########################################################################
110
 
111
our $ToolsetPROJECT_type = 'ant';
112
sub ToolsetPROJECT
113
{
114
    my( $name, $buildxml ,$pArgs, $auto_test, $unit_test, $pGenerated ) = @_;
241 dpurdie 115
    my $cmd = '$(ANT) $(ANT_VERBOSE)';
227 dpurdie 116
    my $io = ToolsetPrinter::New();
117
 
118
    #
119
    #   Generate the recipe to create the project
120
    #   Add names of co-generated targets.
121
    #
122
    $io->Label( "Build project", $name );
123
    $io->Entry( "Project_$name",": $buildxml\n", " \\\n", "" , @{$pGenerated} );
124
    $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)" );
125
    $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,)" );
126
    $io->Newline();
127
 
128
    #
129
    #   Generate the recipe to clean the project
130
    #
131
    $io->Label( "Clean project", $name );
132
    $io->PrtLn( "ProjectClean_$name: $buildxml" );
133
    $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,clean)" );
134
    $io->Newline();
135
 
136
    #
137
    #   Generate the recipe to run unit tests on the project
138
    #   This is optional
139
    #
140
    if ( $auto_test )
141
    {
142
        $io->Label( "Auto Test project", $name );
143
        $io->PrtLn( "ProjectATest_$name: $buildxml" );
144
        $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,$auto_test)" );
145
        $io->Newline();
146
    }
147
 
148
    if ( $unit_test )
149
    {
150
        $io->Label( "Unit Test project", $name );
151
        $io->PrtLn( "ProjectUTest_$name: $buildxml" );
152
        $io->PrtLn( "\t\$(XX_PRE)\$(call ProjectDefine_$name,$unit_test)" );
153
        $io->Newline();
154
    }
155
 
156
    #
157
    #   Generate macro to contain the project invocation
158
    #   The first argument will be a 'build target' argument
159
    #
160
    $io->Label( "Macro to invoke project", $name );
161
    $io->PrtLn( "define ProjectDefine_$name" );
162
    $io->PrtLn( "\t$cmd -f $buildxml -DINTERFACEDIR=\$(PWD)/\$(INTERFACEDIR) -DGBE_TYPE=\$(GBE_TYPE) @{$pArgs} \$1" );
163
    $io->PrtLn( "endef");
164
    $io->Newline();
165
}
166
 
167
1;
168