GCCXML Builder

This is a simple builder, its still a little rough on the implementation side but it has been tested on Linux, Mac (OS X), and Windows.

Current Issues

Usage

   1 # Add our special builder to the environment
   2 env = Environment(tools = ['default', 'gccxml'])
   3 # Process our header into XML
   4 xmlfile = env.XMLHeader('MyHeader.h')
   5 
   6 # Now tell py++ that we already made the xml file
   7 xmlfile = pygccxml.parser.create_gccxml_fc(xmlfile.abspath)
   8 mb = module_builder.module_builder_t(files = [xmlfile]) 

Code

   1 # Copyright 2007 Joseph Lisee
   2 #
   3 # Author: Joseph Lisee
   4 # License: Public Domain
   5 
   6 """
   7 This module contains a custom GCC-XML tool for SCons
   8 """
   9 
  10 import os
  11 
  12 import SCons.Builder
  13 import SCons.Tool
  14 
  15 
  16 
  17 GCCXMLBuilder = SCons.Builder.Builder(action = "$GCCXML $GCCXML_EXTRA_FLAGS $_XML_CPPINCFLAGS $_XML_CPPDEFFLAGS $SOURCE -fxml=$TARGET",
  18                               suffix='xml',
  19                               src_suffic = ['h', 'hpp'],
  20                               source_scanner = SCons.Tool.CScanner)
  21 
  22 def generate(env):
  23     gccxml_path = env.WhereIs('gccxml')
  24     if gccxml_path is None:
  25         print 'Could not find gccxml, please make sure it is on your PATH'
  26         env.Exit(1) 
  27         
  28     env['GCCXML'] = gccxml_path
  29 
  30     gccxml_dir = os.path.dirname(gccxml_path)
  31     extra = ''
  32     if os.name != 'posix':
  33         extra = '--gccxml-config "' + os.path.abspath(os.path.join(gccxml_dir, 'gccxml_config')) +'"'
  34         extra += ' --gccxml-cxxflags " /DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR /MT" '
  35     env['GCCXML_EXTRA_FLAGS'] = extra
  36     #env['GCCXML_EXTRA_FLAGS'] = ''
  37     
  38     # These variables hold the expanded form of the include and defines lists
  39     env['_XML_CPPINCFLAGS'] = '$( ${_concat(INCPREFIX, XMLCPPPATH, INCSUFFIX, __env__, RDirs)} $)'
  40     env['_XML_CPPDFFFLAGS'] = '${_defines(CPPDEFPREFIX, XMLCPPDEFINES, CPPDEFSUFFIX, __env__)}'
  41 
  42     
  43     if os.name != 'posix':
  44         env['GCCXML_INCPREFIX'] = '-I'
  45         env['_XML_CPPINCFLAGS'] = '$( ${_concat(GCCXML_INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE) } $)'
  46     
  47     # Added the builder to the given environment
  48     env.Append(BUILDERS = {'XMLHeader' : GCCXMLBuilder })
  49 
  50 def exists(env):
  51     return env.Detect('gccxml')

GCCXMLBuilder (last edited 2008-03-12 02:47:14 by localhost)