[gobolinux-devel] [gobolinux-commits] tools/Scripts/bin UseFlags

Jonas Karlsson jonka750 at student.liu.se
Mon Feb 25 19:39:46 NZDT 2008


On Mon, 25 Feb 2008 00:53:49 +0100, Michael Homer <michael at e.geek.nz> wrote:

> CVSROOT:	/sources/goboscripts
> Module name:	tools
> Changes by:	Michael Homer <mwh>	08/02/24 23:53:49
>
> Modified files:
> 	Scripts/bin    : UseFlags
>
> Log message:
> 	Add more documentation to code and --help output. Clean code by reducing duplication for flag specs containing program lists.
>
> CVSWeb URLs:
> http://cvs.savannah.gnu.org/viewcvs/tools/Scripts/bin/UseFlags?cvsroot=goboscripts&r1=1.2&r2=1.3
>
> Patches:
> Index: UseFlags
> ===================================================================
> RCS file: /sources/goboscripts/tools/Scripts/bin/UseFlags,v
> retrieving revision 1.2
> retrieving revision 1.3
> diff -u -b -r1.2 -r1.3
> --- UseFlags	20 Feb 2008 08:37:35 -0000	1.2
> +++ UseFlags	24 Feb 2008 23:53:49 -0000	1.3
> @@ -1,30 +1,48 @@
>  #!/usr/bin/env python
>  # Copyright (C) 2008 Michael Homer <=mwh>
>  # Gives information about the state of use flags
> -# Distributed under the GNU GPLv3+
> +# This program is free software: you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation, either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> from GetAvailable import getGoboVariable
>  import sys, os.path
>+# A frozen set of the global set of flags (program=None, or any program with no special flags specified)
>  global_use_flags_cache = None
> +# A dict of program=>set of flags for each program that has been evaluated
>  global_program_use_flags_cache = None
> def UseFlags(program=None):
> -	"""Return the set of flags enabled for program, or whether or not flag is enabled if specified"""
> +	"""Return the set of flags enabled for program"""
>  	global global_use_flags_cache, global_program_use_flags_cache
> +	# When program is specified and a cached set is available, use it.
>  	if program and global_program_use_flags_cache and program in global_program_use_flags_cache:
>  		return global_program_use_flags_cache[program]
> +	# When a program is *not* specified and a cached global set exists, use it.
>  	elif global_use_flags_cache is not None and not program:
>  		return global_use_flags_cache
> +	# Otherwise, generate the set of flags now.
>  	else:
>  		goboSettings = getGoboVariable('goboSettings')
>  		flags = set()
> +		# Import site-specific use flags
>  		if os.path.exists(goboSettings + '/UseFlags.conf'):
>  			f = open(goboSettings + '/UseFlags.conf')
>  			mergeFlags(flags, f, program)
>  			f.close()
> +		# Flags set in the environment for a specific run of Compile are merged,
> +		# and overwrite any previous specifications for the same flag.
>  		if 'USE' in os.environ:
>  			mergeFlags(flags, os.environ['USE'].split(), program)
> +		# If program is specified, the flags should be saved in the program cache.
> +		# Otherwise they are the global flags and can be saved there.
>  		if program:
>  			if not global_program_use_flags_cache: global_program_use_flags_cache = dict()
>  			flags = frozenset(flags)
Does this mean that per-program useflags are supported? Will the used
flags be saved in Resources then? That way users will/can get the same
useflags when they recompile a program. However, which should have the
highest precedence, environment, command prompt or per-program flags?

-- 
/Jonas

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


More information about the gobolinux-devel mailing list