Subversion Repositories DevTools

Rev

Blame | Last modification | View Log | RSS feed

#
# Module name   : VISUALBASIC
# Module type   : Makefile system
# Environment(s): WIN32
#
# Description:
#       Visual BAsic 6 for WIN32
#............................................................................#

use strict;
use warnings;

################################################################################
#   Globals
#
my $toolset_version;
my $toolset_name = "VisualBasic";

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

ToolsetInit();

sub ToolsetInit
{

#.. Parse arguments (Toolset arguments)
#
    Debug( "${toolset_name}(@::ScmToolsetArgs)" );

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

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

#.. Parse arguments (platform arguments)
#
    Debug( "${toolset_name}(@::ScmPlatformArgs)" );

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

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

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

#.. Validate SDK version
#   Currently only one is supported
#       1) Visual Basic 6
#
    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( "visualbasic" );
    ToolsetDefines( "visualbasic.def" );
    ToolsetRules( "visualbasic.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 Visual Basic Project file by:
#       1) Invoke VB6.exe on a .vbg or .vbp
#
########################################################################

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

    #
    #   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( "${toolset_name} PROJECT: unknown option $_ -- ignored\n" );
        }
    }

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

    #
    #   One time only definitions
    #
    unless( $project_defines_done )
    {
        $project_defines_done = 1;
        $io->PrtLn( "ifeq \"\$(GBE_MAKE_TYPE)\" \"D\"");
        $io->PrtLn( "\$(info [VB6] (E) Visual Basic Projects do not build for debug)");
        $io->PrtLn( "\$(info [VB6] (E) The project setting are used and should be set to release)");
        $io->PrtLn( "\$(error Cannot build for Debug)");
        $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,$builddir,$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 build output directory
    #
    $io->Label( "Clean project", $name );
    $io->PrtLn( "ProjectClean_$name: $solution_path" );
    push @cleanfiles, $logfile, "$builddir/*";
    $io->Prt( "\t-\$(XX_PRE)\$(GBE_PERL) -Mjats_runtime -e rm_f -- ");
    $io->Prt( " \\\n\t\t\"$_\"" ) foreach ( @cleanfiles );
    $io->Newline();
}


#.. Successful termination
1;