Skip to content
Snippets Groups Projects
packageBinaries.pl 51.8 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
&Getopt('sopcxmntrjb');
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 or ecl)\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");
    print ("    perl packageBinaries.pl -s \$HOME/xerces-c-src_2_0_0");
    print (" -o \$HOME/xerces-c_2_0_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");
    print ("    perl packageBinaries.pl -s \\xerces-c-src_2_0_0");
    print (" -o\\xerces-c_2_0_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
}

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

#Fix the backslashes on the Windows platform
if ($platform ne "")
{
    $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 = $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

#
#   Itanium platform builds happen here ...
#
if ($platform eq "" ) 
{
    if ($opt_x ne "" && $opt_x ne "cl" && $opt_x ne "ecl")
    {
        print("Compiler on Itanium must be \'cl\' or \'ecl\'\n");
        exit(-1);
    }
    
    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");
    psystem ("mkdir $targetdir\\etc");
    psystem ("mkdir $targetdir\\include");
    psystem ("mkdir $targetdir\\include\\xercesc");
    psystem ("mkdir $targetdir\\samples");
    psystem ("mkdir $targetdir\\samples\\Projects");
    #REVISIT: to change to /Win64 if necessary
    psystem ("mkdir $targetdir\\samples\\Projects\\Win32");
    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
    #
    if ($opt_t =~ 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");
        if (!$opt_j) {   # Optionally suppress ICU build, to speed up overlong builds while debugging.
	    #For nt we ship both debug and release dlls
	    psystem("msdev allinone.dsw /MAKE \"all - $platformname Release\" /REBUILD /OUT buildlog.txt");
	    psystem("type buildlog.txt");
	    psystem("msdev allinone.dsw /MAKE \"all - $platformname Debug\" /REBUILD /OUT buildlog.txt");
	    psystem("type buildlog.txt");
        }

        change_windows_project_for_ICU("$XERCESCROOT/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp");
    }

    # Clean up all the dependency files, causes problems for nmake
    # Also clean up all MSVC-generated project files that just cache the IDE state
    pchdir ("$XERCESCROOT");
    psystem ("del /s /f *.dep *.ncb *.plg *.opt");

    # Make all files in the Xerces-C system including libraries, samples and tests
    pchdir ("$XERCESCROOT\\Projects\\Win64\\Nmake\\xerces-all\\all");
    psystem( "nmake -f all.mak \"CFG=all - $platformname Release\" CPP=$opt_x.exe >buildlog.txt 2>&1");
    system("type buildlog.txt");

    pchdir ("$XERCESCROOT\\Projects\\Win64\\Nmake\\xerces-all\\XercesLib");
    psystem("nmake -f XercesLib.mak \"CFG=XercesLib - $platformname Debug\" CPP=$opt_x.exe > buildlog.txt 2>&1 ");
    system("type buildlog.txt");
        
    # Decide where you want the build copied from
    pchdir ($targetdir);
    $BUILDDIR = $XERCESCROOT . "\\Build\\Win64\\Nmake\\" . $buildmode;
    print "\nBuild is being copied from \'" . $BUILDDIR . "\'";

    # Populate the include output directory
    print ("\n\nCopying headers files ...\n");
    @headerDirectories =
     qw'sax
Loading
Loading full blame...