Subversion Repositories DevTools

Rev

Rev 3839 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3839 dpurdie 1
########################################################################
2
# Copyright (C) 1998-2013 Vix Technology, All rights reserved
3
#
4
# Module name   : MakePax.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   : Build Wrpper for the MakePax directive
10
#                 This script is invoked at 'make' time
11
#                 A perl script is used to provide a little bit of flexability
12
#
13
# Usage:        : Invoked by JAT make system
14
#
15
#......................................................................#
16
 
17
require 5.008_002;
18
use strict;
19
use warnings;
20
 
21
use Pod::Usage;
22
use Getopt::Long;
3852 dpurdie 23
use File::Path;
3839 dpurdie 24
 
25
use JatsError;
26
use JatsSystem;
27
use FileUtils;
28
 
29
#
30
#   Globals
31
#
32
 
33
#
34
#   Command line options
35
#
36
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
37
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
38
my $opt_vargs;                              # Verbose arg
39
my $opt_help = 0;
40
my $opt_manual = 0;
41
my $opt_clean = 0;
42
my $opt_platform;
43
my $opt_buildname;
44
my $opt_buildversion;
45
my $opt_interfacedir;
46
my $opt_pkgdir;
47
my $opt_component;
48
my $opt_src;
49
 
50
#-------------------------------------------------------------------------------
51
# Function        : Main Entry point
52
#
53
# Description     : This function will be called when the package is initialised
54
#                   Extract arguments from the users environment
55
#
56
#                   Done here to greatly simplify the user script
57
#                   There should be no junk in the user script - keep it simple
58
#
59
# Inputs          :
60
#
61
# Returns         : 
62
#
63
main();
64
 
65
sub main
66
{
67
    my $dist_tree;
68
    my @make_args;
69
 
70
    my $result = GetOptions (
71
                "verbose:s"         => \$opt_vargs,
72
                "clean"             => \$opt_clean,
73
                "BuildName=s"       => \$opt_buildname,
74
                "BuildVersion=s"    => \$opt_buildversion,
75
                "Platform=s"        => \$opt_platform,
76
                "InterfaceDir=s"    => \$opt_interfacedir,
77
                "PackageDir=s"      => \$opt_pkgdir,
78
                "Component=s"       => \$opt_component,
79
                "Src=s"             => \$opt_src,
80
    );
81
 
82
    ErrorConfig( 'name'    => 'MakePax',
83
                 'verbose' => $opt_verbose,
84
                 'debug'   => $opt_debug );
85
 
86
    #
87
    #   Init the FileSystem Uiltity interface
88
    #
89
    InitFileUtils();
90
 
91
    #
92
    #   Ensure that we have all required options
93
    #
94
    Error ("BuildName not set")                 unless ( $opt_buildname );
95
    Error ("BuildVersion not set")              unless ( $opt_buildversion );
96
    Error ("InterfaceDir not set")              unless ( $opt_interfacedir );
97
    Error ("Package Dir not set")               unless ( $opt_pkgdir );
98
    Error ("Component not set")                 unless ( $opt_component );
99
    Error ("Source not set")                    unless ( $opt_src );
100
 
101
    #
102
    #   A few sanity checks
103
    #
104
    Error ("Cannot find 'intellect.bat'. This file was generated by JATS")
105
        unless ( -f 'intellect.bat' );
106
 
107
 
108
    Error ("Source does not contain a 'makefile'", 'Src:' . $opt_src)
109
        unless ( -f join('/', $opt_src, 'makefile') );
110
 
111
    #
112
    #   Define some global values
113
    #
114
    push @make_args, '-c', $opt_src;
115
    push @make_args, "-DDIST_PLATFORM=$opt_platform" if ( $opt_platform );
116
    push @make_args, '-DMAKE_VERBOSE=1' if $opt_vargs;
117
 
118
    $dist_tree = FullPath(join('/', $opt_pkgdir, 'pkg', $opt_component));
119
 
120
    #
121
    #   Clean package
122
    #
123
    if ( $opt_clean )
124
    {
125
        Message ("Clean Pax Build");
126
        runMake( @make_args, 'very_clean' );
127
        exit 0;
128
    }
129
 
130
 
131
    #
132
    #   Build Package
133
    #       Remove packageing output
134
    #       Make install - in tree
135
    #       Make install - - for packaging
136
    #
137
    RmDirTree($dist_tree);
3852 dpurdie 138
    mkpath($dist_tree, 0, 0775);
3839 dpurdie 139
    Message ("Build Software");
140
    runMake( @make_args, 'install' );
141
 
142
    Message ("Package Software");
143
    runMake( @make_args, '-DDIST_TREE=' . $dist_tree, 'install' );
144
}
145
 
146
#-------------------------------------------------------------------------------
147
# Function        : runMake
148
#
149
# Description     : Run the PAX Builder Make command in the PAX Builder
150
#                   environment - as setup by intellect.bat
151
#
152
# Inputs          : Array of make arguments
153
#
154
# Returns         : Will not return on error
155
#
156
sub runMake
157
{
158
    my (@args) = @_;
159
    System ('--Exit','--NoShell','intellect.bat', 'make', @args );
160
}
161
 
162
 
3852 dpurdie 163