@@ -64,6 +64,20 @@ class CITool(Enum):
6464 BAMBOO = "Bamboo"
6565 UNKNOWN = "Unknown CI/CD"
6666
67+ def displayVersion ():
68+ versionInfo = "Version Unknown"
69+
70+ # Get absolute path to directory containing the current script
71+ script_dir = os .path .dirname (os .path .abspath (__file__ ))
72+
73+ # Build path to VERSION.txt
74+ version_path = os .path .join (script_dir , 'VERSION.txt' )
75+
76+ if os .path .exists (version_path ):
77+ with open (version_path ,"r" ) as fd :
78+ versionInfo = fd .read ()
79+ print ("vc_scripts_submodule Version: " , versionInfo )
80+
6781class VectorCASTExecute (object ):
6882
6983 def detect_ci_tool (self ):
@@ -124,10 +138,12 @@ def __init__(self, args):
124138 self .failed_count = 0
125139
126140 if args .output_dir :
141+ self .output_dir = args .output_dir
127142 self .xml_data_dir = os .path .join (args .output_dir , 'xml_data' )
128143 if not os .path .exists (self .xml_data_dir ):
129144 os .makedirs (self .xml_data_dir )
130145 else :
146+ self .output_dir = ""
131147 self .xml_data_dir = "xml_data"
132148
133149 if args .build and not args .build_execute :
@@ -230,7 +246,8 @@ def generateIndexHtml(self):
230246 prj_dir = os .getcwd ().replace ("\\ " ,"/" ) + "/"
231247
232248 tempHtmlReportList = glob .glob ("*.html" )
233- tempHtmlReportList += glob .glob (os .path .join (args .html_base_dir , "*.html" ))
249+ tempHtmlReportList += glob .glob (os .path .join (self .xml_data_dir , "*.html" ))
250+ tempHtmlReportList += glob .glob (os .path .join (self .html_base_dir , "*.html" ))
234251 htmlReportList = []
235252
236253 for report in tempHtmlReportList :
@@ -240,7 +257,7 @@ def generateIndexHtml(self):
240257 htmlReportList .append (report )
241258
242259 from create_index_html import create_index_html
243- create_index_html (self .FullMP , self .ciTool == CITool .GITLAB )
260+ create_index_html (self .FullMP , self .ciTool == CITool .GITLAB , output_dir = self . output_dir )
244261
245262 def runJunitMetrics (self ):
246263 print ("Creating JUnit Metrics" )
@@ -323,29 +340,38 @@ def runPcLintPlusMetrics(self):
323340 print ("PC-lint Plus Metrics file: " + report_name )
324341 generate_pclp_reports .generate_reports (self .pclp_input , output_gitlab = report_name )
325342
326- if args .pclp_output_html :
343+ if self .pclp_output_html :
327344 print ("Creating PC-lint Plus Findings" )
328345 generate_pclp_reports .generate_html_report (self .FullMP , self .pclp_input , self .pclp_output_html )
329346
330347 def runReports (self ):
331348 if self .aggregate :
349+ agg_rpt_name = os .path .join (self .output_dir , self .mpName + "_aggregate_report.html" )
332350 print ("Creating Aggregate Coverage Report" )
333- self .manageWait .exec_manage_command ("--create-report=aggregate --output=" + self .mpName + "_aggregate_report.html" )
351+ if os .path .exists (agg_rpt_name ):
352+ os .remove (agg_rpt_name )
353+ self .manageWait .exec_manage_command ("--create-report=aggregate --output=" + agg_rpt_name )
334354 self .needIndexHtml = True
335355 if self .metrics :
356+ met_rpt_name = os .path .join (self .output_dir , self .mpName + "_metrics_report.html" )
336357 print ("Creating Metrics Report" )
337- self .manageWait .exec_manage_command ("--create-report=metrics --output=" + self .mpName + "_metrics_report.html" )
358+ if os .path .exists (met_rpt_name ):
359+ os .remove (met_rpt_name )
360+ self .manageWait .exec_manage_command ("--create-report=metrics --output=" + met_rpt_name )
338361 self .needIndexHtml = True
339362 if self .fullstatus :
363+ fs_rpt_name = os .path .join (self .output_dir , self .mpName + "_full_status_report.html" )
364+ if os .path .exists (fs_rpt_name ):
365+ os .remove (fs_rpt_name )
340366 print ("Creating Full Status Report" )
341- self .manageWait .exec_manage_command ("--full-status=" + self . mpName + "_full_status_report.html" )
367+ self .manageWait .exec_manage_command ("--full-status=" + fs_rpt_name )
342368 self .needIndexHtml = True
343369
344370 def generateTestCaseMgtRpt (self ):
345- if not os .path .exists ("management" ):
346- os .makedirs ("management" )
371+ if not os .path .exists (os . path . join ( self . output_dir , "management" ) ):
372+ os .makedirs (os . path . join ( self . output_dir , "management" ) )
347373 else :
348- for file in glob .glob ("management/ *_management_report.html" ):
374+ for file in glob .glob (os . path . join ( self . output_dir , "management" , " *_management_report.html") ):
349375 os .remove (file )
350376
351377 if checkVectorCASTVersion (21 ):
@@ -360,7 +386,7 @@ def generateTestCaseMgtRpt(self):
360386 self .needIndexHtml = True
361387
362388 report_name = env .compiler .name + "_" + env .testsuite .name + "_" + env .name + "_management_report.html"
363- report_name = os .path .join ("management" ,report_name )
389+ report_name = os .path .join (self . output_dir , "management" ,report_name )
364390 print (f"Creating Test Case Management HTML report for { env .name } in { report_name } " )
365391 env .api .report (report_type = "MANAGEMENT_REPORT" , formats = ["HTML" ], output_file = report_name )
366392 else :
@@ -424,7 +450,7 @@ def runExec(self):
424450if __name__ == '__main__' :
425451
426452 parser = argparse .ArgumentParser ()
427- parser .add_argument ('ManageProject' , help = 'VectorCAST Project Name' )
453+ parser .add_argument ('ManageProject' , nargs = '?' , help = 'VectorCAST Project Name' )
428454
429455 actionGroup = parser .add_argument_group ('Script Actions' , 'Options for the main tasks' )
430456 actionGroup .add_argument ('--build-execute' , help = 'Builds and exeuctes the VectorCAST Project' , action = "store_true" , default = False )
@@ -469,10 +495,24 @@ def runExec(self):
469495 actionGroup .add_argument ('--print_exc' , help = 'Prints exceptions' , action = "store_true" , default = False )
470496 actionGroup .add_argument ('--timing' , help = 'Prints timing information for metrics generation' , action = "store_true" , default = False )
471497 actionGroup .add_argument ('-v' , '--verbose' , help = 'Enable verbose output' , action = "store_true" , default = False )
472-
498+ actionGroup . add_argument ( '--version' , help = 'Displays the version information' , action = "store_true" , default = False )
473499
474500 args = parser .parse_args ()
475501
502+ # Conditional requirement check
503+ if not args .version and not args .ManageProject :
504+ parser .error ("ManageProject is required unless --version is specified" )
505+ sys .exit (0 )
506+
507+ if args .ManageProject and not os .path .isfile (args .ManageProject ):
508+ print ("Manage project (.vcm file) provided does not exist: " + args .ManageProject )
509+ print ("exiting..." )
510+ sys .exit (- 1 )
511+
512+ if args .version :
513+ displayVersion ()
514+ sys .exit (0 )
515+
476516 if args .ci :
477517 os .environ ['VCAST_USE_CI_LICENSES' ] = "1"
478518
0 commit comments