Skip to content
Snippets Groups Projects
packageBinaries.pl 53.5 KiB
Newer Older
# Copyright 1999-2004 The Apache Software Foundation.
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#      http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Ted Leung's avatar
Ted Leung committed

push(@INC, "/home/xml4c/bin", "/home/xml4c/bin/perl/perl-RUN/opt/perl5/lib", "/Development2/cupert/bin/perl/perl-RUN/opt/perl5/lib", "/Development/cupert/usr/local/perl/perl-RUN/opt/perl5/lib");
Ted Leung's avatar
Ted Leung committed

require "getopt.pl";
Ted Leung's avatar
Ted Leung committed

$|=1;   # Force a flush after every print

my $XERCESCROOT = $opt_s;
my $targetdir              = $opt_o;
my $ICUROOT           = $ENV{'ICUROOT'};
my $ICUIsPresent      = (($opt_t =~ m/icu/i || $opt_m =~ m/icu/i) && length($ICUROOT) > 0);
my $ICUResourceDir = "$XERCESCROOT/src/xercesc/util/MsgLoaders/ICU/resources";
    
Ted Leung's avatar
Ted Leung committed
# Check for the environment variables and exit if error
Rahul Jain's avatar
Rahul Jain committed
if (!length($XERCESCROOT) || !length($targetdir) || (length($opt_h) > 0) ) {
    print ("Usage is: packageBinaries <options>\n");
Rahul Jain's avatar
Rahul Jain committed
    print ("  where options are:\n");
    print ("    -s <source_directory>\n");
    print ("    -o <target_directory>\n");
    print ("    -c <C compiler name> (e.g. gcc, cc, xlc_r, VC6, VC7, ecl or icl)\n");
    print ("    -x <C++ compiler name> (e.g. g++, CC, aCC, c++, xlC_r, cl, ecl, ecc, icl, VC6 or VC7)\n");
Rahul Jain's avatar
Rahul Jain committed
    print ("    -m <message loader> can be 'inmem' \(default\), 'icu' or 'iconv'\n");
    print ("    -n <net accessor> can be 'fileonly' or 'socket' \(default\)\n");
    print ("    -t <transcoder> can be 'icu' or 'native' \(default\)\n");
    print ("    -r <thread option> can be 'pthread' \(default\)or 'dce' (only used on HP-11)\n");
    print ("    -b <bitsToBuild> (accepts '64', '32')\n");
    print ("    -j suppress building of ICU (speeds up builds when debugging)\n");
Rahul Jain's avatar
Rahul Jain committed
    print ("    -h to get help on these commands\n\n");
    print ("Example: Under unix's\n");
PeiYong Zhang's avatar
PeiYong Zhang committed
    print ("    perl packageBinaries.pl -s \$HOME/xerces-c-src2_6");
    print (" -o \$HOME/xerces-c2_6-linux -c gcc -x g++ -m inmem -n fileonly -t native\n\n");
Rahul Jain's avatar
Rahul Jain committed
    print ("Example: Under Windows\n");
PeiYong Zhang's avatar
PeiYong Zhang committed
    print ("    perl packageBinaries.pl -s \\xerces-c-src2_6");
    print (" -o\\xerces-c2_5-win32 [-n fileonly] [-t icu]\n\n");
    print ("Note:\n");
    print ("    Under Windows, by default the XercesLib project files is\n");
    print ("    configured to use Win32 resource file based message loader,\n");
    print ("    WinSocket based net accessor and native Win32 based transcoder.\n");
    print ("    The two options mentioned in the example above are the only\n");
    print ("    options relevant under Windows on the command line for this script.\n");
Ted Leung's avatar
Ted Leung committed
}

if (($opt_t =~ m/icu/i || $opt_m =~ m/icu/i) && (length($ICUROOT) == 0)) {
    print "You have specified an ICU build but you have not defined your ICU install directory.\n";
    print "To build with ICU, you must set an environment variable called ICUROOT\n";
    print "Cannot proceed any further.\n";
    exit(-1);
Ted Leung's avatar
Ted Leung committed
}
Ted Leung's avatar
Ted Leung committed
# Check if the source directory exists or not
Rahul Jain's avatar
Rahul Jain committed
if (!(-e $XERCESCROOT)) {
    print ("The directory $XERCESCROOT does not exist. Cannot proceed any further.\n");
    exit(-1);
Ted Leung's avatar
Ted Leung committed
}

