def getGeneralFlags(self, conf):
     flags = super(GccBasicFlags, self).getGeneralFlags(conf)
     flags['CXXFLAGS'] += ['-std=c++14']
     if Utils.unversioned_sys_platform() == 'linux':
         flags['LINKFLAGS'] += ['-fuse-ld=gold']
     elif Utils.unversioned_sys_platform() == 'freebsd':
         flags['LINKFLAGS'] += ['-fuse-ld=lld']
     return flags
 def getGeneralFlags(self, conf):
     flags = super(ClangFlags, self).getGeneralFlags(conf)
     if Utils.unversioned_sys_platform() == 'darwin' and self.getCompilerVersion(conf) >= (9, 0, 0):
         # Bug #4296
         flags['CXXFLAGS'] += [['-isystem', '/usr/local/include'], # for Homebrew
                               ['-isystem', '/opt/local/include']] # for MacPorts
     if Utils.unversioned_sys_platform() == 'freebsd':
         flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']] # Bug #4790
     return flags
    def get_test_env(self):
        """
        In general, tests may require any library built anywhere in the project.
        Override this method if fewer paths are needed
        """
        try:
            fu = getattr(self.generator.bld, 'all_test_paths')
        except AttributeError:
            # this operation may be performed by at most #maxjobs
            fu = os.environ.copy()

            lst = []
            for g in self.generator.bld.groups:
                for tg in g:
                    if getattr(tg, 'link_task', None):
                        s = tg.link_task.outputs[0].parent.abspath()
                        if s not in lst:
                            lst.append(s)

            if Utils.is_win32:
                self.add_path(fu, lst, 'PATH')
            elif Utils.unversioned_sys_platform() == 'darwin':
                self.add_path(fu, lst, 'DYLD_LIBRARY_PATH')
                self.add_path(fu, lst, 'LD_LIBRARY_PATH')
            else:
                self.add_path(fu, lst, 'LD_LIBRARY_PATH')
            self.generator.bld.all_test_paths = fu
        return fu
Beispiel #4
0
	def __init__(self, **kw):
		super(OptionsContext, self).__init__(**kw)

		self.parser = opt_parser(self)
		"""Instance of :py:class:`waflib.Options.opt_parser`"""

		self.option_groups = {}

		jobs = self.jobs()
		p = self.add_option
		color = os.environ.get('NOCOLOR', '') and 'no' or 'auto'
		if os.environ.get('CLICOLOR', '') == '0':
			color = 'no'
		elif os.environ.get('CLICOLOR_FORCE', '') == '1':
			color = 'yes'
		p('-c', '--color',    dest='colors',  default=color, action='store', help='whether to use colors (yes/no/auto) [default: auto]', choices=('yes', 'no', 'auto'))
		p('-j', '--jobs',     dest='jobs',    default=jobs,  type='int', help='amount of parallel jobs (%r)' % jobs)
		p('-k', '--keep',     dest='keep',    default=0,     action='count', help='continue despite errors (-kk to try harder)')
		p('-v', '--verbose',  dest='verbose', default=0,     action='count', help='verbosity level -v -vv or -vvv [default: 0]')
		p('--zones',          dest='zones',   default='',    action='store', help='debugging zones (task_gen, deps, tasks, etc)')
		p('--profile',        dest='profile', default='',    action='store_true', help=optparse.SUPPRESS_HELP)

		gr = self.add_option_group('Configuration options')
		self.option_groups['configure options'] = gr

		gr.add_option('-o', '--out', action='store', default='', help='build dir for the project', dest='out')
		gr.add_option('-t', '--top', action='store', default='', help='src dir for the project', dest='top')

		gr.add_option('--no-lock-in-run', action='store_true', default='', help=optparse.SUPPRESS_HELP, dest='no_lock_in_run')
		gr.add_option('--no-lock-in-out', action='store_true', default='', help=optparse.SUPPRESS_HELP, dest='no_lock_in_out')
		gr.add_option('--no-lock-in-top', action='store_true', default='', help=optparse.SUPPRESS_HELP, dest='no_lock_in_top')

		default_prefix = getattr(Context.g_module, 'default_prefix', os.environ.get('PREFIX'))
		if not default_prefix:
			if Utils.unversioned_sys_platform() == 'win32':
				d = tempfile.gettempdir()
				default_prefix = d[0].upper() + d[1:]
				# win32 preserves the case, but gettempdir does not
			else:
				default_prefix = '/usr/local/'
		gr.add_option('--prefix', dest='prefix', default=default_prefix, help='installation prefix [default: %r]' % default_prefix)
		gr.add_option('--bindir', dest='bindir', help='bindir')
		gr.add_option('--libdir', dest='libdir', help='libdir')

		gr = self.add_option_group('Build and installation options')
		self.option_groups['build and install options'] = gr
		gr.add_option('-p', '--progress', dest='progress_bar', default=0, action='count', help= '-p: progress bar; -pp: ide output')
		gr.add_option('--targets',        dest='targets', default='', action='store', help='task generators, e.g. "target1,target2"')

		gr = self.add_option_group('Step options')
		self.option_groups['step options'] = gr
		gr.add_option('--files',          dest='files', default='', action='store', help='files to process, by regexp, e.g. "*/main.c,*/test/main.o"')

		default_destdir = os.environ.get('DESTDIR', '')

		gr = self.add_option_group('Installation and uninstallation options')
		self.option_groups['install/uninstall options'] = gr
		gr.add_option('--destdir', help='installation root [default: %r]' % default_destdir, default=default_destdir, dest='destdir')
		gr.add_option('-f', '--force', dest='force', default=False, action='store_true', help='force file installation')
		gr.add_option('--distcheck-args', metavar='ARGS', help='arguments to pass to distcheck', default=None, action='store')
 def getGeneralFlags(self, conf):
     flags = super(ClangFlags, self).getGeneralFlags(conf)
     flags['CXXFLAGS'] += ['-std=c++11']
     if Utils.unversioned_sys_platform() == 'darwin':
         flags['CXXFLAGS'] += ['-stdlib=libc++']
         flags['LINKFLAGS'] += ['-stdlib=libc++']
     return flags
Beispiel #6
0
def configure(self):
	self.find_qt5_binaries()
	self.set_qt5_libs_to_check()
	self.set_qt5_defines()
	self.find_qt5_libraries()
	self.add_qt5_rpath()
	self.simplify_qt5_libs()
	if not has_xml:
		Logs.error('No xml.sax support was found, rcc dependencies will be incomplete!')
	frag='#include <QApplication>\nint main(int argc, char **argv) {return 0;}\n'
	uses='QT5CORE QT5WIDGETS QT5GUI'
	for flag in[[],'-fPIE','-fPIC','-std=c++11',['-std=c++11','-fPIE'],['-std=c++11','-fPIC']]:
		msg='See if Qt files compile '
		if flag:
			msg+='with %s'%flag
		try:
			self.check(features='qt5 cxx',use=uses,uselib_store='qt5',cxxflags=flag,fragment=frag,msg=msg)
		except self.errors.ConfigurationError:
			pass
		else:
			break
	else:
		self.fatal('Could not build a simple Qt application')
	from waflib import Utils
	if Utils.unversioned_sys_platform()=='freebsd':
		frag='#include <QApplication>\nint main(int argc, char **argv) { QApplication app(argc, argv); return NULL != (void*) (&app);}\n'
		try:
			self.check(features='qt5 cxx cxxprogram',use=uses,fragment=frag,msg='Can we link Qt programs on FreeBSD directly?')
		except self.errors.ConfigurationError:
			self.check(features='qt5 cxx cxxprogram',use=uses,uselib_store='qt5',libpath='/usr/local/lib',fragment=frag,msg='Is /usr/local/lib required?')
Beispiel #7
0
    def run(self):
        """Execute the test.

        The execution is always successful, but the results are stored on
        ``self.generator.bld.utest_results`` for postprocessing.
        """

        self.testdriver_node = self.inputs[0]
        try:
            fu = getattr(self.generator.bld, "all_test_paths")
        except AttributeError:
            # this operation may be performed by at most #maxjobs
            fu = os.environ.copy()

            lst = []
            for g in self.generator.bld.groups:
                for tg in g:
                    if getattr(tg, "link_task", None):
                        s = tg.link_task.outputs[0].parent.abspath()
                        if s not in lst:
                            lst.append(s)

            def add_path(dct, path, var):
                dct[var] = os.pathsep.join(Utils.to_list(path) + [os.environ.get(var, "")])

            if Utils.is_win32:
                add_path(fu, lst, "PATH")
            elif Utils.unversioned_sys_platform() == "darwin":
                add_path(fu, lst, "DYLD_LIBRARY_PATH")
                add_path(fu, lst, "LD_LIBRARY_PATH")
            else:
                add_path(fu, lst, "LD_LIBRARY_PATH")
            self.generator.bld.all_test_paths = fu

        cwd = self.testdriver_node.parent.abspath()
        testcmd = self.get_testcmd()

        start_time = time.time()
        proc = Utils.subprocess.Popen(
            testcmd, cwd=cwd, env=fu, stderr=Utils.subprocess.STDOUT, stdout=Utils.subprocess.PIPE
        )
        stdout = proc.communicate()[0]
        end_time = time.time()

        if not isinstance(stdout, str):
            stdout = stdout.decode(sys.stdout.encoding or "iso8859-1")

        tup = (self.testdriver_node, proc.returncode, stdout, end_time - start_time, self.generator.source[0])
        self.generator.utest_result = tup

        testlock.acquire()
        try:
            bld = self.generator.bld
            Logs.debug("ut: %r", tup)
            try:
                bld.utest_results.append(tup)
            except AttributeError:
                bld.utest_results = [tup]
        finally:
            testlock.release()
Beispiel #8
0
def cc_load_tools(conf):
	"""
	Load the c tool
	"""
	if not conf.env.DEST_OS:
		conf.env.DEST_OS = Utils.unversioned_sys_platform()
	conf.load('c')
Beispiel #9
0
def cxx_load_tools(conf):
	"""
	Loads the Waf c++ extensions
	"""
	if not conf.env.DEST_OS:
		conf.env.DEST_OS = Utils.unversioned_sys_platform()
	conf.load('cxx')
Beispiel #10
0
def _use_incredibuild(ctx, section_name, option_name, value, verification_fn):
	""" If Incredibuild should be used, check for required packages """
	
	if not ctx.is_option_true('ask_for_user_input'):
		(isValid, warning, error) = verification_fn(ctx, option_name, value)	
		if not isValid:
			return 'False'
		return value
		
	# GUI
	if not ctx.is_option_true('console_mode'):
		return ctx.gui_get_attribute(section_name, option_name, value)
		
	if not value or value != 'True':
		return value
	if not Utils.unversioned_sys_platform() == 'win32':
		return value	
		
	_incredibuild_disclaimer(ctx)	
	ctx.start_msg('Incredibuild Licence Check')
	(res, warning, error) = verification_fn(ctx, option_name, value)	
	if not res:
		if warning:
			Logs.warn(warning)
		if error:
			ctx.end_msg(error, color='YELLOW')			
		return 'False'

	ctx.end_msg('ok')
	return value
Beispiel #11
0
def _defaultValue( _VALUES ):
    PLATFORM = Utils.unversioned_sys_platform()

    if PLATFORM in _VALUES:
        return _VALUES[ PLATFORM ]

    return None
Beispiel #12
0
def configure_paths(ctx):
    """Setup blender paths"""
    # Get the username
    user = getuser()
    _platform = Utils.unversioned_sys_platform()
    config_path = {"user": "", "system": ""}
    if _platform.startswith("linux"):
        config_path["user"] = "******" % user
        config_path["system"] = "/usr/share/blender/"
    elif _platform == "darwin":
        # MAC OS X
        config_path["user"] = "******" % user
        config_path["system"] = "/Library/Application Support/Blender/"
    elif Utils.is_win32:
        # Windows
        appdata_path = ctx.getenv("APPDATA").replace("\\", "/")
        homedrive = ctx.getenv("HOMEDRIVE").replace("\\", "/")

        config_path["user"] = "******" % appdata_path
        config_path["system"] = "%sAll Users/AppData/Roaming/Blender Foundation/Blender/" % homedrive
    else:
        ctx.fatal("Unsupported platform. " "Available platforms: Linux, OSX, MS-Windows.")

    blender_version = ctx.env["BLENDER_VERSION"]

    config_path["user"] += blender_version + "/"
    config_path["system"] += blender_version + "/"

    ctx.env["BLENDER_CONFIG_DIR"] = os.path.abspath(config_path["user"])
    if ctx.options.directory_system:
        ctx.env["BLENDER_CONFIG_DIR"] = config_path["system"]

    ctx.env["BLENDER_ADDONS_DIR"] = os.path.join(ctx.env["BLENDER_CONFIG_DIR"], "scripts/addons")
    Utils.check_dir(ctx.env["BLENDER_ADDONS_DIR"])
 def getGeneralFlags(self, conf):
     flags = super(ClangFlags, self).getGeneralFlags(conf)
     flags["CXXFLAGS"] += ["-std=c++11"]
     if Utils.unversioned_sys_platform() == "darwin":
         flags["CXXFLAGS"] += ["-stdlib=libc++"]
         flags["LINKFLAGS"] += ["-stdlib=libc++"]
     return flags
