build_package.pl
author Dario Sestito <darios@symbian.org>
Thu, 09 Sep 2010 13:49:23 +0100
changeset 82 ec156946b469
parent 76 fe2cee402e0a
permissions -rw-r--r--
Add call to sf-finalize
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     2
# This component and the accompanying materials are made available
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     4
# which accompanies this distribution, and is available
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     6
#
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     7
# Initial Contributors:
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
     9
#
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
    10
# Contributors:
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
    11
#
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
    12
# Description:
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
    13
# This is a helper script which allocates unique drive letter and build number
45ed0efeb8a4 Added copyright header to build_package.pl
darios@symbian.org
parents: 14
diff changeset
    14
# then starts a package build by running FBF bootstrap and build targets
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    15
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    16
use strict;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    17
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    18
use Getopt::Long;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    19
use File::Path;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    20
16
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
    21
my $sBOOTSTRAP_DIR="C:\\Apps\\FBF\\bootstrap";
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
    22
my $sJOB_BASE_DIR="fbf_project";
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
    23
my $nMAX_JOBDIR_AGE_SECONDS = 86400; # max number of seconds after which the letter is forcibly released
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    24
my $nLOCK_FILE_MAX_ATTEMPTS = 5;
51
5db037fb1000 Change location of numbers file to v800020 as builds are published there now
Dario Sestito <darios@symbian.org>
parents: 50
diff changeset
    25
my $sNUMBERS_FILE="\\\\v800020\\Publish\\SF_builds\\numbers.txt";
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
    26
my $sLETTERS_FILE="letters.txt";
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
    27
my $nMAX_LETTER_AGE_SECONDS = 86400; # max number of seconds after which the letter is forcibly released
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    28
73
457adde87bbd Change URLs to fbf repo to match new locations under sftools
Dario Sestito <darios@symbian.org>
parents: 72
diff changeset
    29
my $sFbfProjectRepo = "http://developer.symbian.org/oss/MCL/sftools/fbf/projects/packages";
16
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
    30
my $sFbfProjectDir = '';
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    31
my $sSubProject = '';
55
0d56e5b89632 Add support for subproject variant. Add support for RVCT4 build
Dario Sestito <darios@symbian.org>
parents: 53
diff changeset
    32
my $sSubprojVariant = '';
75
2a106c5499cb Add sourcesrev option to build_package.pl to allow overriding the revision specified in sources.csv
Dario Sestito <darios@symbian.org>
parents: 74
diff changeset
    33
my $sSourcesRevision = '';
58
806b67128bee Removed --rvct4 option and introduced a more generic --sbsconfig option
Dario Sestito <darios@symbian.org>
parents: 57
diff changeset
    34
my $sSBSConfig = '';
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    35
#my $sSourcesFile = '';
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    36
#my $sModelFile = '';
73
457adde87bbd Change URLs to fbf repo to match new locations under sftools
Dario Sestito <darios@symbian.org>
parents: 72
diff changeset
    37
my $sFbfConfigRepo="http://developer.symbian.org/oss/MCL/sftools/fbf/configs/default";
16
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
    38
my $sFbfConfigDir = '';
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    39
my $nCmdLineNumber;
34
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    40
my $sDiamondsTag = '';
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    41
my $bHudson = 0;
28
bf45384632b0 Add support for --testbuild and --nopublish options
Dario Sestito <darios@symbian.org>
parents: 27
diff changeset
    42
my $bPublish = 1;
49
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
    43
my %hHlmDefines = ();
59
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
    44
my $bDisableAntiVirus = 0;
74
72cc60784b23 Add --bom option to be able to run a package build from sources.csv of a previous build
dario.sestito@v800052.ad-sfpd.intra
parents: 73
diff changeset
    45
my $sUseBom = '';
42
71a252d194e6 Add help option
Dario Sestito <darios@symbian.org>
parents: 41
diff changeset
    46
my $bHelp = 0;
19
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
    47
GetOptions((
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    48
	'configrepo=s' => \$sFbfConfigRepo,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    49
	'configdir=s' => \$sFbfConfigDir,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    50
	'projectrepo=s' => \$sFbfProjectRepo,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    51
	'projectdir=s' => \$sFbfProjectDir,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    52
	'subproj=s' => \$sSubProject,
55
0d56e5b89632 Add support for subproject variant. Add support for RVCT4 build
Dario Sestito <darios@symbian.org>
parents: 53
diff changeset
    53
	'variant=s' => \$sSubprojVariant,
76
fe2cee402e0a Fix: option sourcesrev should be string
Dario Sestito <darios@symbian.org>
parents: 75
diff changeset
    54
	'sourcesrev=s' => \$sSourcesRevision,
60
6e2dd2cc846d Fix --sbsconfig option should take a string as argument
Dario Sestito <darios@symbian.org>
parents: 59
diff changeset
    55
	'sbsconfig=s' => \$sSBSConfig,
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    56
	#'sources=s' => \$sSourcesFile,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    57
	#'model=s' => \$sModelFile,
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    58
	'number=s' => \$nCmdLineNumber,
34
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    59
	'tag=s' => \$sDiamondsTag,
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    60
	'hudson!' => \$bHudson,
42
71a252d194e6 Add help option
Dario Sestito <darios@symbian.org>
parents: 41
diff changeset
    61
	'publish!' => \$bPublish,
49
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
    62
	'define=s' => \%hHlmDefines,
65
d0bd2fd2c468 Fix --disableav option is not declared boolean
Dario Sestito <darios@symbian.org>
parents: 61
diff changeset
    63
	'disableav!' => \$bDisableAntiVirus,
74
72cc60784b23 Add --bom option to be able to run a package build from sources.csv of a previous build
dario.sestito@v800052.ad-sfpd.intra
parents: 73
diff changeset
    64
	'bom=s' => \$sUseBom,
42
71a252d194e6 Add help option
Dario Sestito <darios@symbian.org>
parents: 41
diff changeset
    65
	'help!' => \$bHelp
19
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
    66
));
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    67
42
71a252d194e6 Add help option
Dario Sestito <darios@symbian.org>
parents: 41
diff changeset
    68
