-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load flattening_tags_for_git into tags.
git-svn-id: https://wush.net/svn/mdaus-oss/tags/SIX-2.0.0@625 9d772353-a6c9-4ee9-b2cc-df47a7649cd5
- Loading branch information
Showing
1,015 changed files
with
307,572 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from waflib.Build import BuildContext | ||
|
||
class dumpenv(BuildContext): | ||
'''dumps the environment''' | ||
cmd = 'dumpenv' | ||
fun = 'build' | ||
|
||
def execute(self): | ||
# Recurse through all the wscripts to find all available tasks | ||
self.restore() | ||
if not self.all_envs: | ||
self.load_envs() | ||
self.recurse([self.run_dir]) | ||
|
||
targets = self.targets.split(',') | ||
defines = [] | ||
for target in targets: | ||
# Find the target | ||
tsk = self.get_tgen_by_name(target) | ||
|
||
# Actually create the task object | ||
tsk.post() | ||
|
||
# Now we can grab his defines | ||
defines += tsk.env.DEFINES | ||
|
||
# Sort and uniquify it, then print them all out preceded by the | ||
# compiler define flag | ||
defines = sorted(list(set(defines))) | ||
|
||
str = '' | ||
for define in defines: | ||
if str: | ||
str += ' ' | ||
str += self.env['DEFINES_ST'] % define | ||
print str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
import os | ||
from os.path import join, isdir, abspath, dirname | ||
from waflib import Options, Utils, Logs, TaskGen, Errors | ||
from waflib.Errors import ConfigurationError | ||
from waflib.TaskGen import task_gen, feature, after, before | ||
from waflib.Utils import to_list as listify | ||
|
||
def options(opt): | ||
opt.load('java') | ||
opt.add_option('--disable-java', action='store_false', dest='java', | ||
help='Disable java', default=True) | ||
opt.add_option('--with-java-home', action='store', dest='java_home', | ||
help='Specify the location of the java home') | ||
opt.add_option('--require-java', action='store_true', dest='force_java', | ||
help='Require Java (configure option)', default=False) | ||
opt.add_option('--require-jni', action='store_true', dest='force_jni', | ||
help='Require Java lib/headers (configure option)', default=False) | ||
opt.add_option('--require-ant', action='store_true', dest='force_ant', | ||
help='Require Ant (configure option)', default=False) | ||
opt.add_option('--with-ant-home', action='store', dest='ant_home', | ||
help='Specify the Apache Ant Home - where Ant is installed') | ||
|
||
def configure(self): | ||
if not Options.options.java: | ||
return | ||
|
||
from build import recursiveGlob | ||
|
||
ant_home = Options.options.ant_home or self.environ.get('ANT_HOME', None) | ||
if ant_home is not None: | ||
ant_paths = [join(self.environ['ANT_HOME'], 'bin'), self.environ['ANT_HOME']] | ||
else: | ||
ant_paths = [] | ||
|
||
env = self.env | ||
env['HAVE_ANT'] = self.find_program('ant', var='ANT', path_list=ant_paths, mandatory=False) | ||
|
||
if not env['ANT'] and Options.options.force_ant: | ||
raise Errors.WafError('Cannot find ant!') | ||
|
||
if Options.options.java_home: | ||
self.environ['JAVA_HOME'] = Options.options.java_home | ||
|
||
try: | ||
self.load('java') | ||
except Exception as e: | ||
if Options.options.force_java: | ||
raise e | ||
else: | ||
return | ||
|
||
if not self.env.CC_NAME and not self.env.CXX_NAME: | ||
self.fatal('load a compiler first (gcc, g++, ..)') | ||
|
||
try: | ||
if not self.env.JAVA_HOME: | ||
self.fatal('set JAVA_HOME in the system environment') | ||
|
||
# jni requires the jvm | ||
javaHome = abspath(self.env['JAVA_HOME'][0]) | ||
|
||
if not isdir(javaHome): | ||
self.fatal('could not find JAVA_HOME directory %r (see config.log)' % javaHome) | ||
|
||
incDir = abspath(join(javaHome, 'include')) | ||
if not isdir(incDir): | ||
self.fatal('could not find include directory in %r (see config.log)' % javaHome) | ||
|
||
incDirs = list(set(map(lambda x: dirname(x), | ||
recursiveGlob(incDir, ['jni.h', 'jni_md.h'])))) | ||
libDirs = list(set(map(lambda x: dirname(x), | ||
recursiveGlob(javaHome, ['*jvm.a', '*jvm.lib'])))) | ||
if not libDirs: | ||
libDirs = list(set(map(lambda x: dirname(x), | ||
recursiveGlob(javaHome, ['*jvm.so', '*jvm.dll'])))) | ||
|
||
#if not self.check_jni_headers(): | ||
if not self.check(header_name='jni.h', define_name='HAVE_JNI_H', lib='jvm', | ||
libpath=libDirs, includes=incDirs, uselib_store='JAVA', uselib='JAVA', | ||
function_name='JNI_GetCreatedJavaVMs'): | ||
if Options.options.force_jni: | ||
self.fatal('could not find lib jvm in %r (see config.log)' % libDirs) | ||
except ConfigurationError as ex: | ||
err = str(ex).strip() | ||
if err.startswith('error: '): | ||
err = err[7:] | ||
if Options.options.force_java: | ||
self.fatal(err) | ||
else: | ||
self.msg('Java lib/headers', err, color='YELLOW') | ||
|
||
# Used to call ant. Assumes the ant script respects a target property. | ||
@task_gen | ||
@feature('ant') | ||
def ant(self): | ||
if not hasattr(self, 'defines'): | ||
self.defines = [] | ||
if isinstance(self.defines, str): | ||
self.defines = [self.defines] | ||
self.env.ant_defines = map(lambda x: '-D%s' % x, self.defines) | ||
self.rule = ant_exec | ||
|
||
def ant_exec(tsk): | ||
# Source file is build.xml | ||
cmd = [tsk.env['ANT'], '-file', tsk.inputs[0].abspath(), '-Dtarget=' + tsk.outputs[0].abspath()] + tsk.env.ant_defines | ||
return tsk.generator.bld.exec_command(cmd) | ||
|
||
def java_module(bld, **modArgs): | ||
""" | ||
Builds a module, along with optional tests. | ||
It makes assumptions, but most can be overridden by passing in args. | ||
""" | ||
if 'env' in modArgs: | ||
env = modArgs['env'] | ||
else: | ||
variant = modArgs.get('variant', bld.env['VARIANT'] or 'default') | ||
env = bld.all_envs[variant] | ||
|
||
# Basically, if this Java target depends on a JNI target, and for whatever | ||
# reason we don't have JNI, we don't want to even add the Java target onto | ||
# the build queue since we won't be able to build it | ||
native_sourcedir = modArgs.get('native_sourcedir', 'src/jni') | ||
have_native_sourcedir = bld.path.find_dir(native_sourcedir) is not None | ||
jni_ok = bld.is_defined('HAVE_JNI_H') or not have_native_sourcedir | ||
|
||
if env['JAVAC'] and env['JAR'] and jni_ok: | ||
modArgs = dict((k.lower(), v) for k, v in modArgs.iteritems()) | ||
|
||
lang = modArgs.get('lang', 'java') | ||
nlang = modArgs.get('native_lang', 'c') | ||
libExeType = {'java':'javac'}.get(lang, 'java') | ||
nsourceExt = {'cxx':'.cpp','c':'.c'}.get(nlang, 'c') | ||
libName = '%s.jar' % (modArgs['name']) | ||
|
||
path = modArgs.get('path', | ||
'dir' in modArgs and bld.path.find_dir(modArgs['dir']) or bld.path) | ||
|
||
module_deps = map(lambda x: '%s-%s' % (x, lang), listify(modArgs.get('module_deps', ''))) | ||
uselib_local = module_deps + listify(modArgs.get('uselib_local', '')) + listify(modArgs.get('use','')) | ||
uselib = listify(modArgs.get('uselib', '')) + ['JAVA'] | ||
targets_to_add = listify(modArgs.get('targets_to_add', '')) | ||
classpath = listify(modArgs.get('classpath', '')) | ||
compat = modArgs.get('compat', '1.5') | ||
libVersion = modArgs.get('version', None) | ||
installPath = modArgs.get('install_path', None) | ||
libInstallPath = modArgs.get('lib_install_path', None) | ||
manifest = modArgs.get('manifest', None) | ||
jarcreate = modArgs.get('jarcreate', None) | ||
|
||
if modArgs.get('nosuffix', False) : | ||
targetName = modArgs['name'] | ||
else : | ||
targetName = '%s-%s' % (modArgs['name'], lang) | ||
|
||
sourcedir = modArgs.get('sourcedir', 'src/java') | ||
|
||
cp_targets = [] | ||
real_classpath = [] | ||
classpathDirs = [bld.path.find_dir('lib'), bld.path.find_dir('libs'), bld.path.find_dir('../libs')] | ||
for cp in classpath: | ||
for dir in classpathDirs: | ||
if dir is not None and os.path.exists(join(dir.abspath(), cp)): | ||
real_classpath.append(join(dir.abspath(), cp)) | ||
cp_targets.append(bld(name=cp, features='install_tgt', install_path=libInstallPath or '${PREFIX}/lib', dir=dir, files=[cp])) | ||
|
||
# We need a try/catch here for the rare case where we have javac but | ||
# not JNI, we're a module that doesn't depend on JNI, but we depend on | ||
# another module that DOES depend on JNI. In that case, the module we | ||
# depend on won't exist so get_tgen_by_name() will throw. There's no | ||
# way to build this module, which is fine - we're just trying not to | ||
# stop the whole build when something else is targetted. | ||
for dep in module_deps: | ||
try: | ||
tsk = bld.get_tgen_by_name(dep) | ||
for cp in tsk.classpath: | ||
real_classpath.append(cp) | ||
except: | ||
return | ||
|
||
#build the jar | ||
jar = bld(features='javac jar add_targets install_tgt', manifest=manifest, jarcreate=jarcreate, srcdir=sourcedir, classpath=real_classpath, targets_to_add=targets_to_add + cp_targets, | ||
use=module_deps, name=targetName, target=targetName, basedir='classes', outdir='classes', destfile=libName, compat=compat, dir=bld.path.get_bld(), files=[libName]) | ||
|
||
jar.install_path = installPath or '${PREFIX}/lib' | ||
|
||
|
||
if have_native_sourcedir: | ||
lib = bld(features='%s %sshlib' % (nlang, nlang), includes='%s/include' % native_sourcedir, | ||
target='%s.jni-%s' % (modArgs['name'], nlang), env=env.derive(), | ||
uselib=uselib, use=uselib_local, | ||
source=bld.path.find_dir(native_sourcedir).ant_glob('source/*%s' % nsourceExt)) | ||
|
||
jar.targets_to_add.append(lib) | ||
|
||
lib.install_path = installPath or '${PREFIX}/lib' | ||
|
||
return jar | ||
|
||
# Tell waf to ignore any build.xml files, the 'ant' feature will take care of them. | ||
TaskGen.extension('build.xml')(Utils.nada) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
from waflib import Options, Build | ||
from waflib.Errors import ConfigurationError | ||
import os, subprocess, re | ||
from os.path import join, dirname, abspath | ||
|
||
|
||
def options(opt): | ||
opt.add_option('--disable-matlab', action='store_false', dest='matlab', | ||
help='Disable matlab', default=True) | ||
opt.add_option('--with-matlab-home', action='store', dest='matlab_home', | ||
help='Specify the location of the matlab home') | ||
opt.add_option('--require-matlab', action='store_true', dest='force_matlab', | ||
help='Require matlab (configure option)', default=False) | ||
|
||
def configure(self): | ||
if not Options.options.matlab: | ||
return | ||
|
||
from build import recursiveGlob | ||
|
||
matlabHome = Options.options.matlab_home or self.env['MATLAB_HOME'] | ||
matlabBin = matlabHome and join(matlabHome, 'bin') | ||
mandatory=Options.options.force_matlab | ||
|
||
if self.find_program('matlab', var='matlab', path_list=filter(None, [matlabBin]), | ||
mandatory=mandatory): | ||
matlabBin = dirname(self.env['matlab']) | ||
if not matlabHome: | ||
matlabHome = join(matlabBin, os.pardir) | ||
|
||
platform = self.env['PLATFORM'] | ||
|
||
#TODO put these in a utility somewhere | ||
winRegex = r'win32' | ||
|
||
incDirs = map(lambda x: os.path.dirname(x), | ||
recursiveGlob(abspath(join(matlabHome, 'extern')), ['mex.h'])) | ||
|
||
exts = 'so dll lib'.split() | ||
libs = 'mx mex mat'.split() | ||
|
||
searches = [] | ||
for x in exts: | ||
for l in libs: | ||
searches.append('*%s.%s' % (l, x)) | ||
|
||
libDirs = map(lambda x: os.path.dirname(x), | ||
recursiveGlob(matlabBin, searches)) | ||
libDirs.extend(map(lambda x: os.path.dirname(x), | ||
recursiveGlob(abspath(join(matlabHome, 'extern', 'lib')), searches))) | ||
|
||
mexExtCmd = os.path.join(matlabBin, 'mexext') | ||
if re.match(winRegex, platform): | ||
archdir = self.env['IS64BIT'] and 'win64' or 'win32' | ||
mexExtCmd += '.bat' | ||
else: | ||
#retrieve the matlab environment | ||
matlabEnvCmd = '%s -nojvm -nosplash -nodisplay -e' % self.env['matlab'] | ||
out, err = subprocess.Popen(matlabEnvCmd.split(), stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE).communicate() | ||
for line in out.split('\n'): | ||
keyVal = line.split('=', 1) | ||
if len(keyVal) == 2 and keyVal[0] == 'ARCH': | ||
archdir = keyVal[1] | ||
break | ||
|
||
# Get the appropriate mex extension. Matlab provides a script to | ||
# tell us this. | ||
out, err = subprocess.Popen(mexExtCmd, stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE).communicate() | ||
self.env['MEX_EXT'] = '.' + out.rstrip() | ||
|
||
filtered = filter(lambda x: archdir in x, libDirs) | ||
if filtered: | ||
libDirs = filtered | ||
libDirs = list(set(libDirs)) | ||
|
||
self.env.append_value('CFLAGS_MEX', '-DMATLAB_MEX_FILE'.split()) | ||
# self.env.append_value('LINKFLAGS_MEX', '-Wl,-rpath-link,%s' % ':'.join(libDirs)) | ||
try: | ||
env = self.env.derive() | ||
|
||
self.check(header_name='mex.h', define_name='HAVE_MEX_H', | ||
includes=incDirs, uselib_store='MEX', uselib='MEX', | ||
mandatory=True, env=env) | ||
|
||
libPrefix = '' | ||
if re.match(winRegex, platform): | ||
libPrefix = 'lib' | ||
|
||
# self.check(lib='%smat' % libPrefix, libpath=libDirs, uselib_store='MEX', uselib='MEX', | ||
# type='cshlib', mandatory=True, env=env) | ||
self.check(lib='%smex' % libPrefix, libpath=libDirs, uselib_store='MEX', uselib='MEX', | ||
mandatory=True, env=env) | ||
self.check(lib='%smx' % libPrefix, libpath=libDirs, uselib_store='MEX', uselib='MEX', | ||
mandatory=True, env=env) | ||
|
||
if re.match(winRegex, platform): | ||
self.env.append_value('LINKFLAGS_MEX', '/EXPORT:mexFunction'.split()) | ||
|
||
except ConfigurationError as ex: | ||
err = str(ex).strip() | ||
if err.startswith('error: '): | ||
err = err[7:] | ||
if mandatory: | ||
self.fatal(err) | ||
else: | ||
self.undefine('HAVE_MEX_H') | ||
self.msg('matlab/mex lib/headers', err, color='YELLOW') | ||
|
||
|
Oops, something went wrong.