Beispiel #14
0
def _defaultValue( _values ):
    PLATFORM = Utils.unversioned_sys_platform()

    if PLATFORM in _values:
        return _values[ PLATFORM ]

    return None
Beispiel #15
0
def set_qt5_libs_to_check(self):
	self.qt5_vars = Utils.to_list(getattr(self, 'qt5_vars', []))
	if not self.qt5_vars:
		dirlst = Utils.listdir(self.env.QTLIBS)

		pat = self.env.cxxshlib_PATTERN
		if Utils.is_win32:
			pat = pat.replace('.dll', '.lib')
		if self.environ.get('QT5_FORCE_STATIC'):
			pat = self.env.cxxstlib_PATTERN
		if Utils.unversioned_sys_platform() == 'darwin':
			pat = "%s\.framework"
		re_qt = re.compile(pat%'Qt5?(?P<name>.*)'+'$')
		for x in dirlst:
			m = re_qt.match(x)
			if m:
				self.qt5_vars.append("Qt5%s" % m.group('name'))
		if not self.qt5_vars:
			self.fatal('cannot find any Qt5 library (%r)' % self.env.QTLIBS)

	qtextralibs = getattr(Options.options, 'qtextralibs', None)
	if qtextralibs:
		self.qt5_vars.extend(qtextralibs.split(','))

	if not hasattr(self, 'qt5_vars_debug'):
		self.qt5_vars_debug = [a + '_DEBUG' for a in self.qt5_vars]
	self.qt5_vars_debug = Utils.to_list(self.qt5_vars_debug)
Beispiel #16
0
    def configure_env(self, cfg, env):
        super(sitl, self).configure_env(cfg, env)

        env.DEFINES.update(
            CONFIG_HAL_BOARD = 'HAL_BOARD_SITL',
            CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_NONE',
            AP_SCRIPTING_CHECKS = 1, # SITL should always do runtime scripting checks
        )

        env.CXXFLAGS += [
            '-Werror=float-equal'
        ]

        if not cfg.env.DEBUG:
            env.CXXFLAGS += [
                '-O3',
            ]

        env.LIB += [
            'm',
        ]

        cfg.check_librt(env)

        env.LINKFLAGS += ['-pthread',]
        env.AP_LIBRARIES += [
            'AP_HAL_SITL',
            'SITL',
        ]

        if cfg.options.enable_sfml:
            if not cfg.check_SFML(env):
                cfg.fatal("Failed to find SFML libraries")
            env.CXXFLAGS += ['-DWITH_SITL_OSD','-DOSD_ENABLED=ENABLED','-DHAL_HAVE_AP_ROMFS_EMBEDDED_H']
            import fnmatch
            for f in os.listdir('libraries/AP_OSD/fonts'):
                if fnmatch.fnmatch(f, "font*bin"):
                    env.ROMFS_FILES += [(f,'libraries/AP_OSD/fonts/'+f)]

        if cfg.options.enable_sfml_audio:
            if not cfg.check_SFML_Audio(env):
                cfg.fatal("Failed to find SFML Audio libraries")
            env.CXXFLAGS += ['-DWITH_SITL_TONEALARM']

        if cfg.options.sitl_flash_storage:
            env.CXXFLAGS += ['-DSTORAGE_USE_FLASH=1']

        if cfg.env.DEST_OS == 'cygwin':
            env.LIB += [
                'winmm',
            ]

        if Utils.unversioned_sys_platform() == 'cygwin':
            env.CXXFLAGS += ['-DCYGWIN_BUILD']

        if 'clang++' in cfg.env.COMPILER_CXX:
            print("Disabling SLP for clang++")
            env.CXXFLAGS += [
                '-fno-slp-vectorize' # compiler bug when trying to use SLP
            ]
    def init_dirs(self):
        # Waf calls this function to set the output directory.
        # Waf sets the output dir in the following order
        # 1) Check whether the -o option has been specified
        # 2) Check whether the wscript has an out variable defined
        # 3) Fall-back and use the name of the lock-file
        #
        # In order to not surprise anybody we will disallow the out variable
        # but allow our output dir to be overwritten by using the -o option

        assert(getattr(Context.g_module, Context.OUT, None) is None)

        if not Options.options.out:

            if self.has_tool_option('cxx_mkspec'):
                mkspec = self.get_tool_option('cxx_mkspec')
                self.out_dir = os.path.join("build", mkspec)
            else:
                build_platform = Utils.unversioned_sys_platform()
                self.out_dir = os.path.join("build", build_platform)

            # Use the _debug postfix for debug builds
            if self.has_tool_option('cxx_debug'):
                self.out_dir += '_debug'

        super(ToolchainConfigurationContext, self).init_dirs()
Beispiel #18
0
def find_qt5_libraries(self):
	env = self.env

	qtincludes =  self.environ.get('QT5_INCLUDES') or self.cmd_and_log(env.QMAKE + ['-query', 'QT_INSTALL_HEADERS']).strip()
	force_static = self.environ.get('QT5_FORCE_STATIC')
	try:
		if self.environ.get('QT5_XCOMPILE'):
			self.fatal('QT5_XCOMPILE Disables pkg-config detection')
		self.check_cfg(atleast_pkgconfig_version='0.1')
	except self.errors.ConfigurationError:
		for i in self.qt5_vars:
			uselib = i.upper()
			if Utils.unversioned_sys_platform() == 'darwin':
				# Since at least qt 4.7.3 each library locates in separate directory
				fwk = i.replace('Qt5', 'Qt')
				frameworkName = fwk + '.framework'

				qtDynamicLib = os.path.join(env.QTLIBS, frameworkName, fwk)
				if os.path.exists(qtDynamicLib):
					env.append_unique('FRAMEWORK_' + uselib, fwk)
					env.append_unique('FRAMEWORKPATH_' + uselib, env.QTLIBS)
					self.msg('Checking for %s' % i, qtDynamicLib, 'GREEN')
				else:
					self.msg('Checking for %s' % i, False, 'YELLOW')
				env.append_unique('INCLUDES_' + uselib, os.path.join(env.QTLIBS, frameworkName, 'Headers'))
			else:
				ret = self.find_single_qt5_lib(i, uselib, env.QTLIBS, qtincludes, force_static)
				if not force_static and not ret:
					ret = self.find_single_qt5_lib(i, uselib, env.QTLIBS, qtincludes, True)
				self.msg('Checking for %s' % i, ret, 'GREEN' if ret else 'YELLOW')
	else:
		path = '%s:%s:%s/pkgconfig:/usr/lib/qt5/lib/pkgconfig:/opt/qt5/lib/pkgconfig:/usr/lib/qt5/lib:/opt/qt5/lib' % (
			self.environ.get('PKG_CONFIG_PATH', ''), env.QTLIBS, env.QTLIBS)
		for i in self.qt5_vars:
			self.check_cfg(package=i, args='--cflags --libs', mandatory=False, force_static=force_static, pkg_config_path=path)
Beispiel #19
0
def configure(ctx):
    ctx.load('bdeunittest', tooldir = os.path.join('tools', 'waf', 'bde'))

    ufid = _make_ufid_from_options(ctx.options)

    platform = Utils.unversioned_sys_platform()
    if platform == 'win32':
        if '64' in ufid.ufid:
            ctx.options.msvc_targets = 'x64'
        else:
            ctx.options.msvc_targets = 'x86'


    bde_configure = BdeWafConfigure(ctx)
    bde_configure.load_metadata()
    bde_configure.configure_external_libs(ufid)

    ctx.load('compiler_cxx')
    uplid = _make_uplid_from_context(ctx)

    ctx.msg('os_type', uplid.uplid['os_type'])
    ctx.msg('os_name', uplid.uplid['os_name'])
    ctx.msg('cpu_type', uplid.uplid['cpu_type'])
    ctx.msg('os_ver', uplid.uplid['os_ver'])
    ctx.msg('comp_type', uplid.uplid['comp_type'])
    ctx.msg('comp_ver', uplid.uplid['comp_ver'])
    ctx.msg('uplid', uplid)
    ctx.msg('ufid', '_'.join(ufid.ufid))
    ctx.msg('prefix', ctx.options.prefix)

    bde_configure.configure_options(uplid)
    bde_configure.save()
Beispiel #20
0
def _make_uplid_from_context(ctx):
    platform = Utils.unversioned_sys_platform()

    from bdeoptions import get_linux_osinfo, get_aix_osinfo, get_sunos_osinfo, get_darwin_osinfo, get_windows_osinfo
    osinfo_getters = {
        'linux': get_linux_osinfo,
        'aix': get_aix_osinfo,
        'sunos': get_sunos_osinfo,
        'darwin': get_darwin_osinfo,
        'win32': get_windows_osinfo
        }

    comp_getters = {
        'linux': _get_linux_comp,
        'aix': _get_aix_comp,
        'sunos': _get_sunos_comp,
        'win32': _get_windows_comp,
        'darwin': _get_darwin_comp
        }

    if platform not in osinfo_getters:
        ctx.fatal('Unsupported platform: %s' % platform)

    (os_type, os_name, os_ver) = osinfo_getters[platform](ctx)
    (cpu_type, cxx, cxx_version) = _sanitize_comp(ctx, comp_getters[platform](ctx))

    uplid = Uplid(os_type,
                  os_name,
                  cpu_type,
                  os_ver,
                  cxx,
                  cxx_version)
    return uplid
def _check_pthread_flag(self, *k, **kw):
	'''
	Computes which flags should be added to CXXFLAGS and LINKFLAGS to compile in multi-threading mode

	Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
	boost/thread.hpp will trigger a #error if -pthread isn't used:
	  boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
	  is not turned on. Please set the correct command line options for
	  threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"

	Based on _BOOST_PTHREAD_FLAG(): https://github.com/tsuna/boost.m4/blob/master/build-aux/boost.m4
    '''

	var = kw.get('uselib_store', 'BOOST')

	self.start_msg('Checking the flags needed to use pthreads')

	# The ordering *is* (sometimes) important.  Some notes on the
	# individual items follow:
	# (none): in case threads are in libc; should be tried before -Kthread and
	#       other compiler flags to prevent continual compiler warnings
	# -lpthreads: AIX (must check this before -lpthread)
	# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
	# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
	# -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
	# -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
	# -pthreads: Solaris/GCC
	# -mthreads: MinGW32/GCC, Lynx/GCC
	# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
	#      doesn't hurt to check since this sometimes defines pthreads too;
	#      also defines -D_REENTRANT)
	#      ... -mt is also the pthreads flag for HP/aCC
	# -lpthread: GNU Linux, etc.
	# --thread-safe: KAI C++
	if Utils.unversioned_sys_platform() == "sunos":
		# On Solaris (at least, for some versions), libc contains stubbed
		# (non-functional) versions of the pthreads routines, so link-based
		# tests will erroneously succeed.  (We need to link with -pthreads/-mt/
		# -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
		# a function called by this macro, so we could check for that, but
		# who knows whether they'll stub that too in a future libc.)  So,
		# we'll just look for -pthreads and -lpthread first:
		boost_pthread_flags = ["-pthreads", "-lpthread", "-mt", "-pthread"]
	else:
		boost_pthread_flags = ["", "-lpthreads", "-Kthread", "-kthread", "-llthread", "-pthread",
							   "-pthreads", "-mthreads", "-lpthread", "--thread-safe", "-mt"]

	for boost_pthread_flag in boost_pthread_flags:
		try:
			self.env.stash()
			self.env['CXXFLAGS_%s' % var] += [boost_pthread_flag]
			self.env['LINKFLAGS_%s' % var] += [boost_pthread_flag]
			self.check_cxx(code=PTHREAD_CODE, msg=None, use=var, execute=False)

			self.end_msg(boost_pthread_flag)
			return
		except self.errors.ConfigurationError:
			self.env.revert()
	self.end_msg('None')
Beispiel #22
0
	def skip_unbuildable_variant(self):
		# skip variants that cannot be built on this OS
		for k in Options.commands:
			a, _, b = k.partition('_')
			if b in Context.g_module.variants:
				c, _, _ = b.partition('_')
				if c != Utils.unversioned_sys_platform():
					Options.commands.remove(k)
Beispiel #23
0
Datei: gxx.py Projekt: zsx/waf
def gxx_modifier_platform(conf):
	# * set configurations specific for a platform.
	# * the destination platform is detected automatically by looking at the macros the compiler predefines,
	#   and if it's not recognised, it fallbacks to sys.platform.
	dest_os = conf.env['DEST_OS'] or Utils.unversioned_sys_platform()
	gxx_modifier_func = globals().get('gxx_modifier_' + dest_os)
	if gxx_modifier_func:
			gxx_modifier_func(conf)
