20 |
20 |
21 my $sBOOTSTRAP_DIR="C:\\Apps\\FBF\\bootstrap"; |
21 my $sBOOTSTRAP_DIR="C:\\Apps\\FBF\\bootstrap"; |
22 my $sJOB_BASE_DIR="D:\\fbf_project"; |
22 my $sJOB_BASE_DIR="D:\\fbf_project"; |
23 my $nMAX_JOBDIR_AGE_SECONDS = 86400; # max number of seconds after which the letter is forcibly released |
23 my $nMAX_JOBDIR_AGE_SECONDS = 86400; # max number of seconds after which the letter is forcibly released |
24 my $nLOCK_FILE_MAX_ATTEMPTS = 5; |
24 my $nLOCK_FILE_MAX_ATTEMPTS = 5; |
25 my $sNUMBERS_FILE="\\\\bishare\\SF_builds\\numbers.txt"; |
25 my $sNUMBERS_FILE="\\\\bishare\\SF_builds\\numbers2.txt"; |
26 my $sLETTERS_FILE="D:\\letters.txt"; |
26 my $sLETTERS_FILE="D:\\letters.txt"; |
27 my $nMAX_LETTER_AGE_SECONDS = 86400; # max number of seconds after which the letter is forcibly released |
27 my $nMAX_LETTER_AGE_SECONDS = 86400; # max number of seconds after which the letter is forcibly released |
28 |
28 |
29 my $sFbfProjectRepo = ''; |
29 my $sFbfProjectRepo = "\\\\bishare\\mercurial_internal\\fbf\\projects\\packages"; |
30 my $sFbfProjectDir = ''; |
30 my $sFbfProjectDir = ''; |
|
31 my $sSubProject = ''; |
|
32 #my $sSourcesFile = ''; |
|
33 #my $sModelFile = ''; |
31 my $sFbfConfigRepo="\\\\bishare\\mercurial_internal\\fbf\\configs\\pkgbuild"; |
34 my $sFbfConfigRepo="\\\\bishare\\mercurial_internal\\fbf\\configs\\pkgbuild"; |
32 my $sFbfConfigDir = ''; |
35 my $sFbfConfigDir = ''; |
33 my $nCmdLineNumber; |
36 my $nCmdLineNumber; |
34 my $bProduction = 0; |
37 my $bProduction = 0; |
35 my $bPublish = 1; |
38 my $bPublish = 1; |
36 GetOptions(( |
39 GetOptions(( |
37 'configrepo:s' => \$sFbfConfigRepo, |
40 'configrepo=s' => \$sFbfConfigRepo, |
38 'configdir:s' => \$sFbfConfigDir, |
41 'configdir=s' => \$sFbfConfigDir, |
39 'projectrepo:s' => \$sFbfProjectRepo, |
42 'projectrepo=s' => \$sFbfProjectRepo, |
40 'projectdir:s' => \$sFbfProjectDir, |
43 'projectdir=s' => \$sFbfProjectDir, |
41 'number:s' => \$nCmdLineNumber, |
44 'subproj=s' => \$sSubProject, |
|
45 #'sources=s' => \$sSourcesFile, |
|
46 #'model=s' => \$sModelFile, |
|
47 'number=s' => \$nCmdLineNumber, |
42 'production!' => \$bProduction, |
48 'production!' => \$bProduction, |
43 'publish!' => \$bPublish |
49 'publish!' => \$bPublish |
44 )); |
50 )); |
45 |
51 |
46 if (!$sFbfProjectRepo and !$sFbfProjectDir) |
52 if (!$sSubProject) |
47 { |
53 { |
48 print "Usage: build_package.pl --projectrepo=REPO [OPTIONS]\n"; |
54 print "Usage: build_package.pl --subproj=RELPATH [OPTIONS]\n"; |
49 print "where OPTIONS are:\n"; |
55 print "where OPTIONS are:\n"; |
50 print "\t--projectrepo=REPO[#REV] Use repository REPO at revision REV for the project.\n"; |
56 print "\t--subproj=RELPATH Select subproject located at RELPATH (relative to the root of the project repository)\n"; |
51 print "\t--projectdir=DIR Use DIR location for the project (exclusive with --projectrepo). Option --nopublish is required.\n"; |
57 print "\t--projectrepo=REPO[#REV] Use repository REPO at revision REV for the project (instead of \\\\bishare\\mercurial_internal\\fbf\\projects\\packages)\n"; |
|
58 print "\t--projectdir=DIR Use DIR location for the project (exclusive with --projectrepo).\n"; |
|
59 #print "\t--sources=FILE ...\n"; |
|
60 #print "\t--model=FILE ...\n"; |
52 print "\t--configrepo=REPO[#REV] Use repository REPO at revision REV for the config (instead of \\\\bishare\\mercurial_internal\\fbf\\config\\pkgbuild)\n"; |
61 print "\t--configrepo=REPO[#REV] Use repository REPO at revision REV for the config (instead of \\\\bishare\\mercurial_internal\\fbf\\config\\pkgbuild)\n"; |
53 print "\t--configdir=DIR Use DIR location for the config (exclusive with --configrepo). Option --nopublish is required.\n"; |
62 print "\t--configdir=DIR Use DIR location for the config (exclusive with --configrepo).\n"; |
54 print "\t--number=N Force build number to N\n"; |
63 print "\t--number=N Force build number to N\n"; |
55 print "\t--production Tag this build as 'production' (default: 'test') and use nnn numbering (default: Tnnn)\n"; |
64 print "\t--production Tag this build as 'production' (default: 'test') and use nnn numbering (default: Tnnn)\n"; |
56 print "\t--nopublish Use d:\\numbers_test.txt for numbers and disable publishing\n"; |
65 print "\t--nopublish Use d:\\numbers_test.txt for numbers and disable publishing\n"; |
57 exit(0); |
66 exit(0); |
58 } |
67 } |
59 |
68 |
60 if ($sFbfProjectDir and $bPublish) |
69 if ($sSubProject !~ m,^([^/]+)/[^/]+/([^/]+)$,) |
61 { |
70 { |
62 print "Error: Option --projectdir requires --nopublish\n"; |
71 print "Error: Option --subproj must be in the format codeline/layer/package (e.g. MCL/os/boardsupport)\n"; |
63 exit(0); |
72 exit(0); |
64 } |
73 } |
65 |
74 |
66 if ($sFbfConfigDir and $bPublish) |
75 #if (!$sFbfProjectRepo and !$sFbfProjectDir and (!$sSourcesFile or !$sModelFile)) |
67 { |
76 #{ |
68 print "Error: Option --configdir requires --nopublish\n"; |
77 # print "Error: If you don't provide --projectrepo or --projectdir then you have to provide both --sources and --model\n"; |
69 exit(0); |
78 # exit(0); |
70 } |
79 #} |
71 |
80 |
72 my $sFbfProjectRev = ''; |
81 my $sFbfProjectRev = ''; |
73 if ($sFbfProjectRepo =~ m,(.*)#(.*),) |
82 if ($sFbfProjectRepo =~ m,(.*)#(.*),) |
74 { |
83 { |
75 $sFbfProjectRepo = $1; |
84 $sFbfProjectRepo = $1; |
86 $sTestBuildOpt = "-Dsf.spec.publish.diamonds.tag=production" if ( $bProduction ); |
95 $sTestBuildOpt = "-Dsf.spec.publish.diamonds.tag=production" if ( $bProduction ); |
87 my $sNoPublishOpt = ""; |
96 my $sNoPublishOpt = ""; |
88 $sNoPublishOpt = "-Dsf.spec.publish.enable=false" if ( !$bPublish ); |
97 $sNoPublishOpt = "-Dsf.spec.publish.enable=false" if ( !$bPublish ); |
89 $sNUMBERS_FILE = "d:\\numbers_test.txt" if ( !$bPublish ); |
98 $sNUMBERS_FILE = "d:\\numbers_test.txt" if ( !$bPublish ); |
90 |
99 |
91 my $sLabelBaseString = $sFbfProjectRepo; |
100 my $sJobLabel = 'job'; |
92 $sLabelBaseString = $sFbfProjectDir if ($sFbfProjectDir); |
101 if ($sSubProject) |
93 $sLabelBaseString =~ m,.*[\\/]([^\\^/]+),; |
102 { |
94 my $sJobLabel = $1; |
103 $sSubProject =~ m,^([^/]+)/[^/]+/([^/]+)$,; |
95 $sJobLabel = $sLabelBaseString if (! $1); |
104 $sJobLabel = $2; |
|
105 } |
|
106 elsif ($sFbfProjectRepo) |
|
107 { |
|
108 $sFbfProjectRepo =~ m,(.*[\\/])?([^\\^/]+),; |
|
109 $sJobLabel = $2; |
|
110 } |
|
111 elsif ($sFbfProjectDir) |
|
112 { |
|
113 $sFbfProjectDir =~ m,(.*[\\/])?([^\\^/]+),; |
|
114 $sJobLabel = $2; |
|
115 } |
|
116 #elsif ($sSourcesFile) |
|
117 #{ |
|
118 # $sSourcesFile =~ m,/(adaptation|app|mw|os|ostools|tools)[\\/]([^\\^/]+),i; |
|
119 # $sJobLabel = $2; |
|
120 # $sSourcesFile =~ m,(.*[\\/])?([^\\^/]+),; |
|
121 # $sJobLabel = $2 if (!$sJobLabel); |
|
122 #} |
96 mkdir($sJOB_BASE_DIR) if (!-d$sJOB_BASE_DIR); |
123 mkdir($sJOB_BASE_DIR) if (!-d$sJOB_BASE_DIR); |
97 my $sJobDir = mkdir_unique("$sJOB_BASE_DIR\\$sJobLabel"); |
124 my $sJobDir = mkdir_unique("$sJOB_BASE_DIR\\$sJobLabel"); |
98 print "Created project dir $sJOB_BASE_DIR\\$sJobLabel\n"; |
125 print "Created project dir $sJOB_BASE_DIR\\$sJobLabel\n"; |
99 |
126 |
100 print("cd $sBOOTSTRAP_DIR\n"); |
127 print("cd $sBOOTSTRAP_DIR\n"); |
122 { |
149 { |
123 $nUnformattedNumber = $nCmdLineNumber; |
150 $nUnformattedNumber = $nCmdLineNumber; |
124 } |
151 } |
125 elsif ($sFbfProjectRepo) |
152 elsif ($sFbfProjectRepo) |
126 { |
153 { |
127 my $sRevZeroHash = get_rev_zero_hash($sFbfProjectRepo); |
154 my $sJobNumberKey = ''; |
128 my $sJobNumberKey = $sRevZeroHash; |
155 if ($sSubProject) |
|
156 { |
|
157 # key = <package>_<codeline>, e.g. for subproj=MCL/os/boardsupport -> key=boardsupport_MCL |
|
158 $sSubProject =~ m,^([^/]+)/[^/]+/([^/]+)$,; |
|
159 $sJobNumberKey = "$2_$1"; |
|
160 } |
|
161 else |
|
162 { |
|
163 # key = hash of the rev.0 of the package project repo |
|
164 my $sRevZeroHash = get_rev_zero_hash($sFbfProjectRepo); |
|
165 $sJobNumberKey = $sRevZeroHash; |
|
166 } |
129 $sJobNumberKey .= ".T" if (!$bProduction); |
167 $sJobNumberKey .= ".T" if (!$bProduction); |
130 $nUnformattedNumber = get_job_number($sJobNumberKey); |
168 $nUnformattedNumber = get_job_number($sJobNumberKey); |
131 } |
169 } |
132 my $nJobNumber = sprintf("%.3d", $nUnformattedNumber); |
170 my $nJobNumber = sprintf("%.3d", $nUnformattedNumber); |
133 $nJobNumber = "T$nJobNumber" if (!$bProduction); |
171 $nJobNumber = "T$nJobNumber" if (!$bProduction); |
143 # acquire drive letter |
181 # acquire drive letter |
144 my $sDriveLetter = acquire_drive_letter(); |
182 my $sDriveLetter = acquire_drive_letter(); |
145 print "acquired drive letter: $sDriveLetter\n"; |
183 print "acquired drive letter: $sDriveLetter\n"; |
146 die "Could not acquire drive letter" if (! $sDriveLetter); |
184 die "Could not acquire drive letter" if (! $sDriveLetter); |
147 |
185 |
|
186 my $sSubProjArg = ''; |
|
187 $sSubProjArg = "-Dsf.subproject.path=$sSubProject" if ($sSubProject); |
148 print("cd $sJobDir\\sf-config\n"); |
188 print("cd $sJobDir\\sf-config\n"); |
149 chdir("$sJobDir\\sf-config"); |
189 chdir("$sJobDir\\sf-config"); |
150 print "###### BUILD PREPARATION ######\n"; |
190 print "###### BUILD PREPARATION ######\n"; |
151 print("hlm sf-prep -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt\n"); |
191 print("hlm sf-prep -Dsf.project.type=package $sSubProjArg -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt\n"); |
152 system("hlm sf-prep -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt"); |
192 system("hlm sf-prep -Dsf.project.type=package $sSubProjArg -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt"); |
153 |
193 |
154 print "###### EXECUTE BUILD ######\n"; |
194 print "###### EXECUTE BUILD ######\n"; |
155 print("hlm sf-build-all -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt\n"); |
195 print("hlm sf-build-all -Dsf.project.type=package $sSubProjArg -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt\n"); |
156 system("hlm sf-build-all -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt"); |
196 system("hlm sf-build-all -Dsf.project.type=package $sSubProjArg -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt"); |
157 |
197 |
158 # release the drive letter |
198 # release the drive letter |
159 release_drive_letter($sDriveLetter); |
199 release_drive_letter($sDriveLetter); |
160 system("subst $sDriveLetter: /d"); # this is not required, but it's a good idea to keep things in order |
200 system("subst $sDriveLetter: /d"); # this is not required, but it's a good idea to keep things in order |
161 print "drive letter $sDriveLetter released (and drive unsubsted)\n"; |
201 print "drive letter $sDriveLetter released (and drive unsubsted)\n"; |