if ($bHelp or !($sSubProject or $sFbfProjectRepo or $sFbfProjectDir))
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
    69
{
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    70
	print "Usage: build_package.pl --subproj=RELPATH [OPTIONS]\n";
38
6da50515cbeb Fix start package build with no --subproj option, pointed defaults to mercurial_development
Dario Sestito <darios@symbian.org>
parents: 37
diff changeset
    71
	print "       build_package.pl --projectrepo=REPO [OPTIONS]\n";
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    72
	print "where OPTIONS are:\n";
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    73
	print "\t--subproj=RELPATH Select subproject located at RELPATH (relative to the root of the project repository)\n";
55
0d56e5b89632 Add support for subproject variant. Add support for RVCT4 build
Dario Sestito <darios@symbian.org>
parents: 53
diff changeset
    74
	print "\t--variant=VARIANT If specified use sources_VARIANT.csv instead of sources.csv and add \"VARIANT\" as tag for this build\n";
75
2a106c5499cb Add sourcesrev option to build_package.pl to allow overriding the revision specified in sources.csv
Dario Sestito <darios@symbian.org>
parents: 74
diff changeset
    75
	print "\t--sourcesrev=REV Sync source repos at revision REV (overrides the revision specified in sources.csv). Note this is the same for all source repos.\n";
58
806b67128bee Removed --rvct4 option and introduced a more generic --sbsconfig option
Dario Sestito <darios@symbian.org>
parents: 57
diff changeset
    76
	print "\t--sbsconfig=CONFIG Pass on CONFIG as configuration to SBS (can also be a comma separated list, e.g. 'armv5,winscw')\n";
73
457adde87bbd Change URLs to fbf repo to match new locations under sftools
Dario Sestito <darios@symbian.org>
parents: 72
diff changeset
    77
	print "\t--projectrepo=REPO[#REV] Use repository REPO at revision REV for the project (instead of http://developer.symbian.org/oss/MCL/sftools/fbf/projects/packages)\n";
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    78
	print "\t--projectdir=DIR Use DIR location for the project (exclusive with --projectrepo).\n";
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    79
	#print "\t--sources=FILE ...\n";
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    80
	#print "\t--model=FILE ...\n";
73
457adde87bbd Change URLs to fbf repo to match new locations under sftools
Dario Sestito <darios@symbian.org>
parents: 72
diff changeset
    81
	print "\t--configrepo=REPO[#REV] Use repository REPO at revision REV for the config (instead of http://developer.symbian.org/oss/MCL/sftools/fbf/configs/default)\n";
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    82
	print "\t--configdir=DIR Use DIR location for the config (exclusive with --configrepo).\n";
19
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
    83
	print "\t--number=N Force build number to N\n";
52
511dcb217499 Remove --production option. Remove .T numbering scheme
Dario Sestito <darios@symbian.org>
parents: 51
diff changeset
    84
	print "\t--tag=TAG Apply Diamonds tag TAG to this build\n";
72
50ab3bef1c6a No more check for drive space if given --hudson as this makes the builds fail most of the time unnecessarily
Dario Sestito <darios@symbian.org>
parents: 71
diff changeset
    85
	print "\t--hudson Clean up all job dirs after the build)\n";
45
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
    86
	print "\t--nopublish Use \\numbers_test.txt for numbers and disable publishing\n";
49
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
    87
	print "\t--define ATTRIBUTE=VALUE Pass -D statements to the Helium Framework\n";
59
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
    88
	print "\t--disableav Disable Anti-Virus for the duration of the build (also sync with other concurrent package builds)\n";
74
72cc60784b23 Add --bom option to be able to run a package build from sources.csv of a previous build
dario.sestito@v800052.ad-sfpd.intra
parents: 73
diff changeset
    89
	print "\t--bom=LOCATION Use to build by taking the sources.csv from the build_BOM.zip at LOCATION\n";
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    90
	exit(0);
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    91
}
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    92
38
6da50515cbeb Fix start package build with no --subproj option, pointed defaults to mercurial_development
Dario Sestito <darios@symbian.org>
parents: 37
diff changeset
    93
