本文整理汇总了Python中waflib.Configure.conf.define函数的典型用法代码示例。如果您正苦于以下问题:Python define函数的具体用法?Python define怎么用?Python define使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了define函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_variant
def set_variant(conf, variant, env):
conf.msg('----------------------------------------', '----{ %s' % variant)
conf.setenv(variant, env=env)
compiler = FLAGS[conf.env.COMPILER_CXX]
arch = 'arch_%d' % TARGETS[conf.env.TARGET]['arch']
compiler_target = compiler[arch] if arch in compiler else None
# Compiler options
conf.env.CXXFLAGS = compiler['common'] + compiler[variant]
if compiler_target and 'cxxflags' in compiler_target:
conf.env.CXXFLAGS += compiler_target['cxxflags']
# Linker options
conf.env.LINKFLAGS = compiler['link_' + variant]
if compiler_target and 'linkflags' in compiler_target:
conf.env.LINKFLAGS += compiler_target['linkflags']
# Includes and defines
if conf.env.TARGET == 'windows_x86':
conf.define('WIN32_LEAN_AND_MEAN', 1)
if compiler_target and 'env' in compiler_target:
for key, value in compiler_target['env'].items():
conf.env[key] = value
conf.env.MSVC_MANIFEST = False
示例2: check_sqlite3
def check_sqlite3(self, *k, **kw):
root = k and k[0] or kw.get('path', None) or Options.options.with_sqlite3
mandatory = kw.get('mandatory', True)
var = kw.get('uselib_store', 'SQLITE3')
if not self.options.with_sqlite_locking:
conf.define('DISABLE_SQLITE3_FS_LOCKING', 1)
if root:
self.check_cxx(lib='sqlite3',
msg='Checking for SQLite3 library',
define_name='HAVE_%s' % var,
uselib_store=var,
mandatory=mandatory,
includes="%s/include" % root,
libpath="%s/lib" % root)
else:
try:
self.check_cfg(package='sqlite3',
args=['--cflags', '--libs'],
global_define=True,
define_name='HAVE_%s' % var,
uselib_store='SQLITE3',
mandatory=True)
except:
self.check_cxx(lib='sqlite3',
msg='Checking for SQLite3 library',
define_name='HAVE_%s' % var,
uselib_store=var,
mandatory=mandatory)
示例3: check_python_version
def check_python_version(conf, minver=None):
assert minver is None or isinstance(minver, tuple)
pybin = conf.env["PYTHON"]
if not pybin:
conf.fatal("could not find the python executable")
cmd = pybin + ["-c", "import sys\nfor x in sys.version_info: print(str(x))"]
debug("python: Running python command %r" % cmd)
lines = conf.cmd_and_log(cmd).split()
assert len(lines) == 5, "found %i lines, expected 5: %r" % (len(lines), lines)
pyver_tuple = (int(lines[0]), int(lines[1]), int(lines[2]), lines[3], int(lines[4]))
result = (minver is None) or (pyver_tuple >= minver)
if result:
pyver = ".".join([str(x) for x in pyver_tuple[:2]])
conf.env["PYTHON_VERSION"] = pyver
if "PYTHONDIR" in conf.environ:
pydir = conf.environ["PYTHONDIR"]
else:
if Utils.is_win32:
(python_LIBDEST, pydir) = conf.get_python_variables(
[
"get_config_var('LIBDEST') or ''",
"get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env["PREFIX"],
],
["from distutils.sysconfig import get_config_var, get_python_lib"],
)
else:
python_LIBDEST = None
(pydir,) = conf.get_python_variables(
["get_python_lib(standard_lib=0, prefix=%r) or ''" % conf.env["PREFIX"]],
["from distutils.sysconfig import get_python_lib"],
)
if python_LIBDEST is None:
if conf.env["LIBDIR"]:
python_LIBDEST = os.path.join(conf.env["LIBDIR"], "python" + pyver)
else:
python_LIBDEST = os.path.join(conf.env["PREFIX"], "lib", "python" + pyver)
if "PYTHONARCHDIR" in conf.environ:
pyarchdir = conf.environ["PYTHONARCHDIR"]
else:
(pyarchdir,) = conf.get_python_variables(
["get_python_lib(plat_specific=1, standard_lib=0, prefix=%r) or ''" % conf.env["PREFIX"]],
["from distutils.sysconfig import get_python_lib"],
)
if not pyarchdir:
pyarchdir = pydir
if hasattr(conf, "define"):
conf.define("PYTHONDIR", pydir)
conf.define("PYTHONARCHDIR", pyarchdir)
conf.env["PYTHONDIR"] = pydir
conf.env["PYTHONARCHDIR"] = pyarchdir
pyver_full = ".".join(map(str, pyver_tuple[:3]))
if minver is None:
conf.msg("Checking for python version", pyver_full)
else:
minver_str = ".".join(map(str, minver))
conf.msg("Checking for python version", pyver_tuple, ">= %s" % (minver_str,) and "GREEN" or "YELLOW")
if not result:
conf.fatal("The python version is too old, expecting %r" % (minver,))
示例4: check_ssl
def check_ssl(conf):
if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
libcrypto = conf.check_cc(lib='crypto',
header_name='openssl/crypto.h',
define_name='HAVE_SSL',
uselib_store='SSL')
else:
conf.define("HAVE_SSL", 1)
if not conf.get_define ("HAVE_SSL"):
conf.fatal("Cannot find SSL libraries")
示例5: check_sferes
def check_sferes(conf):
if conf.options.sferes:
conf.env.INCLUDES_SFERES = [conf.options.sferes]
conf.env.LIBPATH_SFERES = [conf.options.sferes + '/build/default/sferes']
try:
res = conf.find_file('sferes/ea/ea.hpp', conf.env.INCLUDES_SFERES)
conf.define("USE_SFERES", 1)
except:
print 'SFERES not found'
return 1
示例6: check_filesystem
def check_filesystem(conf):
conf.start_msg('Checking filesystem support')
try:
conf.check_cxx(
fragment='\n'.join([
'#include <filesystem>',
'int main() { std::tr2::sys::path path; }',
]),
execute=False,
)
conf.define('STL_FILESYSTEM_ENABLED', 1)
conf.end_msg('<filesystem>')
except:
conf.end_msg('<boost/filesystem.hpp>')
示例7: check_python_version
def check_python_version(conf,minver=None):
assert minver is None or isinstance(minver,tuple)
pybin=conf.env['PYTHON']
if not pybin:
conf.fatal('could not find the python executable')
cmd=pybin+['-c','import sys\nfor x in sys.version_info: print(str(x))']
Logs.debug('python: Running python command %r'%cmd)
lines=conf.cmd_and_log(cmd).split()
assert len(lines)==5,"found %i lines, expected 5: %r"%(len(lines),lines)
pyver_tuple=(int(lines[0]),int(lines[1]),int(lines[2]),lines[3],int(lines[4]))
result=(minver is None)or(pyver_tuple>=minver)
if result:
pyver='.'.join([str(x)for x in pyver_tuple[:2]])
conf.env['PYTHON_VERSION']=pyver
if'PYTHONDIR'in conf.env:
pydir=conf.env['PYTHONDIR']
elif'PYTHONDIR'in conf.environ:
pydir=conf.environ['PYTHONDIR']
else:
if Utils.is_win32:
(python_LIBDEST,pydir)=conf.get_python_variables(["get_config_var('LIBDEST') or ''","get_python_lib(standard_lib=0) or ''"])
else:
python_LIBDEST=None
(pydir,)=conf.get_python_variables(["get_python_lib(standard_lib=0) or ''"])
if python_LIBDEST is None:
if conf.env['LIBDIR']:
python_LIBDEST=os.path.join(conf.env['LIBDIR'],"python"+pyver)
else:
python_LIBDEST=os.path.join(conf.env['PREFIX'],"lib","python"+pyver)
if'PYTHONARCHDIR'in conf.env:
pyarchdir=conf.env['PYTHONARCHDIR']
elif'PYTHONARCHDIR'in conf.environ:
pyarchdir=conf.environ['PYTHONARCHDIR']
else:
(pyarchdir,)=conf.get_python_variables(["get_python_lib(plat_specific=1, standard_lib=0) or ''"])
if not pyarchdir:
pyarchdir=pydir
if hasattr(conf,'define'):
conf.define('PYTHONDIR',pydir)
conf.define('PYTHONARCHDIR',pyarchdir)
conf.env['PYTHONDIR']=pydir
conf.env['PYTHONARCHDIR']=pyarchdir
pyver_full='.'.join(map(str,pyver_tuple[:3]))
if minver is None:
conf.msg('Checking for python version',pyver_full)
else:
minver_str='.'.join(map(str,minver))
conf.msg('Checking for python version',pyver_tuple,">= %s"%(minver_str,)and'GREEN'or'YELLOW')
if not result:
conf.fatal('The python version is too old, expecting %r'%(minver,))
示例8: check_tbb
def check_tbb(conf):
conf.env.LIB_TBB = ['tbb']
if conf.options.tbb:
conf.env.INCLUDES_TBB = [conf.options.tbb + '/include']
conf.env.LIBPATH_TBB = [conf.options.tbb + '/lib']
else:
conf.env.INCLUDES_TBB = ['/usr/local/include',
'/usr/include']
conf.env.LIBPATH_TBB = ['/usr/local/lib/',
'/usr/lib']
try:
res = conf.find_file('tbb/parallel_for.h', conf.env.INCLUDES_TBB)
conf.define("USE_TBB", 1)
except:
print 'TBB not found'
示例9: check_osx_security
def check_osx_security(conf, *k, **kw):
if Utils.unversioned_sys_platform() == "darwin":
try:
conf.check_cxx(framework_name='CoreFoundation', uselib_store='OSX_COREFOUNDATION',
mandatory=True)
conf.check_cxx(framework_name='CoreServices', uselib_store='OSX_CORESERVICES',
mandatory=True)
conf.check_cxx(framework_name='Security', uselib_store='OSX_SECURITY',
define_name='HAVE_SECURITY', use="OSX_COREFOUNDATION",
fragment=OSX_SECURITY_CODE, mandatory=True)
conf.define('HAVE_OSX_SECURITY', 1)
conf.env['HAVE_OSX_SECURITY'] = True
except:
Logs.warn("Compiling on OSX, but CoreFoundation, CoreServices, or Security framework is not functional.")
Logs.warn("The frameworks are known to work only with Apple-specific compilers: llvm-gcc-4.2 or clang")
示例10: configure
def configure (conf):
# debugging option
if conf.options.debug:
conf.define ("DEBUG", 1)
conf.define ("_DEBUG", 1)
conf.env.append_unique ('CXXFLAGS', ['-g', '-ggdb', '-O0'])
conf.env.append_unique ('CFLAGS', ['-g', '-ggdb', '-O0'])
else:
conf.define ("NDEBUG", 1)
conf.env.append_unique ('CXXFLAGS', ['-Os'])
conf.env.append_unique ('CFLAGS', ['-Os'])
# output dir (build dir)
outdir = conf.options.out
if len (outdir) == 0:
outdir = "build"
# module path
if not conf.env.JUCE_MODULE_PATH:
conf.env.JUCE_MODULE_PATH = os.path.join (os.path.expanduser("~"), 'juce/modules')
# define a library pattern suitable for plugins/modules
# (e.g. remove the 'lib' from libplugin.XXX)
pat = conf.env['cshlib_PATTERN']
if not pat:
pat = conf.env['cxxshlib_PATTERN']
if pat.startswith('lib'):
pat = pat[3:]
conf.env['plugin_PATTERN'] = pat
conf.env['plugin_EXT'] = pat[pat.rfind('.'):]
# do platform stuff
if is_linux():
conf.define ('LINUX', 1)
elif is_mac():
conf.env.FRAMEWORK_ACCELERATE = 'Accelerate'
conf.env.FRAMEWORK_AUDIO_TOOLBOX = 'AudioToolbox'
conf.env.FRAMEWORK_AUDIO_UNIT = 'AudioUnit'
conf.env.FRAMEWORK_CORE_AUDIO = 'CoreAudio'
conf.env.FRAMEWORK_CORE_AUDIO_KIT = 'CoreAudioKit'
conf.env.FRAMEWORK_CORE_MIDI = 'CoreMIDI'
conf.env.FRAMEWORK_COCOA = 'Cocoa'
conf.env.FRAMEWORK_CARBON = 'Carbon'
conf.env.FRAMEWORK_DISC_RECORDING = 'DiscRecording'
conf.env.FRAMEWORK_IO_KIT = 'IOKit'
conf.env.FRAMEWORK_OPEN_GL = 'OpenGL'
conf.env.FRAMEWORK_QT_KIT = 'QTKit'
conf.env.FRAMEWORK_QuickTime = 'QuickTime'
conf.env.FRAMEWORK_QUARTZ_CORE = 'QuartzCore'
conf.env.FRAMEWORK_WEB_KIT = 'WebKit'
elif is_win32(): pass
示例11: set_env
def set_env(conf):
conf.env.MSVC_LAZY_AUTODETECT = True
conf.define('BOOSTTHREAD_USE_LIB', 1)
conf.define('BOOSTTHREAD_VERSION', 4)
conf.define('GTEST_LANG_CXX11', 1)
for key, value in TARGETS[conf.env.TARGET].items():
conf.env[key] = value
示例12: check_python_headers
def check_python_headers(conf):
env=conf.env
if not env['CC_NAME']and not env['CXX_NAME']:
conf.fatal('load a compiler first (gcc, g++, ..)')
if not env['PYTHON_VERSION']:
conf.check_python_version()
pybin=conf.env.PYTHON
if not pybin:
conf.fatal('Could not find the python executable')
v='prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION'.split()
try:
lst=conf.get_python_variables(["get_config_var('%s') or ''"%x for x in v])
except RuntimeError:
conf.fatal("Python development headers not found (-v for details).")
vals=['%s = %r'%(x,y)for(x,y)in zip(v,lst)]
conf.to_log("Configuration returned from %r:\n%r\n"%(pybin,'\n'.join(vals)))
dct=dict(zip(v,lst))
x='MACOSX_DEPLOYMENT_TARGET'
if dct[x]:
conf.env[x]=conf.environ[x]=dct[x]
if not env.pyext_PATTERN:
if dct['SO']:
env.pyext_PATTERN='%s'+dct['SO']
else:
env.pyext_PATTERN=(conf.env.cshlib_PATTERN or conf.env.cxxshlib_PATTERN).lstrip('lib')
num='.'.join(env['PYTHON_VERSION'].split('.')[:2])
conf.find_program([''.join(pybin)+'-config','python%s-config'%num,'python-config-%s'%num,'python%sm-config'%num],var='PYTHON_CONFIG',msg="python-config")
all_flags=[['--cflags','--libs','--ldflags']]
if sys.hexversion<0x2060000:
all_flags=[[x]for x in all_flags[0]]
xx=conf.env.CXX_NAME and'cxx'or'c'
for flags in all_flags:
conf.check_cfg(msg='Asking python-config for pyembed %r flags'%' '.join(flags),path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEMBED',args=flags)
conf.check(header_name='Python.h',define_name='HAVE_PYEMBED',msg='Getting pyembed flags from python-config',fragment=FRAG,errmsg='Could not build a python embedded interpreter',features='%s %sprogram pyembed'%(xx,xx))
for flags in all_flags:
conf.check_cfg(msg='Asking python-config for pyext %r flags'%' '.join(flags),path=conf.env.PYTHON_CONFIG,package='',uselib_store='PYEXT',args=flags)
conf.check(header_name='Python.h',define_name='HAVE_PYEXT',msg='Getting pyext flags from python-config',features='%s %sshlib pyext'%(xx,xx),fragment=FRAG,errmsg='Could not build python extensions')
conf.define('HAVE_PYTHON_H',1)
示例13: configure
def configure(conf):
conf.env.TARGET = platform.system().lower() + '_' + platform.machine().lower()
conf.msg('Setting target to', conf.env.TARGET)
conf.define('GTEST_LANG_CXX11', 1)
conf.define('BOOSTTHREAD_USE_LIB', 1)
conf.define('BOOSTTHREAD_VERSION', 4)
for key, value in TARGETS[conf.env.TARGET].items():
conf.env[key] = value
conf.load('cpplint waf_unit_test compiler_cxx boost qt5')
env = conf.env.derive()
conf.set_variant('release', env)
conf.check_libs()
conf.set_variant('debug', env)
conf.check_libs()
Logs.info('---------------------------------------- :')
conf.check_cpp14()
示例14: check_python_headers
def check_python_headers(conf, features='pyembed pyext'):
"""
Check for headers and libraries necessary to extend or embed python by using the module *distutils*.
On success the environment variables xxx_PYEXT and xxx_PYEMBED are added:
* PYEXT: for compiling python extensions
* PYEMBED: for embedding a python interpreter
"""
features = Utils.to_list(features)
assert ('pyembed' in features) or ('pyext' in features), "check_python_headers features must include 'pyembed' and/or 'pyext'"
env = conf.env
if not env.CC_NAME and not env.CXX_NAME:
conf.fatal('load a compiler first (gcc, g++, ..)')
# bypass all the code below for cross-compilation
if conf.python_cross_compile(features):
return
if not env.PYTHON_VERSION:
conf.check_python_version()
pybin = env.PYTHON
if not pybin:
conf.fatal('Could not find the python executable')
# so we actually do all this for compatibility reasons and for obtaining pyext_PATTERN below
v = 'prefix SO LDFLAGS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET LDSHARED CFLAGS LDVERSION'.split()
try:
lst = conf.get_python_variables(["get_config_var('%s') or ''" % x for x in v])
except RuntimeError:
conf.fatal("Python development headers not found (-v for details).")
vals = ['%s = %r' % (x, y) for (x, y) in zip(v, lst)]
conf.to_log("Configuration returned from %r:\n%s\n" % (pybin, '\n'.join(vals)))
dct = dict(zip(v, lst))
x = 'MACOSX_DEPLOYMENT_TARGET'
if dct[x]:
env[x] = conf.environ[x] = dct[x]
env.pyext_PATTERN = '%s' + dct['SO'] # not a mistake
# Try to get pythonX.Y-config
num = '.'.join(env.PYTHON_VERSION.split('.')[:2])
conf.find_program([''.join(pybin) + '-config', 'python%s-config' % num, 'python-config-%s' % num, 'python%sm-config' % num], var='PYTHON_CONFIG', msg="python-config", mandatory=False)
if env.PYTHON_CONFIG:
# python2.6-config requires 3 runs
all_flags = [['--cflags', '--libs', '--ldflags']]
if sys.hexversion < 0x2070000:
all_flags = [[k] for k in all_flags[0]]
xx = env.CXX_NAME and 'cxx' or 'c'
if 'pyembed' in features:
for flags in all_flags:
conf.check_cfg(msg='Asking python-config for pyembed %r flags' % ' '.join(flags), path=env.PYTHON_CONFIG, package='', uselib_store='PYEMBED', args=flags)
try:
conf.test_pyembed(xx)
except conf.errors.ConfigurationError:
# python bug 7352
if dct['Py_ENABLE_SHARED'] and dct['LIBDIR']:
env.append_unique('LIBPATH_PYEMBED', [dct['LIBDIR']])
conf.test_pyembed(xx)
else:
raise
if 'pyext' in features:
for flags in all_flags:
conf.check_cfg(msg='Asking python-config for pyext %r flags' % ' '.join(flags), path=env.PYTHON_CONFIG, package='', uselib_store='PYEXT', args=flags)
try:
conf.test_pyext(xx)
except conf.errors.ConfigurationError:
# python bug 7352
if dct['Py_ENABLE_SHARED'] and dct['LIBDIR']:
env.append_unique('LIBPATH_PYEXT', [dct['LIBDIR']])
conf.test_pyext(xx)
else:
raise
conf.define('HAVE_PYTHON_H', 1)
return
# No python-config, do something else on windows systems
all_flags = dct['LDFLAGS'] + ' ' + dct['CFLAGS']
conf.parse_flags(all_flags, 'PYEMBED')
all_flags = dct['LDFLAGS'] + ' ' + dct['LDSHARED'] + ' ' + dct['CFLAGS']
conf.parse_flags(all_flags, 'PYEXT')
result = None
if not dct["LDVERSION"]:
dct["LDVERSION"] = env.PYTHON_VERSION
# further simplification will be complicated
for name in ('python' + dct['LDVERSION'], 'python' + env.PYTHON_VERSION + 'm', 'python' + env.PYTHON_VERSION.replace('.', '')):
# LIBPATH_PYEMBED is already set; see if it works.
#.........这里部分代码省略.........
示例15: configure
def configure(conf):
conf.load('compiler_c intltool')
path, version = get_pkg_path_and_version("pidgin")
conf.env.PIDGIN_PATH = path
conf.env.PURPLE_PATH = join(path, "libpurple")
conf.env.PURPLE_VERSION = version
if conf.env.PURPLE_SSL:
# Order matters: It seems like ssl-gnutls has to be loaded before
# core-ssl to be found (see ssl.c:probe_ssl_plugins)
conf.env.PURPLE_PLUGINS += ["ssl-" + conf.env.PURPLE_SSL, "ssl"]
conf.env.append_value("LIB_PURPLE_BUILD", ["gnutls"])
plugins = conf.env.PURPLE_PLUGINS
conf.check_cfg(atleast_pkgconfig_version='0.1')
conf.check_cfg(package='libxml-2.0', uselib_store='XML',
args=['--cflags', '--libs'])
conf.env.append_value("DEFINES_PURPLE_BUILD", ["HAVE_CONFIG_H"])
conf.env.append_value("INCLUDES_PURPLE_BUILD", ["libpurple_config",
conf.env.PURPLE_PATH])
conf.env.append_value("LIB_PURPLE_BUILD", ["resolv"])
# We are going to build a shared library
conf.env.append_value("CFLAGS_PURPLE_BUILD", ["-fPIC"])
headers = ["arpa/nameser_compat", "fcntl", "sys/time",
"unistd", "locale", "libintl", "signal", "stdint", "regex"]
for i in headers:
conf.check_cc(header_name=i + ".h", mandatory=False,
auto_add_header_name=True)
conf.define("PURPLE_PLUGINS", 1)
conf.define("HAVE_GETIFADDRS", 1)
conf.define("HAVE_INET_NTOP", 1)
conf.define("HAVE_INET_ATON", 1)
conf.define("HAVE_GETADDRINFO", 1)
conf.define("HAVE_STRUCT_TM_TM_ZONE", 1)
conf.define("HAVE_TM_GMTOFF", 1)
conf.define("HAVE_TIMEZONE", 1)
conf.define("HAVE_TIMGM", 1)
conf.define("HAVE_STRFTIME_Z_FORMAT", 1)
conf.define("HAVE_FILENO", 1)
conf.define("HAVE_STRUCT_SOCKADDR_SA_LEN", 1)
conf.define("VERSION", conf.env.PURPLE_VERSION)
conf.define("DISPLAY_VERSION", conf.env.PURPLE_VERSION)
conf.define("DATADIR", ".")
conf.define("SYSCONFDIR", ".")
conf.define("PACKAGE_NAME", "libpurple")
conf.define("HAVE_SSL", 1)
conf.define("HAVE_ICONV", 1)
conf.define("SIZEOF_TIME_T", 4, quote=False)
conf.define("HAVE_CONFIG_H", 1, quote=False)
conf.define("HAVE_GNUTLS_PRIORITY_FUNCS", 1)
conf.define("_GNU_SOURCE", 1, quote=False)
conf.define("SSL_CERTIFICATES_DIR",
join(conf.env.APP_PATH, "share", "ca-certs")
)
conf.define("LIBDIR", conf.env.PLUGIN_PATH)
conf.define("ENABLE_NLS", 1, quote=False)
conf.define("PACKAGE", "libpurple")
conf.define("LOCALEDIR",
join(conf.env.APP_PATH, "share", "locale")
)
conf.define("STATIC_PROTO_INIT", "void static_proto_init() {}", quote=False)
conf.write_config_header('libpurple_config/config.h')
conf.load('protocols', tooldir=conf.env.TOOLDIR)