def configure(conf): conf.find_dmd() conf.check_tool('ar') conf.check_tool('d') conf.common_flags_dmd() conf.d_platform_flags() if str(conf.env.D).find('ldc') > -1: conf.common_flags_ldc()
def find_msvc(conf): # due to path format limitations, limit operation only to native Win32. Yeah it sucks. if sys.platform != 'win32': conf.fatal('MSVC module only works under native Win32 Python! cygwin is not supported yet') v = conf.env compiler, path, includes, libdirs = detect_msvc(conf) v['PATH'] = path v['INCLUDES'] = includes v['LIBPATH'] = libdirs compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler) # compiler cxx = None if v['CXX']: cxx = v['CXX'] elif 'CXX' in conf.environ: cxx = conf.environ['CXX'] if not cxx: cxx = conf.find_program(compiler_name, var='CXX', path_list=path) if not cxx: conf.fatal('%s was not found (compiler)' % compiler_name) cxx = conf.cmd_to_list(cxx) # before setting anything, check if the compiler is really msvc env = dict(conf.environ) env.update(PATH = ';'.join(path)) if not conf.cmd_and_log(cxx + ['/nologo', '/?'], env=env): conf.fatal('the msvc compiler could not be identified') # c/c++ compiler v['CC'] = v['CXX'] = cxx v['CC_NAME'] = v['CXX_NAME'] = 'msvc' # environment flags try: v.prepend_value('INCLUDES', conf.environ['INCLUDE']) except KeyError: pass try: v.prepend_value('LIBPATH', conf.environ['LIB']) except KeyError: pass # linker if not v['LINK_CXX']: link = conf.find_program(linker_name, path_list=path) if link: v['LINK_CXX'] = link else: conf.fatal('%s was not found (linker)' % linker_name) v['LINK'] = link if not v['LINK_CC']: v['LINK_CC'] = v['LINK_CXX'] # staticlib linker if not v['AR']: stliblink = conf.find_program(lib_name, path_list=path) if not stliblink: return v['AR'] = stliblink v['ARFLAGS'] = ['/NOLOGO'] # manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later manifesttool = conf.find_program('MT', path_list=path) if manifesttool: v['MT'] = [manifesttool] v['MTFLAGS'] = ['/NOLOGO'] conf.check_tool('winres') if not conf.env['WINRC']: warn('Resource compiler not found. Compiling resource file is disabled')
def cxx_load_tools(conf): conf.check_tool('cxx')
def cc_load_tools(conf): conf.check_tool('c')
def check_python_headers(conf): """Check for headers and libraries necessary to extend or embed python. On success the environment variables xxx_PYEXT and xxx_PYEMBED are added for uselib PYEXT: for compiling python extensions PYEMBED: for embedding a python interpreter""" if not conf.env['CC_NAME'] and not conf.env['CXX_NAME']: conf.fatal('load a compiler first (gcc, g++, ..)') if not conf.env['PYTHON_VERSION']: conf.check_python_version() env = conf.env python = env['PYTHON'] if not python: conf.fatal('could not find the python executable') ## On Mac OSX we need to use mac bundles for python plugins if Options.platform == 'darwin': conf.check_tool('osx') try: # Get some python configuration variables using distutils v = 'prefix SO SYSLIBS LDFLAGS SHLIBS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET'.split() (python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED, python_MACOSX_DEPLOYMENT_TARGET) = \ conf.get_python_variables(python, ["get_config_var('%s')" % x for x in v], ['from distutils.sysconfig import get_config_var']) except RuntimeError: conf.fatal("Python development headers not found (-v for details).") conf.to_log("""Configuration returned from %r: python_prefix = %r python_SO = %r python_SYSLIBS = %r python_LDFLAGS = %r python_SHLIBS = %r python_LIBDIR = %r python_LIBPL = %r INCLUDEPY = %r Py_ENABLE_SHARED = %r MACOSX_DEPLOYMENT_TARGET = %r """ % (python, python_prefix, python_SO, python_SYSLIBS, python_LDFLAGS, python_SHLIBS, python_LIBDIR, python_LIBPL, INCLUDEPY, Py_ENABLE_SHARED, python_MACOSX_DEPLOYMENT_TARGET)) if python_MACOSX_DEPLOYMENT_TARGET: conf.env['MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET conf.environ['MACOSX_DEPLOYMENT_TARGET'] = python_MACOSX_DEPLOYMENT_TARGET env['pyext_PATTERN'] = '%s'+python_SO # Check for python libraries for embedding if python_SYSLIBS is not None: for lib in python_SYSLIBS.split(): if lib.startswith('-l'): lib = lib[2:] # strip '-l' env.append_value('LIB_PYEMBED', [lib]) if python_SHLIBS is not None: for lib in python_SHLIBS.split(): if lib.startswith('-l'): lib = lib[2:] # strip '-l' env.append_value('LIB_PYEMBED', [lib]) if Options.platform != 'darwin' and python_LDFLAGS: env.append_value('LINKFLAGS_PYEMBED', python_LDFLAGS.split()) result = False name = 'python' + env['PYTHON_VERSION'] if python_LIBDIR is not None: path = [python_LIBDIR] conf.to_log("\n\n# Trying LIBDIR: %r\n" % path) result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if not result and python_LIBPL is not None: conf.to_log("\n\n# try again with -L$python_LIBPL (some systems don't install the python library in $prefix/lib)\n") path = [python_LIBPL] result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if not result: conf.to_log("\n\n# try again with -L$prefix/libs, and pythonXY name rather than pythonX.Y (win32)\n") path = [os.path.join(python_prefix, "libs")] name = 'python' + env['PYTHON_VERSION'].replace('.', '') result = conf.check(lib=name, uselib='PYEMBED', libpath=path) if result: env['LIBPATH_PYEMBED'] = path env.append_value('LIB_PYEMBED', [name]) else: conf.to_log("\n\n### LIB NOT FOUND\n") # under certain conditions, python extensions must link to # python libraries, not just python embedding programs. if (sys.platform == 'win32' or sys.platform.startswith('os2') or sys.platform == 'darwin' or Py_ENABLE_SHARED): env['LIBPATH_PYEXT'] = env['LIBPATH_PYEMBED'] env['LIB_PYEXT'] = env['LIB_PYEMBED'] # We check that pythonX.Y-config exists, and if it exists we # use it to get only the includes, else fall back to distutils. python_config = conf.find_program( 'python%s-config' % ('.'.join(env['PYTHON_VERSION'].split('.')[:2])), var='PYTHON_CONFIG') if not python_config: python_config = conf.find_program( 'python-config-%s' % ('.'.join(env['PYTHON_VERSION'].split('.')[:2])), var='PYTHON_CONFIG') includes = [] if python_config: for incstr in conf.cmd_and_log("%s %s --includes" % (python, python_config)).strip().split(): # strip the -I or /I if (incstr.startswith('-I') or incstr.startswith('/I')): incstr = incstr[2:] # append include path, unless already given if incstr not in includes: includes.append(incstr) conf.to_log("Include path for Python extensions " "(found via python-config --includes): %r\n" % (includes,)) env['INCLUDES_PYEXT'] = includes env['INCLUDES_PYEMBED'] = includes else: conf.to_log("Include path for Python extensions " "(found via distutils module): %r\n" % (INCLUDEPY,)) env['INCLUDES_PYEXT'] = [INCLUDEPY] env['INCLUDES_PYEMBED'] = [INCLUDEPY] # Code using the Python API needs to be compiled with -fno-strict-aliasing if env['CC_NAME'] == 'gcc': env.append_value('CCFLAGS_PYEMBED', ['-fno-strict-aliasing']) env.append_value('CCFLAGS_PYEXT', ['-fno-strict-aliasing']) if env['CXX_NAME'] == 'gcc': env.append_value('CXXFLAGS_PYEMBED', ['-fno-strict-aliasing']) env.append_value('CXXFLAGS_PYEXT', ['-fno-strict-aliasing']) # See if it compiles conf.check(header_name='Python.h', define_name='HAVE_PYTHON_H', uselib='PYEMBED', fragment=FRAG, errmsg='Could not find the python development headers')
def configure(conf): conf.find_gdc() conf.check_tool('ar') conf.check_tool('d') conf.common_flags_gdc() conf.d_platform_flags()
def find_ar(conf): conf.check_tool('ar')