On Mon, Feb 25, 2008 at 7:39 PM, Jonas Karlsson <[EMAIL PROTECTED]> wrote:
>
> On Mon, 25 Feb 2008 00:53:49 +0100, Michael Homer <[EMAIL PROTECTED]> 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?
Yes. SystemUseFlags.conf and UseFlags.conf can contain lines of the form:
+foo Bar Baz
-quux Baz
to enable the foo flag for Bar and Baz, and disable quux for Baz. The
USE environment variable can have the same thing, but with semicolons
instead of spaces all through (since flags are space-separated within
the variable already).

The used flags are not saved anywhere (at the moment; they could be,
but determining which are actually used versus which are just enabled
at the time is difficult). But users should *not* get the same flags
enabled when they recompile unless the flags actually are the same;
that's the reason they changed them. However, they can fix the flags
for a given program with lines like this in UseFlags.conf:
 -* Bar
 +foo Bar
 +quux Bar
To set exactly and only "foo" and "quux" for the program Bar.

Flags are merged in the order system, site, environment, and later
settings of any kind always overwrite earlier ones. That means that
setting a flag within USE will overload a program-specific setting in
UseFlags.conf, which I think is the expected behaviour.
-Michael
_______________________________________________
gobolinux-devel mailing list
gobolinux-devel@lists.gobolinux.org
http://lists.gobolinux.org/mailman/listinfo/gobolinux-devel

Reply via email to