if ($sSubProject and $sSubProject !~ m,^([^/]+)/[^/]+/([^/]+)$,)
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
    94
{
34
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    95
	print "ERROR: Option --subproj must be in the format codeline/layer/package (e.g. MCL/os/boardsupport)\n";
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    96
	exit(0);
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    97
}
d156d56b00c2 Add --hudson option to check availability of space on working drive. Add --tag option to allow arbitrary Diamonds tags
Dario Sestito <darios@symbian.org>
parents: 33
diff changeset
    98
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
    99
#if (!$sFbfProjectRepo and !$sFbfProjectDir and (!$sSourcesFile or !$sModelFile))
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   100
#{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   101
#	print "Error: If you don't provide --projectrepo or --projectdir then you have to provide both --sources and --model\n";
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   102
#	exit(0);
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   103
#}
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   104
45
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   105
my $sWORKING_DRIVE = find_working_drive();
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   106
print "Will use drive $sWORKING_DRIVE as working drive for this build\n";
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   107
70
450398a72180 Move creation of letter file before Hudson space check, otherwise check could fail (if no file at all is present on the working drive)
Dario Sestito <darios@symbian.org>
parents: 69
diff changeset
   108
# check that $sLETTERS_FILE exists, otherwise create it
450398a72180 Move creation of letter file before Hudson space check, otherwise check could fail (if no file at all is present on the working drive)
Dario Sestito <darios@symbian.org>
parents: 69
diff changeset
   109
if (!-f "$sWORKING_DRIVE\\$sLETTERS_FILE")
450398a72180 Move creation of letter file before Hudson space check, otherwise check could fail (if no file at all is present on the working drive)
Dario Sestito <darios@symbian.org>
parents: 69
diff changeset
   110
{
450398a72180 Move creation of letter file before Hudson space check, otherwise check could fail (if no file at all is present on the working drive)
Dario Sestito <darios@symbian.org>
parents: 69
diff changeset
   111
	open FILE, ">$sWORKING_DRIVE\\$sLETTERS_FILE";
450398a72180 Move creation of letter file before Hudson space check, otherwise check could fail (if no file at all is present on the working drive)
Dario Sestito <darios@symbian.org>
parents: 69
diff changeset
   112
	print FILE "\n";
450398a72180 Move creation of letter file before Hudson space check, otherwise check could fail (if no file at all is present on the working drive)
Dario Sestito <darios@symbian.org>
parents: 69
diff changeset
   113
	close FILE;
450398a72180 Move creation of letter file before Hudson space check, otherwise check could fail (if no file at all is present on the working drive)
Dario Sestito <darios@symbian.org>
parents: 69
diff changeset
   114
}
450398a72180 Move creation of letter file before Hudson space check, otherwise check could fail (if no file at all is present on the working drive)
Dario Sestito <darios@symbian.org>
parents: 69
diff changeset
   115