Beispiel #24
0
def options(opt):
    global mpi_c_compiler
    build_platform=Utils.unversioned_sys_platform()
    test_for_compiler=' '.join(mpi_c_compilers)
    mpicc_compiler_opts=opt.add_option_group("MPI C Compiler Options")
    mpicc_compiler_opts.add_option('--check-mpi-c-compiler',default="%s"%test_for_compiler,help='On this platform (%s) the following MPI C-Compiler will be checked by default: "%s"'%(build_platform,test_for_compiler),dest="check_mpi_c_compiler")
    for x in test_for_compiler.split():
        opt.load('%s'%x, tooldir='waf-tools')
Beispiel #25
0
def configure(conf):
	'''Create and configure C/C++ build environment(s).
	
	:param conf: configuration context 
	:type conf: waflib.Configure.ConfigurationContext
	'''
	conf.check_waf_version(mini='1.7.6', maxi='1.9.0')
	conf.env.PREFIX = str(conf.env.PREFIX).replace('\\', '/')
	conf.env.CCENVINI = getattr(conf.options, CCENV_OPT)
	conf.env.CCENV = get_ccenv(conf.env.CCENVINI)
	conf.env.HOST = Utils.unversioned_sys_platform()
	c = c_compiler.copy()
	cxx = cxx_compiler.copy()
	host = Utils.unversioned_sys_platform()
	if host not in c_compiler:
		host = 'default'
	configure_variants(conf, host)
	configure_host(conf, host, c, cxx)
 def getOptimizedFlags(self, conf):
     flags = super(ClangFlags, self).getOptimizedFlags(conf)
     version = tuple(int(i) for i in conf.env['CC_VERSION'])
     if Utils.unversioned_sys_platform() == 'darwin' and version < (7, 0, 0):
         flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
     flags['CXXFLAGS'] += ['-fcolor-diagnostics',
                           '-Wno-unused-local-typedef', # Bugs #2657 and #3209
                           ]
     return flags
Beispiel #27
0
def set_macosx_deployment_target(self):
    """
    see WAF issue 285 and also and also http://trac.macports.org/ticket/17059
    """
    if self.env['MACOSX_DEPLOYMENT_TARGET']:
        os.environ['MACOSX_DEPLOYMENT_TARGET'] = self.env['MACOSX_DEPLOYMENT_TARGET']
    elif 'MACOSX_DEPLOYMENT_TARGET' not in os.environ:
        if Utils.unversioned_sys_platform() == 'darwin':
            os.environ['MACOSX_DEPLOYMENT_TARGET'] = '.'.join(platform.mac_ver()[0].split('.')[:2])
Beispiel #28
0
def options(opt):
	build_platform=Utils.unversioned_sys_platform()
	detected_platform=Options.platform
	possible_compiler_list=__list_possible_compiler(detected_platform)
	test_for_compiler=' '.join(possible_compiler_list)
	fortran_compiler_opts=opt.add_option_group("Fortran Compiler Options")
	fortran_compiler_opts.add_option('--check-fortran-compiler',default="%s"%test_for_compiler,help='On this platform (%s) the following Fortran Compiler will be checked by default: "%s"'%(detected_platform,test_for_compiler),dest="check_fc")
	for compiler in test_for_compiler.split():
		opt.load('%s'%compiler)
Beispiel #29
0
def set_macosx_deployment_target(self):
    """
	see WAF issue 285 and also and also http://trac.macports.org/ticket/17059
	"""
    if self.env["MACOSX_DEPLOYMENT_TARGET"]:
        os.environ["MACOSX_DEPLOYMENT_TARGET"] = self.env["MACOSX_DEPLOYMENT_TARGET"]
    elif "MACOSX_DEPLOYMENT_TARGET" not in os.environ:
        if Utils.unversioned_sys_platform() == "darwin":
            os.environ["MACOSX_DEPLOYMENT_TARGET"] = ".".join(platform.mac_ver()[0].split(".")[:2])
Beispiel #30
0
def options(opt):
	global cxx_compiler
	build_platform=Utils.unversioned_sys_platform()
	possible_compiler_list=cxx_compiler[build_platform in cxx_compiler and build_platform or'default']
	test_for_compiler=' '.join(possible_compiler_list)
	cxx_compiler_opts=opt.add_option_group('C++ Compiler Options')
	cxx_compiler_opts.add_option('--check-cxx-compiler',default="%s"%test_for_compiler,help='On this platform (%s) the following C++ Compiler will be checked by default: "%s"'%(build_platform,test_for_compiler),dest="check_cxx_compiler")
	for x in test_for_compiler.split():
		opt.load('%s'%x)
Beispiel #31
0
    def run(self):
        """
        Execute the test. The execution is always successful, but the results
        are stored on ``self.generator.bld.utest_results`` for postprocessing.
        """

        filename = self.inputs[0].abspath()
        self.ut_exec = getattr(self.generator, 'ut_exec', [filename])
        if getattr(self.generator, 'ut_fun', None):
            # FIXME waf 1.8 - add a return statement here?
            self.generator.ut_fun(self)

        try:
            fu = getattr(self.generator.bld, 'all_test_paths')
        except AttributeError:
            # this operation may be performed by at most #maxjobs
            fu = os.environ.copy()

            lst = []
            for g in self.generator.bld.groups:
                for tg in g:
                    if getattr(tg, 'link_task', None):
                        s = tg.link_task.outputs[0].parent.abspath()
                        if s not in lst:
                            lst.append(s)

            def add_path(dct, path, var):
                dct[var] = os.pathsep.join(
                    Utils.to_list(path) + [os.environ.get(var, '')])

            if Utils.is_win32:
                add_path(fu, lst, 'PATH')
            elif Utils.unversioned_sys_platform() == 'darwin':
                add_path(fu, lst, 'DYLD_LIBRARY_PATH')
                add_path(fu, lst, 'LD_LIBRARY_PATH')
            else:
                add_path(fu, lst, 'LD_LIBRARY_PATH')
            self.generator.bld.all_test_paths = fu

        cwd = (getattr(self.generator, 'ut_cwd', '')
               or self.inputs[0].parent.abspath())

        testcmd = getattr(Options.options, 'testcmd', False)
        if testcmd:
            ut_exec = self.ut_exec[0]
            self.ut_exec = (testcmd % ut_exec).split(' ')
            if Options.options.test_junit:
                self.ut_exec += ('--junit=%s-junit.xml' % ut_exec).split(' ')

        proc = Utils.subprocess.Popen(self.ut_exec,
                                      cwd=cwd,
                                      env=fu,
                                      stderr=Utils.subprocess.STDOUT,
                                      stdout=Utils.subprocess.PIPE)
        stdout = proc.communicate()[0]
        if stdout:
            stdout = stdout.decode(sys.stdout.encoding or 'iso8859-1')

        tup = (filename, proc.returncode, stdout)
        self.generator.utest_result = tup

        testlock.acquire()
        try:
            bld = self.generator.bld
            Logs.debug("ut: %r", tup)
            try:
                bld.utest_results.append(tup)
            except AttributeError:
                bld.utest_results = [tup]
        finally:
            testlock.release()
Beispiel #32
0
                last_build_engine_version_node.write(ctx.engine_root_version)

@conf
def is_engine_local(conf):
    """
    Determine if we are within an engine path
    :param conf: The configuration context
    :return: True if we are running from the engine folder, False if not
    """
    current_dir = os.path.normcase(os.path.abspath(os.path.curdir))
    engine_dir = os.path.normcase(os.path.abspath(conf.engine_path))
    return current_dir == engine_dir


# Create Build Context Commands for multiple platforms/configurations
for platform in PLATFORMS[Utils.unversioned_sys_platform()]:
    for configuration in CONFIGURATIONS:
        platform_config_key = platform + '_' + configuration
        # for platform/for configuration generates invalid configurations
        # if a filter exists, don't generate all combinations
        if platform in PLATFORM_CONFIGURATION_FILTER:
            if configuration not in PLATFORM_CONFIGURATION_FILTER[platform]:
                # Dont add the command but track it to report that this platform + configuration is explicitly not supported (yet)
                UNSUPPORTED_PLATFORM_CONFIGURATIONS.add(platform_config_key)
                continue
        # Create new class to execute clean with variant
        name = CleanContext.__name__.replace('Context','').lower()
        class tmp_clean(CleanContext):
            cmd = name + '_' + platform_config_key
            variant = platform_config_key
Beispiel #33
0
def set_bundle(self):
    """Mac-specific pyext extension that enables bundles from c_osx.py"""
    if Utils.unversioned_sys_platform() == 'darwin':
        self.mac_bundle = True
Beispiel #34
0
def configure(self):
    """
	Besides the configuration options, the environment variable QT5_ROOT may be used
	to give the location of the qt5 libraries (absolute path).

	The detection uses the program ``pkg-config`` through :py:func:`waflib.Tools.config_c.check_cfg`
	"""
    self.find_qt5_binaries()
    self.set_qt5_libs_dir()
    self.set_qt5_libs_to_check()
    self.set_qt5_defines()
    self.find_qt5_libraries()
    self.add_qt5_rpath()
    self.simplify_qt5_libs()

    # warn about this during the configuration too
    if not has_xml:
        Logs.error(
            'No xml.sax support was found, rcc dependencies will be incomplete!'
        )

    if 'COMPILER_CXX' not in self.env:
        self.fatal(
            'No CXX compiler defined: did you forget to configure compiler_cxx first?'
        )

    # Qt5 may be compiled with '-reduce-relocations' which requires dependent programs to have -fPIE or -fPIC?
    frag = '#include <QApplication>\nint main(int argc, char **argv) {return 0;}\n'
    uses = 'QT5CORE QT5WIDGETS QT5GUI'
    for flag in [[], '-fPIE', '-fPIC', '-std=c++11', ['-std=c++11', '-fPIE'],
                 ['-std=c++11', '-fPIC']]:
        msg = 'See if Qt files compile '
        if flag:
            msg += 'with %s' % flag
        try:
            self.check(features='qt5 cxx',
                       use=uses,
                       uselib_store='qt5',
                       cxxflags=flag,
                       fragment=frag,
                       msg=msg)
        except self.errors.ConfigurationError:
            pass
        else:
            break
    else:
        self.fatal('Could not build a simple Qt application')

    # FreeBSD does not add /usr/local/lib and the pkg-config files do not provide it either :-/
    if Utils.unversioned_sys_platform() == 'freebsd':
        frag = '#include <QApplication>\nint main(int argc, char **argv) { QApplication app(argc, argv); return NULL != (void*) (&app);}\n'
        try:
            self.check(features='qt5 cxx cxxprogram',
                       use=uses,
                       fragment=frag,
                       msg='Can we link Qt programs on FreeBSD directly?')
        except self.errors.ConfigurationError:
            self.check(features='qt5 cxx cxxprogram',
                       use=uses,
                       uselib_store='qt5',
                       libpath='/usr/local/lib',
                       fragment=frag,
                       msg='Is /usr/local/lib required?')
Beispiel #35
0
def cxx_load_tools(conf):
	if not conf.env.DEST_OS:
		conf.env.DEST_OS=Utils.unversioned_sys_platform()
	conf.load('cxx')
Beispiel #36
0
def openf95_modifier_platform(conf):
    dest_os = conf.env["DEST_OS"] or Utils.unversioned_sys_platform()
    openf95_modifier_func = getattr(conf, "openf95_modifier_" + dest_os, None)
    if openf95_modifier_func:
        openf95_modifier_func()
