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')
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')
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 you're on a 64-bit machine building 32-bit, you're not going to have # the right Mex files sitting around skipMatlab = '64' in platform.machine() and not self.env['IS64BIT'] if skipMatlab and mandatory: self.fatal('32-bit Matlab not available on 64-bit machines') if not skipMatlab and self.find_program('matlab', var='matlab', path_list=[_f for _f in [matlabBin] if _f], mandatory=mandatory): matlabPath = expandIfSymlink(self.env['matlab']) matlabBin = dirname(matlabPath) if not matlabHome: matlabHome = join(matlabBin, os.pardir) #TODO put these in a utility somewhere winRegex = r'win32' incDirs = [os.path.dirname(x) for x in 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 = [os.path.dirname(x) for x in recursiveGlob(matlabBin, searches)] libDirs.extend([os.path.dirname(x) for x in recursiveGlob(abspath(join(matlabHome, 'extern', 'lib')), searches)]) mexExtCmd = os.path.join(matlabBin, 'mexext') if re.match(winRegex, self.env['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, universal_newlines=True).communicate() for line in out.split('\n'): keyVal = line.split('=', 1) if len(keyVal) == 2 and keyVal[0] == 'ARCH': archdir = keyVal[1] break if not os.path.exists(mexExtCmd): Logs.warn('Unable to find {0}. Disabling MATLAB'.format(mexExtCmd)) return False # Get the appropriate mex extension. Matlab provides a script to # tell us this. out, err = subprocess.Popen(mexExtCmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).communicate() self.env['MEX_EXT'] = '.' + out.rstrip() filtered = [x for x in libDirs if archdir in x] 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() if self.check(header_name='mex.h', define_name='HAVE_MEX_H', includes=incDirs, uselib_store='MEX', uselib='MEX', mandatory=True, env=env): self.env['HAVE_MATLAB'] = True self.undefine('HAVE_MEX_H') libPrefix = '' if re.match(winRegex, self.env['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, self.env['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')
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 appleRegex = r'i.86-apple-.*' linuxRegex = r'.*-.*-linux-.*|i686-pc-.*|linux' sparcRegex = r'sparc-sun.*' 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() matlabEnv = dict( map(lambda x: x.split('=', 1), filter(None, out.split('\n')))) archdir = matlabEnv['ARCH'] # 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')
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 appleRegex = r"i.86-apple-.*" linuxRegex = r".*-.*-linux-.*|i686-pc-.*|linux" sparcRegex = r"sparc-sun.*" 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() matlabEnv = dict(map(lambda x: x.split("=", 1), filter(None, out.split("\n")))) archdir = matlabEnv["ARCH"] # 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")
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 you're on a 64-bit machine building 32-bit, you're not going to have # the right Mex files sitting around skipMatlab = '64' in platform.machine() and not self.env['IS64BIT'] if skipMatlab and mandatory: self.fatal('32-bit Matlab not available on 64-bit machines') if not skipMatlab and self.find_program( 'matlab', var='matlab', path_list=[_f for _f in [matlabBin] if _f], mandatory=mandatory): matlabPath = expandIfSymlink(self.env['matlab']) matlabBin = dirname(matlabPath) if not matlabHome: matlabHome = join(matlabBin, os.pardir) #TODO put these in a utility somewhere winRegex = r'win32' incDirs = [ os.path.dirname(x) for x in 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 = [ os.path.dirname(x) for x in recursiveGlob(matlabBin, searches) ] libDirs.extend([ os.path.dirname(x) for x in recursiveGlob( abspath(join(matlabHome, 'extern', 'lib')), searches) ]) mexExtCmd = os.path.join(matlabBin, 'mexext') if re.match(winRegex, self.env['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, universal_newlines=True).communicate() for line in out.split('\n'): keyVal = line.split('=', 1) if len(keyVal) == 2 and keyVal[0] == 'ARCH': archdir = keyVal[1] break if not os.path.exists(mexExtCmd): Logs.warn('Unable to find {0}. Disabling MATLAB'.format(mexExtCmd)) return False # Get the appropriate mex extension. Matlab provides a script to # tell us this. out, err = subprocess.Popen(mexExtCmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).communicate() self.env['MEX_EXT'] = '.' + out.rstrip() filtered = [x for x in libDirs if archdir in x] 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() if self.check(header_name='mex.h', define_name='HAVE_MEX_H', includes=incDirs, uselib_store='MEX', uselib='MEX', mandatory=True, env=env): self.env['HAVE_MATLAB'] = True self.undefine('HAVE_MEX_H') libPrefix = '' if re.match(winRegex, self.env['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, self.env['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')