Files
Phoenix/wscript

184 lines
5.4 KiB
Python

#!/usr/bin/python
import os
import sys
import TaskGen
import Utils
from buildtools.config import Config, msg, opj, loadETG
from distutils.file_util import copy_file
from distutils.dir_util import mkpath
from distutils.dep_util import newer, newer_group
from distutils.spawn import spawn
source_exts = [".cpp"]
out = 'build_waf'
from waflib.TaskGen import feature, after
from waflib.Task import Task
from waflib.Tools import c_preproc
os.environ["MACOSX_DEPLOYMENT_TARGET"] = "10.4"
def options(opt):
opt.load('compiler_cc compiler_cxx')
opt.add_option('--wx-config', dest='wx_config', default='wx-config', action='store')
def configure(conf):
conf.load('compiler_cc compiler_cxx python')
conf.check_python_headers()
wx_config = conf.options.wx_config
conf.env.append_value('CFLAGS', '-g')
conf.env.append_value('CXXFLAGS', '-g')
conf.check_cfg(path=wx_config, package='', args='--cxxflags --libs', uselib_store='WX', mandatory=True)
def build(bld):
#----------------------------------------------------------------------
# Create a buildtools.config.Configuration object
cfg = Config()
# Ensure that the directory containing this script is on the python
# path for spawned commands so the builder and phoenix packages can be
# found.
thisdir = os.path.abspath(".")
os.environ['PYTHONPATH'] = thisdir + os.pathsep + os.environ.get('PYTHONPATH', '')
WX_PKGLIST = [ cfg.PKGDIR ]
SCRIPTS = None
DATA_FILES = []
HEADERS = None
BUILD_OPTIONS = { 'build_base' : cfg.BUILD_BASE }
if cfg.WXPORT == 'msw':
BUILD_OPTIONS[ 'compiler' ] = cfg.COMPILER
copy_file('src/__init__.py', cfg.PKGDIR, update=1, verbose=0)
cfg.CLEANUP.append(opj(cfg.PKGDIR, '__init__.py'))
# update the license files
mkpath('license')
for filename in ['preamble.txt', 'licence.txt', 'licendoc.txt', 'lgpl.txt']:
copy_file(opj(cfg.WXDIR, 'docs', filename), opj('license',filename), update=1, verbose=0)
cfg.CLEANUP.append(opj('license',filename))
cfg.CLEANUP.append('license')
# create the package's __version__ module
open(opj(cfg.PKGDIR, '__version__.py'), 'w').write("""\
# This file was generated by setup.py...
VERSION_STRING = '%(VERSION)s'
MAJOR_VERSION = %(VER_MAJOR)s
MINOR_VERSION = %(VER_MINOR)s
RELEASE_NUMBER = %(VER_RELEASE)s
SUBRELEASE_NUMBER = %(VER_SUBREL)s
VERSION = (MAJOR_VERSION, MINOR_VERSION, RELEASE_NUMBER,
SUBRELEASE_NUMBER, '%(VER_FLAGS)s')
""" % cfg.__dict__)
cfg.CLEANUP.append(opj(cfg.PKGDIR,'__version__.py'))
if sys.platform in ['win32', 'darwin']:
cfg.build_locale_dir(opj(cfg.PKGDIR, 'locale'))
DATA_FILES += cfg.build_locale_list(opj(cfg.PKGDIR, 'locale'))
if os.name == 'nt':
rc_file = ['src/wxc.rc']
else:
rc_file = []
source_dirs = [
"sip/cpp",
]
etg = loadETG('etg/_core.py')
etg = loadETG('etg/_dataview.py')
def remove_archs(var):
result = []
skipnext = False
for flag in var:
index = var.index(flag)
nextflag = var[index+1]
if flag == '-arch' or flag == '-isysroot':
skipnext = True
elif not skipnext:
result.append(flag)
else:
skipnext = False
return result
bld.env.CFLAGS_PYEXT = remove_archs(bld.env.CFLAGS_PYEXT)
bld.env.CFLAGS_PYEMBED = remove_archs(bld.env.CFLAGS_PYEMBED)
bld.env.CXXFLAGS_PYEXT = remove_archs(bld.env.CXXFLAGS_PYEXT)
bld.env.CXXFLAGS_PYEMBED = remove_archs(bld.env.CXXFLAGS_PYEMBED)
bld.env.LINKFLAGS_PYEXT = remove_archs(bld.env.LINKFLAGS_PYEXT)
bld.env.LINKFLAGS_PYEMBED = remove_archs(bld.env.LINKFLAGS_PYEMBED)
archs = ['-arch', 'i386', '-mmacosx-version-min=10.5']
bld.env.append_value('CFLAGS_PYEXT', archs)
bld.env.append_value('CFLAGS_PYEMBED', archs)
bld.env.append_value('CXXFLAGS_PYEXT', archs)
bld.env.append_value('CXXFLAGS_PYEMBED', archs)
bld.env.append_value('LINKFLAGS_PYEXT', archs)
bld.env.append_value('LINKFLAGS_PYEMBED', archs)
siplib = bld(
features='c cxx cshlib pyext',
target='siplib',
name='sip',
includes=cfg.includes + ['sip/siplib'],
cflags=cfg.cflags,
defines=cfg.defines,
libpath=cfg.libdirs,
uselib='WX',
install_path="wx"
)
siplib.source = siplib.path.ant_glob("sip/siplib/*.c sip/siplib/*.cpp", incl=source_exts)
bld.add_group()
corelib = bld(
features='c cxx cxxshlib pyext',
target='_core',
includes=cfg.includes + ['sip/siplib'],
cflags=cfg.cflags,
defines=cfg.defines,
libpath=cfg.libdirs,
linkflags='./siplib.so',
use= ['WX'],
install_path="wx"
)
corelib.source = corelib.path.ant_glob("sip/cpp/sip_core*.cpp", incl=source_exts, remove=False, maxdepth=3)
dataviewlib = bld(
features='c cxx cxxshlib pyext',
target='_dataview',
includes=cfg.includes + ['sip/siplib'],
cflags=cfg.cflags,
defines=cfg.defines,
libpath=cfg.libdirs,
linkflags='./siplib.so ./_core.so',
use= ['WX'],
install_path="wx"
)
dataviewlib.source = dataviewlib.path.ant_glob("sip/cpp/sip_dataview*.cpp", incl=source_exts, remove=False, maxdepth=3)