Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1612 dpurdie 1
########################################################################
2
# Copyright (C) 2008 ERG Limited, All rights reserved
3
#
4
# Module name   : wsdl-tools
5
# Module type   : JATS Plugin
6
# Compiler(s)   : Perl
7
# Environment(s): JATS
8
#
9
# Description   : This package extends the JATS toolset at build time
10
#                 It provides additional directives to the JATS makefiles
11
#                 to simplify the directives.
12
#
13
#                 The directive matches up with a run-time tool to
14
#                 do the bulk of the work.
15
#
16
# Operation     : This package adds the JATS directive GenerateWsdls
17
#                 When used the directive will use GenerateFiles to invoke
18
#                 a program at make-time to actually do the hard work.
19
#
20
# Directives    : GenerateWsdls (platform, Library, ... )
21
#                 GenerateWSClasses (platform, Wsdl, ... )
22
#
23
#......................................................................#
24
 
25
use strict;
26
use warnings;
27
use File::Basename;
28
use JatsError;
29
 
30
#
31
#   Global JATS-internal variables
32
#
33
our @WSDLS;                         # Complete list of WSDLs defined in makefile
34
our $so;                            # Toolset dependent shared library suffix
35
our %SHLIB_LIBS;                    # Hash keyed by known Shared Libraries
36
 
37
#-------------------------------------------------------------------------------
38
# Function        : GenerateWsdls
39
#
40
# Description     : Generate WSDL files from a Web Services DLL
41
#                   This directive simplifies the process of invoking the
42
#                   utility
43
#
44
# Inputs          : platform          - Standard Platform Specifier
45
#                   dll               - Name of the source DLL
46
#                   uargs             - User options
47
#
48
#                     --Wsdl=Name     - Name of WSDL that will be generated
49
#                                       Multiple allowed
50
#                                       .WSDL suffix will be added if not present
51
#                                       Names will be added to the @WSDL array
52
#                                       This can be used to simplify packaging
53
#                     --Url=url       - URL Used in the creation of the WSDL
54
#                                       Optional
55
#                     --EnvVar=Name   - Name of EnvVar to scan looking for dependent
56
#                                       DLLs. Optional. Multiple allowed
57
#                     --NoSuffix      - Do not append P or D to the name of the
58
#                                       DLL. Optional.
59
#                     --Verbose       - Increase execution messages
60
#
61
# Returns         : Nothing
62
#                   Creates a WSDL array to simplify Packaging
63
#                   Will contain the list of created WSDL files.
64
#
65
sub GenerateWsdls
66
{
67
    my ($platforms, $dll, @uargs) = @_;
68
    my @wsdls;
69
    my @envvar;
70
    my $url;
71
    my $suffix = '$(GBE_TYPE)';
72
    my $prefix = '';
73
    my @args;
74
 
75
    return if ( ! ActivePlatform($platforms) );
76
 
77
    #
78
    #   Parse arguments
79
    #
80
    foreach ( @uargs )
81
    {
82
        if ( /^--Wsdl=(.+)/i ) {
83
            my $name = $1;
84
            $name .= '.wsdl' unless ( $name =~ m~\.wsdl~i );
85
            push @wsdls, $name;
86
 
87
        } elsif ( /^--EnvVar=(.+)/i ) {
88
            push @envvar, $1;
89
 
90
        } elsif ( /^--Url=(.+)/i ) {
91
            $url = $1;
92
 
93
        } elsif ( /--NoSuffix/i ) {
94
            $suffix = '';
95
 
96
        } elsif ( /--Verbose/i ) {
97
            push @args, '/v';
98
 
99
        } else {
100
            Error ("GenerateWsdls: Unknown option: $_");
101
        }
102
    }
103
 
104
    Error ("GenerateWsdls: No DLL specified" )
105
        unless ( $dll );
106
    Error ("GenerateWsdls: No WSDLs specified" )
107
        unless ( @wsdls );
108
 
109
    #
110
    #   Attempt to locate the source DLL
111
    #       - It may be created within this make file
112
    #       - It may be within this package (not handled)
113
    #       - May be in an external package (not handled)
114
    #
115
    if ( exists $SHLIB_LIBS{$dll} )
116
    {
117
        #
118
        #   Is a locally generated DLL
119
        #   We make assumptions about its name and location
120
        #
121
        $prefix = '$(LIBDIR)/';
122
    }
123
 
124
    #
125
    #   Generate a nice command for the user
126
    #
127
    push @args, '--Prerequisite[' . $prefix . $dll . $suffix . '.' . $so . ']';
128
    push @args, '/r:' . $url if ( $url );
129
    push @args, '/o:--Var(ObjDir,--notag)/';
130
    push @args, '/p:' . $_ foreach ( @envvar );
131
    push @args, '--Created=' . $_  foreach ( @wsdls );
132
 
133
    #
134
    #   Generate the files
135
    #   Use standard JATS directive
136
    #
137
    GenerateFiles ('*', '--Tool=WsdlExtract', '--AutoGenerate', @args );
138
 
139
    #
140
    #   Add wsdl files created by this instance of the directive to the
141
    #   global list of all WSDLs created within the users makefile.pl
142
    #
143
    push @WSDLS, @wsdls;
144
 
145
}
146
 
147
#-------------------------------------------------------------------------------
148
# Function        : GenerateWSClasses
149
#
150
# Description     : Generate Csharp proxy from a WSDL
151
#
152
# Inputs          : $platforms              - Platform selector
153
#                   $wsdl                   - Source file
154
#                   Options
155
#                           --Namespace=NameSpace
156
#
157
# Returns         : 
158
#
159
sub GenerateWSClasses
160
{
161
    my ($platforms, $wsdl, @uargs) = @_;
162
    my $namespace;
163
    my @args;
164
 
165
    return if ( ! ActivePlatform($platforms) );
166
 
167
    #
168
    #   Parse arguments
169
    #
170
    foreach ( @uargs )
171
    {
172
        if ( /^--NameSpace=(.+)/i ) {
173
            $namespace = $1;
174
 
175
        } else {
176
            Error ("GenerateProxy: Unknown option: $_");
177
        }
178
    }
179
 
180
    Error ("GenerateProxy: No WSDL specified" )
181
        unless ( $wsdl );
182
 
183
    #
184
    #   Create a nice name for output file
185
    #       Prepend Jats_
186
    #       Append .cs - as it will be C# source
187
    #
188
    my $name =  'Jats_' . fileparse($wsdl, '\.[^.]+$') . '.cs';
189
 
190
    #
191
    #   Create command line
192
    #
193
    push @args, '--Prerequisite[' . $wsdl . ']';
194
    push @args, '/namespace:' . $namespace if ( $namespace );
195
    push @args, '/out:--Generated(' . $name . ')';
196
 
197
    #
198
    #   Generate the files
199
    #   Use standard JATS directive
200
    #
201
    GenerateFiles ('*', '--Tool=wsdl', '/nologo', @args );
202
}
203
 
204
1;