def parse_args(self, _args=None):
        """
		Parse arguments from a list (not bound to the command-line).

		:param _args: arguments
		:type _args: list of strings
		"""
        global options, commands, envvars
        (options, leftover_args) = self.parser.parse_args(args=_args)

        for arg in leftover_args:
            if '=' in arg:
                envvars.append(arg)
            else:
                commands.append(arg)

        if options.destdir:
            options.destdir = os.path.abspath(
                os.path.expanduser(options.destdir))

        if options.verbose >= 1:
            self.load('errcheck')

        colors = {'yes': 2, 'auto': 1, 'no': 0}[options.colors]
        Logs.enable_colors(colors)
示例#2
0
	def init_logs(self,options,commands,envvars):
		if options.verbose>=1:
			self.load('errcheck')
		colors={'yes':2,'auto':1,'no':0}[options.colors]
		Logs.enable_colors(colors)
		if options.zones:
			Logs.zones=options.zones.split(',')
			if not Logs.verbose:
				Logs.verbose=1
		elif Logs.verbose>0:
			Logs.zones=['runner']
		if Logs.verbose>2:
			Logs.zones=['*']
示例#3
0
	def parse_args(self,_args=None):
		global options,commands,envvars
		(options,leftover_args)=self.parser.parse_args(args=_args)
		for arg in leftover_args:
			if'='in arg:
				envvars.append(arg)
			else:
				commands.append(arg)
		if options.destdir:
			options.destdir=Utils.sane_path(options.destdir)
		if options.verbose>=1:
			self.load('errcheck')
		colors={'yes':2,'auto':1,'no':0}[options.colors]
		Logs.enable_colors(colors)
	def parse_args(self,_args=None):
		global options,commands,envvars
		(options,leftover_args)=self.parser.parse_args(args=_args)
		for arg in leftover_args:
			if'='in arg:
				envvars.append(arg)
			else:
				commands.append(arg)
		if options.destdir:
			options.destdir=os.path.abspath(os.path.expanduser(options.destdir))
		if options.verbose>=1:
			self.load('errcheck')
		colors={'yes':2,'auto':1,'no':0}[options.colors]
		Logs.enable_colors(colors)
示例#5
0
 def parse_args(self, _args=None):
     global options, commands, envvars
     (options, leftover_args) = self.parser.parse_args(args=_args)
     for arg in leftover_args:
         if "=" in arg:
             envvars.append(arg)
         else:
             commands.append(arg)
     if options.destdir:
         options.destdir = Utils.sane_path(options.destdir)
     if options.verbose >= 1:
         self.load("errcheck")
     colors = {"yes": 2, "auto": 1, "no": 0}[options.colors]
     Logs.enable_colors(colors)
示例#6
0
文件: Options.py 项目: afeldman/waf
	def init_logs(self, options, commands, envvars):
		Logs.verbose = options.verbose
		if options.verbose >= 1:
			self.load('errcheck')

		colors = {'yes' : 2, 'auto' : 1, 'no' : 0}[options.colors]
		Logs.enable_colors(colors)

		if options.zones:
			Logs.zones = options.zones.split(',')
			if not Logs.verbose:
				Logs.verbose = 1
		elif Logs.verbose > 0:
			Logs.zones = ['runner']
		if Logs.verbose > 2:
			Logs.zones = ['*']
    def init_logs(self, options, commands, envvars):
        Logs.verbose = options.verbose
        if options.verbose >= 1:
            self.load("errcheck")

        colors = {"yes": 2, "auto": 1, "no": 0}[options.colors]
        Logs.enable_colors(colors)

        if options.zones:
            Logs.zones = options.zones.split(",")
            if not Logs.verbose:
                Logs.verbose = 1
        elif Logs.verbose > 0:
            Logs.zones = ["runner"]
        if Logs.verbose > 2:
            Logs.zones = ["*"]
示例#8
0
def build(bld):
    USELIB_VARS['c'].add('SYSINCLUDES')
    USELIB_VARS['cxx'].add('SYSINCLUDES')

    if sysconfig.get_platform() == 'mingw':
        Logs.enable_colors(2)
    #endif

    global run_tests
    if run_tests:
        bld.options.all_tests = True
        bld.options.no_tests = False
    else:
        bld.options.all_tests = False
        bld.options.no_tests = True
    #endif

    bld.options.clear_failed_tests = True
    bld.add_post_fun(summary)
    bld.add_post_fun(waf_unit_test.set_exit_code)