Beispiel #37
0
    def configure_env(self, cfg, env):
        super(sitl, self).configure_env(cfg, env)

        env.DEFINES.update(
            CONFIG_HAL_BOARD='HAL_BOARD_SITL',
            CONFIG_HAL_BOARD_SUBTYPE='HAL_BOARD_SUBTYPE_NONE',
            AP_SCRIPTING_CHECKS=
            1,  # SITL should always do runtime scripting checks
        )

        env.CXXFLAGS += ['-Werror=float-equal']

        if not cfg.env.DEBUG:
            env.CXXFLAGS += [
                '-O3',
            ]

        env.LIB += ['m', 'hinj']

        env.LIBPATH += ['/usr/local/lib/']

        cfg.check_librt(env)

        env.LINKFLAGS += ['-pthread']
        env.AP_LIBRARIES += [
            'AP_HAL_SITL',
            'SITL',
        ]

        if cfg.options.enable_sfml:
            if not cfg.check_SFML(env):
                cfg.fatal("Failed to find SFML libraries")

        if cfg.options.sitl_osd:
            env.CXXFLAGS += [
                '-DWITH_SITL_OSD', '-DOSD_ENABLED=ENABLED',
                '-DHAL_HAVE_AP_ROMFS_EMBEDDED_H'
            ]
            import fnmatch
            for f in os.listdir('libraries/AP_OSD/fonts'):
                if fnmatch.fnmatch(f, "font*bin"):
                    env.ROMFS_FILES += [(f, 'libraries/AP_OSD/fonts/' + f)]

        if cfg.options.sitl_rgbled:
            env.CXXFLAGS += ['-DWITH_SITL_RGBLED']

        if cfg.options.enable_sfml_audio:
            if not cfg.check_SFML_Audio(env):
                cfg.fatal("Failed to find SFML Audio libraries")
            env.CXXFLAGS += ['-DWITH_SITL_TONEALARM']

        if cfg.options.sitl_flash_storage:
            env.CXXFLAGS += ['-DSTORAGE_USE_FLASH=1']

        if cfg.env.DEST_OS == 'cygwin':
            env.LIB += [
                'winmm',
            ]

        if Utils.unversioned_sys_platform() == 'cygwin':
            env.CXXFLAGS += ['-DCYGWIN_BUILD']

        if 'clang++' in cfg.env.COMPILER_CXX:
            print("Disabling SLP for clang++")
            env.CXXFLAGS += [
                '-fno-slp-vectorize'  # compiler bug when trying to use SLP
            ]
Beispiel #38
0
def _get_project_overrides(ctx, target):

    if ctx.cmd == 'generate_uber_files' or ctx.cmd == 'msvs' or ctx.cmd == 'configure':
        return ({}, {})

    # Only perform on VS executed builds
    if not getattr(ctx.options, 'execsolution', None):
        return ({}, {})

    if Utils.unversioned_sys_platform() != 'win32':
        return ({}, {})

    if not hasattr(ctx, 'project_options_overrides'):
        ctx.project_options_overrides = {}

    if not hasattr(ctx, 'project_file_options_overrides'):
        ctx.project_file_options_overrides = {}

    try:
        return (ctx.project_options_overrides[target],
                ctx.project_file_options_overrides[target])
    except:
        pass

    # Check if project is valid for current spec, config and platform
    waf_spec = ctx.options.project_spec
    waf_platform = ctx.env['PLATFORM']
    waf_configuration = ctx.env['CONFIGURATION']

    if not ctx.is_valid_build_target(target, waf_spec, waf_configuration,
                                     waf_platform):
        return ({}, {})

    ctx.project_options_overrides[target] = {}
    ctx.project_file_options_overrides[target] = {}

    project_options_overrides = ctx.project_options_overrides[target]
    project_file_options_overrides = ctx.project_file_options_overrides[target]

    vs_spec = ctx.convert_waf_spec_to_vs_spec(waf_spec)
    vs_platform = ctx.convert_waf_platform_to_vs_platform(waf_platform)
    vs_configuration = ctx.convert_waf_configuration_to_vs_configuration(
        waf_configuration)
    vs_valid_spec_for_build = '[%s] %s|%s' % (vs_spec, vs_configuration,
                                              vs_platform)

    vcxproj_file = (ctx.get_project_output_folder().make_node(
        '%s%s' % (target, '.vcxproj'))).abspath()

    # Example: <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='[Hunt] Profile|Win64'">
    project_override = '<ItemDefinitionGroup Condition="\'$(Configuration)|$(Platform)\'==\'%s\'"' % vs_valid_spec_for_build

    # Open file
    try:
        file = open(vcxproj_file)
    except Exception as e:
        Logs.warn(
            'warning: Unable to parse .vcxproj file to extract configuration overrides. [File:%s] [Exception:%s, %s]'
            % (vcxproj_file, sys.exc_info()[0], e))
        return ({}, {})

    # Iterate line by line
    #(Note: skipping lines inside loop)
    file_iter = iter(file)
    for line in file_iter:
        stripped_line = line.lstrip()

        #[Per Project]
        # Example:
        # <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='[Hunt] Profile|x64'">
        #	<ClCompile>
        #		<WAF_DisableCompilerOptimization>true</WAF_DisableCompilerOptimization>
        #		<WAF_AdditionalPreprocessorDefinitions>/MyProjectDefinition</WAF_AdditionalPreprocessorDefinitions>
        #	</ClCompile>
        #</ItemDefinitionGroup>
        if stripped_line.startswith(project_override) == True:

            # Extract WAF items
            while True:
                next_line = file_iter.next().strip()
                if next_line.startswith('<WAF_'):
                    element_name = get_element_name(next_line)
                    element_value = get_element_value(next_line)

                    # Cache override
                    _set_override(project_options_overrides, element_name,
                                  element_value, ctx.env, ctx.path)

                elif next_line.startswith('</ItemDefinitionGroup>'):
                    break

        #[Per Item]
        # Example:
        # <ItemGroup>
        #		<ClCompile Include="e:\P4\CE_STREAMS\Code\CryEngine\CryAnimation\Attachment.cpp">
        #			<WAF_AdditionalPreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='[Hunt] Profile|x64'">/MyItemDefinition</WAF_AdditionalPreprocessorDefinitions>
        #			<WAF_AdditionalCompilerOptions_CXX Condition="'$(Configuration)|$(Platform)'=='[Hunt] Profile|x64'">/MyItemCompilerOption</WAF_AdditionalCompilerOptions_CXX>
        #		</ClCompile>
        # </ItemGroup>
        elif stripped_line.startswith('<ItemGroup>') == True:
            while True:
                next_line = file_iter.next().strip()

                # Check that element is a "ClCompile" element that has child elements i.e. not <ClCompile ... />
                if next_line.endswith('/>') == False and next_line.startswith(
                        '<ClCompile') == True:
                    item_tasks = []
                    # Is WAF Element
                    while True:
                        next_line_child = file_iter.next().strip()
                        if next_line_child.startswith('<WAF_'):
                            # Condition meets platform specs (optimize if needed)
                            if vs_valid_spec_for_build in next_line_child:

                                # For first valid item, collect tasks
                                if not item_tasks:
                                    # Get include path
                                    pos_include_name_start = next_line.find(
                                        '"') + 1
                                    pos_include_name_end = next_line.find(
                                        '"', pos_include_name_start)
                                    vs_file_path = next_line[
                                        pos_include_name_start:
                                        pos_include_name_end].lower()

                                # Get element info
                                element_name = get_element_name(
                                    next_line_child)
                                element_value = get_element_value(
                                    next_line_child)

                                # Cache override
                                try:
                                    override_map = project_file_options_overrides[
                                        vs_file_path]
                                except:
                                    project_file_options_overrides[
                                        vs_file_path] = {}
                                    override_map = project_file_options_overrides[
                                        vs_file_path]

                                    _set_override(override_map, element_name,
                                                  element_value, ctx.env,
                                                  ctx.path)

                        #end of ClCompile Element
                        elif next_line_child.startswith('</ClCompile>'):
                            break
                # end of "ItemGroup" Element
                elif next_line.startswith('</ItemGroup>'):
                    break

    return (project_options_overrides, project_file_options_overrides)
Beispiel #39
0
def find_qt4_libraries(self):
    qtlibs = getattr(Options.options, 'qtlibs',
                     None) or os.environ.get("QT4_LIBDIR")
    if not qtlibs:
        try:
            qtlibs = self.cmd_and_log(self.env.QMAKE +
                                      ['-query', 'QT_INSTALL_LIBS']).strip()
        except Errors.WafError:
            qtdir = self.cmd_and_log(
                self.env.QMAKE +
                ['-query', 'QT_INSTALL_PREFIX']).strip() + os.sep
            qtlibs = os.path.join(qtdir, 'lib')
    self.msg('Found the Qt4 libraries in', qtlibs)

    qtincludes = os.environ.get("QT4_INCLUDES") or self.cmd_and_log(
        self.env.QMAKE + ['-query', 'QT_INSTALL_HEADERS']).strip()
    env = self.env
    if not 'PKG_CONFIG_PATH' in os.environ:
        os.environ[
            'PKG_CONFIG_PATH'] = '%s:%s/pkgconfig:/usr/lib/qt4/lib/pkgconfig:/opt/qt4/lib/pkgconfig:/usr/lib/qt4/lib:/opt/qt4/lib' % (
                qtlibs, qtlibs)

    try:
        if os.environ.get("QT4_XCOMPILE"):
            raise self.errors.ConfigurationError()
        self.check_cfg(atleast_pkgconfig_version='0.1')
    except self.errors.ConfigurationError:
        for i in self.qt4_vars:
            uselib = i.upper()
            if Utils.unversioned_sys_platform() == "darwin":
                # Since at least qt 4.7.3 each library locates in separate directory
                frameworkName = i + ".framework"
                qtDynamicLib = os.path.join(qtlibs, frameworkName, i)
                if os.path.exists(qtDynamicLib):
                    env.append_unique('FRAMEWORK_' + uselib, i)
                    self.msg('Checking for %s' % i, qtDynamicLib, 'GREEN')
                else:
                    self.msg('Checking for %s' % i, False, 'YELLOW')
                env.append_unique(
                    'INCLUDES_' + uselib,
                    os.path.join(qtlibs, frameworkName, 'Headers'))
            elif env.DEST_OS != "win32":
                qtDynamicLib = os.path.join(qtlibs, "lib" + i + ".so")
                qtStaticLib = os.path.join(qtlibs, "lib" + i + ".a")
                if os.path.exists(qtDynamicLib):
                    env.append_unique('LIB_' + uselib, i)
                    self.msg('Checking for %s' % i, qtDynamicLib, 'GREEN')
                elif os.path.exists(qtStaticLib):
                    env.append_unique('LIB_' + uselib, i)
                    self.msg('Checking for %s' % i, qtStaticLib, 'GREEN')
                else:
                    self.msg('Checking for %s' % i, False, 'YELLOW')

                env.append_unique('LIBPATH_' + uselib, qtlibs)
                env.append_unique('INCLUDES_' + uselib, qtincludes)
                env.append_unique('INCLUDES_' + uselib,
                                  os.path.join(qtincludes, i))
            else:
                # Release library names are like QtCore4
                for k in ("lib%s.a", "lib%s4.a", "%s.lib", "%s4.lib"):
                    lib = os.path.join(qtlibs, k % i)
                    if os.path.exists(lib):
                        env.append_unique('LIB_' + uselib,
                                          i + k[k.find("%s") + 2:k.find('.')])
                        self.msg('Checking for %s' % i, lib, 'GREEN')
                        break
                else:
                    self.msg('Checking for %s' % i, False, 'YELLOW')

                env.append_unique('LIBPATH_' + uselib, qtlibs)
                env.append_unique('INCLUDES_' + uselib, qtincludes)
                env.append_unique('INCLUDES_' + uselib,
                                  os.path.join(qtincludes, i))

                # Debug library names are like QtCore4d
                uselib = i.upper() + "_debug"
                for k in ("lib%sd.a", "lib%sd4.a", "%sd.lib", "%sd4.lib"):
                    lib = os.path.join(qtlibs, k % i)
                    if os.path.exists(lib):
                        env.append_unique('LIB_' + uselib,
                                          i + k[k.find("%s") + 2:k.find('.')])
                        self.msg('Checking for %s' % i, lib, 'GREEN')
                        break
                else:
                    self.msg('Checking for %s' % i, False, 'YELLOW')

                env.append_unique('LIBPATH_' + uselib, qtlibs)
                env.append_unique('INCLUDES_' + uselib, qtincludes)
                env.append_unique('INCLUDES_' + uselib,
                                  os.path.join(qtincludes, i))
    else:
        for i in self.qt4_vars_debug + self.qt4_vars:
            self.check_cfg(package=i, args='--cflags --libs', mandatory=False)
Beispiel #40
0
BOOST_LIBS = [
    '/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib'
]
BOOST_INCLUDES = [
    '/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include'
]
BOOST_VERSION_FILE = 'boost/version.hpp'
BOOST_VERSION_CODE = '''
#include <iostream>
#include <boost/version.hpp>
int main() { std::cout << BOOST_LIB_VERSION << std::endl; }
'''

