130 lines
5.2 KiB
Python
Executable File
130 lines
5.2 KiB
Python
Executable File
#!/usr/bin/python
|
|
# coding: utf-8
|
|
#
|
|
|
|
import argparse
|
|
import fileinput
|
|
import glob
|
|
import inspect
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
|
|
parser = argparse.ArgumentParser( description='Perform cqm analysis of a component.')
|
|
parser.add_argument( 'projectName', help='Name of the project as shown in the server or in the gui.')
|
|
parser.add_argument( 'buildRoot', help='Absolute path to a preconfigured (cmake) build folder of the component to be analyzed..')
|
|
parser.add_argument( 'scriptFolder', help='Absolute path with qav helper scripts')
|
|
parser.add_argument( 'qafProjectRoot', help='Absolute path to generate the qav project files')
|
|
args = parser.parse_args()
|
|
|
|
scriptFolder = args.scriptFolder
|
|
if not os.path.isdir(args.scriptFolder):
|
|
print >> sys.stderr, "Given script folder does not exist: %s" % scriptFolder
|
|
sys.path.append(scriptFolder) # to make sure import createPrqaXmls200 works
|
|
|
|
# after sys.path.append
|
|
import createPrqaXmls200
|
|
import modifyJSON
|
|
|
|
scriptFolder = args.scriptFolder
|
|
qafProjectRoot = args.qafProjectRoot
|
|
qafConfigFolder = os.path.join(os.getenv('HOME'), '.config/PRQA/prqa-framework-2.1.1')
|
|
qafInstallFolder = os.path.join(os.getenv('HOME'), 'qav/prqa-framework-2.1.1')
|
|
qaCliExe = qafInstallFolder + "/common/bin/qacli"
|
|
qaGuiExe = qafInstallFolder + "/common/bin/qagui"
|
|
qaVerifyHost = "compile.defence-elec.de"
|
|
qaVerifyPort = "22230"
|
|
licenseServerAndPort = "5055@ubuntu-polarion.defence-elec.de"
|
|
|
|
###### PROJECT SPECIFIC CONFIGURATION
|
|
qafProjectXML = qafProjectRoot+"/prqaproject.xml"
|
|
acfFile = os.path.join( qafProjectRoot, args.projectName + ".acf" )
|
|
rcfFile = qafInstallFolder + "/config/rcf/RDE-CodingStandard.rcf"
|
|
cctfileCpp = qafInstallFolder + "/config/cct/GNU_GCC-g++_4.8-x86_64-generic-linux-C++-c++11.cct"
|
|
cctfileC = qafInstallFolder + "/config/cct/GNU_GCC-gcc_4.8-x86_64-generic-linux-C-c11.cct"
|
|
|
|
excludedSourceDirs = []
|
|
additionalIncludeDirs= []
|
|
|
|
excludedIncludeDirs = ['/opt'
|
|
]
|
|
|
|
analysisDefinitions = ['__PIC__',
|
|
'__x86_64__',
|
|
'__LP64__',
|
|
'__GNUC__=4',
|
|
'__GNUC_MINOR__=8',
|
|
'__cplusplus=201103',
|
|
]
|
|
|
|
# this stuff here is not used by qacli admin -F (or -j) ... so why do we need this?
|
|
defineOptionSyntax = [ '-D',
|
|
'/D'
|
|
]
|
|
|
|
includeOptionSyntax = [ '-I',
|
|
'/I',
|
|
'-i',
|
|
'-isystem'
|
|
]
|
|
|
|
###### PROJECT SPECIFIC CONFIGURATION
|
|
|
|
|
|
prqaProjectFileList = glob.glob( qafProjectRoot + "/prqaproject.xml*")
|
|
for prqaprojectFile in prqaProjectFileList:
|
|
os.remove( prqaprojectFile)
|
|
|
|
prqaConfigFolder = os.path.join(qafProjectRoot, 'prqa', 'config')
|
|
if not os.path.exists(prqaConfigFolder):
|
|
os.makedirs(prqaConfigFolder)
|
|
|
|
print( "######################################################")
|
|
print( "## QAF Projekt ANLEGEN " + qafProjectRoot)
|
|
print( "######################################################")
|
|
|
|
createPrqaXmls200.createACF(acfFile, additionalIncludeDirs, excludedIncludeDirs, analysisDefinitions)
|
|
|
|
os.system( qaCliExe+' admin --qaf-project-config --qaf-project '+ qafProjectRoot+' --cct '+cctfileCpp+' --cct '+cctfileC+' --rcf '+rcfFile+' --acf '+acfFile)
|
|
|
|
print( "######################################################")
|
|
print( "## XML FILES SCHREIBEN " + qafProjectRoot)
|
|
print( "######################################################")
|
|
createPrqaXmls200.createPrqaProjectXML(qafProjectXML, cctfileCpp, cctfileC, includeOptionSyntax, defineOptionSyntax, excludedSourceDirs, args.buildRoot, qafConfigFolder)
|
|
|
|
#print( "######################################################")
|
|
#print( "## SET LICENCE SERVER")
|
|
#print( "######################################################")
|
|
os.system( qaCliExe+' admin --set-license-server ' + licenseServerAndPort)
|
|
|
|
#print( "######################################################")
|
|
#print( "## ENABLE DEBUG INFO")
|
|
#print( "######################################################")
|
|
os.system( qaCliExe + " admin --debug-level DEBUG")
|
|
|
|
#print( "######################################################")
|
|
#print( "## REMOVE ALL LOCKS THAT MAY BE ACTIVE DUE TO DISTURBED ANALYZES")
|
|
#print( "######################################################")
|
|
os.system( qaCliExe + " admin --qaf-project \"" + qafProjectRoot + "\" --remove-locks")
|
|
print (qaCliExe + " admin --qaf-project \"" + qafProjectRoot + "\" --remove-locks")
|
|
|
|
#print( "######################################################")
|
|
#print( "## LIST FILES --- TEST")
|
|
#print( "######################################################")
|
|
os.system( qaCliExe + " admin -P \"" + qafProjectRoot + "\" --list-config-files")
|
|
|
|
#print( "######################################################")
|
|
#print( "## CMAKE CONFIGURE WITH JSON")
|
|
#print( "######################################################")
|
|
#print('####')
|
|
|
|
cc_json = os.path.join(args.buildRoot, 'compile_commands.json')
|
|
cc_txt = os.path.join(args.qafProjectRoot, 'compile_commands.txt')
|
|
if not modifyJSON.generate_compile_commands_from_json(cc_json, cc_txt, args.buildRoot):
|
|
sys.exit(1)
|
|
|
|
print(qaCliExe + ' admin -P ' + qafProjectRoot + ' -F ' + cc_txt)
|
|
os.system( qaCliExe + ' admin -P ' + qafProjectRoot + ' -F ' + cc_txt)
|
|
print('####')
|