示例#9
0
	def parse_args(self, _args=None):
		"""
		Parse arguments from a list (not bound to the command-line).

		:param _args: arguments
		:type _args: list of strings
		"""
		global options, commands, envvars
		(options, leftover_args) = self.parser.parse_args(args=_args)

		for arg in leftover_args:
			if '=' in arg:
				envvars.append(arg)
			else:
				commands.append(arg)

		if options.destdir:
			options.destdir = Utils.sane_path(options.destdir)

		if options.verbose >= 1:
			self.load('errcheck')

		colors = {'yes' : 2, 'auto' : 1, 'no' : 0}[options.colors]
		Logs.enable_colors(colors)
示例#10
0
文件: Options.py 项目: solarblue/waf
    def parse_args(self, _args=None):
        """
		Parses arguments from a list which is not necessarily the command-line.

		:param _args: arguments
		:type _args: list of strings
		"""
        global options, commands, envvars
        (options, leftover_args) = self.parser.parse_args(args=_args)

        for arg in leftover_args:
            if '=' in arg:
                envvars.append(arg)
            else:
                commands.append(arg)

        if options.destdir:
            options.destdir = Utils.sane_path(options.destdir)

        if options.verbose >= 1:
            self.load('errcheck')

        colors = {'yes': 2, 'auto': 1, 'no': 0}[options.colors]
        Logs.enable_colors(colors)
示例#11
0
文件: Options.py 项目: yukimori/waf
    def parse_args(self, _args=None):
        """
		Parses arguments from a list which is not necesarily the command-line.

		:param _args: arguments
		:type _args: list of strings
		"""
        global options, commands, envvars
        (options, leftover_args) = self.parser.parse_args(args=_args)

        for arg in leftover_args:
            if "=" in arg:
                envvars.append(arg)
            else:
                commands.append(arg)

        if options.destdir:
            options.destdir = Utils.sane_path(options.destdir)

        if options.verbose >= 1:
            self.load("errcheck")

        colors = {"yes": 2, "auto": 1, "no": 0}[options.colors]
        Logs.enable_colors(colors)
示例#12
0
    def execute(self):

        # Check whether the main wscript has a resolve function defined,
        # if not we create one. This is also done for other functions such
        # as options by waf itself. See:
        # https://github.com/waf-project/waf/blob/master/waflib/Scripting.py#L201-L207
        #
        if 'resolve' not in Context.g_module.__dict__:
            Context.g_module.resolve = Utils.nada

        # Create the nodes that will be used during the resolve step. The build
        # directory is also used by the waf BuildContext
        self.srcnode = self.path
        self.bldnode = self.path.make_node('build')
        self.bldnode.mkdir()

        default_resolve_path = os.path.join(
            self.path.abspath(), 'resolved_dependencies')

        default_symlinks_path = os.path.join(
            self.path.abspath(), 'resolve_symlinks')

        self.registry = registry.build_registry(
            ctx=self, git_binary='git',
            semver=semver,
            archive_extractor=archive.extract,
            default_resolve_path=default_resolve_path,
            resolve_config_path=self.resolve_config_path(),
            default_symlinks_path=default_symlinks_path,
            waf_utils=Utils, args=sys.argv[1:],
            project_path=self.path.abspath(),
            waf_lock_file=Options.lockfile)

        # Enable/disable colors based on the currently used terminal.
        # Note: this prevents jumbled output if waf is invoked from an IDE
        # that does not render colors in its output window
        Logs.enable_colors(1)

        # Lets make a different log file for the different resolver chains
        configuration = self.registry.require('configuration')

        path = os.path.join(self.bldnode.abspath(),
                            configuration.resolver_chain() + '.resolve.log')

        self.logger = Logs.make_logger(path, 'cfg')
        self.logger.debug('wurf: Resolve execute {}'.format(
            configuration.resolver_chain()))

        self.dependency_manager = self.registry.require('dependency_manager')

        try:
            # Calling the context execute will call the resolve(...) functions
            # in the wscripts. These will in turn call add_dependency(...)
            # which will trigger loading the dependency.
            super(WafResolveContext, self).execute()

        except Error as e:
            self.logger.debug("Error in resolve:\n", exc_info=True)
            self.fatal(str(e))
        except Exception:
            raise

        # Get the cache with the resolved dependencies
        global dependency_cache
        dependency_cache = self.registry.require('dependency_cache')

        self.logger.debug('wurf: dependency_cache {}'.format(dependency_cache))

        # If needed execute any actions which cannot run until after the
        # dependency resolution has completed
        post_resolver_actions = self.registry.require('post_resolver_actions')

        for action in post_resolver_actions:
            action()
