Skip to content
Snippets Groups Projects
packageBinaries.pl 66.1 KiB
Newer Older
Ted Leung's avatar
Ted Leung committed
#!/usr/local/bin/perl5

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";
require 5.0;
Ted Leung's avatar
Ted Leung committed

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


# Extract the source and target directories
Rahul Jain's avatar
Rahul Jain committed
$XERCESCROOT = $opt_s;
Ted Leung's avatar
Ted Leung committed
$targetdir = $opt_o;

# 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 or xlc_r)\n");
    print ("    -x <C++ compiler name> (e.g. g++, CC, aCC, c++, xlC_r, cl, ecl or ecc)\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");
Tinny Ng's avatar
Tinny Ng committed
    print ("    perl packageBinaries.pl -s \$HOME/xerces-c-src2_2_0");
    print (" -o \$HOME/xerces-c_2_2_0-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");
Tinny Ng's avatar
Tinny Ng committed
    print ("    perl packageBinaries.pl -s \\xerces-c-src2_2_0");
    print (" -o\\xerces-c_2_2_0-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
}

# Set up the environment variables for ICU
Rahul Jain's avatar
Rahul Jain committed
# As of Version 3, ICU is not a required component of XERCES-C
Ted Leung's avatar
Ted Leung committed
$ICUROOT = $ENV{'ICUROOT'};
Tinny Ng's avatar
Tinny Ng committed
$ICU_DATA = $ENV{'ICU_DATA'};
Ted Leung's avatar
Ted Leung committed
if (!length($ICUROOT)) {
    print "You have not defined your ICU install directory.\n";
    print "To build with ICU, you must set an environment variable called ICUROOT\n";
    print "Proceeding to build XERCES-C without ICU...\n";
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

#set platform variable if on windows 64bit
my $return_code = system( "ls" );
if ($return_code != 0)
{  $platform = "win64bit";
}

#Fix the backslashes on the Windows platform
if ($platform ne "win64bit")
{
    $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 = $targetdir;
$zipfiles =~ s/.*(\/|\\)([\w-\.]*)$/$2/g;
$zipfiles = $zipfiles . "/*";
Ted Leung's avatar
Ted Leung committed

Rahul Jain's avatar
Rahul Jain committed
$buildmode = "Release";         # Universally, why do you want to package Debug builds anyway?
Ted Leung's avatar
Ted Leung committed

Tinny Ng's avatar
Tinny Ng committed
#   Architecture: Itanium
#   OS:           Windows XP
#   Compiler:     Intel's cl and/or ecl
#   cygwin:       Not Available
if ($platform eq "win64bit" )
{
    if ($opt_x ne "" && $opt_x ne "cl" && $opt_x ne "ecl")
    {
        print("Compiler on Itanium/WindowsXP must be \'cl\' or \'ecl\'\n");
Tinny Ng's avatar
Tinny Ng committed

    if ($opt_x eq "")
    {
    	$opt_x = 'cl';
    }

    $platformname = 'Win64';    # Needed this way by nmake

    if (-e "$targetdir.zip") {
        print ("Deleting old target file \'$targetdir.zip\' \n");
        unlink("$targetdir.zip");
    }

    # Make the target directory and its main subdirectories
    psystem ("mkdir $targetdir");
    psystem ("mkdir $targetdir\\bin");
    psystem ("mkdir $targetdir\\lib");
    if ( $opt_m =~ m/icu/i ) {
        psystem ("mkdir $targetdir\\msg");
    }    
    psystem ("mkdir $targetdir\\etc");
    psystem ("mkdir $targetdir\\include");
    psystem ("mkdir $targetdir\\include\\xercesc");
    psystem ("mkdir $targetdir\\samples");
    psystem ("mkdir $targetdir\\samples\\Projects");
    psystem ("mkdir $targetdir\\samples\\Projects\\Win32");
    psystem ("mkdir $targetdir\\samples\\Projects\\Win32\\VC6");
    psystem ("mkdir $targetdir\\samples\\data");
    psystem ("mkdir $targetdir\\samples\\SAXCount");
    psystem ("mkdir $targetdir\\samples\\SAX2Count");
    psystem ("mkdir $targetdir\\samples\\SAXPrint");
    psystem ("mkdir $targetdir\\samples\\SAX2Print");
    psystem ("mkdir $targetdir\\samples\\DOMCount");
    psystem ("mkdir $targetdir\\samples\\DOMPrint");
    psystem ("mkdir $targetdir\\samples\\Redirect");
    psystem ("mkdir $targetdir\\samples\\MemParse");
    psystem ("mkdir $targetdir\\samples\\PParse");
    psystem ("mkdir $targetdir\\samples\\StdInParse");
    psystem ("mkdir $targetdir\\samples\\EnumVal");
    psystem ("mkdir $targetdir\\samples\\SEnumVal");
    psystem ("mkdir $targetdir\\samples\\CreateDOMDocument");
    psystem ("mkdir $targetdir\\doc");
    psystem ("mkdir $targetdir\\doc\\html");
    psystem ("mkdir $targetdir\\doc\\html\\apiDocs");

    # If 'FileOnly' NetAccessor has been specified, then the project files have to be
    # changed.
    #REVISIT: we are make from makefile, not from *.dsp
    #         need to look at it later
    if ($opt_n =~ m/fileonly/i) {
        changeWindowsProjectForFileOnlyNA("$XERCESCROOT/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp");
    }

    #
    #	ICU Build happens here, if one is required.
    #
    #REVISIT: icu
    #
Tinny Ng's avatar
Tinny Ng committed
    if (($opt_t =~ m/icu/i || $opt_m =~ m/icu/i) && length($ICUROOT) > 0) {
        print ("Building ICU from $ICUROOT ...\n");

        #Clean up all the dependency files, causes problems for nmake
        pchdir ("$ICUROOT");
        psystem ("del /s /f *.dep *.ncb *.plg *.opt");

        # Make the icu dlls
        pchdir ("$ICUROOT\\source\\allinone\\all");
        if (!(length($opt_j) > 0)) {   # Optionally suppress ICU build, to speed up overlong builds while debugging.
	    #For XP we ship both release and debug dlls
Tinny Ng's avatar
Tinny Ng committed
            psystem("nmake -f all_win64_release.mak \"CFG=all - $platformname Release\" CPP=$opt_x.exe >buildlog.txt 2>&1");	    	
	    psystem("type buildlog.txt");
Tinny Ng's avatar
Tinny Ng committed
            psystem("nmake -f all_win64_debug.mak \"CFG=all - $platformname Debug\" CPP=$opt_x.exe >buildlog.txt 2>&1");	    	
	    psystem("type buildlog.txt");
        }

        $transcoder = 0;
        if ($opt_t =~ m/icu/i )
        {
            $transcoder = 1;
        }
Tinny Ng's avatar
Tinny Ng committed

        $msgloader = 0;
        if ($opt_m =~ m/icu/i)
        change_windows_makefile_for_ICU("$XERCESCROOT\\Projects\\Win32\\VC6\\xerces-all/XercesLib/XercesLib.mak", $transcoder, $msgloader);
Loading
Loading full blame...