# toolsets from {boost_dir}/tools/build/v2/tools/common.jam
PLATFORM = Utils.unversioned_sys_platform()
detect_intel = lambda env: (PLATFORM == 'win32') and 'iw' or 'il'
detect_clang = lambda env: (PLATFORM == 'darwin') and 'clang-darwin' or 'clang'
detect_mingw = lambda env: (re.search('MinGW', env.CXX[0])) and 'mgw' or 'gcc'
BOOST_TOOLSETS = {
    'borland': 'bcb',
    'clang': detect_clang,
    'como': 'como',
    'cw': 'cw',
    'darwin': 'xgcc',
    'edg': 'edg',
    'g++': detect_mingw,
    'gcc': detect_mingw,
    'icpc': detect_intel,
    'intel': detect_intel,
    'kcc': 'kcc',
Beispiel #41
0
def set_bundle(self):
	if Utils.unversioned_sys_platform()=='darwin':
		self.mac_bundle=True
Beispiel #42
0
def _check_pthread_flag(self, *k, **kw):
    '''
	Computes which flags should be added to CXXFLAGS and LINKFLAGS to compile in multi-threading mode

	Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
	boost/thread.hpp will trigger a #error if -pthread isn't used:
	  boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
	  is not turned on. Please set the correct command line options for
	  threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"

	Based on _BOOST_PTHREAD_FLAG(): https://github.com/tsuna/boost.m4/blob/master/build-aux/boost.m4
    '''

    var = kw.get('uselib_store', 'BOOST')

    self.start_msg('Checking the flags needed to use pthreads')

    # The ordering *is* (sometimes) important.  Some notes on the
    # individual items follow:
    # (none): in case threads are in libc; should be tried before -Kthread and
    #       other compiler flags to prevent continual compiler warnings
    # -lpthreads: AIX (must check this before -lpthread)
    # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
    # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
    # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
    # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
    # -pthreads: Solaris/GCC
    # -mthreads: MinGW32/GCC, Lynx/GCC
    # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
    #      doesn't hurt to check since this sometimes defines pthreads too;
    #      also defines -D_REENTRANT)
    #      ... -mt is also the pthreads flag for HP/aCC
    # -lpthread: GNU Linux, etc.
    # --thread-safe: KAI C++
    if Utils.unversioned_sys_platform() == "sunos":
        # On Solaris (at least, for some versions), libc contains stubbed
        # (non-functional) versions of the pthreads routines, so link-based
        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
        # a function called by this macro, so we could check for that, but
        # who knows whether they'll stub that too in a future libc.)  So,
        # we'll just look for -pthreads and -lpthread first:
        boost_pthread_flags = ["-pthreads", "-lpthread", "-mt", "-pthread"]
    else:
        boost_pthread_flags = [
            "-lpthreads", "-Kthread", "-kthread", "-llthread", "-pthread",
            "-pthreads", "-mthreads", "-lpthread", "--thread-safe", "-mt"
        ]

    for boost_pthread_flag in boost_pthread_flags:
        try:
            self.env.stash()
            self.env['CXXFLAGS_%s' % var] += [boost_pthread_flag]
            self.env['LINKFLAGS_%s' % var] += [boost_pthread_flag]
            self.check_cxx(code=PTHREAD_CODE, msg=None, use=var, execute=False)

            self.end_msg(boost_pthread_flag)
            return
        except self.errors.ConfigurationError:
            self.env.revert()
    self.end_msg('None')
Beispiel #43
0
    def configure_env(self, cfg, env):
        super(chibios, self).configure_env(cfg, env)

        cfg.load('chibios')
        env.BOARD = self.name

        env.DEFINES.update(
            CONFIG_HAL_BOARD='HAL_BOARD_CHIBIOS',
            HAVE_OCLOEXEC=0,
            HAVE_STD_NULLPTR_T=0,
        )

        env.AP_LIBRARIES += [
            'AP_HAL_ChibiOS',
        ]

        # make board name available for USB IDs
        env.CHIBIOS_BOARD_NAME = 'HAL_BOARD_NAME="%s"' % self.name
        env.CFLAGS += cfg.env.CPU_FLAGS + [
            '-Wno-cast-align',
            '-Wlogical-op',
            '-Wframe-larger-than=1300',
            '-fsingle-precision-constant',
            '-Wno-attributes',
            '-Wno-error=double-promotion',
            '-Wno-error=missing-declarations',
            '-Wno-error=float-equal',
            '-Wno-error=undef',
            '-Wno-error=cpp',
            '-fno-exceptions',
            '-Wall',
            '-Wextra',
            '-Wno-sign-compare',
            '-Wfloat-equal',
            '-Wpointer-arith',
            '-Wmissing-declarations',
            '-Wno-unused-parameter',
            '-Werror=array-bounds',
            '-Wfatal-errors',
            '-Werror=unused-variable',
            '-Werror=uninitialized',
            '-Werror=init-self',
            '-Wframe-larger-than=1024',
            '-Werror=unused-but-set-variable',
            '-Wno-missing-field-initializers',
            '-Wno-trigraphs',
            '-Os',
            '-fno-strict-aliasing',
            '-fomit-frame-pointer',
            '-falign-functions=16',
            '-ffunction-sections',
            '-fdata-sections',
            '-fno-strength-reduce',
            '-fno-builtin-printf',
            '-fno-builtin-fprintf',
            '-fno-builtin-vprintf',
            '-fno-builtin-vfprintf',
            '-fno-builtin-puts',
            '-mno-thumb-interwork',
            '-mthumb',
            '--specs=nano.specs',
            '-specs=nosys.specs',
            '-DCHIBIOS_BOARD_NAME="%s"' % self.name,
        ]
        env.CXXFLAGS += env.CFLAGS + [
            '-fno-rtti',
            '-fno-threadsafe-statics',
        ]

        if Utils.unversioned_sys_platform() == 'cygwin':
            env.CXXFLAGS += ['-DCYGWIN_BUILD']

        bldnode = cfg.bldnode.make_node(self.name)
        env.BUILDROOT = bldnode.make_node('').abspath()
        env.LINKFLAGS = cfg.env.CPU_FLAGS + [
            '-Os', '-fomit-frame-pointer', '-falign-functions=16',
            '-ffunction-sections', '-fdata-sections', '-u_port_lock',
            '-u_port_unlock', '-u_exit', '-u_kill', '-u_getpid', '-u_errno',
            '-uchThdExit', '-fno-common', '-nostartfiles',
            '-mno-thumb-interwork', '-mthumb', '-specs=nano.specs',
            '-specs=nosys.specs',
            '-L%s' % env.BUILDROOT,
            '-L%s' % cfg.srcnode.make_node(
                'modules/ChibiOS/os/common/startup/ARMCMx/compilers/GCC/ld/'
            ).abspath(),
            '-L%s' % cfg.srcnode.make_node(
                'libraries/AP_HAL_ChibiOS/hwdef/common/').abspath(),
            '-Wl,--gc-sections,--no-warn-mismatch,--library-path=/ld,--script=ldscript.ld,--defsym=__process_stack_size__=%s,--defsym=__main_stack_size__=%s'
            % (cfg.env.PROCESS_STACK, cfg.env.MAIN_STACK)
        ]

        if cfg.env.DEBUG:
            env.CFLAGS += [
                '-gdwarf-4',
                '-g3',
            ]
            env.LINKFLAGS += [
                '-gdwarf-4',
                '-g3',
            ]

        if cfg.env.ENABLE_ASSERTS:
            cfg.msg("Enabling ChibiOS asserts", "yes")
            env.CFLAGS += ['-DHAL_CHIBIOS_ENABLE_ASSERTS']
            env.CXXFLAGS += ['-DHAL_CHIBIOS_ENABLE_ASSERTS']
        else:
            cfg.msg("Enabling ChibiOS asserts", "no")

        env.LIB += ['gcc', 'm']

        env.GIT_SUBMODULES += [
            'ChibiOS',
        ]

        try:
            import intelhex
            env.HAVE_INTEL_HEX = True
            cfg.msg("Checking for intelhex module:", 'OK')
        except Exception:
            cfg.msg("Checking for intelhex module:",
                    'disabled',
                    color='YELLOW')
            env.HAVE_INTEL_HEX = False
Beispiel #44
0
	def run(self):
		self.ut_exec = getattr(self, 'ut_exec', [ self.inputs[0].abspath() ])
		if getattr(self.generator, 'ut_fun', None):
			self.generator.ut_fun(self)

		try:
			fu = getattr(self.generator.bld, 'all_test_paths')
		except AttributeError:
			fu = os.environ.copy()
			self.generator.bld.all_test_paths = fu

			lst = []
			asm = []
			for g in self.generator.bld.groups:
				for tg in g:
					if getattr(tg, 'link_task', None):
						if tg.link_task.__class__.__name__ == 'fake_csshlib':
							asm.append(tg.link_task.outputs[0].parent.abspath())
						lst.append(tg.link_task.outputs[0].parent.abspath())
					if getattr(tg, 'cs_task', None):
						if tg.gen.endswith('.dll'):
							asm.append(tg.cs_task.outputs[0].parent.abspath())
						lst.append(tg.cs_task.outputs[0].parent.abspath())
					if getattr(tg, 'install', None):
						lst.append(tg.path.get_src().abspath())

			def add_path(dct, path, var):
				dct[var] = os.pathsep.join(Utils.to_list(path) + [os.environ.get(var, '')])

			add_path(fu, lst, 'PATH')

			if Utils.unversioned_sys_platform() == 'darwin':
				add_path(fu, lst, 'DYLD_LIBRARY_PATH')
				add_path(fu, lst, 'LD_LIBRARY_PATH')
			else:
				add_path(fu, lst, 'LD_LIBRARY_PATH')

			path_var = self.generator.env.CS_NAME == 'mono' and 'MONO_PATH' or 'DEVPATH'
			fu[path_var] = os.pathsep.join(asm)

		Logs.debug('runner: %r' % self.ut_exec)
		cwd = getattr(self.generator, 'ut_cwd', '') or self.inputs[0].parent.abspath()

		stderr = stdout = None
		if Logs.verbose == 0:
			stderr = stdout = Utils.subprocess.PIPE

		proc = Utils.subprocess.Popen(self.ut_exec, cwd=cwd, env=fu, stderr=stderr, stdout=stdout)
		(stdout, stderr) = proc.communicate()

		xml = getattr(self.generator, 'ut_nunit', False) and self.outputs[0].abspath() or None

		tup = (self.inputs[0].name, proc.returncode, xml)
		self.generator.utest_result = tup

		testlock.acquire()
		try:
			bld = self.generator.bld
			Logs.debug("ut: %r", tup)
			try:
				bld.utest_results.append(tup)
			except AttributeError:
				bld.utest_results = [tup]
		finally:
			testlock.release()
Beispiel #45
0
    def configure_env(self, cfg, env):
        super(sitl, self).configure_env(cfg, env)
        env.DEFINES.update(
            CONFIG_HAL_BOARD='HAL_BOARD_SITL',
            CONFIG_HAL_BOARD_SUBTYPE='HAL_BOARD_SUBTYPE_NONE',
            AP_SCRIPTING_CHECKS=
            1,  # SITL should always do runtime scripting checks
        )

        if self.with_can:
            cfg.define('HAL_NUM_CAN_IFACES', 2)
            cfg.define('UAVCAN_EXCEPTIONS', 0)

        env.CXXFLAGS += ['-Werror=float-equal']

        if not cfg.env.DEBUG:
            env.CXXFLAGS += [
                '-O3',
            ]

        if 'clang++' in cfg.env.COMPILER_CXX and cfg.options.asan:
            env.CXXFLAGS += [
                '-fsanitize=address',
                '-fno-omit-frame-pointer',
            ]

        env.LIB += [
            'm',
        ]

        cfg.check_librt(env)
        cfg.check_feenableexcept()

        env.LINKFLAGS += [
            '-pthread',
        ]

        if cfg.env.DEBUG and 'clang++' in cfg.env.COMPILER_CXX and cfg.options.asan:
            env.LINKFLAGS += ['-fsanitize=address']

        env.AP_LIBRARIES += [
            'AP_HAL_SITL',
        ]

        if not cfg.env.AP_PERIPH:
            env.AP_LIBRARIES += [
                'SITL',
            ]

        if cfg.options.enable_sfml:
            if not cfg.check_SFML(env):
                cfg.fatal("Failed to find SFML libraries")

        if cfg.options.sitl_osd:
            env.CXXFLAGS += ['-DWITH_SITL_OSD', '-DOSD_ENABLED=1']
            for f in os.listdir('libraries/AP_OSD/fonts'):
                if fnmatch.fnmatch(f, "font*bin"):
                    env.ROMFS_FILES += [(f, 'libraries/AP_OSD/fonts/' + f)]

        for f in os.listdir('Tools/autotest/models'):
            if fnmatch.fnmatch(f, "*.json") or fnmatch.fnmatch(f, "*.parm"):
                env.ROMFS_FILES += [('models/' + f,
                                     'Tools/autotest/models/' + f)]

        # embed any scripts from ROMFS/scripts
        if os.path.exists('ROMFS/scripts'):
            for f in os.listdir('ROMFS/scripts'):
                if fnmatch.fnmatch(f, "*.lua"):
                    env.ROMFS_FILES += [('scripts/' + f, 'ROMFS/scripts/' + f)]

        if len(env.ROMFS_FILES) > 0:
            env.CXXFLAGS += ['-DHAL_HAVE_AP_ROMFS_EMBEDDED_H']

        if cfg.options.sitl_rgbled:
            env.CXXFLAGS += ['-DWITH_SITL_RGBLED']

        if cfg.options.enable_sfml_audio:
            if not cfg.check_SFML_Audio(env):
                cfg.fatal("Failed to find SFML Audio libraries")
            env.CXXFLAGS += ['-DWITH_SITL_TONEALARM']

        if cfg.options.sitl_flash_storage:
            env.CXXFLAGS += ['-DSTORAGE_USE_FLASH=1']

        if cfg.env.DEST_OS == 'cygwin':
            env.LIB += [
                'winmm',
            ]

        if Utils.unversioned_sys_platform() == 'cygwin':
            env.CXXFLAGS += ['-DCYGWIN_BUILD']

        if 'clang++' in cfg.env.COMPILER_CXX:
            print("Disabling SLP for clang++")
            env.CXXFLAGS += [
                '-fno-slp-vectorize'  # compiler bug when trying to use SLP
            ]

        def srcpath(path):
            return cfg.srcnode.make_node(path).abspath()

        env.SRCROOT = srcpath('')
"""

commands = []
"""
List of commands to execute extracted from the command-line. This list is consumed during the execution, see :py:func:`waflib.Scripting.run_commands`.
"""

envvars = []
"""
List of environment variable declarations placed after the Waf executable name.
These are detected by searching for "=" in the rest arguments.
"""

lockfile = os.environ.get('WAFLOCK', '.lock-waf_%s_build' % sys.platform)
platform = Utils.unversioned_sys_platform()


class opt_parser(optparse.OptionParser):
    """
	Command-line options parser.
	"""
    def __init__(self, ctx):
        optparse.OptionParser.__init__(
            self,
            conflict_handler="resolve",
            version='waf %s (%s)' % (Context.WAFVERSION, Context.WAFREVISION))

        self.formatter.width = Logs.get_term_cols()
        self.ctx = ctx
Beispiel #47
0
 def __init__(self):
     if Utils.unversioned_sys_platform().startswith("linux"):
         self.with_can = True
     else:
         self.with_can = False
Beispiel #48
0
    def configure_env(self, cfg, env):
        if hasattr(self, 'hwdef'):
            cfg.env.HWDEF = self.hwdef
        super(chibios, self).configure_env(cfg, env)

        cfg.load('chibios')
        env.BOARD = self.name

        env.DEFINES.update(
            CONFIG_HAL_BOARD = 'HAL_BOARD_CHIBIOS',
            HAVE_STD_NULLPTR_T = 0,
            USE_LIBC_REALLOC = 0,
        )

        env.AP_LIBRARIES += [
            'AP_HAL_ChibiOS',
        ]

        # make board name available for USB IDs
        env.CHIBIOS_BOARD_NAME = 'HAL_BOARD_NAME="%s"' % self.name
        env.HAL_MAX_STACK_FRAME_SIZE = 'HAL_MAX_STACK_FRAME_SIZE=%d' % 1300 # set per Wframe-larger-than, ensure its same
        env.CFLAGS += cfg.env.CPU_FLAGS + [
            '-Wlogical-op',
            '-Wframe-larger-than=1300',
            '-fsingle-precision-constant',
            '-Wno-attributes',
            '-fno-exceptions',
            '-Wall',
            '-Wextra',
            '-Wno-sign-compare',
            '-Wfloat-equal',
            '-Wpointer-arith',
            '-Wmissing-declarations',
            '-Wno-unused-parameter',
            '-Werror=array-bounds',
            '-Wfatal-errors',
            '-Werror=uninitialized',
            '-Werror=init-self',
            '-Werror=unused-but-set-variable',
            '-Wno-missing-field-initializers',
            '-Wno-trigraphs',
            '-fno-strict-aliasing',
            '-fomit-frame-pointer',
            '-falign-functions=16',
            '-ffunction-sections',
            '-fdata-sections',
            '-fno-strength-reduce',
            '-fno-builtin-printf',
            '-fno-builtin-fprintf',
            '-fno-builtin-vprintf',
            '-fno-builtin-vfprintf',
            '-fno-builtin-puts',
            '-mno-thumb-interwork',
            '-mthumb',
            '--specs=nano.specs',
            '--specs=nosys.specs',
            '-DCHIBIOS_BOARD_NAME="%s"' % self.name,
            '-D__USE_CMSIS',
            '-Werror=deprecated-declarations',
            '-DNDEBUG=1'
        ]
        if not cfg.options.Werror:
            env.CFLAGS += [
            '-Wno-error=double-promotion',
            '-Wno-error=missing-declarations',
            '-Wno-error=float-equal',
            '-Wno-error=cpp',
            ]

        env.CXXFLAGS += env.CFLAGS + [
            '-fno-rtti',
            '-fno-threadsafe-statics',
        ]
        env.CFLAGS += [
            '-std=c11'
        ]

        if Utils.unversioned_sys_platform() == 'cygwin':
            env.CXXFLAGS += ['-DCYGWIN_BUILD']

        bldnode = cfg.bldnode.make_node(self.name)
        env.BUILDROOT = bldnode.make_node('').abspath()
        env.LINKFLAGS = cfg.env.CPU_FLAGS + [
            '-fomit-frame-pointer',
            '-falign-functions=16',
            '-ffunction-sections',
            '-fdata-sections',
            '-u_port_lock',
            '-u_port_unlock',
            '-u_exit',
            '-u_kill',
            '-u_getpid',
            '-u_errno',
            '-uchThdExit',
            '-fno-common',
            '-nostartfiles',
            '-mno-thumb-interwork',
            '-mthumb',
            '--specs=nano.specs',
            '--specs=nosys.specs',
            '-L%s' % env.BUILDROOT,
            '-L%s' % cfg.srcnode.make_node('modules/ChibiOS/os/common/startup/ARMCMx/compilers/GCC/ld/').abspath(),
            '-L%s' % cfg.srcnode.make_node('libraries/AP_HAL_ChibiOS/hwdef/common/').abspath(),
            '-Wl,--gc-sections,--no-warn-mismatch,--library-path=/ld,--script=ldscript.ld,--defsym=__process_stack_size__=%s,--defsym=__main_stack_size__=%s' % (cfg.env.PROCESS_STACK, cfg.env.MAIN_STACK)
        ]

        if cfg.env.DEBUG:
            env.CFLAGS += [
                '-gdwarf-4',
                '-g3',
            ]
            env.LINKFLAGS += [
                '-gdwarf-4',
                '-g3',
            ]

        if cfg.env.ENABLE_ASSERTS:
            cfg.msg("Enabling ChibiOS asserts", "yes")
            env.CFLAGS += [ '-DHAL_CHIBIOS_ENABLE_ASSERTS' ]
            env.CXXFLAGS += [ '-DHAL_CHIBIOS_ENABLE_ASSERTS' ]
        else:
            cfg.msg("Enabling ChibiOS asserts", "no")


        if cfg.options.disable_watchdog:
            cfg.msg("Disabling Watchdog", "yes")
            env.CFLAGS += [ '-DDISABLE_WATCHDOG' ]
            env.CXXFLAGS += [ '-DDISABLE_WATCHDOG' ]
        else:
            cfg.msg("Disabling Watchdog", "no")

        if cfg.env.ENABLE_MALLOC_GUARD:
            cfg.msg("Enabling malloc guard", "yes")
            env.CFLAGS += [ '-DHAL_CHIBIOS_ENABLE_MALLOC_GUARD' ]
            env.CXXFLAGS += [ '-DHAL_CHIBIOS_ENABLE_MALLOC_GUARD' ]
        else:
            cfg.msg("Enabling malloc guard", "no")
            
        if cfg.env.ENABLE_STATS:
            cfg.msg("Enabling ChibiOS thread statistics", "yes")
            env.CFLAGS += [ '-DHAL_ENABLE_THREAD_STATISTICS' ]
            env.CXXFLAGS += [ '-DHAL_ENABLE_THREAD_STATISTICS' ]
        else:
            cfg.msg("Enabling ChibiOS thread statistics", "no")

        env.LIB += ['gcc', 'm']

        env.GIT_SUBMODULES += [
            'ChibiOS',
        ]

        env.INCLUDES += [
            cfg.srcnode.find_dir('libraries/AP_GyroFFT/CMSIS_5/include').abspath()
        ]

        # whitelist of compilers which we should build with -Werror
        gcc_whitelist = [
            ('4','9','3'),
            ('6','3','1'),
            ('9','2','1'),
            ('9','3','1'),
            ('10','2','1'),
        ]

        if cfg.options.Werror or cfg.env.CC_VERSION in gcc_whitelist:
            cfg.msg("Enabling -Werror", "yes")
            if '-Werror' not in env.CXXFLAGS:
                env.CXXFLAGS += [ '-Werror' ]
        else:
            cfg.msg("Enabling -Werror", "no")

        try:
            import intelhex
            env.HAVE_INTEL_HEX = True
            cfg.msg("Checking for intelhex module:", 'OK')
        except Exception:
            cfg.msg("Checking for intelhex module:", 'disabled', color='YELLOW')
            env.HAVE_INTEL_HEX = False
Beispiel #49
0
def configure(ctx):
    if Logs.verbose == 0:

        def null_fatal(self, msg, ex=None):
            raise self.errors.ConfigurationError(msg, ex)

        setattr(Configure.ConfigurationContext, 'fatal', null_fatal)

    out = getattr(Context.g_module, 'out')
    inst = getattr(Context.g_module, 'inst')
    appname = getattr(Context.g_module, 'appname')
    supported_variant = getattr(Context.g_module, 'supported_variant')

    base_env = ctx.env
    base_env.APPNAME = appname
    base_env.OUTPUT = base_env.PREFIX = base_env.BINDIR = base_env.LIBDIR = base_env.DOCDIR = inst
    base_env.BUILDTAG = Options.options.buildtag

    tool_dir = [
        os.path.join(Context.waf_dir, 'waflib', 'Tools'),
        os.path.join(Context.waf_dir, 'waflib', 'extras'),
    ]

    platform = Utils.unversioned_sys_platform()

    for tgt in targets:
        try:
            config = Context.load_tool('config.%s' % tgt)
            ctx.msg("Loading '%s' config" % tgt, config.__file__)
        except:
            ctx.msg("Loading '%s' config" % tgt, 'not found', color='YELLOW')
            continue

        platforms = getattr(config, 'host_plat', [])
        archs = getattr(config, 'archs', None)
        options = [('%s_%s' % (tgt, arch), arch)
                   for arch in archs] or [(tgt, None)]

        for (name, arch) in options:
            if not supported_variant(name):
                continue

            if Logs.verbose == 0:
                Logs.pprint('NORMAL',
                            'Configuring variant %s :' % name.ljust(20),
                            sep='')

            try:
                if platform not in platforms:
                    raise Exception('Unsupported build host')

                ctx.setenv(name, env=base_env)
                arch_env = ctx.get_env()
                arch_env.BASENAME = name
                arch_env.TARGET = tgt
                arch_env.SUBARCH = arch
                arch_env.PREFIX = os.path.join(base_env.PREFIX, name)
                arch_env.BINDIR = os.path.join(base_env.BINDIR, name)
                arch_env.LIBDIR = os.path.join(base_env.LIBDIR, name)
                arch_env.DOCDIR = os.path.join(base_env.DOCDIR, name)
                config.prepare(ctx)

                for tool in getattr(config, 'tools', []):
                    ctx.load(tool, tool_dir)

                config.configure(ctx)
                cfgs = ctx.env.VARIANTS

                if not cfgs:
                    base_env.append_value('variants', name)

                for cfg in cfgs:
                    variant = '%s_%s' % (name, cfg)
                    ctx.setenv(variant, env=arch_env)
                    cfg_env = ctx.get_env()
                    cfg_env.PREFIX = os.path.join(base_env.BINDIR, variant)
                    cfg_env.BINDIR = os.path.join(base_env.BINDIR, variant,
                                                  'bin')
                    cfg_env.LIBDIR = os.path.join(base_env.LIBDIR, variant,
                                                  'bin')
                    cfg_env.DOCDIR = os.path.join(base_env.DOCDIR, variant,
                                                  'doc')
                    cfg_env.VARIANT = cfg
                    cfg_func = getattr(config, cfg)
                    cfg_func(cfg_env)
                    base_env.append_value('variants', variant)

                if Logs.verbose == 0:
                    missing = cfg_env['missing_features'] or ''
                    if missing:
                        missing = ' - Missing Features: %s' % ','.join(missing)
                    Logs.pprint('GREEN', 'Available%s' % missing)

            except Exception, e:
                if Logs.verbose == 0:
                    Logs.pprint('YELLOW', 'Not Available - %s' % e)
                else:
                    if str(e).startswith('msvc:'):
                        Logs.warn('Could not find %s: %s' %
                                  (ctx.env['MSVC_VERSIONS'][0],
                                   ctx.env['MSVC_TARGETS'][0]))
                        Logs.warn('Available compilers:')
                        for msvc_ver, msvc_tgts in ctx.env[
                                'MSVC_INSTALLED_VERSIONS']:
                            msvs_tgt = ' '.join([k for k, v in msvc_tgts])
                            Logs.warn("\t%s: %s" % (msvc_ver, msvs_tgt))
                    if Logs.verbose > 1:
                        import traceback
                        traceback.print_exc()
                    Logs.warn('%s is not available: %s' % (name, e))
Beispiel #50
0
def configure(conf):
    platform = Utils.unversioned_sys_platform()
    if platform == 'win32' and not conf.options.fi_path:
        return
    conf.check_freeimage(conf.options.fi_path, conf.options.fip)
Beispiel #51
0
    def prepare_task(self):
        # Create the directory if it doesn't already exist
        self.output_dir.mkdir()
        # We expect json output for friendlier parsing
        self.add_argument("-output-using-json")

        self.add_argument('-input-path "{}"'.format(
            clean_path(self.input_dir.abspath())))
        self.add_argument('-output-path "{}"'.format(
            clean_path(self.output_dir.abspath())))

        # Write input files to a file (command line version is too long)
        for input_file in self.inputs:
            input_file_rel_path = clean_path(
                input_file.path_from(self.input_dir))
            self.add_argument('-input-file "{}"'.format(input_file_rel_path))
            input_file.parent.get_bld().mkdir()

        def pypath(python_path):
            # Absolute paths are good to go as-is
            # Relative paths are assumed relative to src
            if not os.path.isabs(python_path):
                # Toss it in a node to figure out an absolute path
                python_path_node = self.generator.bld.srcnode.make_node(
                    python_path)
                python_path = python_path_node.abspath()

            if not os.path.exists(python_path):
                Logs.warn(
                    'az_code_gen: Path given as python path does not exist: {}'
                    .format(python_path))
            return clean_path(python_path)

        # Python paths
        self.add_argument('-python-home "{}"'.format(
            pypath(self.env['CODE_GENERATOR_PYTHON_HOME'])))
        for python_path in self.env['CODE_GENERATOR_PYTHON_PATHS']:
            self.add_argument('-python-path "{}"'.format(pypath(python_path)))

        # Debug python paths
        self.add_argument('-python-home-debug "{}"'.format(
            pypath(self.env['CODE_GENERATOR_PYTHON_HOME_DEBUG'])))
        for python_debug_path in self.env['CODE_GENERATOR_PYTHON_DEBUG_PATHS']:
            self.add_argument('-python-debug-path "{}"'.format(
                pypath(python_debug_path)))

        if code_generator_ignore_includes:
            self.add_argument('-ignore-includes')

        if code_generator_suppress_errors_as_warnings:
            self.add_argument('-suppress-errors-as-warnings')

        if code_generator_verbose:
            self.add_argument('-v')

        if Utils.unversioned_sys_platform().startswith('linux'):
            self.add_argument('-include-path /usr/include/c++/v1')

        for include in self.includes:
            self.add_argument('-include-path "{}"'.format(
                clean_path(include.abspath())))

        for include_path in self.env['CODE_GENERATOR_INCLUDE_PATHS']:
            self.add_argument('-include-path "{}"'.format(
                pypath(include_path)))

        if 'CODE_GENERATOR_CLANG_INCLUDE_PATH' in self.env:
            for clang_include_path in self.env[
                    'CODE_GENERATOR_CLANG_INCLUDE_PATH']:
                self.add_argument('-include-path "{}"'.format(
                    clean_path(clang_include_path)))

        for define in self.defines:
            self.add_argument('-define {}'.format(quote(define)))

        for script_node in self.script_nodes:
            self.add_argument('-codegen-script "{}"'.format(
                clean_path(script_node.get_src().abspath())))

        # Include file that contains code generation tag definitions
        codegen_tags = self.env['CODE_GENERATOR_TAGS']
        if not codegen_tags:
            codegen_tags = 'Code/Framework/AzCore/AzCore/Preprocessor/CodeGen.h'
        self.add_argument('-force-include "{}"'.format(
            clean_path(
                self.generator.bld.CreateRootRelativePath(codegen_tags))))

        if self.error_output_file_node:
            self.add_argument('-redirect-output-file "{}"'.format(
                clean_path(self.error_output_file_node.abspath())))

        if 'CLANG_SEARCH_PATHS' in self.env:
            self.add_argument('-resource-dir "{}"'.format(
                self.env['CLANG_SEARCH_PATHS']['libraries'][0]))

        if 'ISYSROOT' in self.env:
            self.add_argument('-isysroot "{}"'.format(self.env['ISYSROOT']))

        if 'ANDROID' in self.defines:
            self.add_argument('-is-android-build')
            for flag in self.env['CXXFLAGS']:
                if flag.startswith('--gcc-toolchain='):
                    gcc_toolchain = flag.split('=', 2)
                    self.add_argument('-android-toolchain "{}"'.format(
                        clean_path(gcc_toolchain[1])))
                    continue
                if flag.startswith('--target='):
                    android_target = flag.split('=', 2)
                    self.add_argument('-android-target "{}"'.format(
                        clean_path(android_target[1])))
                    continue
                if flag.startswith('--sysroot='):
                    android_sysroot = flag.split('=', 2)
                    self.add_argument('-android-sysroot "{}"'.format(
                        clean_path(android_sysroot[1])))
                    continue

        status, self.argument_file = self.write_argument_list_to_file()
        if not status:
            raise Errors.WafError('[ERROR] az_code_gen task creation failed')
def gfortran_modifier_platform(conf):
    dest_os = conf.env.DEST_OS or Utils.unversioned_sys_platform()
    gfortran_modifier_func = getattr(conf, 'gfortran_modifier_' + dest_os,
                                     None)
    if gfortran_modifier_func:
        gfortran_modifier_func()
Beispiel #53
0
 def __init__(self, **kw):
     super(OptionsContext, self).__init__(**kw)
     self.parser = opt_parser(self)
     self.option_groups = {}
     jobs = self.jobs()
     p = self.add_option
     color = os.environ.get('NOCOLOR', '') and 'no' or 'auto'
     p('-c',
       '--color',
       dest='colors',
       default=color,
       action='store',
       help='whether to use colors (yes/no/auto) [default: auto]',
       choices=('yes', 'no', 'auto'))
     p('-j',
       '--jobs',
       dest='jobs',
       default=jobs,
       type='int',
       help='amount of parallel jobs (%r)' % jobs)
     p('-k',
       '--keep',
       dest='keep',
       default=0,
       action='count',
       help='continue despite errors (-kk to try harder)')
     p('-v',
       '--verbose',
       dest='verbose',
       default=0,
       action='count',
       help='verbosity level -v -vv or -vvv [default: 0]')
     p('--zones',
       dest='zones',
       default='',
       action='store',
       help='debugging zones (task_gen, deps, tasks, etc)')
     p('--profile',
       dest='profile',
       default='',
       action='store_true',
       help=optparse.SUPPRESS_HELP)
     gr = self.add_option_group('Configuration options')
     self.option_groups['configure options'] = gr
     gr.add_option('-o',
                   '--out',
                   action='store',
                   default='',
                   help='build dir for the project',
                   dest='out')
     gr.add_option('-t',
                   '--top',
                   action='store',
                   default='',
                   help='src dir for the project',
                   dest='top')
     gr.add_option('--no-lock-in-run',
                   action='store_true',
                   default='',
                   help=optparse.SUPPRESS_HELP,
                   dest='no_lock_in_run')
     gr.add_option('--no-lock-in-out',
                   action='store_true',
                   default='',
                   help=optparse.SUPPRESS_HELP,
                   dest='no_lock_in_out')
     gr.add_option('--no-lock-in-top',
                   action='store_true',
                   default='',
                   help=optparse.SUPPRESS_HELP,
                   dest='no_lock_in_top')
     default_prefix = getattr(Context.g_module, 'default_prefix',
                              os.environ.get('PREFIX'))
     if not default_prefix:
         if Utils.unversioned_sys_platform() == 'win32':
             d = tempfile.gettempdir()
             default_prefix = d[0].upper() + d[1:]
         else:
             default_prefix = '/usr/local/'
     gr.add_option('--prefix',
                   dest='prefix',
                   default=default_prefix,
                   help='installation prefix [default: %r]' %
                   default_prefix)
     gr.add_option('--bindir', dest='bindir', help='bindir')
     gr.add_option('--libdir', dest='libdir', help='libdir')
     gr = self.add_option_group('Build and installation options')
     self.option_groups['build and install options'] = gr
     gr.add_option('-p',
                   '--progress',
                   dest='progress_bar',
                   default=0,
                   action='count',
                   help='-p: progress bar; -pp: ide output')
     gr.add_option('--targets',
                   dest='targets',
                   default='',
                   action='store',
                   help='task generators, e.g. "target1,target2"')
     gr = self.add_option_group('Step options')
     self.option_groups['step options'] = gr
     gr.add_option(
         '--files',
         dest='files',
         default='',
         action='store',
         help='files to process, by regexp, e.g. "*/main.c,*/test/main.o"')
     default_destdir = os.environ.get('DESTDIR', '')
     gr = self.add_option_group('Installation and uninstallation options')
     self.option_groups['install/uninstall options'] = gr
     gr.add_option('--destdir',
                   help='installation root [default: %r]' % default_destdir,
                   default=default_destdir,
                   dest='destdir')
     gr.add_option('-f',
                   '--force',
                   dest='force',
                   default=False,
                   action='store_true',
                   help='force file installation')
     gr.add_option('--distcheck-args',
                   metavar='ARGS',
                   help='arguments to pass to distcheck',
                   default=None,
                   action='store')
Beispiel #54
0
def solstudio_modifier_platform(conf):
    dest_os = conf.env['DEST_OS'] or Utils.unversioned_sys_platform()
    solstudio_modifier_func = getattr(conf, 'solstudio_modifier_' + dest_os,
                                      None)
    if solstudio_modifier_func:
        solstudio_modifier_func()
Beispiel #55
0
def prepare_build_environment(bld):
    """
    Prepare the build environment for the current build command and setup optional additional commands if necessary

    :param bld: The BuildContext
    """

    if bld.cmd in NON_BUILD_COMMANDS:
        bld.env['PLATFORM'] = 'project_generator'
        bld.env['CONFIGURATION'] = 'project_generator'
    else:
        if not bld.variant:
            bld.fatal("[ERROR] Invalid build variant.  Please use a valid build configuration. "
                      "Type in '{} --help' for more information".format(CURRENT_WAF_EXECUTABLE))

        (platform, configuration) = bld.get_platform_and_configuration()
        bld.env['PLATFORM'] = platform
        bld.env['CONFIGURATION'] = configuration

        if platform in PLATFORM_CONFIGURATION_FILTER:
            if configuration not in PLATFORM_CONFIGURATION_FILTER[platform]:
                bld.fatal('[ERROR] Configuration ({}) for platform ({}) currently not supported'.format(configuration, platform))

        if not platform in bld.get_supported_platforms():
            bld.fatal('[ERROR] Target platform "%s" not supported. [on host platform: %s]' % (platform, Utils.unversioned_sys_platform()))

        # make sure the android launchers are included in the build
        if bld.is_android_platform(bld.env['PLATFORM']):
            android_path = os.path.join(bld.path.abspath(), bld.get_android_project_relative_path(), 'wscript')
            if not os.path.exists(android_path):
                bld.fatal('[ERROR] Android launchers not correctly configured. Run \'configure\' again')
            SUBFOLDERS.append(bld.get_android_project_absolute_path())

        # If a spec was supplied, check for platform limitations
        if bld.options.project_spec != '':
            validated_platforms = bld.preprocess_platform_list(bld.spec_platforms(), True)
            if platform not in validated_platforms:
                bld.fatal('[ERROR] Target platform "{}" not supported for spec {}'.format(platform, bld.options.project_spec))
            validated_configurations = bld.preprocess_configuration_list(None, platform, bld.spec_configurations(), True)
            if configuration not in validated_configurations:
                bld.fatal('[ERROR] Target configuration "{}" not supported for spec {}'.format(configuration, bld.options.project_spec))

        if bld.is_cmd_monolithic():
            if len(bld.spec_modules()) == 0:
                bld.fatal('[ERROR] no available modules to build for that spec "%s" in "%s|%s"' % (bld.options.project_spec, platform, configuration))

            # Ensure that, if specified, target is supported in this spec
            if bld.options.targets:
                for target in bld.options.targets.split(','):
                    if not target in bld.spec_modules():
                        bld.fatal('[ERROR] Module "%s" is not configured to build in spec "%s" in "%s|%s"' % (target, bld.options.project_spec, platform, configuration))

        deploy_cmd = 'deploy_' + platform + '_' + configuration
        # Only deploy to specific target platforms
        if 'build' in bld.cmd and platform in [
    'android_armv7_gcc',
    'android_armv7_clang',
    'android_armv8_clang'] and deploy_cmd not in Options.commands:
            # Only deploy if we are not trying to rebuild 3rd party libraries for the platforms above
            if '3rd_party' != getattr(bld.options, 'project_spec', ''):
                Options.commands.append(deploy_cmd)
Beispiel #56
0
def get_solution_overrides(self):

    if self.cmd == 'generate_uber_files' or self.cmd == 'msvs':
        return {}

    # Only perform on VS executed builds
    try:
        sln_file = self.options.execsolution
    except:
        return {}

    if not sln_file:
        return {}

    if Utils.unversioned_sys_platform() != 'win32':
        return

    # Open sln file
    try:
        file = open(sln_file)
    except Exception as e:
        Logs.debug(
            'warning: Unable to parse .sln file to extract configuration overrides: [File:%s] [Exception:%s,%s]'
            % (sln_file, sys.exc_info()[0], e))
        return {}

    ret_vs_project_override = {}
    vs_spec = self.convert_waf_spec_to_vs_spec(self.options.project_spec)
    vs_platform = self.convert_waf_platform_to_vs_platform(
        self.env['PLATFORM'])
    vs_configuration = self.convert_waf_configuration_to_vs_configuration(
        self.env['CONFIGURATION'])

    vs_build_configuration = '[%s] %s|%s' % (
        vs_spec, vs_configuration, vs_platform)  # Example: [Hunt] Debug|x64
    vs_project_identifier = 'Project("{8BC9CEB8'  # C++ project: 8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942

    # Iterate over all basic project  information
    # Example:
    #   Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cry3DEngine", "e:\P4\CE_STREAMS\Solutions\.depproj\Cry3DEngine.vcxproj", "{60178AE3-57FD-488C-9A53-4AE4F66419AA}"
    project_guid_to_name = {}
    file_iter = iter(file)
    for line in file_iter:
        stripped_line = line.lstrip()
        if stripped_line.startswith(vs_project_identifier) == True:
            project_info = stripped_line[51:].split(
                ','
            )  # skip first 51 character ... "Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") ="
            project_name = project_info[0].strip()[
                1:-1]  # trim left and right and remove '"'
            project_path = project_info[1].strip()[1:-1]
            project_guid = project_info[2].strip()[2:-2]

            # Store project GUID and Name pair
            project_guid_to_name[project_guid] = project_name

        elif stripped_line.startswith('Global') == True:
            file_iter.next()
            break
        else:
            continue

    # Skip to beginning of project configurations information
    for line in file_iter:
        if line.lstrip().startswith(
                'GlobalSection(ProjectConfigurationPlatforms) = postSolution'
        ) == True:
            file_iter.next()
            break

    # Loop over all project
    # Example:
    # {60178AE3-57FD-488C-9A53-4AE4F66419AA}.[Hunt] Debug|x64.ActiveCfg = [GameSDK and Tools] Debug|x64
    # or
    # {60178AE3-57FD-488C-9A53-4AE4F66419AA}.[Hunt] Debug|x64.Build.0 = [GameSDK and Tools] Debug|x64
    for line in file_iter:
        stripped_line = line.strip()

        # Reached end of section
        if stripped_line.startswith('EndGlobalSection'):
            break

        if stripped_line[39:].startswith(vs_build_configuration) == True:
            project_build_info = stripped_line.split('.')

            starts_of_override_configuration = project_build_info[-1].find('[')
            project_build_info[-1] = project_build_info[-1][
                starts_of_override_configuration:]  # remove anything prior to [xxx] e.g. "ActiveCfg = "

            vs_project_configuration = project_build_info[1]
            vs_project_override_configuation = project_build_info[-1]

            # Check for no override condition
            if vs_project_configuration == vs_project_override_configuation:
                continue

            project_guid = project_build_info[0][
                1:-1]  # remove surrounding '{' and '}'

            try:
                project_name = project_guid_to_name[project_guid]
            except:
                # Continue if project GUID not in list.
                # Since we only store C++ projects in the list this project is most likely of an other type e.g. C#. The user will have added this project to the solution manualy.
                Logs.debug(
                    'Warning: Override Handling: Unsupported project id "%s" found. Project is most likely not a C++ project'
                    % project_gui)
                continue

            # Check that spec is the same
            vs_override_spec_end = vs_project_override_configuation.find(']')
            vs_override_spec = vs_project_override_configuation[
                1:vs_override_spec_end]
            if vs_spec != vs_override_spec:
                self.cry_error(
                    'Project "%s" : Invalid override spec is of type "%s" when it should be "%s"'
                    % (project_name, vs_override_spec, vs_spec))

            # Get WAF configuration from VS project configuration e.g. [Hunt] Debug|x64 -> debug
            vs_project_configuration_end = vs_project_override_configuation.rfind(
                '|')
            vs_project_configuration_start = vs_project_override_configuation.rfind(
                ']', 0, vs_project_configuration_end) + 2
            vs_project_configuration = vs_project_override_configuation[
                vs_project_configuration_start:vs_project_configuration_end]
            waf_configuration = self.convert_vs_configuration_to_waf_configuration(
                vs_project_configuration)

            # Store override
            ret_vs_project_override[project_name] = waf_configuration

    return ret_vs_project_override
def _validate_incredibuild_registry_settings(ctx):
    """ Helper function to verify the correct incredibuild settings """
    if Utils.unversioned_sys_platform() != 'win32':
        return  # Check windows registry only

    if not ctx.is_option_true('use_incredibuild'):
        return  # No need to check IB settings if there is no IB

    allowUserInput = True
    if not ctx.is_option_true('ask_for_user_input'):
        allowUserInput = False

    if Options.options.execsolution:
        allowUserInput = False

    if ctx.is_option_true('internal_dont_check_recursive_execution'):
        allowUserInput = False

    try:
        import _winreg
        IB_settings_read_only = _winreg.OpenKey(
            _winreg.HKEY_LOCAL_MACHINE,
            "Software\\Wow6432Node\\Xoreax\\Incredibuild\\Builder", 0,
            _winreg.KEY_READ)
    except:
        Logs.warn(
            '[WARNING] Cannot open registry entry "HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\Xoreax\\Incredibuild\\Builder" for reading, please check your incredibuild installation'
        )
        return

    def _check_ib_setting(setting_name, required_value, desc):
        """ Helper function to read (and potentially modify a registry setting for IB """
        (data, type) = (None, _winreg.REG_SZ)
        try:
            (data, type) = _winreg.QueryValueEx(IB_settings_read_only,
                                                setting_name)
        except:
            import traceback
            traceback.print_exc(file=sys.stdout)
            Logs.warn(
                '[WARNING] Cannot find a registry entry for "HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\Xoreax\\Incredibuild\\Builder\\%s"'
                % setting_name)

        # Do we have the right value?
        if str(data) != required_value:

            if not allowUserInput:  # Dont try anything if no input is allowed
                Logs.warn(
                    '[WARNING] "HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\Xoreax\\Incredibuild\\Builder\\%s" set to "%s" but should be "%s"; run WAF outside of Visual Studio to fix automatically'
                    % (setting_name, data, required_value))
                return

            try:  # Try to open the registry for writing
                IB_settings_writing = _winreg.OpenKey(
                    _winreg.HKEY_LOCAL_MACHINE,
                    "Software\\Wow6432Node\\Xoreax\\Incredibuild\\Builder", 0,
                    _winreg.KEY_SET_VALUE | _winreg.KEY_READ)
            except:
                Logs.warn(
                    '[WARNING] Cannot access a registry entry "HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\Xoreax\\Incredibuild\\Builder\\%s" for writing.'
                    % setting_name)
                Logs.warn(
                    '[WARNING] Please run cry_waf.exe as an administrator or change the value to "%s" in the registry to ensure a correct operation of WAF'
                    % required_value)
                return

            if data is None:
                info_str = [(
                    'Should WAF create "HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\Xoreax\\Incredibuild\\Builder\\%s" with value "%s"?'
                    % (setting_name, required_value))]
            else:
                info_str = [(
                    'Should WAF change "HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\Xoreax\\Incredibuild\\Builder\\%s" from "%s" to "%s"?'
                    % (setting_name, data, required_value))]
            info_str.append(desc)

            # Get user choice
            if not ctx.is_option_true('console_mode'):  # gui
                retVal = 'True' if ctx.gui_get_choice(
                    '\n'.join(info_str)) else 'False'
            else:  # console
                Logs.info('\n'.join(info_str))
                retVal = _get_boolean_value(ctx, 'Input', 'Yes')

            if retVal == 'True' or retVal == 'Yes':
                _winreg.SetValueEx(IB_settings_writing, setting_name, 0, type,
                                   str(required_value))
            else:
                Logs.warn(
                    '[WARNING] WAF is running with "unsupported" IncrediBuild settings. Expect to encounter IncrediBuild errors during compilation.'
                )

    _check_ib_setting(
        'MaxConcurrentPDBs', '0',
        '"MaxConcurrentPDBs" controls how many files can be processed in parallel (an optimization also useful for MSBuild)'
    )
    _check_ib_setting(
        'AllowDoubleTargets', '0',
        '"AllowDoubleTargets" controls if remote processes can be restarted on local machine when possible\nThis option is mandatory since it causes compiler crashed with WAF'
    )
Beispiel #58
0
def process_custom_configure_commands(conf):
    """
    Add any additional custom commands that need to be run during the configure phase

    :param conf:                Configuration context
    """

    host = Utils.unversioned_sys_platform()

    if host == 'win32':
        # Win32 platform optional commands

        # Generate the visual studio projects & solution if specified
        if conf.is_option_true('generate_vs_projects_automatically'):
            Options.commands.insert(0, 'msvs')

    elif host == 'darwin':

        # Darwin/Mac platform optional commands

        # Create Xcode-iOS-Projects automatically during configure when running on mac
        if conf.is_option_true('generate_ios_projects_automatically'):
            # Workflow improvement: for all builds generate projects after the build
            # except when using the default build target 'utilities' then do it before
            if 'build' in Options.commands:
                build_cmd_idx = Options.commands.index('build')
                Options.commands.insert(build_cmd_idx, 'xcode_ios')
            else:
                Options.commands.append('xcode_ios')

        # Create Xcode-AppleTV-Projects automatically during configure when running on mac
        if conf.is_option_true('generate_appletv_projects_automatically'):
            # Workflow improvement: for all builds generate projects after the build
            # except when using the default build target 'utilities' then do it before
            if 'build' in Options.commands:
                build_cmd_idx = Options.commands.index('build')
                Options.commands.insert(build_cmd_idx, 'xcode_appletv')
            else:
                Options.commands.append('xcode_appletv')

        # Create Xcode-darwin-Projects automatically during configure when running on mac
        if conf.is_option_true('generate_mac_projects_automatically'):
            # Workflow improvement: for all builds generate projects after the build
            # except when using the default build target 'utilities' then do it before
            if 'build' in Options.commands:
                build_cmd_idx = Options.commands.index('build')
                Options.commands.insert(build_cmd_idx, 'xcode_mac')
            else:
                Options.commands.append('xcode_mac')

    # Android target platform commands
    if any(platform for platform in conf.get_supported_platforms() if platform.startswith('android')):

        # this is required for building any android projects. It adds the Android launchers
        # to the list of build directories
        android_builder_func = getattr(conf, 'create_and_add_android_launchers_to_build', None)
        if android_builder_func != None and android_builder_func():
            SUBFOLDERS.append(conf.get_android_project_absolute_path())

        # rebuild the project if invoked from android studio or sepcifically requested to do so
        if conf.options.from_android_studio or conf.is_option_true('generate_android_studio_projects_automatically'):
            if 'build' in Options.commands:
                build_cmd_idx = Options.commands.index('build')
                Options.commands.insert(build_cmd_idx, 'android_studio')
            else:
                Options.commands.append('android_studio')

    # Make sure the intermediate files are generated and updated
    if len(Options.commands) == 0:
        Options.commands.insert(0, 'generate_uber_files')
        Options.commands.insert(1, 'generate_module_def_files')
    else:
        has_generate_uber_files = 'generate_uber_files' in Options.commands
        has_generate_module_def_files = 'generate_module_def_files' in Options.commands
        if not has_generate_uber_files:
            Options.commands.insert(0, 'generate_uber_files')
        if not has_generate_module_def_files:
            Options.commands.insert(1, 'generate_module_def_files')
Beispiel #59
0
def default_compilers():
    build_platform = Utils.unversioned_sys_platform()
    possible_compiler_list = cxx_compiler.get(build_platform,
                                              cxx_compiler['default'])
    return ' '.join(possible_compiler_list)
Beispiel #60
0
def ifort_modifier_platform(conf):
    dest_os = conf.env['DEST_OS'] or Utils.unversioned_sys_platform()
    ifort_modifier_func = getattr(conf, 'ifort_modifier_' + dest_os, None)
    if ifort_modifier_func:
        ifort_modifier_func()