24
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   116
my $sFbfProjectRev = '';
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   117
if ($sFbfProjectRepo =~ m,(.*)#(.*),)
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   118
{
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   119
	$sFbfProjectRepo = $1;
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   120
	$sFbfProjectRev = $2;
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   121
}
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   122
my $sFbfConfigRev = '';
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   123
if ($sFbfConfigRepo =~ m,(.*)#(.*),)
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   124
{
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   125
	$sFbfConfigRepo = $1;
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   126
	$sFbfConfigRev = $2;
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   127
}
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   128
49
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   129
my $sHlmDefineOpt = '';
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   130
for (keys %hHlmDefines)
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   131
{
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   132
	$sHlmDefineOpt .= "-D$_=$hHlmDefines{$_} ";
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   133
}
07eb981b2b45 Support for passing -D options to Helium
Dario Sestito <darios@symbian.org>
parents: 48
diff changeset
   134
28
bf45384632b0 Add support for --testbuild and --nopublish options
Dario Sestito <darios@symbian.org>
parents: 27
diff changeset
   135
my $sNoPublishOpt = "";
bf45384632b0 Add support for --testbuild and --nopublish options
Dario Sestito <darios@symbian.org>
parents: 27
diff changeset
   136
$sNoPublishOpt = "-Dsf.spec.publish.enable=false" if ( !$bPublish );
45
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   137
$sNUMBERS_FILE = "$sWORKING_DRIVE\\numbers_test.txt" if ( !$bPublish );
19
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
   138
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   139
my $sJobLabel = 'job';
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   140
if ($sSubProject)
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   141
{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   142
	$sSubProject =~ m,^([^/]+)/[^/]+/([^/]+)$,;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   143
	$sJobLabel = $2;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   144
}
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   145
elsif ($sFbfProjectRepo)
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   146
{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   147
	$sFbfProjectRepo =~ m,(.*[\\/])?([^\\^/]+),;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   148
	$sJobLabel = $2;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   149
}
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   150
elsif ($sFbfProjectDir)
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   151
{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   152
	$sFbfProjectDir =~ m,(.*[\\/])?([^\\^/]+),;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   153
	$sJobLabel = $2;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   154
}
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   155
#elsif ($sSourcesFile)
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   156
#{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   157
#	$sSourcesFile =~ m,/(adaptation|app|mw|os|ostools|tools)[\\/]([^\\^/]+),i;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   158
#	$sJobLabel = $2;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   159
#	$sSourcesFile =~ m,(.*[\\/])?([^\\^/]+),;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   160
#	$sJobLabel = $2 if (!$sJobLabel);
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   161
#}
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   162
mkdir("$sWORKING_DRIVE\\$sJOB_BASE_DIR") if (!-d "$sWORKING_DRIVE\\$sJOB_BASE_DIR");
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   163
my $sJobDir = mkdir_unique("$sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel");
71
f7ba24a607f8 Remove the correct job directory after the build, otherwise concurrent builds of the same package if run at the same time will have their jobdir removed and hence fail
Dario Sestito <darios@symbian.org>
parents: 70
diff changeset
   164
print "Created project dir $sJobDir\n";
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   165
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   166
print("cd $sBOOTSTRAP_DIR\n");
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   167
chdir("$sBOOTSTRAP_DIR");
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   168
print "###### BOOTSTRAP ######\n";
16
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
   169
my $sConfigArg = "-Dsf.config.repo=$sFbfConfigRepo";
24
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   170
$sConfigArg .= " -Dsf.config.rev=$sFbfConfigRev" if ($sFbfConfigRev);
16
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
   171
$sConfigArg = "-Dsf.config.dir=$sFbfConfigDir" if ($sFbfConfigDir);
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
   172
my $sProjectArg = "-Dsf.project.repo=$sFbfProjectRepo";
24
ed4e68942437 Allow revisions for projects and configs
Dario Sestito <darios@symbian.org>
parents: 22
diff changeset
   173
$sProjectArg .= " -Dsf.project.rev=$sFbfProjectRev" if ($sFbfProjectRev);
16
e1b9f78cef38 Project spec and config to be taken from a dir instead of from a repo
darios@symbian.org
parents: 15
diff changeset
   174
$sProjectArg = "-Dsf.project.dir=$sFbfProjectDir" if ($sFbfProjectDir);
40
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   175
my $sBootstrapCmd = "hlm -f bootstrap.xml $sConfigArg $sProjectArg -Dsf.target.dir=$sJobDir";
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   176
print("$sBootstrapCmd\n");
50
e8b76d25d90c Remove dump of stdout/stderr to files as no longer required for brag computation
Dario Sestito <darios@symbian.org>
parents: 49
diff changeset
   177
system($sBootstrapCmd);
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   178
74
72cc60784b23 Add --bom option to be able to run a package build from sources.csv of a previous build
dario.sestito@v800052.ad-sfpd.intra
parents: 73
diff changeset
   179
# get sources.csv from supplied BOM location
72cc60784b23 Add --bom option to be able to run a package build from sources.csv of a previous build
dario.sestito@v800052.ad-sfpd.intra
parents: 73
diff changeset
   180
if ($sUseBom)
72cc60784b23 Add --bom option to be able to run a package build from sources.csv of a previous build
dario.sestito@v800052.ad-sfpd.intra
parents: 73
diff changeset
   181
{
72cc60784b23 Add --bom option to be able to run a package build from sources.csv of a previous build
dario.sestito@v800052.ad-sfpd.intra
parents: 73
diff changeset
   182
  print("get sources.csv from supplied BOM location\n");
72cc60784b23 Add --bom option to be able to run a package build from sources.csv of a previous build
dario.sestito@v800052.ad-sfpd.intra
parents: 73
diff changeset
   183
  my $sGetSourcesCmd = "7z e -y -i!build_info\\logs\\BOM\\sources.csv -o$sJobDir\\build\\config\\$sSubProject $sUseBom\\build_BOM.zip";
72cc60784b23 Add --bom option to be able to run a package build from sources.csv of a previous build
dario.sestito@v800052.ad-sfpd.intra
parents: 73
diff changeset
   184
  print("$sGetSourcesCmd\n");
72cc60784b23 Add --bom option to be able to run a package build from sources.csv of a previous build
dario.sestito@v800052.ad-sfpd.intra
parents: 73
diff changeset
   185
  system($sGetSourcesCmd);
72cc60784b23 Add --bom option to be able to run a package build from sources.csv of a previous build
dario.sestito@v800052.ad-sfpd.intra
parents: 73
diff changeset
   186
}
72cc60784b23 Add --bom option to be able to run a package build from sources.csv of a previous build
dario.sestito@v800052.ad-sfpd.intra
parents: 73
diff changeset
   187
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   188
# check that $sNUMBERS_FILE exists, otherwise create it
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   189
if (!-f $sNUMBERS_FILE)
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   190
{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   191
	open FILE, ">$sNUMBERS_FILE";
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   192
	print FILE "\n";
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   193
	close FILE;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   194
}
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   195
35
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   196
my $sJobNumberKey = '';
39
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   197
my $sPackage = '';
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   198
my $sPlatform = '';
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   199
my $nUnformattedNumber = 0;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   200
if ($nCmdLineNumber)
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   201
{
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   202
	$nUnformattedNumber = $nCmdLineNumber;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   203
}
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   204
elsif ($sFbfProjectRepo)
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   205
{
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   206
	if ($sSubProject)
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   207
	{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   208
		# key = <package>_<codeline>, e.g. for subproj=MCL/os/boardsupport -> key=boardsupport_MCL
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   209
		$sSubProject =~ m,^([^/]+)/[^/]+/([^/]+)$,;
39
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   210
		$sPackage = $2;
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   211
		$sPlatform = $1;
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   212
		$sJobNumberKey = "$2_$1";
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   213
	}
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   214
	else
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   215
	{
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   216
		# key = hash of the rev.0 of the package project repo
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   217
		my $sRevZeroHash = get_rev_zero_hash($sFbfProjectRepo);
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   218
		$sJobNumberKey = $sRevZeroHash;
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   219
	}
28
bf45384632b0 Add support for --testbuild and --nopublish options
Dario Sestito <darios@symbian.org>
parents: 27
diff changeset
   220
	$nUnformattedNumber = get_job_number($sJobNumberKey);
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   221
}
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   222
my $nJobNumber = sprintf("%.3d", $nUnformattedNumber);
35
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   223
print "For build key $sJobNumberKey got assigned number \"$nJobNumber\"\n";
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   224
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   225
# acquire drive letter
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   226
my $sDriveLetter = acquire_drive_letter();
59
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   227
die "Could not acquire drive letter" if (!$sDriveLetter);
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   228
print "acquired drive letter: $sDriveLetter\n";
59
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   229
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   230
# disable antivirus:
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   231
# done after the acquisition of the drive letter as letter file
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   232
# is used as a means to sync with concurrent package builds
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   233
if ($bDisableAntiVirus)
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   234
{
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   235
	print "disabling anti-virus\n";
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   236
	my $disableav_cmd = "av.bat /stop";
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   237
	print "$disableav_cmd\n";
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   238
	system($disableav_cmd);
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   239
}
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   240
33
4d7642508510 Pass the job rootdir as parameter to helium
Dario Sestito <darios@symbian.org>
parents: 32
diff changeset
   241
my $sJobRootDirArg = "-Dsf.spec.job.rootdir=$sWORKING_DRIVE\\fbf_job";
4d7642508510 Pass the job rootdir as parameter to helium
Dario Sestito <darios@symbian.org>
parents: 32
diff changeset
   242
31
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   243
my $sSubProjArg = '';
7d05cbb136ad Enable package builds from one common repository
Dario Sestito <darios@symbian.org>
parents: 29
diff changeset
   244
$sSubProjArg = "-Dsf.subproject.path=$sSubProject" if ($sSubProject);
55
0d56e5b89632 Add support for subproject variant. Add support for RVCT4 build
Dario Sestito <darios@symbian.org>
parents: 53
diff changeset
   245
my $sVariantArg = '';
0d56e5b89632 Add support for subproject variant. Add support for RVCT4 build
Dario Sestito <darios@symbian.org>
parents: 53
diff changeset
   246
$sVariantArg = "-Dsf.spec.sourcesync.sourcespecfile=sources_$sSubprojVariant.csv" if ($sSubprojVariant);
75
2a106c5499cb Add sourcesrev option to build_package.pl to allow overriding the revision specified in sources.csv
Dario Sestito <darios@symbian.org>
parents: 74
diff changeset
   247
my $sSourcesRevisionArg = '';
2a106c5499cb Add sourcesrev option to build_package.pl to allow overriding the revision specified in sources.csv
Dario Sestito <darios@symbian.org>
parents: 74
diff changeset
   248
$sSourcesRevisionArg = "-Dsf.spec.sources.revision=\"$sSourcesRevision\"" if ($sSourcesRevision);
58
806b67128bee Removed --rvct4 option and introduced a more generic --sbsconfig option
Dario Sestito <darios@symbian.org>
parents: 57
diff changeset
   249
my $sSBSConfigArg = '';
806b67128bee Removed --rvct4 option and introduced a more generic --sbsconfig option
Dario Sestito <darios@symbian.org>
parents: 57
diff changeset
   250
$sSBSConfigArg = "-Dsf.spec.sbs.config=\"$sSBSConfig\"" if ($sSBSConfig);
55
0d56e5b89632 Add support for subproject variant. Add support for RVCT4 build
Dario Sestito <darios@symbian.org>
parents: 53
diff changeset
   251
my $sAllTags = '';
0d56e5b89632 Add support for subproject variant. Add support for RVCT4 build
Dario Sestito <darios@symbian.org>
parents: 53
diff changeset
   252
$sAllTags = $sDiamondsTag if ($sDiamondsTag);
0d56e5b89632 Add support for subproject variant. Add support for RVCT4 build
Dario Sestito <darios@symbian.org>
parents: 53
diff changeset
   253
$sAllTags .= ',' if ($sAllTags and $sSubprojVariant);
0d56e5b89632 Add support for subproject variant. Add support for RVCT4 build
Dario Sestito <darios@symbian.org>
parents: 53
diff changeset
   254
$sAllTags .= $sSubprojVariant if ($sSubprojVariant);
0d56e5b89632 Add support for subproject variant. Add support for RVCT4 build
Dario Sestito <darios@symbian.org>
parents: 53
diff changeset
   255
my $sTagsArg = "";
0d56e5b89632 Add support for subproject variant. Add support for RVCT4 build
Dario Sestito <darios@symbian.org>
parents: 53
diff changeset
   256
$sTagsArg = "-Dsf.spec.publish.diamonds.tag=\"$sAllTags\"" if ($sAllTags);
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   257
print("cd $sJobDir\\sf-config\n");
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   258
chdir("$sJobDir\\sf-config");
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   259
print "###### BUILD PREPARATION ######\n";
75
2a106c5499cb Add sourcesrev option to build_package.pl to allow overriding the revision specified in sources.csv
Dario Sestito <darios@symbian.org>
parents: 74
diff changeset
   260
my $sPreparationCmd = "hlm sf-prep -Dsf.project.type=package $sSubProjArg -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTagsArg $sNoPublishOpt $sJobRootDirArg $sHlmDefineOpt $sVariantArg $sSourcesRevisionArg $sSBSConfigArg";
40
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   261
print("$sPreparationCmd\n");
50
e8b76d25d90c Remove dump of stdout/stderr to files as no longer required for brag computation
Dario Sestito <darios@symbian.org>
parents: 49
diff changeset
   262
system($sPreparationCmd);
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   263
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   264
print "###### EXECUTE BUILD ######\n";
75
2a106c5499cb Add sourcesrev option to build_package.pl to allow overriding the revision specified in sources.csv
Dario Sestito <darios@symbian.org>
parents: 74
diff changeset
   265
my $sBuildallCmd = "hlm sf-build-all -Dsf.project.type=package $sSubProjArg -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTagsArg $sNoPublishOpt $sJobRootDirArg $sHlmDefineOpt $sVariantArg $sSourcesRevisionArg $sSBSConfigArg";
40
6661369591af Build console output must be redirected to file but must also go to console
Dario Sestito <darios@symbian.org>
parents: 39
diff changeset
   266
print("$sBuildallCmd\n");
50
e8b76d25d90c Remove dump of stdout/stderr to files as no longer required for brag computation
Dario Sestito <darios@symbian.org>
parents: 49
diff changeset
   267
system($sBuildallCmd);
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   268
82
ec156946b469 Add call to sf-finalize
Dario Sestito <darios@symbian.org>
parents: 76
diff changeset
   269
print "###### FINALIZE BUILD ######\n";
ec156946b469 Add call to sf-finalize
Dario Sestito <darios@symbian.org>
parents: 76
diff changeset
   270
my $sFinalizeCmd = "hlm sf-finalize -Dsf.project.type=package $sSubProjArg -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTagsArg $sNoPublishOpt $sJobRootDirArg $sHlmDefineOpt $sVariantArg $sSourcesRevisionArg $sSBSConfigArg";
ec156946b469 Add call to sf-finalize
Dario Sestito <darios@symbian.org>
parents: 76
diff changeset
   271
print("$sFinalizeCmd\n");
ec156946b469 Add call to sf-finalize
Dario Sestito <darios@symbian.org>
parents: 76
diff changeset
   272
system($sFinalizeCmd);
ec156946b469 Add call to sf-finalize
Dario Sestito <darios@symbian.org>
parents: 76
diff changeset
   273
37
2e0ebeeeaf52 Change back to bootstrap dir after the build to allow removal of project dir
Dario Sestito <darios@symbian.org>
parents: 36
diff changeset
   274
print("cd $sBOOTSTRAP_DIR\n");
2e0ebeeeaf52 Change back to bootstrap dir after the build to allow removal of project dir
Dario Sestito <darios@symbian.org>
parents: 36
diff changeset
   275
chdir("$sBOOTSTRAP_DIR");
2e0ebeeeaf52 Change back to bootstrap dir after the build to allow removal of project dir
Dario Sestito <darios@symbian.org>
parents: 36
diff changeset
   276
59
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   277
# release the drive letter and optionally re-enable the AV
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   278
release_drive_letter_and_reenable_av($sDriveLetter);
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   279
system("subst $sDriveLetter: /d"); # this is not required, but it's a good idea to keep things in order
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   280
print "drive letter $sDriveLetter released (and drive unsubsted)\n";
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   281
35
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   282
if ($bHudson)
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   283
{
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   284
	print "cleaning job directories...\n";
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   285
	if (-d "$sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel") # project dir
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   286
	{
71
f7ba24a607f8 Remove the correct job directory after the build, otherwise concurrent builds of the same package if run at the same time will have their jobdir removed and hence fail
Dario Sestito <darios@symbian.org>
parents: 70
diff changeset
   287
		print "rmdir /S /Q $sJobDir\n";
f7ba24a607f8 Remove the correct job directory after the build, otherwise concurrent builds of the same package if run at the same time will have their jobdir removed and hence fail
Dario Sestito <darios@symbian.org>
parents: 70
diff changeset
   288
		system("rmdir /S /Q $sJobDir");
35
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   289
	}
39
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   290
	if (-d "$sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber") # build drive
35
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   291
	{
39
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   292
		print "rmdir /S $sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber\n";
d6975a94a893 Dump console output to files and upload them to \\bishare
Dario Sestito <darios@symbian.org>
parents: 38
diff changeset
   293
		system("rmdir /S /Q $sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber");
35
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   294
	}
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   295
}
4d500511bf5a Add removal of job directories if build is run from build management system (i.e. --hudson is given)
Dario Sestito <darios@symbian.org>
parents: 34
diff changeset
   296
45
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   297
sub find_working_drive
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   298
{
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   299
	my @drive_list = ('E', 'G', 'D', 'C');
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   300
	
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   301
	for my $drive (@drive_list)
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   302
	{
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   303
		return "$drive:" if (-d "$drive:/");
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   304
	}
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   305
	
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   306
	die "Could not find suitable working drive.";
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   307
}
61887c5ee9db Include drive E in the search for a working drive. Make copy of console output files conditional on --publish
Dario Sestito <darios@symbian.org>
parents: 44
diff changeset
   308
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   309
sub mkdir_unique
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   310
{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   311
	my ($sBaseDir) = @_;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   312
	
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   313
	# check that the path where the new dir must be created exists.
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   314
	$sBaseDir =~ m,(.*[\\/])?(.*),;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   315
	mkpath($1) if ($1 && !-d $1);
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   316
	
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   317
	my $nI = 0;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   318
	my $sNewDirName = "$sBaseDir";
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   319
	while(!mkdir($sNewDirName))
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   320
	{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   321
		$nI++;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   322
		$sNewDirName = "$sBaseDir.$nI";
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   323
	}
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   324
	
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   325
	return $sNewDirName;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   326
}
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   327
22
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   328
sub get_rev_zero_hash
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   329
{
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   330
	my ($sFbfProjectRepo) = @_;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   331
	
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   332
	my $sOutput = `hg -R $sFbfProjectRepo identify -r0`;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   333
	
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   334
	# remove leading and trailing spaces
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   335
	$sOutput =~ s,^\s+,,;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   336
	$sOutput =~ s,\s+$,,;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   337
	
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   338
	# remove tags e.g. "1fc39a7e9d79 tip"
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   339
	$sOutput =~ s,([0-9a-z]+)\s+.*,$1,;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   340
	
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   341
	return $sOutput;
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   342
}
7a9425957569 Label to be retrieved automatically from project repo path, numbers file indexed by revision zero hash
Dario Sestito <darios@symbian.org>
parents: 21
diff changeset
   343
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   344
sub get_job_number
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   345
{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   346
	my ($sKey) = @_;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   347
	
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   348
	$sKey=lc($sKey);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   349
	
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   350
	my %hnNumbers = ();
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   351
	
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   352
	my $nAttempts = 0;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   353
	my $bGotNumber = 0;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   354
	do
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   355
	{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   356
		open(FILE, "+<$sNUMBERS_FILE") or die("Can't open $sNUMBERS_FILE");
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   357
		if ( flock(FILE, 6) )
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   358
		{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   359
			my $sLine;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   360
			while ($sLine = <FILE>)
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   361
			{
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   362
				$hnNumbers{lc($1)} = $2 if ($sLine =~ m%(.*),(.*)%);
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   363
			}
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   364
			
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   365
			$hnNumbers{$sKey} = 0 if (! $hnNumbers{$sKey} );
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   366
			$hnNumbers{$sKey} = $hnNumbers{$sKey} + 1;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   367
			
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   368
			seek(FILE, 0, 0);
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   369
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   370
			for my $sStr ( keys(%hnNumbers) )
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   371
			{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   372
				print FILE "$sStr,$hnNumbers{$sStr}\n";
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   373
			}
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   374
			truncate(FILE,tell(FILE));
11
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   375
			
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   376
			$bGotNumber = 1;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   377
		}
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   378
		else
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   379
		{
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   380
			$nAttempts ++;
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   381
			sleep(3);
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   382
		}
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   383
		close(FILE);
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   384
	}
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   385
	until ( $bGotNumber or $nAttempts == $nLOCK_FILE_MAX_ATTEMPTS );
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   386
	
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   387
	return $hnNumbers{$sKey};
f3475510d60c Added script to automate package build steps
BuildAdmin@LON-ENGBUILD89
parents:
diff changeset
   388
}
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   389
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   390
sub acquire_drive_letter
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   391
{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   392
	my %hsPidsAndTimestamps = ();
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   393
	
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   394
	my $sLetterToRelease = '';
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   395
	
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   396
	my $nAttempts = 0;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   397
	my $bAcquired = 0;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   398
	do
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   399
	{
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   400
		open(FILE, "+<$sWORKING_DRIVE\\$sLETTERS_FILE") or die("Can't open $sWORKING_DRIVE\\$sLETTERS_FILE");
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   401
		if ( flock(FILE, 6) )
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   402
		{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   403
			my $sLine;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   404
			while ($sLine = <FILE>)
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   405
			{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   406
				if ($sLine =~ m%([^,]*),(.*)%)
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   407
				{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   408
					my $sLetter=$1;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   409
					my $sString=$2;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   410
					
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   411
					$sString=~m%([^,]*),(.*)%;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   412
					my $nPid=$1;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   413
					my $nTimestamp=$2;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   414
					
61
cfb15e4d62a4 In letters file allow timestamp=0 to have the drive left alone
Dario Sestito <darios@symbian.org>
parents: 60
diff changeset
   415
					if (time()-$nTimestamp<=$nMAX_LETTER_AGE_SECONDS or $nTimestamp == 0 or $nTimestamp == -1)
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   416
					{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   417
						$hsPidsAndTimestamps{$sLetter} = $sString;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   418
					}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   419
					else
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   420
					{
19
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
   421
						# lease has expired: unsubst drive letter and don't add to hash
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
   422
						system("subst $sLetter: /d");
472feb69d0c9 Changed location of default config repo, added --testbuild option, extended help
Dario Sestito <darios@symbian.org>
parents: 17
diff changeset
   423
						print "forced release of letter: $sLetter (and drive unsubsted)\n";
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   424
					}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   425
				}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   426
			}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   427
			
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   428
			for my $sNewLetter ('H'..'Y')
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   429
			{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   430
				if (! $hsPidsAndTimestamps{$sNewLetter})
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   431
				{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   432
					my $sTimestamp = time();
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   433
					$hsPidsAndTimestamps{$sNewLetter} = "$$,$sTimestamp";
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   434
					$sLetterToRelease = $sNewLetter;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   435
					last;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   436
				}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   437
			}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   438
			
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   439
			seek(FILE, 0, 0);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   440
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   441
			for my $sLetter ( keys(%hsPidsAndTimestamps) )
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   442
			{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   443
				print FILE "$sLetter,$hsPidsAndTimestamps{$sLetter}\n";
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   444
			}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   445
			truncate(FILE,tell(FILE));
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   446
			
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   447
			$bAcquired = 1;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   448
		}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   449
		else
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   450
		{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   451
			$nAttempts ++;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   452
			sleep(3);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   453
		}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   454
		close(FILE);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   455
	}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   456
	until ( $bAcquired or $nAttempts == $nLOCK_FILE_MAX_ATTEMPTS );
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   457
	
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   458
	return $sLetterToRelease;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   459
}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   460
59
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   461
sub release_drive_letter_and_reenable_av
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   462
{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   463
	my ($sLetterToRelease) = @_;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   464
	
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   465
	my %hsPidsAndTimestamps = ();
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   466
	
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   467
	my $nAttempts = 0;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   468
	my $bAcquired = 0;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   469
	do
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   470
	{
32
11821242bc3e Make G: the working drive (unless not ready) and D: the second option
Dario Sestito <darios@symbian.org>
parents: 31
diff changeset
   471
		open(FILE, "+<$sWORKING_DRIVE\\$sLETTERS_FILE") or die("Can't open $sWORKING_DRIVE\\$sLETTERS_FILE");
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   472
		if ( flock(FILE, 6) )
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   473
		{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   474
			my $sLine;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   475
			while ($sLine = <FILE>)
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   476
			{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   477
				$hsPidsAndTimestamps{$1} = $2 if ($sLine =~ m%([^,]*),(.*)%);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   478
			}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   479
			
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   480
			delete $hsPidsAndTimestamps{$sLetterToRelease};
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   481
			
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   482
			seek(FILE, 0, 0);
59
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   483
			
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   484
			# if there are no other builds at this time then enable back the antivirus
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   485
			my $nConcurrentBuilds = scalar(keys(%hsPidsAndTimestamps));
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   486
			if ($nConcurrentBuilds == 0)
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   487
			{
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   488
				if ($bDisableAntiVirus)
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   489
				{
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   490
					print "enabling anti-virus\n";
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   491
					my $enableav_cmd = "av.bat /start";
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   492
					print "$enableav_cmd\n";
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   493
					system($enableav_cmd);
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   494
				}
d41d4cdb97ad Add --disableav option to disable the antivirus for the duration of the build
Dario Sestito <darios@symbian.org>
parents: 58
diff changeset
   495
			}
13
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   496
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   497
			for my $sLetter ( keys(%hsPidsAndTimestamps) )
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   498
			{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   499
				print FILE "$sLetter,$hsPidsAndTimestamps{$sLetter}\n";
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   500
			}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   501
			truncate(FILE,tell(FILE));
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   502
			
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   503
			$bAcquired = 1;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   504
		}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   505
		else
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   506
		{
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   507
			$nAttempts ++;
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   508
			sleep(3);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   509
		}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   510
		close(FILE);
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   511
	}
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   512
	until ( $bAcquired or $nAttempts == $nLOCK_FILE_MAX_ATTEMPTS );
85202f272e4a Changes to make build_package.pl allocate drive and build number automatically
darios@symbian.org
parents: 12
diff changeset
   513
}