""" PYCASSO User Scripts Do not change the arguments of the defined routines, only their content ! """ #------------------------------------------------- # arguments and options #------------------------------------------------- def DefineOptions( parser ) : """ Usage : DefineOptions( parser ) Define options supported by user scripts. Arugments: parser : optparse object """ # define flag: parser.add_option( "-c", "--clean", help="remove object and module files before compilation", dest="clean", action="store_true", default=False ) # ok return #enddef # * def StoreOptions( settings, values ) : """ Add the parsed flag to a dictionairy. The values have data fields with names defined by 'dest' in the previous calls to 'parser.add_option' . """ # translate options into a dictionairy if they should # replace rcfile values: if values.clean : settings['build.make.clean' ] = True # ok return #enddef #------------------------------------------------- # source #------------------------------------------------- def Build_Configure( rcf ) : """ Configure a source code. This script is called from the source directory. Arguments: rcf : dictionairy with settings from rc file """ # external import logging # info ... #logging.info( 'User script Build_Configure ...' ) pass #enddef # *** def Build_Make( rcf ) : """ Make and install an executable. This script is called from the source directory. Arguments: rcf : dictionairy with settings from rc file """ # external import os import logging import pycasso_tools # remove old object files ? if rcf['build.make.clean'] : # info ... logging.debug( ' make clean ...' ) # make command: command = 'make -f Makefile.mk clean' # info ... logging.debug( ' run command: %s' % command ) # run: status,stdout,stderr = pycasso_tools.SystemCall( command ) if status != 0 : raise Exception #endif # module dir ? mdir = rcf.get('compiler.mdir',default='None') if mdir != 'None' : # not present yet ? then create: if not os.path.exists( mdir ) : os.mkdir( mdir ) #endif # info ... logging.debug( ' make ...' ) # make command: command = 'make -f Makefile.mk %s' % rcf.get('build.make.exec') # info ... logging.debug( ' run command: %s' % command ) # run: status,stdout,stderr = pycasso_tools.SystemCall( command ) if status != 0 : raise Exception # ok return #enddef