示例#13
0
def configure(cfg):
    USELIB_VARS['c'].add('SYSINCLUDES')
    USELIB_VARS['cxx'].add('SYSINCLUDES')

    if sysconfig.get_platform() == 'mingw':
        Logs.enable_colors(2)
    #endif

    # Cache configuration flags so they can't be overriden at build (1)
    cfg.env.cur_toolset = cfg.options.toolset

    config = get_config(cfg)
    toolset = get_toolset(cfg)

    # Cache configuration flags so they can't be overriden at build (2)
    config_found = False
    for configuration in config['configurations']:
        if cfg.options.config == configuration:
            config_found = True
        #endif
    #endfor

    if config_found == False:
        cfg.fatal('Invalid configuration used!')
    #endif

    # Save the configuration for error checking during build
    cfg.env.cur_conf = cfg.options.config

    # Cache configuration flags so they can't be overriden at build (3)
    platform_found = False
    for platform in config['target_platforms']:
        if cfg.options.target_platform == platform:
            platform_found = True
        #endif
    #endfor

    if platform_found == False:
        cfg.fatal('Invalid platform used!')
    #endif

    cfg.env.cur_platform = cfg.options.target_platform

    ignore_paths = False
    if 'ignore_paths' in toolset:
        ignore_paths = toolset['ignore_paths']
    #endif

    ## Set the compiler paths so waf can find them
    if not ignore_paths:
        cfg.env.CC = toolset['cc_path']
        cfg.env.CXX = toolset['cxx_path']
        cfg.env.AR = toolset['ar_path']
    #endif

    cfg.load(toolset['cc'])
    cfg.load(toolset['cxx'])
    cfg.load('clang_compilation_database')

    if toolset['cc'] == 'msvc' or toolset['cxx'] == 'msvc':
        cfg.load('msvc_pdb')
    #endif

    if not 'forced_include_flag' in toolset:
        cfg.fatal('Toolset requires a forced_include_flag attribute')
    #endif

    if toolset['forced_include_flag'] == None \
        or toolset['forced_include_flag'] == '' \
        or toolset['forced_include_flag'] == []:
        cfg.fatal('forced_include_flag cannot be empty')
    #endif
    cfg.env.FORCEINCFLAG = toolset['forced_include_flag']
    cfg.env.FORCEINCLUDES = []

    def read_optional_flag(target, option, obj=toolset):
        if option in obj:
            cfg.env.append_value(target, obj[option])
        #endif

    #enddef

    # Parse compiler flags, defines and system includes
    for env_flag, toolset_flag in \
        [ \
            ('CFLAGS', 'cc_flags'), \
            ('CXXFLAGS', 'cxx_flags'), \
            ('ARFLAGS', 'stlib_flags'), \
            ('STLIBPATH', 'stlib_path'), \
            ('LINKFLAGS_cshlib', 'shlib_flags'), \
            ('LINKFLAGS_cxxshlib', 'shlib_flags'), \
            ('LIBPATH', 'shlib_path'), \
            ('LINKFLAGS_EXE', 'exe_flags'), \
            ('LDFLAGS', 'ld_flags')
        ]:
        cfg.env[env_flag] = toolset[toolset_flag]
        read_optional_flag(env_flag, toolset_flag + '_' + cfg.options.config)
    #endfor

    if cfg.options.development:
        cfg.env.CFLAGS += toolset['dev_cc_flags']
        cfg.env.CXXFLAGS += toolset['dev_cxx_flags']
    #endif

    cfg.env.DEFINES += toolset['defines']['base']
    read_optional_flag('DEFINES', cfg.options.config, toolset['defines'])

    system_include_flag = None
    if not 'system_include_flag' in toolset:
        cfg.fatal('system_include_flag is required!')
    #endif

    system_include_flag = toolset['system_include_flag']

    if system_include_flag == '' or system_include_flag == []:
        system_include_flags = None
    #endif
    cfg.env.SYSINCFLAG = system_include_flag
    cfg.env.SYSINCLUDES = []

    for path in toolset['system_includes']:
        flag = [
            os.path.normcase(
                os.path.normpath(os.path.join(cfg.path.abspath(), path)))
        ]
        cfg.env.SYSINCLUDES += flag
    #endfor

    # Configure use flags
    configure_use(cfg)