cross-plat-dev-utils/build_target.pl
author Mike Kinghan <mikek@symbian.org>
Wed, 01 Dec 2010 12:02:41 +0000
changeset 42 cf609178ac39
parent 10 b2a53d442fd6
permissions -rwxr-xr-x
1) fix_tools_exports.pl need only be run on Windows hosts; was run unnecessarily on Linux too. 2) Need to export modload.pm on Linux as well as Windows hosts.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     1
#!/usr/bin/perl
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     2
# Copyright (c) 2010 Symbian Foundation Ltd
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     3
# This component and the accompanying materials are made available
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     5
# which accompanies this distribution, and is available
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     7
#
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     8
# Initial Contributors:
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
     9
# Mike Kinghan, mikek@symbian.org, for Symbian Foundation Ltd - initial contribution.
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    10
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    11
# Script to build a given tools target with Raptor
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    12
# Will look for BLD.INF or bld.inf in the current directory.
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    13
# If not found will try in ./group.
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    14
# $1 is the build dir for the desired target relative to $EPOCROOT/build/
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    15
# $@ is shifted to get optional additional arguments to the sbs command
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    16
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    17
use strict;
6
787612182dd0 1) Make cross-plat-dev-utils perl scripts independent of the package directory name
mikek
parents: 2
diff changeset
    18
use places;
2
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    19
use File::Spec;
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    20
use Cwd; 
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    21
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    22
if (@ARGV) {
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    23
    if (grep(/$ARGV[0]/,("-h","--help"))) {
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    24
        print "This script builds a target with Raptor\n";
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    25
        print "Call with \$ARG[0] = the name of a component directory ";
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    26
        print "relative to EPOCROOT/build\n";        
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    27
        print "Subsequent arguments will be passed to Raptor\n";
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    28
        print "Looks for BLD.INF or bld.inf in the component directory\n";
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    29
        print "In not found will try in ./group\n";                        
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    30
        exit 0;
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    31
    }         
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    32
}
6
787612182dd0 1) Make cross-plat-dev-utils perl scripts independent of the package directory name
mikek
parents: 2
diff changeset
    33
my $epocroot = get_epocroot();
787612182dd0 1) Make cross-plat-dev-utils perl scripts independent of the package directory name
mikek
parents: 2
diff changeset
    34
my $sbs_home = get_sbs_home();
2
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    35
my $build_dir = shift;
6
787612182dd0 1) Make cross-plat-dev-utils perl scripts independent of the package directory name
mikek
parents: 2
diff changeset
    36
$build_dir = File::Spec->catfile(get_pkg_dir(),"$build_dir");
2
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    37
if (! -d $build_dir) {
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    38
    die "*** Error: \"$build_dir\" not found ***\n";
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    39
}
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    40
chdir "$build_dir" or die $!;
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    41
if (! -f "BLD.INF" and ! -f "bld.inf") {
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    42
	if ( -d "group") {
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    43
		chdir "group" or die $!;
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    44
		$build_dir = cwd;
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    45
	}
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    46
}
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    47
print ">>> Build dir is \"$build_dir\"\n";
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    48
my $bld_inf = "BLD.INF"; 
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    49
if (! -f $bld_inf) {
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    50
	$bld_inf = "bld.inf";
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    51
}
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    52
if (! -f $bld_inf) {
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    53
	die "*** Error: No bld.inf in \"$build_dir\" ***";
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    54
}
6
787612182dd0 1) Make cross-plat-dev-utils perl scripts independent of the package directory name
mikek
parents: 2
diff changeset
    55
my $log_stem = File::Spec->catfile(get_epoc32_dir(),"build","Makefile");
2
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    56
my $log_pattern = "$log_stem\.\*\.log"; 
6
787612182dd0 1) Make cross-plat-dev-utils perl scripts independent of the package directory name
mikek
parents: 2
diff changeset
    57
my $raptor = File::Spec->catfile(get_sbs_home(),"bin","sbs");
2
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    58
my $cmd = "$raptor -c tools2 -b $bld_inf @ARGV";
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    59
print ">>> Executing: $cmd\n";
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    60
my $rc = system($cmd) >> 8;
10
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents: 6
diff changeset
    61
my $warnings = 0;
2
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    62
my @build_logs = glob($log_pattern);
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    63
open BLDLOG, "<$build_logs[-1]" or die $!;
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    64
while(<BLDLOG>) {
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    65
    print $_;
10
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents: 6
diff changeset
    66
	++$warnings, if (/<warning>/);
2
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    67
}
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    68
close BLDLOG;
10
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents: 6
diff changeset
    69
print "*** Build failed ***\n", if ($rc);
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents: 6
diff changeset
    70
if ($warnings) {
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents: 6
diff changeset
    71
	print "*** Build has warnings ***\n";
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents: 6
diff changeset
    72
	$rc = 1;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents: 6
diff changeset
    73
}
2
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    74
exit $rc;
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    75
39c28ec933dd Removing all prior files. Adding a complete branch of the 'build' package with fixes
mikek
parents:
diff changeset
    76