From 36705194304f4f810b3518377e1af95b040ab234 Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Wed, 11 Jul 2012 17:42:05 +0000 Subject: [PATCH] Enable etg code to be used to build extensions other than Phoenix itself. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@72038 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- build.py | 8 +++++--- buildtools/config.py | 33 ++++++++++++++++++++------------- etgtools/__init__.py | 17 ++++++++++------- etgtools/sip_generator.py | 5 ++++- 4 files changed, 39 insertions(+), 24 deletions(-) diff --git a/build.py b/build.py index b00e70d1..7f1efff7 100755 --- a/build.py +++ b/build.py @@ -375,10 +375,10 @@ def getTool(cmdName, version, MD5, envVar, platformBinary): ext = '' if platform == 'win32': ext = '.exe' - cmd = opj('bin', '%s-%s-%s%s' % (cmdName, version, platform, ext)) + cmd = opj(phoenixDir(), 'bin', '%s-%s-%s%s' % (cmdName, version, platform, ext)) md5 = MD5[platform] else: - cmd = opj('bin', '%s-%s' % (cmdName, version)) + cmd = opj(phoenixDir(), 'bin', '%s-%s' % (cmdName, version)) md5 = MD5 msg('Checking for %s...' % cmd) @@ -542,7 +542,8 @@ def doxhtml(options, args): def etg(options, args): cmdTimer = CommandTimer('etg') - pwd = pushDir(phoenixDir()) + cfg = Config() + pwd = pushDir(cfg.ROOT_DIR) # TODO: Better support for selecting etg cmd-line flags... flags = '--sip' @@ -692,6 +693,7 @@ def docs_bdist(options, args): def sip(options, args): cmdTimer = CommandTimer('sip') cfg = Config() + pwd = pushDir(cfg.ROOT_DIR) modules = glob.glob(opj(cfg.SIPGEN, '_*.sip')) # move _core the to the front of the list modules.remove(opj(cfg.SIPGEN, '_core.sip')) diff --git a/buildtools/config.py b/buildtools/config.py index b6021dc2..7460661c 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -38,15 +38,11 @@ class Configuration(object): SIPGEN = 'sip/gen' # Where the generated .sip files go SIPFILES = 'sip' # where to find other sip files for %Include or %Import SIPOUT = 'sip/cpp' # where to put the generated C++ code - - SIPOPTS = ' '.join(['-w', # enable warnings - '-o', # turn on auto-docstrings - #'-e', # turn on exceptions support - '-T', # turn off writing the timestamp to the generated files - '-g', # always release and reaquire the GIL - #'-r', # turn on function call tracing - '-I', 'src' - ]) + + ROOT_DIR = os.path.abspath(os.path.split(__file__)[0]+'/..') + + # we need the WXWIN dir to configure this, see __init__ + DOXY_XML_DIR = None WX_CONFIG = None # Usually you shouldn't need to touch this, but you can set it to @@ -94,7 +90,6 @@ class Configuration(object): def __init__(self, noWxConfig=False): self.CLEANUP = list() - # load the version numbers into this instance's namespace versionfile = opj(os.path.split(__file__)[0], 'version.py') myExecfile(versionfile, self.__dict__) @@ -112,7 +107,7 @@ class Configuration(object): # change the PORT default for wxMac if sys.platform[:6] == "darwin": - self.WXPORT = 'osx_carbon' + self.WXPORT = 'osx_cocoa' # and do the same for wxMSW, just for consistency if os.name == 'nt': @@ -130,7 +125,19 @@ class Configuration(object): self.includes = [phoenixDir() + '/sip/siplib', # to get our version of sip.h phoenixDir() + '/src', # for any hand-written headers ] - + + self.DOXY_XML_DIR = os.path.join(self.WXDIR, 'docs/doxygen/out/xml') + + self.SIPOPTS = ' '.join(['-w', # enable warnings + '-o', # turn on auto-docstrings + #'-e', # turn on exceptions support + '-T', # turn off writing the timestamp to the generated files + '-g', # always release and reaquire the GIL + #'-r', # turn on function call tracing + '-I', os.path.join(phoenixDir(), 'src'), + '-I', os.path.join(phoenixDir(), 'sip', 'gen'), + ]) + if noWxConfig: # this is as far as we go for now return @@ -378,7 +385,7 @@ class Configuration(object): break else: msg("ERROR: WX_CONFIG not specified and wx-config not found on the $PATH") - + sys.exit(1) # TODO: execute WX_CONFIG --list and verify a matching config is found diff --git a/etgtools/__init__.py b/etgtools/__init__.py index 51217cc8..66056d2c 100644 --- a/etgtools/__init__.py +++ b/etgtools/__init__.py @@ -13,17 +13,20 @@ them from the Doxygen XML, and producing wrapper code from them. """ import sys, os +# Mac Python actually has a buildtools module, so we need +# to make sure ours is picked up when we're not run from the +# Phoenix root dir. +sys.path.insert(0, os.path.abspath(os.path.split(__file__)[0]+'/..')) + +from buildtools.config import Config from .extractors import * #--------------------------------------------------------------------------- +cfg = Config(noWxConfig=True) -from buildtools.config import phoenixDir, wxDir - -xmlsrcbase = 'docs/doxygen/out/xml' -WXWIN = wxDir() -if WXWIN: - XMLSRC = os.path.join(WXWIN, xmlsrcbase) -assert WXWIN and os.path.exists(XMLSRC), "Unable to locate Doxygen XML files" +phoenixRoot = cfg.ROOT_DIR +XMLSRC = cfg.DOXY_XML_DIR +assert os.path.exists(XMLSRC), "Unable to locate Doxygen XML files at " + XMLSRC #--------------------------------------------------------------------------- diff --git a/etgtools/sip_generator.py b/etgtools/sip_generator.py index a9087a2c..50c329bd 100644 --- a/etgtools/sip_generator.py +++ b/etgtools/sip_generator.py @@ -18,8 +18,11 @@ import etgtools.generators as generators from etgtools.generators import nci, Utf8EncodingStream, textfile_open, wrapText +from buildtools.config import Config +cfg = Config(noWxConfig=True) + divider = '//' + '-'*75 + '\n' -phoenixRoot = os.path.abspath(os.path.split(__file__)[0]+'/..') +phoenixRoot = cfg.ROOT_DIR class SipGeneratorError(RuntimeError): pass