Subversion Repositories DevTools

Rev

Rev 261 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#
# Module name   : BORLAND
# Module type   : Makefile system
# Compiler(s)   : ANSI C
# Environment(s): WIN32
#
# Description:
#       Borland C/C++ Builder for WIN32
#............................................................................#

use strict;
use warnings;

################################################################################
#   Globals
#
my $toolset_version;

##############################################################################
#   ToolsetInit()
#       Runtime initialisation
#
##############################################################################

ToolsetInit();

sub ToolsetInit
{

#.. Parse arguments (Toolset arguments)
#
    Debug( "Borland(@::ScmToolsetArgs)" );

    foreach $_ ( @::ScmToolsetArgs ) {
        if (/^--Version=(.*)/) {                # MS SDK Version
            $toolset_version = $1;

        } else {
            Message( "Borland toolset: unknown option $_ -- ignored\n" );
        }
    }

#.. Parse arguments (platform arguments)
#
    Debug( "Borland(@::ScmPlatformArgs)" );

    foreach $_ ( @::ScmPlatformArgs ) {
        if (/^--product=(.*)/) {                # GBE product

        } elsif (/^--Version=(.*)/) {           # MS SDK Version
            $toolset_version = $1;

        } else {
            Message( "Borland toolset: unknown platform argument $_ -- ignored\n" );
        }
    }

#.. Validate SDK version
#   Currently only one is supported
#       1) Borland C++ Builder 6 installed
#
    Error( "Unknown version: $toolset_version" ) if ( defined $toolset_version );


#.. Standard.rul requirements
#
    $::s = 'asm';
    $::o = 'obj';
    $::a = 'lib';
    $::so = 'dll';
    $::exe = '.exe';

#.. Toolset configuration
#
    $::ScmToolsetVersion = "1.0.0";             # our version
    $::ScmToolsetGenerate = 0;                  # generate optional

#.. define Borland C/C++ environment
    Init( "borlandc" );
    ToolsetDefines( "borland.def" );
    ToolsetRequire( "exctags" );                # and Exuberant Ctags
    ToolsetRules( "borland.rul" );
    ToolsetRules( "standard.rul" );

#.. define PCLint envrionment
#    ToolsetRequire( "pclint" );                 # using pclint
#    PlatformDefine ("LINT_COFILE\t= co-msc60.lnt");
#    PlatformDefine ("LINT_PRJ_FILE\t=lint.borland");

#.. Cleanup rules
#   None at the moment as we only build projects
#
    return 1;
}

########################################################################
#
#   Generate a project from the provided project file
#
#   Arguments   : $name             - Base name of the project
#                 $solution         - Path to the project file
#                 $pArgs            - Project specific options
#
#   Process a Borland Project file by:
#       1) Convert .bpr to a Borland .mak file
#       2) Invoke Borland make on the .mak file
#          Must change to the directory of the target project
#          Need to create "ilink32.cfg" in the project directory
#          to set the '/Lib/Release'
#
########################################################################

my $project_defines_done = 0;
sub ToolsetPROJECT
{
    my( $name, $solution ,$pArgs ) = @_;
    my @cleanfiles;
    my $cname = $name;
    $cname =~ s~\..+$~~;
    my $logfile = "$cname\$(GBE_TYPE).log";
    my $makefile = "$cname.jats.mak";
    my $basedir = StripFileExt( $solution ) || '.';

    #
    #   Some existing projects are in directories that have a 'space'
    #   Fix this by creating a path that uses a '?' wildcard instead of
    #   a space.
    #
    my $solution_path = $solution;
    $solution_path =~ s~ ~\?~g;
    
    #
    #   Process options
    #
    foreach ( @$pArgs ) {
        if ( m~^--CleanDir=(.+)~ ) {
            my $path = ($basedir) ? "$basedir/$1" : $1;
            push @cleanfiles, "$path/*";

        } elsif ( m~^--CleanFiles=(.+)~ ) {
            my $path = ($basedir) ? "$basedir/$1" : $1;
            push @cleanfiles, $path;

        } else {
            Message( "bcb PROJECT: unknown option $_ -- ignored\n" );
        }
    }

    my ($io) = ToolsetPrinter::New();

    #
    #   One time only definitions
    #
    unless( $project_defines_done )
    {
        $project_defines_done = 1;
        $io->PrtLn( "ifeq \"\$(DEBUG)\" \"1\"");
        $io->PrtLn( "\techo 'Borland Builder Projects do not build for debug'");
        $io->PrtLn( "\techo 'The project setting are used and should be for release'");
        $io->PrtLn( "\texit 1");
        $io->PrtLn( "endif");
        $io->Newline();
    }

    #
    #   Generate the recipe to create the project
    #   Use the set_WIN32.sh file to extend the DLL search path
    #
    $io->Label( "Build project", $name );
    $io->PrtLn( "Project_$name: $solution_path \$(INTERFACEDIR)/set_$::ScmPlatform.sh" );
    $io->PrtLn( "\t\$(call MakeProject,$name,$basedir,$makefile,$logfile)" );
    $io->Newline();

    #
    #   Generate the recipe to clean the project
    #       Delete the contents of the listed files and directories
    #       Delete the log file
    #       Delete the generated makefile
    #       Delete the generated ilink32.cfg file
    #
    $io->Label( "Clean project", $name );
    $io->PrtLn( "ProjectClean_$name: $solution_path" );
    push @cleanfiles, $logfile, $makefile, "$basedir/ilink32.cfg";
    $io->Prt( "\t-\$(XX_PRE)\$(GBE_PERL) -Mjats_runtime -e rm_f -- ");
    $io->Prt( " \\\n\t\t\"$_\"" ) foreach ( @cleanfiles );
    $io->Newline();
}


#.. Successful termination
1;