1 package BuildFunctions
;
5 our @ISA = qw(Exporter);
6 our @EXPORT = qw(build_project Check_For_Warnings_and_Errors get_time_and_date get_date);
11 # Copyright (C)2000-2002 Sony Online Entertainment Inc.
14 # Title: BuildFunctions.pl
15 # Description: This file contains the various functions used by the different build scripts.
16 # @author $Author: gmcdaniel $
17 # @version $Revision: #1 $
25 #todo Possible failure points that I need to fix. The ResultsLogfile file can fail to be opened in one sub but still try to be written to in Check_Logfile_For_Warnings_and_Errors
26 #todo Bad coding to call ResultsLogFile without acutally passing it in to the sub? Probably
31 # This subroutine builds the passed project. It is passed the project name, the string for the project to build, and the project type (release or debug)
35 print ("Beginning $_[1] build...\n");
36 system("msdev ..\\src\\build\\win32\\swg.dsw /MAKE \"$_[1]\" /y3 /REBUILD /OUT d:\\buildlogs\\$_[0]_$_[2].log");
37 print ("$_[1] build complete\n");
39 $timestamp = get_time_and_date
();
40 $timeStamped_Log = $_[0]."_".$_[2]."_".$timestamp.".log";
41 system ("copy d:\\buildlogs\\$_[0]_$_[2].log d:\\buildlogs\\$timeStamped_Log");
52 # This subroutine calls the build subroutine to build both the release and debug versions of the project that is passed
57 $project = $_[0]." - Win32 Release";
59 build
($_[0],$project,$type);
62 $project = $_[0]." - Win32 Debug";
64 build
($_[0],$project,$type);
67 $project = $_[0]." - Win32 Optimized";
69 build
($_[0],$project,$type);
71 } # End of sub build_project
77 # This subroutine returns the current local time and date
81 ($sec, $min, $hour, $day, $month, $year) = (localtime) [0,1,2,3,4,5];
84 $dayandtime = $month."_".$day."_".$year."__".$hour."_".$min."_".$sec;
87 } # End of sub get_time_and_date
93 # This subroutine returns the current local date
97 ($day, $month, $year) = (localtime) [3,4,5];
100 $date = $month."/".$day."/".$year;
103 } # End of sub get_date
109 # This subroutine checks for warnings and errors in the build logs. If there is an error it returns true otherwise it returns false.
110 # It takes the name the logfile to check and the resulting exe or project name as input.
112 sub Check_Logfile_For_Warnings_and_Errors
115 $third_to_last_line = "test_line_3";
116 $second_to_last_line = "test_line_2";
118 open (Logfile
,"d:\\buildlogs\\$_[0]") || die "Cannot open $_[0] for reading.";
122 $third_to_last_line = $second_to_last_line;
123 $second_to_last_line = $_;
125 close (Logfile
) || die "can't close $_[0]";
127 print ("$third_to_last_line\n");
128 print ("$second_to_last_line\n");
129 print ResultsLogfile
("$third_to_last_line\n");
130 print ResultsLogfile
("$second_to_last_line\n");
131 print ResultsLogfile
("\n");
136 $search_for_errors= "0 error";
137 $search_for_warnings= "0 warning";
141 if (index($third_to_last_line, $search_for_errors,$match) > -1) {
142 print ("No errors Found in $_[0]\n");
146 if (index($third_to_last_line, $search_for_warnings,$match) > -1) {
147 #no warnings or errors found
148 print ("No Warnings Found in $_[0]\n");
153 print ("Warning Found in $_[0]\n");
160 print ("Error Found in $_[0]\n");
166 } # End of sub Check_Logfile_For_Warnings_and_Errors
172 # This subroutine checks for warnings and errors in the build logs. If there is an error or warning it notifies QA and the lead programmers.
173 # If there is not an error or warning then the build log is just sent to QA.
174 # It takes the name of the project and the resulting exe or project name as input.
176 sub Check_For_Warnings_and_Errors
179 print ("Checking for errors and warnings...\n");
182 # create file to store warnings and errors for inclusion in body of email.
183 open (ResultsLogfile
, ">d:\\buildlogs\\$_[0]Results.log") || die "Sorry, I couldn't create $_[0]Results.log";
187 # Prints to results file for easier email formatting
188 print ResultsLogfile
("\n");
189 print ResultsLogfile
("Release Build:\n");
192 # Checks for errors or warnings in the release build
193 $Logfile_to_check = $_[0]."_Release.log";
194 $ReleaseError = Check_Logfile_For_Warnings_and_Errors
($Logfile_to_check);
197 # Prints to results file for easier email formatting
198 print ResultsLogfile
("\n");
199 print ResultsLogfile
("Debug Build:\n");
202 # Checks for errors or warnings in the debug build
203 $Logfile_to_check = $_[0]."_Debug.log";
204 $DebugError = Check_Logfile_For_Warnings_and_Errors
($Logfile_to_check);
208 # Prints to results file for easier email formatting
209 print ResultsLogfile
("\n");
210 print ResultsLogfile
("Optimized Build:\n");
213 # Checks for errors or warnings in the debug build
214 $Logfile_to_check = $_[0]."_Optimized.log";
215 $OptimizedError = Check_Logfile_For_Warnings_and_Errors
($Logfile_to_check);
218 # Closes file used for the number of errors and warnings
219 close (ResultsLogfile
);
226 $gmcdaniel = "gmcdaniel\@soe.sony.com";
227 $jbrack = "jbrack\@soe.sony.com";
228 $jgrills = "jgrills\@soe.sony.com";
229 $asommers = "asommers\@soe.sony.com";
230 $cmayer = "cmayer\@soe.sony.com";
231 $prog_leads = "-to:$gmcdaniel -to:$jgrills -to:$cmayer -to:$asommers -cc:$jbrack";
235 $date_stamp = get_date
();
237 if ($ReleaseError eq "true")
239 print ("Error or warning found in $_[0] Release Log. Emailing appropriate people.\n");
241 # Email the results to Programmer Leads and QA
242 system ("postie -host:sdt-mx1.station.sony.com $prog_leads -from:$gmcdaniel -s:\"[BUILDLOG] Errors or Warnings in Daily $_[0] Build Logs $date_stamp\" -nomsg -file:d:\\buildlogs\\$_[0]Results.log -a:d:\\buildlogs\\$_[0]_Release.log -a:d:\\buildlogs\\$_[0]_Debug.log -a:d:\\buildlogs\\$_[0]_Optimized.log");
245 elsif ($DebugError eq "true")
247 print ("Error or warning found in $_[0] Debug Log. Emailing appropriate people.\n");
249 # Email the results to Programmer Leads and QA
250 system ("postie -host:sdt-mx1.station.sony.com $prog_leads -from:$gmcdaniel -s:\"[BUILDLOG] Errors or Warnings in Daily $_[0] Build Logs $date_stamp\" -nomsg -file:d:\\buildlogs\\$_[0]Results.log -a:d:\\buildlogs\\$_[0]_Release.log -a:d:\\buildlogs\\$_[0]_Debug.log -a:d:\\buildlogs\\$_[0]_Optimized.log");
253 elsif ($OptimizedError eq "true")
255 print ("Error or warning found in $_[0] Optimized Log. Emailing appropriate people.\n");
257 # Email the results to Programmer Leads and QA
258 system ("postie -host:sdt-mx1.station.sony.com $prog_leads -from:$gmcdaniel -s:\"[BUILDLOG] Errors or Warnings in Daily $_[0] Build Logs $date_stamp\" -nomsg -file:d:\\buildlogs\\$_[0]Results.log -a:d:\\buildlogs\\$_[0]_Release.log -a:d:\\buildlogs\\$_[0]_Debug.log -a:d:\\buildlogs\\$_[0]_Optimized.log");
263 print ("No errors or warnings found in $_[0] logs.");
265 # Email the results to QA and Programmer Leads
266 system ("postie -host:sdt-mx1.station.sony.com $prog_leads -from:$gmcdaniel -s:\"[BUILDLOG] $_[0] Build Successful $date_stamp\" -nomsg -file:d:\\buildlogs\\$_[0]Results.log");
271 print ("End of errors and warning check for $_[0] logs.\n");
275 } # End of sub Check_For_Warnings_and_Errors