def createDiagram(context, detailLevel=0, mode='dot'): """Creates an UML diagram based on the classes of the server. Keyword arguments: detailLevel -- Detail level of the diagram. If it is not present, 0 will be assumed mode -- one of graph layout modes to be passed to graphviz """ graphvizArgs = { 'dot': [], 'circo': [ '-Kcirco', '-Gsplines=true', '-Granksep=0.1', '-Gmindist=0', '-Goverlap=false', '-Gepsilon=0.00001' ], 'fdp': [ '-Kfdp', '-Gsplines=true', '-Goverlap=false', '-Gepsilon=0.00001', '-GK=0.01', '-Gmaxiter=10000', '-Gstart=random' ] } print 'Using {0} as level of detail'.format(str(detailLevel)) print 'Using {0} as layout mode. Hint: from quasar 1.3.5, you can choose among: {1}, run with -h for help.'.format( mode, ','.join(graphvizArgs.keys())) transformByKey(TransformKeys.CREATE_DIAGRAM_DOT, { 'context': context, 'detailLevel': detailLevel }) args = [ "-Tpdf", "-o", designPath + "diagram.pdf", getTransformOutput(TransformKeys.CREATE_DIAGRAM_DOT, {'context': context}) ] + graphvizArgs[mode] subprocessWithImprovedErrors([getCommand("graphviz")] + args, "GraphViz (dot)")
def validateDesign(context): """Checks design.xml against Design.xsd, and after that performs some additional checks (defined in designValidation.xslt)""" # 1st line of validation -- does it matches its schema? # This allows some basic checks print("1st line of check -- XSD conformance") print("Validating the file " + designXML + " with the schema " + designXSD) subprocessWithImprovedErrors([getCommand("xmllint"), "--noout", "--schema", designPath + designXSD, designPath + designXML], getCommand("xmllint")) # 2nd line of validation -- including XSLT print("2nd line of check -- more advanced checks using XSLT processor") transformByKey(TransformKeys.DESIGN_VALIDATION, {'context':context} )
def upgradeDesign(context, additionalParam): """Method for adjusting Design.xml for a new Design.xsd when updating to a new version of the Framework""" print("Formatting your design file ...") formatDesign() transformByKey(TransformKeys.UPGRADE_DESIGN, {'context':context, 'whatToDo':additionalParam}) print("Formatting the upgraded file ") upgradedNonFormatted = getTransformOutput(TransformKeys.UPGRADE_DESIGN, {'context':context} ) upgradedFormatted = upgradedNonFormatted + ".formatted" formatXml(upgradedNonFormatted, upgradedFormatted) print("Now running merge-tool. Please merge the upgraded changed") subprocessWithImprovedErrors([getCommand("diff"), "-o", designPath + designXML, designPath + designXML, upgradedFormatted], getCommand("diff"))
def generateConfiguration(context): """Generates the file Configuration.xsd. This method is called automatically by cmake, it does not need to be called by the user.""" config_xsd_path = os.path.join(context['projectBinaryDir'],'Configuration','Configuration.xsd') try: transformByKey( TransformKeys.CONFIGURATION_XSD, { 'context':context, 'metaXsdPath':os.path.join(context['projectSourceDir'],'Meta','config','Meta.xsd').replace('\\','/') } ) except: if os.path.isfile(config_xsd_path): os.remove(config_xsd_path) raise subprocessWithImprovedErrorsPipeOutputToFile( [getCommand("xmllint"), "--xinclude", getTransformOutput(TransformKeys.CONFIGURATION_XSD, {'context':context})], config_xsd_path, getCommand("xmllint"))
def createDiagram(context, detailLevel=0): """Creates an UML diagram based on the classes of the server. Keyword arguments: detailLevel -- Detail level of the diagram. If it is not present, 0 will be assumed """ if detailLevel == "": detailLevel = 0 transformByKey(TransformKeys.CREATE_DIAGRAM_DOT, { 'context': context, 'detailLevel': detailLevel }) print("Generating pdf diagram with dot.") subprocessWithImprovedErrors([ getCommand("graphviz"), "-Tpdf", "-o", designPath + "diagram.pdf", getTransformOutput(TransformKeys.CREATE_DIAGRAM_DOT, {'context': context}) ], "GraphViz (dot)")
def generateCmake(context, *args): """Generates CMake header lists in various directories, and then calls cmake. Keyword arguments: buildType -- Optional parameter to specify Debug or Release build. If it is not specified it will default to Release. """ args = list(args) # we do it to be able to remove things via extract_argument, otherwise it is immutable tuple (args2, builder) = extract_argument(args, "--builder") if len(args2) > 1: raise WrongArguments("Max one positional argument for generateCmake") buildType = "Release" if len(args2) == 0 else args2[0] if builder is None: builder = BuilderDefault if not context['projectSourceDir'] == context['projectBinaryDir']: # out-of-source build if os.path.isfile(os.path.join(context['projectSourceDir'], 'CMakeCache.txt')): raise Mistake('User mistake? CMakeCache.txt exists in source directory; '+ 'that will prevent CMake to make a successful out-of-source build. '+ 'Remove CMakeCache.txt and all cmake_install.cmake files, and build/ directory') projectSourceDir = context['projectSourceDir'] projectBinaryDir = context['projectBinaryDir'] if not os.path.isdir(projectBinaryDir): print("PROJECT_BINARY_DIR {0} doesn't exist -- creating it.".format(projectBinaryDir)) os.mkdir(projectBinaryDir) os.mkdir(os.path.join(projectBinaryDir, "bin")) print("Creating symlinks for xml files in the build directory") symlinkRuntimeDeps(context, '*.xml') transformByKey(TransformKeys.AS_CMAKE, {'context':context}) transformByKey(TransformKeys.D_CMAKE, {'context':context}) print("Build type [{0}], Builder [{1}]".format(buildType, builder)) os.chdir(projectBinaryDir) print("Calling CMake") if platform.system() == "Windows": subprocessWithImprovedErrors([getCommand("cmake"), "-DCMAKE_BUILD_TYPE=" + buildType, "-G", "Visual Studio 15 2017 Win64", projectSourceDir], getCommand("cmake")) elif platform.system() == "Linux": builderArgs = [] if builder == BuilderDefault else ["-G", builder] subprocessWithImprovedErrors([getCommand("cmake"), "-DCMAKE_BUILD_TYPE=" + buildType] + builderArgs + [projectSourceDir], getCommand("cmake"))
def generateCmake(context, buildType="Release"): """Generates CMake header lists in various directories, and then calls cmake. Keyword arguments: buildType -- Optional parameter to specify Debug or Release build. If it is not specified it will default to Release. """ if not context['projectSourceDir'] == context[ 'projectBinaryDir']: # out-of-source build if os.path.isfile( os.path.join(context['projectSourceDir'], 'CMakeCache.txt')): raise Mistake( 'User mistake? CMakeCache.txt exists in source directory; ' + 'that will prevent CMake to make a successful out-of-source build. ' + 'Remove CMakeCache.txt (or attempt "quasar.py clean" and retry' ) projectSourceDir = context['projectSourceDir'] projectBinaryDir = context['projectBinaryDir'] if not os.path.isdir(projectBinaryDir): print("PROJECT_BINARY_DIR {0} doesn't exist -- creating it.".format( projectBinaryDir)) os.mkdir(projectBinaryDir) os.mkdir(os.path.join(projectBinaryDir, "bin")) print("Creating symlinks for xml files in the build directory") symlinkRuntimeDeps(context, '*.xml') transformByKey(TransformKeys.AS_CMAKE, {'context': context}) transformByKey(TransformKeys.D_CMAKE, {'context': context}) print("Build type [" + buildType + "]") os.chdir(projectBinaryDir) print("Calling CMake") if platform.system() == "Windows": subprocessWithImprovedErrors([ getCommand("cmake"), "-DCMAKE_BUILD_TYPE=" + buildType, "-G", "Visual Studio 15 2017 Win64", projectSourceDir ], getCommand("cmake")) elif platform.system() == "Linux": subprocessWithImprovedErrors([ getCommand("cmake"), "-DCMAKE_BUILD_TYPE=" + buildType, projectSourceDir ], getCommand("cmake"))
def generateOneDeviceClass(context, className): transformByKey([TransformKeys.D_DEVICE_H, TransformKeys.D_DEVICE_CPP], { 'context': context, 'className': className })
from designTools import createDiagram from runDoxygen import runDoxygen from externalToolCheck import checkExternalDependencies from optionalModules import enableModule, disableModule, listModules, listEnabledModules, removeModules, removeModule from transformDesign import transformByKey, TransformKeys from quasar_basic_utils import extract_argument # format is: [command name], callable, for_users # where for_users is True for non-internal commands commands = [ [['generate', 'cmake_headers'], generateCmake, False], # This one takes variable number of params [['prepare_build'], generateCmake, True], # [['generate', 'root'], lambda context: transformByKey([ TransformKeys.D_ROOT_H, TransformKeys.D_ROOT_CPP ], {'context': context}), False], # This takes none - check [['generate', 'base_h'], lambda context, className: transformByKey([TransformKeys.D_BASE_H], { 'context': context, 'className': className }), False], [['generate', 'base_cpp_all'], lambda context: transformByKey( [TransformKeys.D_BASE_CPP_ALL], {'context': context}), False], [['generate', 'device', '--all'], generateAllDevices, True], [['generate', 'device'], generateDeviceClass, True], [['generate', 'source_variables'], lambda context: transformByKey([ TransformKeys.AS_SOURCEVARIABLES_H, TransformKeys. AS_SOURCEVARIABLES_CPP ], {'context': context}), False],