123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- """
- 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
|