pycasso_user_scripts_template.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. """
  2. PYCASSO User Scripts
  3. Do not change the arguments of the defined routines, only their content !
  4. """
  5. #-------------------------------------------------
  6. # arguments and options
  7. #-------------------------------------------------
  8. def DefineOptions( parser ) :
  9. """
  10. Usage : DefineOptions( parser )
  11. Define options supported by user scripts.
  12. Arugments:
  13. parser : optparse object
  14. """
  15. # define flag:
  16. parser.add_option( "-c", "--clean",
  17. help="remove object and module files before compilation",
  18. dest="clean", action="store_true", default=False )
  19. # ok
  20. return
  21. #enddef
  22. # *
  23. def StoreOptions( settings, values ) :
  24. """
  25. Add the parsed flag to a dictionairy.
  26. The values have data fields with names defined by 'dest'
  27. in the previous calls to 'parser.add_option' .
  28. """
  29. # translate options into a dictionairy if they should
  30. # replace rcfile values:
  31. if values.clean : settings['build.make.clean' ] = True
  32. # ok
  33. return
  34. #enddef
  35. #-------------------------------------------------
  36. # source
  37. #-------------------------------------------------
  38. def Build_Configure( rcf ) :
  39. """
  40. Configure a source code.
  41. This script is called from the source directory.
  42. Arguments:
  43. rcf : dictionairy with settings from rc file
  44. """
  45. # external
  46. import logging
  47. # info ...
  48. #logging.info( 'User script Build_Configure ...' )
  49. pass
  50. #enddef
  51. # ***
  52. def Build_Make( rcf ) :
  53. """
  54. Make and install an executable.
  55. This script is called from the source directory.
  56. Arguments:
  57. rcf : dictionairy with settings from rc file
  58. """
  59. # external
  60. import os
  61. import logging
  62. import pycasso_tools
  63. # remove old object files ?
  64. if rcf['build.make.clean'] :
  65. # info ...
  66. logging.debug( ' make clean ...' )
  67. # make command:
  68. command = 'make -f Makefile.mk clean'
  69. # info ...
  70. logging.debug( ' run command: %s' % command )
  71. # run:
  72. status,stdout,stderr = pycasso_tools.SystemCall( command )
  73. if status != 0 : raise Exception
  74. #endif
  75. # module dir ?
  76. mdir = rcf.get('compiler.mdir',default='None')
  77. if mdir != 'None' :
  78. # not present yet ? then create:
  79. if not os.path.exists( mdir ) : os.mkdir( mdir )
  80. #endif
  81. # info ...
  82. logging.debug( ' make ...' )
  83. # make command:
  84. command = 'make -f Makefile.mk %s' % rcf.get('build.make.exec')
  85. # info ...
  86. logging.debug( ' run command: %s' % command )
  87. # run:
  88. status,stdout,stderr = pycasso_tools.SystemCall( command )
  89. if status != 0 : raise Exception
  90. # ok
  91. return
  92. #enddef