Title: [272712] trunk/Tools
Revision
272712
Author
[email protected]
Date
2021-02-11 01:29:22 -0800 (Thu, 11 Feb 2021)

Log Message

[Flatpak SDK] Support multiple builds running at the same time
https://bugs.webkit.org/show_bug.cgi?id=221711

Reviewed by Philippe Normand.

Instead of writing the environment to a file, read the --setenv
arguments from the --args file descriptor passed to webkit-bwrap like
bwrap itself would do.

* flatpak/flatpakutils.py: Do not write the env file anymore
(WebkitFlatpak.run_in_sandbox):
* flatpak/webkit-bwrap: Read the environment from the args file
descriptor.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (272711 => 272712)


--- trunk/Tools/ChangeLog	2021-02-11 08:44:54 UTC (rev 272711)
+++ trunk/Tools/ChangeLog	2021-02-11 09:29:22 UTC (rev 272712)
@@ -1,3 +1,19 @@
+2021-02-11  Lauro Moura  <[email protected]>
+
+        [Flatpak SDK] Support multiple builds running at the same time
+        https://bugs.webkit.org/show_bug.cgi?id=221711
+
+        Reviewed by Philippe Normand.
+
+        Instead of writing the environment to a file, read the --setenv
+        arguments from the --args file descriptor passed to webkit-bwrap like
+        bwrap itself would do.
+
+        * flatpak/flatpakutils.py: Do not write the env file anymore
+        (WebkitFlatpak.run_in_sandbox):
+        * flatpak/webkit-bwrap: Read the environment from the args file
+        descriptor.
+
 2021-02-10  Wenson Hsieh  <[email protected]>
 
         [Webpage translation] Add support for the -_translate: action on WKContentView

Modified: trunk/Tools/flatpak/flatpakutils.py (272711 => 272712)


--- trunk/Tools/flatpak/flatpakutils.py	2021-02-11 08:44:54 UTC (rev 272711)
+++ trunk/Tools/flatpak/flatpakutils.py	2021-02-11 09:29:22 UTC (rev 272712)
@@ -882,20 +882,10 @@
             pkg_config_path = self.build_path
         flatpak_env["PKG_CONFIG_PATH"] = pkg_config_path
 
-        env_file = os.path.join(self.build_root, 'flatpak-env.json')
-        if not os.path.exists(env_file):
-            with open(env_file, 'w') as f:
-                json.dump(dict(flatpak_env), f, indent=2)
-        else:
-            env_file = None
-
         try:
             return self.execute_command(flatpak_command, stdout=stdout, env=flatpak_env)
         except KeyboardInterrupt:
             return 0
-        finally:
-            if env_file is not None and os.path.exists(env_file):
-                os.remove(env_file)
 
         return 0
 

Modified: trunk/Tools/flatpak/webkit-bwrap (272711 => 272712)


--- trunk/Tools/flatpak/webkit-bwrap	2021-02-11 08:44:54 UTC (rev 272711)
+++ trunk/Tools/flatpak/webkit-bwrap	2021-02-11 09:29:22 UTC (rev 272712)
@@ -20,6 +20,7 @@
 import os
 import itertools
 import shlex
+import stat
 import sys
 import tempfile
 import json
@@ -26,6 +27,23 @@
 
 scriptdir = os.path.abspath(os.path.dirname(__file__))
 
+def read_lines(fd: int):
+    new_fd = os.dup(fd)
+    pos = os.lseek(fd, 0, os.SEEK_CUR)
+    try:
+        with os.fdopen(new_fd, 'r') as handle:
+            data = ""
+            lines = data.split('\x00')
+            for line in lines:
+                yield line
+    except Exception as e:
+        print("Error reading brwap arguments", file=sys.stderr)
+        print(e, file=sys.stderr)
+    finally:
+        os.lseek(fd, pos, os.SEEK_SET)
+
+
+
 def main(args: list) -> int:
     tmpdir = tempfile.gettempdir()
     source_root = os.path.normpath(os.path.abspath(os.path.join(scriptdir, '../../')))
@@ -37,9 +55,21 @@
         "/run/shm": "/dev/shm",
     }
 
+    args_idx = args.index('--args')
+    arg_fd = int(args[args_idx + 1])
+
+    lines = read_lines(arg_fd)
+
     environ = {}
-    with open(os.path.join(build_root, 'flatpak-env.json')) as f:
-        environ = json.load(f)
+    while True:
+        try:
+            arg = next(lines)
+            if arg == '--setenv':
+                key = next(lines)
+                value = next(lines)
+                environ[key] = value
+        except StopIteration:
+            break
 
     flatpak_user_dir = environ.get("WEBKIT_FLATPAK_USER_DIR")
     if flatpak_user_dir:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to