# Check if the target directory exists, exit if it does
if (-e $targetdir) {
    print ("Error: The target directory \'$targetdir\' already exists.\n");
    print ("       You must start with a clean directory to package your product.\n");
    exit(1);
Ted Leung's avatar
Ted Leung committed
}

Tinny Ng's avatar
Tinny Ng committed
# Find out the platform from 'uname -s'
open(PLATFORM, "uname -s|");
$platform = <PLATFORM>;
chomp($platform);
close (PLATFORM);
Ted Leung's avatar
Ted Leung committed

#Fix the backslashes on the Windows platform
$XERCESCROOT =~ s/\\/\//g;
$ICUROOT =~ s/\\/\//g;
$targetdir =~ s/\\/\//g;

print "Packaging binaries for \`" . $platform . "\` in " . $targetdir . " ...\n";   # "
Ted Leung's avatar
Ted Leung committed

#Construct the name of the zip file by extracting the last directory name
$zipfiles =~ s/.*(\/|\\)([\w-\.]*)$/$2/g;
$zipfiles = $zipfiles . "/*";
Ted Leung's avatar
Ted Leung committed

#   WINDOWS builds happen here, as long as they
#     aren't using gcc...
#
#  Tasks:
#
#    Preparation
#          Initialize Vars
#          Make the target directory and its main subdirectories
#          'FileOnly' NetAccessor
#
#   Build
#          ICU and/or Resource bundle library for ICUMsgLoader
#          Xerces-C libraries, samples and tests
#
#   Population
#          include
#          ICU and/or ICUMsgLoader
#          Xerces-C libraries, samples and tests
#          Documentation
if ($platform =~ m/Windows/  || ($platform =~ m/CYGWIN/ && !($opt_c =~ m/gcc/))) {
#
# Preparation Begin
#
#    Preparation::Initialize Vars
#
    my $PlatformName = 'Win32'; 
    my $DevStudioVer = "6.0";
    my $VCBuildDir     = "VC6";
    my $Transcoder     = 0;
    my $MsgLoader     = 0;

    my $ReleaseBuildDir  = undef;
    my $DebugBuildDir    = undef;
    my $ProjectDir          = undef;
                        
    if ($opt_b eq "64") {
        $PlatformName = 'Win64';
    }
      
    if ($opt_x eq "" || $opt_x =~ m/VC6/i )
        $DevStudioVer = "6.0";
        $VCBuildDir     = "VC6"; 
        $ProjectDir      = "$XERCESCROOT/Projects/Win32/$VCBuildDir/xerces-all";
        $DevStudioVer = "7.0";
        $VCBuildDir     = "VC7"; 
        $ProjectDir      = "$XERCESCROOT/Projects/Win32/$VCBuildDir/xerces-all";
Tinny Ng's avatar
Tinny Ng committed
    }
    elsif ($opt_x =~ m/ecl/i || $opt_x =~ m/icl/i )
    {
        $DevStudioVer = "6.1";
        $VCBuildDir     = "VC6"; 
        $PlatformName = "Win64";
        $ProjectDir       = "$XERCESCROOT/Projects/Win32/$VCBuildDir/xerces-all/all";
    else
    {
        print ("Error: Invalid compilers used \n");
        print ("-x <C++ compiler name> VC6, VC7, ecl and icl \n");        
    $ReleaseBuildDir = "$XERCESCROOT/Build/$PlatformName/$VCBuildDir/Release";
    $DebugBuildDir   = "$XERCESCROOT/Build/$PlatformName/$VCBuildDir/Debug";    
        
    if ($opt_t =~ m/icu/i ) {
        $Transcoder = 1;
                
    print "PlatformName    =$PlatformName\n";
    print "DevStudioVer    =$DevStudioVer\n";
    print "VCBuildDir        =$VCBuildDir\n";
    print "ReleaseBuildDir =$ReleaseBuildDir\n";
    print "DebugBuildDir   =$DebugBuildDir\n";
    print "ProjectDir          =$ProjectDir\n";
    print "Transcoder        =$Transcoder\n";
    print "MsgLoader        =$MsgLoader\n";
PeiYong Zhang's avatar
PeiYong Zhang committed
        
    if (-e "$targetdir.zip") {
        print ("Deleting old target file \'$targetdir.zip\' \n");
        unlink("$targetdir.zip");
    # Preparation::Make the target directory and its main subdirectories
Loading
Loading full blame...