def setup(conf): try: conf.pkg_config('libevdev', vars='evdev') except Exception: pprint('YELLOW', '-evdev', sep=' ') else: pprint('GREEN', '+evdev', sep=' ')
def check_sanity(ctx, cond, lib): define = "HAVE_%s" % lib.upper() if cond and (not ctx.get_define(define)): pprint("RED", "Warning %s headers detected, binaries do not build/run" % lib) elif (not cond) and ctx.get_define(define): pprint("RED", "Warning %s headers not detected, binaries build/run" % lib)
def cmd_bin_test(ctx, config): fail = True for cmd in sorted(cmd_map): fail = run(cmd, cmd_map[cmd]) if fail: pprint("RED", "Tests failed!")
def setup(conf): if 'posix' in conf.env.VALID_PLATFORMS: try: conf.pkg_config('fontconfig', var='fontconfig') except Exception as e: pprint('YELLOW', '-fontconfig', sep=' ') else: pprint('GREEN', '+fontconfig', sep=' ') conf.env.SYSTEM_FONTCONFIG = True
def setup(conf): try: conf.pkg_config('squirrel3', var='squirrel') except Exception as e: include = 'squirrel.h' if conf.check_lib('squirrel', includes=[include], functions=['sq_open']): conf.env.SYSTEM_SQUIRREL = True else: pprint('BLUE', '=squirrel', sep=' ') else: conf.env.SYSTEM_SQUIRREL = True pprint('GREEN', '+squirrel', sep=' ')
def setup(conf): if 'darwin' in conf.env.VALID_PLATFORMS: conf.check_framework('OpenAL') else: try: conf.pkg_config('openal', var='OpenAL') except Exception as e: conf.check_lib('openal', var='OpenAL', libpath=[os.path.join(conf.path.abspath(), 'lib.%s.%s'%(conf.env.VALID_PLATFORMS[0], a)) for a in conf.env.VALID_ARCHITECTURES], includepath=[os.path.join(conf.path.abspath(), 'api')], includes=['AL/alc.h', 'AL/al.h'], functions=['alcOpenDevice']) or pprint('YELLOW', '-openal', sep=' ') else: conf.env.SYSTEM_OPENAL = True pprint('GREEN', '+openal', sep=' ')
def install_boost(ctx): pprint('YELLOW', 'Attempting BOOST auto-installation ...') # First, search for the source files ctx.start_msg('Searching for BOOST sources') source_path = ctx.env.DEPS_SRC + '/boost_1_57_0' source_node = ctx.root.find_node(source_path) # If sources not found, try to download them if not source_node: ctx.end_msg('not found', color='YELLOW') ctx.download_boost() else: ctx.end_msg('ok') # At this point, we should have the sources chdir(source_path) # Bootstrap msg = 'Bootstrapping BOOST.Build' command = ['./bootstrap.sh'] ctx.exec_with_msg(command, msg) # Build msg = 'Building and installing BOOST' command = ['./b2', '--prefix=' + ctx.env.DEPS_PREFIX ] + \ ['--with-test'] + \ ['--with-' + lib for lib in ctx.env.BOOST_PKGS if ctx.boost_is_compiled(lib)] + \ ['install'] ctx.exec_with_msg(command, msg) # On MacOSX, the install_name is not set correctly by the boost build # Fix that by invoking the install_name_tool if unversioned_sys_platform() == 'darwin': chdir(ctx.env.DEPS_LIB) msg = 'Fixing dynamic library install name' command = 'for i in libboost*.dylib; do' + \ ' install_name_tool -id "@rpath/$i" $i;' + \ ' for j in libboost*.dylib; do' + \ ' install_name_tool -change $j "@rpath/$j" $i;' + \ ' done;' + \ 'done;' ctx.exec_with_msg(command, msg, shell=True) pprint('YELLOW', '... BOOST auto-installation complete.')
def setup_shipped(conf): include = 'CL/cl.h' libpath=[os.path.join(conf.path.abspath(), 'lib.%s.%s'%(conf.env.VALID_PLATFORMS[0], a)) for a in conf.env.VALID_ARCHITECTURES] conf.check_lib('OpenCL', includes=[include], libpath=libpath, includepath=[os.path.join(conf.path.abspath(), 'api')], functions=['clGetDeviceInfo']) or pprint('YELLOW', '-OpenCL', sep=' ')
def configure(conf): conf.env.ALL_VARIANTS = ['debug', 'profile', 'final'] conf.platforms = [] platforms = Options.options.platforms platforms = platforms.split(',') if platforms else [] for target in conf.path.make_node('target').listdir(): if not platforms or target in platforms: conf.recurse('target/%s/configure.py'%target) for extra in conf.bugenginenode.make_node('extra').listdir(): if not platforms or extra in platforms: if os.path.isfile(os.path.join(conf.bugenginenode.abspath(), 'extra', extra, 'wscript')): conf.recurse(os.path.join(conf.bugenginenode.abspath(), 'extra', extra)) for p in conf.platforms: configuration_list = p.get_available_compilers(conf.compilers) if configuration_list: pprint('BLUE', ' + configuring for platform %s' % p.NAME) for main_toolchain, sub_toolchains, platform in configuration_list: platform.add_toolchain(conf, main_toolchain, sub_toolchains) conf.env.store('.waf_toolchains.py')
def test_write_log(ctx): file_out = "%s/test.log" % ctx.bldnode.abspath() log = lst = getattr(ctx, 'utest_results', []) if not log: return with open(file_out, "w") as fp: for binary, retval, lines, error in ctx.utest_results: fp.write("BINARY : %s\n" % binary) fp.write("RETURN VALUE: %s\n" % retval) fp.write("\n*** stdout ***\n") fp.write(str(lines)) fp.write("\n*** stderr ***\n") fp.write(str(error)) fp.write("\n\n\n") pprint("BLUE", "Wrote test log to: ", file_out)
def test_write_log(ctx): file_out = "%s/test.log" % ctx.bldnode.abspath() log = getattr(ctx, 'utest_results', []) if not log: return with open(file_out, "w") as fp: for binary, retval, lines, error in ctx.utest_results: fp.write("BINARY : %s\n" % binary) fp.write("RETURN VALUE: %s\n" % retval) fp.write("\n*** stdout ***\n") fp.write(polystr(lines)) fp.write("\n*** stderr ***\n") fp.write(polystr(error)) fp.write("\n\n\n") pprint("BLUE", "Wrote test log to: ", file_out)
def setup(conf): if 'darwin' in conf.env.VALID_PLATFORMS: include = 'OpenCL/cl.h' libpath=[os.path.join(conf.path.abspath(), 'lib.%s'%(conf.env.VALID_PLATFORMS[0]))] conf.check_lib('OpenCL', includes=[include], libpath=libpath, includepath=[os.path.join(conf.path.abspath(), 'api')], functions=['clGetDeviceInfo']) or pprint('YELLOW', '-OpenCL', sep=' ') elif conf.env.CC_NAME == 'icc': setup_shipped(conf) else: try: conf.pkg_config('OpenCL') except Exception as e: setup_shipped(conf) else: conf.env.SYSTEM_OPENCL = True pprint('GREEN', '+OpenCL', sep=' ')
def setup(conf): if 'darwin' in conf.env.VALID_PLATFORMS: conf.check_framework('OpenGL', includepath=[os.path.join(conf.path.abspath(), 'api')]) or pprint('YELLOW', '-GL', sep=' ') elif 'windows' in conf.env.VALID_PLATFORMS: conf.check_lib(['opengl32', 'gdi32'], includes=['windows.h', 'GL/gl.h'], includepath=[os.path.join(conf.path.abspath(), 'api')], functions=['glBegin']) or pprint('YELLOW', '-GL', sep=' ') else: try: conf.pkg_config('gl', var='OpenGL') conf.env.append_unique('check_OpenGL_includes', [os.path.join(conf.path.abspath(), 'api')]) except Exception as e: conf.check_lib('GL', var='OpenGL', includes=['GL/gl.h'], includepath=[os.path.join(conf.path.abspath(), 'api')], functions=['glBegin']) or pprint('YELLOW', '-GL', sep=' ') else: conf.env.SYSTEM_OPENGL = True pprint('GREEN', '+GL', sep=' ')
def setup(conf): for v in '-5.3', '5.3', '-5.2', '5.2', '-5.1', '5.1': try: conf.pkg_config('lua%s' % v, var='lua') except Exception as e: pass else: conf.env.SYSTEM_LUA = True pprint('GREEN', '+lua%s'%v, sep=' ') break else: conf.env.SYSTEM_LUA = conf.check_lib('lua', var='lua', libpath=[os.path.join(conf.path.abspath(), 'lib.%s.%s'%(conf.env.VALID_PLATFORMS[0], a)) for a in conf.env.VALID_ARCHITECTURES], includepath=[os.path.join(conf.path.abspath(), 'api')], includes_externc=['lua.h', 'lauxlib.h'], defines=['LUA_LIB'], functions=['luaL_newmetatable']) if not conf.env.SYSTEM_LUA: pprint('BLUE', '=lua', sep=' ')
def check_libevent2_run(ctx): if ctx.env.ENABLE_CROSS: if ctx.env.EVENT2_HEADER: # XXX Remove when variant builds exist ctx.define("HAVE_LIBEVENT2", 1, comment="libevent2 support") ctx.env.LIBEVENT2_ENABLE = True return ctx.check( fragment = LIBEVENT2_FRAG, define_name = "HAVE_LIBEVENT2", features = "c", use = "LIBEVENT, LIBEVENT_CORE, LIBEVENT_PTHREADS", msg = "Checking if libevent2 works", includes = ctx.env.PLATFORM_INCLUDES, export_includes = ctx.env.PLATFORM_INCLUDES, mandatory = False, comment = "libevent2 support" ) check_sanity(ctx, ctx.env.EVENT2_HEADER, "libevent2") if not ctx.get_define("HAVE_LIBEVENT2"): print("") pprint("RED", "Warning libevent2 does not work") pprint("RED", "This means ntpdig will not be built") pprint("RED", "While not necessary you will lose 'ntpdate' functionality.") print("") else: ctx.env.LIBEVENT2_ENABLE = True ctx.define("HAVE_LIBEVENT2", 1, comment="libevent2 support")
def run(cmd, reg): check = False if cmd[1] is None: cmd = [cmd[0]] print("running: ", " ".join(cmd), end="") if not exists("build/%s" % cmd[0]): pprint("YELLOW", " SKIPPING (does not exist)") return False p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=None, cwd="build") stdout, stderr = p.communicate() regex = re.compile(reg) if regex.match(stdout) or regex.match(stderr): check = True if check: pprint("GREEN", " OK") return False else: pprint("RED", " FAILED") return True
def setup(conf): if 'windows' in conf.env.VALID_PLATFORMS: from waflib import Options if Options.options.dx_sdk: includes=[os.path.join(Options.options.dx_sdk, 'Include')] libdirs = [] for arch in conf.env.VALID_ARCHITECTURES: p = os.path.join(Options.options.dx_sdk, 'Lib', arch) if os.path.isdir(p): libdirs.append(p) else: includes=[] libdirs=[] conf.check_lib('d3d9', var='dx9', libpath=libdirs, includepath=includes, includes=['d3d9.h'], functions=['Direct3DCreate9']) or pprint('YELLOW', '-dx9', sep=' ') conf.check_lib('d3d10', var='dx10', libpath=libdirs, includepath=includes, includes=['d3d10.h'], functions=['D3D10CreateDevice']) or pprint('YELLOW', '-dx10', sep=' ') conf.check_lib('d3d11', var='dx11', libpath=libdirs, includepath=includes, includes=['d3d11.h'], functions=['D3D11CreateDevice']) or pprint('YELLOW', '-dx11', sep=' ')
def test_print_log(ctx): for binary, retval, lines, error in ctx.utest_results: pprint("YELLOW", "BINARY :", binary) pprint("YELLOW", "RETURN VALUE:", retval) print("") if retval or error: pprint("RED", "****** ERROR ******\n") print(error or lines) if (not retval) and (not error): pprint("GREEN", "****** LOG ******\n", lines) print("")
def setup(conf): if not 'windows' in conf.env.VALID_PLATFORMS: try: conf.pkg_config('minizip') except Exception as e: pprint('BLUE', '=minizip', sep=' ') else: conf.env.SYSTEM_MINIZIP = True pprint('GREEN', '+minizip', sep=' ') else: pprint('BLUE', '=minizip', sep=' ')
def setup(conf): if 'windows' in conf.env.VALID_PLATFORMS: if not conf.check_lib(['psapi', 'dbghelp', 'version'], includepath=[os.path.join(conf.path.abspath(), 'api')], libpath=[os.path.join(conf.path.abspath(), 'lib.%s.%s'%(conf.env.VALID_PLATFORMS[0], a)) for a in conf.env.VALID_ARCHITECTURES], includes=['windows.h', 'dbghelp.h'], functions=['SymInitialize']): pprint('YELLOW', '-psapi', sep=' ') pprint('YELLOW', '-dbghelp', sep=' ') pprint('YELLOW', '-version', sep=' ')
def setup(conf): if 'posix' in conf.env.VALID_PLATFORMS: try: conf.pkg_config('zlib') except Exception as e: pprint('BLUE', '=zlib', sep=' ') else: conf.env.SYSTEM_ZLIB = True pprint('GREEN', '+zlib', sep=' ') else: pprint('BLUE', '=zlib', sep=' ')
def setup(conf): if 'darwin' in conf.env.VALID_PLATFORMS: conf.check_framework('OpenGLES') else: try: conf.pkg_config('glesv2', var='OpenGLES2') conf.pkg_config('egl', var='OpenGLES2') except Exception as e: if not conf.check_lib(['GLESv2', 'EGL'], var='OpenGLES2', libpath=[os.path.join(conf.path.abspath(), 'lib.%s.%s'%(conf.env.VALID_PLATFORMS[0], a)) for a in conf.env.VALID_ARCHITECTURES], includepath=[os.path.join(conf.path.abspath(), 'api')], includes=['GLES2/gl2.h', 'EGL/egl.h'], functions=['glGenFramebuffers', 'eglCreateContext']): pprint('YELLOW', '-GLESv2', sep=' ') pprint('YELLOW', '-EGL', sep=' ') else: conf.env.SYSTEM_OPENGLES2 = True pprint('GREEN', '+GLESv2', sep=' ') pprint('GREEN', '+EGL', sep=' ')
def check_seccomp(ctx): if not ctx.options.enable_seccomp: return if not sys.platform.startswith("linux"): return ctx.check_cc(header_name="seccomp.h", mandatory=False) ctx.check_cc(lib="seccomp", comment="seccomp library", mandatory=False) if ctx.get_define("HAVE_SECCOMP_H") and ctx.env.LIB_SECCOMP: ctx.define("HAVE_SECCOMP", 1) else: pprint("RED", "Warning libseccomp and headers") pprint("RED", "Fedora needs libseccomp-devel") pprint("RED", "Debian needs libseccomp-dev")
def check_seccomp(ctx): if not ctx.options.enable_seccomp: return if ctx.env.DEST_OS != "linux": return ctx.check_cc(header_name="seccomp.h", mandatory=False) ctx.check_cc(lib="seccomp", comment="seccomp library", mandatory=False) if ctx.get_define("HAVE_SECCOMP_H") and ctx.env.LIB_SECCOMP: ctx.define("HAVE_SECCOMP", 1) else: pprint("RED", "Warning libseccomp and headers") pprint("RED", "Fedora needs libseccomp-devel") pprint("RED", "Debian needs libseccomp-dev")
def check_cap(ctx): if ctx.options.disable_droproot: return if ctx.env.DEST_OS != "linux": return ctx.check_cc(header_name="sys/prctl.h", mandatory=False) ctx.check_cc(header_name="sys/capability.h", mandatory=False) ctx.check_cc(lib="cap", comment="Capability library", mandatory=False) if ((ctx.get_define("HAVE_SYS_CAPABILITY_H") and ctx.get_define("HAVE_SYS_PRCTL_H") and ctx.env.LIB_CAP)): ctx.define("HAVE_LINUX_CAPABILITY", 1) else: pprint("RED", "Warning libcap and headers not installed") pprint("RED", "Fedora needs libcap-devel") pprint("RED", "Debian needs libcap-dev")
def check_cap(ctx): if ctx.options.disable_droproot: return if not sys.platform.startswith("linux"): return ctx.check_cc(header_name="sys/prctl.h", mandatory=False) ctx.check_cc(header_name="sys/capability.h", mandatory=False) ctx.check_cc(lib="cap", comment="Capability library", mandatory=False) if ctx.get_define("HAVE_SYS_CAPABILITY_H") and \ ctx.get_define("HAVE_SYS_PRCTL_H") and ctx.env.LIB_CAP: ctx.define("HAVE_LINUX_CAPABILITY", 1) else: pprint("RED", "Warning libcap and headers not installed") pprint("RED", "Fedora needs libcap-devel") pprint("RED", "Debian needs libcap-dev")
def setup(conf): if conf.env.CXX_NAME != 'sun' and 'posix' in conf.env.VALID_PLATFORMS: try: conf.pkg_config('bullet') except Exception as e: pprint('BLUE', '=bullet', sep=' ') else: conf.env.SYSTEM_BULLET = True pprint('GREEN', '+bullet', sep=' ') else: conf.env.SYSTEM_BULLET = conf.check_lib('bullet', var='bullet', libpath=[os.path.join(conf.path.abspath(), 'lib.%s.%s'%(conf.env.VALID_PLATFORMS[0], a)) for a in conf.env.VALID_ARCHITECTURES], includepath=[os.path.join(conf.path.abspath(), 'src')], includes=['btBulletDynamicsCommon.h', 'LinearMath/btAlignedAllocator.h'], functions=['btAlignedAllocSetCustom']) if not conf.env.SYSTEM_BULLET: pprint('BLUE', '=bullet', sep=' ')
def setup(conf): if 'posix' in conf.env.VALID_PLATFORMS: try: conf.pkg_config('ogg', var='oggvorbis') conf.pkg_config('vorbis', var='oggvorbis') conf.pkg_config('vorbisenc', var='oggvorbis') conf.pkg_config('vorbisfile', var='oggvorbis') except Exception as e: pprint('BLUE', '=oggvorbis', sep=' ') else: conf.env.SYSTEM_OGGVORBIS = True pprint('GREEN', '+oggvorbis', sep=' ') else: conf.env.SYSTEM_OGGVORBIS = conf.check_lib('oggvorbis', var='oggvorbis', libpath=[os.path.join(conf.path.abspath(), 'lib.%s.%s'%(conf.env.VALID_PLATFORMS[0], a)) for a in conf.env.VALID_ARCHITECTURES], includepath=[os.path.join(conf.path.abspath(), 'api')], includes=['ogg/ogg.h'], functions=['oggpack_writeinit']) if not conf.env.SYSTEM_OGGVORBIS: pprint('BLUE', '=oggvorbis', sep=' ')
def refclock_config(ctx): if ctx.options.refclocks == "all": ids = refclock_map.keys() else: # XXX: better error checking ids = ctx.options.refclocks.split(",") ctx.env.REFCLOCK_SOURCE = [] # Remove duplicate IDs while preserving order. unique_id = [] [unique_id.append(x) for x in ids if x not in unique_id] refclock = False for id in unique_id: if id not in refclock_map: ctx.fatal("'%s' is not a valid Refclock ID" % id) rc = refclock_map[id] if rc['define'] == "CLOCK_GENERIC": parse_clocks = ( "CLOCK_COMPUTIME", "CLOCK_DCF7000", "CLOCK_HOPF6021", "CLOCK_MEINBERG", "CLOCK_RAWDCF", "CLOCK_RCC8000", "CLOCK_SCHMID", "CLOCK_SEL240X", "CLOCK_TRIMTAIP", "CLOCK_TRIMTSIP", "CLOCK_VARITEXT", "CLOCK_WHARTON_400A", ) for subtype in parse_clocks: ctx.define(subtype, 1, comment="Enable individual parse clock") ctx.start_msg("Enabling Refclock %s (%s):" % (rc["descr"], id)) if "require" in rc: if "ppsapi" in rc["require"]: if not ctx.get_define("HAVE_PPSAPI"): ctx.end_msg("No") pprint( "RED", "Refclock \"%s\" disabled, PPS API has not " "been detected as working." % rc["descr"]) continue ctx.env.REFCLOCK_SOURCE.append((rc["file"], rc["define"])) ctx.env["REFCLOCK_%s" % rc["file"].upper()] = True ctx.define(rc["define"], 1, comment="Enable '%s' refclock" % rc["descr"]) ctx.env.REFCLOCK_LIST += [str(id)] ctx.end_msg("Yes") refclock = True if refclock: ctx.env.REFCLOCK_ENABLE = True ctx.define("REFCLOCK", 1, comment="Enable refclock support")
def msg(str): pprint("YELLOW", str)
def msg_setting(name, val): pprint("NORMAL", " %-30s: " % name, sep="") pprint("YELLOW", val)