[Webkit-unassigned] [Bug 280610] [GLib] Centralize handling of environment variables

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Sep 30 05:03:52 PDT 2024


https://bugs.webkit.org/show_bug.cgi?id=280610

Adrian Perez <aperez at igalia.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://bugs.webkit.org/sho
                   |                            |w_bug.cgi?id=192405
                 CC|                            |bugs-noreply at webkitgtk.org

--- Comment #1 from Adrian Perez <aperez at igalia.com> ---
I am aware of bug #192405 where there was been a previous attempt at
doing something similar. Contrary to that attempt, I'd say we want to
have a smaller scope but approach things in a different way:

 - Cover only the GLib ports. Other ports may want to adopt the mechanism,
   but we would rather have something earlier and help out later

 - Only handle *getting* values from the environment. All of them
   would be read and parsed at once as soon the Environment instance
   is created, defaults applied, and warnings emitted on stderr for
   invalid values.

 - Avoid using strings and parsing on each callsite, whenever possible,
   solved by generating the accessors from the YAML description. This is
   one more reason to have the types declared in the YAML.   

 - Avoid each callsite having to handle the case where a variable
   is not defined in the environment. If a default value is declared
   in the YAML source, then use it as fallback (like in the example
   above):

     // Default value used if not present in the environment.
     bool useTimer = Environment::singleton().WEBKIT_FORCE_VBLANK_TIMER;

   If there is no default then the type is wrapped in std::optional, e.g.

     // No default value declared in the YAML description.
     if (auto address = Environment::singleton().WEBKIT_INSPECTOR_SERVER)
         WTF_ALWAYS_LOG("Env var was defined, value: " << *address);

 - Start porting over a few uses of [g_]getenv() to the new mechanism,
   and then incrementally port more code, instead of trying to solve all
   cases in one go.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240930/ab87f55e/attachment.htm>


More information about the webkit-unassigned mailing list