Title: [292390] trunk/Tools
Revision
292390
Author
commit-qu...@webkit.org
Date
2022-04-05 03:55:51 -0700 (Tue, 05 Apr 2022)

Log Message

[Flatpak SDK] Local dependencies override support
https://bugs.webkit.org/show_bug.cgi?id=238452

Patch by Philippe Normand <pnorm...@igalia.com> on 2022-04-05
Reviewed by Adrian Perez de Castro.

When the environment variable WEBKIT_SDK_LOCAL_DEPS is set at compile-time and runtime, some
dependencies (currently only libsoup and GStreamer) will be picked up from local git
checkouts located in Tools/flatpak/. If no checkout is present, one will be made based on
the corresponding .wrap file.

Example: WEBKIT_SDK_LOCAL_DEPS=libsoup,gstreamer-full build-webkit --wpe ...

Additional Meson options can be supplied with WEBKIT_SDK_LOCAL_DEPS_OPTIONS. Nested
subprojects configuration is supported as well, for example:

export WEBKIT_SDK_LOCAL_DEPS_OPTIONS="-Dgstreamer-full:introspection=disabled -Dgst-plugins-good:soup=disabled"

This setup replaces the previous one that was specific to GStreamer.

* flatpak/flatpakutils.py:
(WebkitFlatpak.load_from_args):
(WebkitFlatpak.__init__):
(WebkitFlatpak.setup_local_deps):
(WebkitFlatpak._merge_env_variables):
(WebkitFlatpak.run_in_sandbox):
(WebkitFlatpak.setup_dev_env):
(WebkitFlatpak.setup_gstbuild): Deleted.
* flatpak/local-projects/meson.build: Added.
* flatpak/local-projects/subprojects/gstreamer-full.wrap: Added.
* flatpak/local-projects/subprojects/libsoup.wrap: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (292389 => 292390)


--- trunk/Tools/ChangeLog	2022-04-05 10:48:43 UTC (rev 292389)
+++ trunk/Tools/ChangeLog	2022-04-05 10:55:51 UTC (rev 292390)
@@ -1,3 +1,36 @@
+2022-04-05  Philippe Normand  <pnorm...@igalia.com>
+
+        [Flatpak SDK] Local dependencies override support
+        https://bugs.webkit.org/show_bug.cgi?id=238452
+
+        Reviewed by Adrian Perez de Castro.
+
+        When the environment variable WEBKIT_SDK_LOCAL_DEPS is set at compile-time and runtime, some
+        dependencies (currently only libsoup and GStreamer) will be picked up from local git
+        checkouts located in Tools/flatpak/. If no checkout is present, one will be made based on
+        the corresponding .wrap file.
+
+        Example: WEBKIT_SDK_LOCAL_DEPS=libsoup,gstreamer-full build-webkit --wpe ...
+
+        Additional Meson options can be supplied with WEBKIT_SDK_LOCAL_DEPS_OPTIONS. Nested
+        subprojects configuration is supported as well, for example:
+
+        export WEBKIT_SDK_LOCAL_DEPS_OPTIONS="-Dgstreamer-full:introspection=disabled -Dgst-plugins-good:soup=disabled"
+
+        This setup replaces the previous one that was specific to GStreamer.
+
+        * flatpak/flatpakutils.py:
+        (WebkitFlatpak.load_from_args):
+        (WebkitFlatpak.__init__):
+        (WebkitFlatpak.setup_local_deps):
+        (WebkitFlatpak._merge_env_variables):
+        (WebkitFlatpak.run_in_sandbox):
+        (WebkitFlatpak.setup_dev_env):
+        (WebkitFlatpak.setup_gstbuild): Deleted.
+        * flatpak/local-projects/meson.build: Added.
+        * flatpak/local-projects/subprojects/gstreamer-full.wrap: Added.
+        * flatpak/local-projects/subprojects/libsoup.wrap: Added.
+
 2022-04-05  Kimmo Kinnunen  <kkinnu...@apple.com>
 
         update-angle output varies unpredictably due to blob hash abbreviation

Modified: trunk/Tools/flatpak/flatpakutils.py (292389 => 292390)


--- trunk/Tools/flatpak/flatpakutils.py	2022-04-05 10:48:43 UTC (rev 292389)
+++ trunk/Tools/flatpak/flatpakutils.py	2022-04-05 10:55:51 UTC (rev 292390)
@@ -488,9 +488,8 @@
         general.add_argument("-u", "--update", dest="update",
                              action=""
                              help="Update the SDK")
-        general.add_argument("-bgst", "--build-gst", dest="build_gst",
-                             action=""
-                             help="Force rebuilding gst-build, repository path is defined by the `GST_BUILD_PATH` environment variable.")
+        general.add_argument("-bdeps", "--build-local-deps", dest="build_local_deps",
+                             action="" help="Force rebuilding local dependencies")
         general.add_argument("-q", "--quiet", dest="quiet",
                              action=""
                              help="Do not print anything")
@@ -558,7 +557,7 @@
         self.release = False
         self.debug = False
 
-        self.build_gst = False
+        self.build_local_deps = False
 
         self.platform = "gtk"
         self.check_available = False
@@ -669,50 +668,48 @@
 
         return True
 
-
-    def setup_gstbuild(self, building):
-        gst_dir = os.environ.get('GST_BUILD_PATH')
-        if not gst_dir:
+    def setup_local_deps(self, building):
+        if not os.environ.get('WEBKIT_SDK_LOCAL_DEPS'):
             if building:
-                _log.debug("$GST_BUILD_PATH environment variable not set. Skipping gst-build\n")
+                _log.debug("$WEBKIT_SDK_LOCAL_DEPS environment variable not set. Skipping local dependencies build")
             return {}
 
-        if not os.path.exists(os.path.join(gst_dir, 'gst-env.py')):
-            raise RuntimeError('GST_BUILD_PATH set to %s but it doesn\'t seem to be a valid `gst-build` checkout.' % gst_dir)
-
-        gst_builddir = os.path.join(DEFAULT_BUILD_ROOT, 'gst-build')
-        if not os.path.exists(os.path.join(DEFAULT_BUILD_ROOT, 'gst-build', 'build.ninja')):
+        src_dir = os.path.join(WEBKIT_SOURCE_DIR, 'Tools', 'flatpak', 'local-projects')
+        build_dir = os.path.join(DEFAULT_BUILD_ROOT, 'deps-build')
+        sandbox_build_dir = convert_webkit_source_path_to_sandbox_path(build_dir)
+        if not os.path.exists(os.path.join(build_dir, 'build.ninja')):
             if not building:
-                raise RuntimeError('Trying to enter gst-build env from %s but it is not built, make sure to rebuild webkit.' % gst_dir)
+                raise RuntimeError('Trying to enter deps-build env from %s but it is not built, make sure to rebuild webkit.', src_dir)
 
-            args = ['meson', ]
-            extra_args = os.environ.get('GST_BUILD_ARGS', '')
-            args.extend(shlex.split(extra_args) + [gst_dir, gst_builddir])
-            Console.message("Running %s ", ' '.join(args))
-            self.run_in_sandbox(*args, building_gst=True, start_sccache=False)
+            projects = '-Dsubprojects=%s' % os.environ['WEBKIT_SDK_LOCAL_DEPS']
+            options = shlex.split(os.environ.get('WEBKIT_SDK_LOCAL_DEPS_OPTIONS', ''))
+            args = ['meson', projects]
+            args.extend(options + [convert_webkit_source_path_to_sandbox_path(src_dir), sandbox_build_dir])
+            self.run_in_sandbox(*args, building_local_deps=True, start_sccache=False)
 
         if building:
-            Console.message("Building `gst-build` %s ", gst_dir)
-            if self.run_in_sandbox('ninja', '-C', gst_builddir, building_gst=True, start_sccache=False) != 0:
-                raise RuntimeError('Error while building gst-build.')
+            Console.message("Building local dependencies from %s ", src_dir)
+            if self.run_in_sandbox('meson', 'compile', '-C', sandbox_build_dir, building_local_deps=True, start_sccache=False) != 0:
+                raise RuntimeError('Error while building local dependencies.')
 
-        command = [os.path.join(gst_dir, 'gst-env.py'), '--builddir', gst_builddir, '--srcdir', gst_dir, "--only-environment"]
-        gst_env = run_sanitized(command, gather_output=True)
-        allowlist = ("LD_LIBRARY_PATH", "PATH", "PKG_CONFIG_PATH")
-        nopathlist = ("GST_DEBUG", "GST_VERSION", "GST_ENV", "GST_TRACERS")
+        command = ['meson', 'devenv', '-C', sandbox_build_dir, '--dump']
+        local_env = self.run_in_sandbox(*command, building_local_deps=True, start_sccache=False, gather_output=True)
         env = {}
-        for line in [line for line in gst_env.splitlines() if not line.startswith("export")]:
+        for line in [line for line in local_env.splitlines() if not line.startswith("export")]:
             tokens = line.split("=")
             var_name, contents = tokens[0], "=".join(tokens[1:])
-            if not var_name.startswith("GST_") and var_name not in allowlist:
-                continue
-            if var_name not in nopathlist:
-                new_contents = ':'.join([convert_webkit_source_path_to_sandbox_path(p) for p in contents.split(":")])
-            else:
-                new_contents = contents.replace("'", "")
-            env[var_name] = new_contents
+            env[var_name] = contents
         return env
 
+    def _merge_env_variables(self, environment, additional_environment):
+        for var_name, value in additional_environment.items():
+            if var_name not in environment:
+                environment[var_name] = value
+            else:
+                if var_name.endswith('PATH'):
+                    environment[var_name] = "%s:%s" % (environment[var_name], value)
+        return environment
+
     def is_branch_build(self):
         try:
             with open(os.devnull, 'w') as devnull:
@@ -751,13 +748,12 @@
         extra_flatpak_args = kwargs.get("extra_flatpak_args", [])
         start_sccache = kwargs.get("start_sccache", True)
         skip_icc = kwargs.get("skip_icc", False)
-        building_gst = kwargs.get("building_gst", False)
+        building_local_deps = kwargs.get("building_local_deps", False)
         gather_output = kwargs.get("gather_output", False)
 
         if gather_output:
             start_sccache = False
             skip_icc = True
-            building_gst = False
 
         if not isinstance(args, list):
             args = list(args)
@@ -896,7 +892,7 @@
         remote_sccache_configs = set(["SCCACHE_REDIS", "SCCACHE_BUCKET", "SCCACHE_MEMCACHED",
                                       "SCCACHE_GCS_BUCKET", "SCCACHE_AZURE_CONNECTION_STRING",
                                       "WEBKIT_USE_SCCACHE"])
-        if remote_sccache_configs.intersection(set(os.environ.keys())) and start_sccache and not building_gst:
+        if remote_sccache_configs.intersection(set(os.environ.keys())) and start_sccache and not building_local_deps:
             _log.debug("Enabling network access for the remote sccache")
             flatpak_command.append(share_network_option)
 
@@ -913,7 +909,7 @@
             if building:
                 # Spawn the sccache server in background, and avoid recursing here, using a bool keyword.
                 _log.debug("Pre-starting the SCCache dist server")
-                self.run_in_sandbox("sccache", "--start-server", env=sccache_environment, building_gst=building_gst,
+                self.run_in_sandbox("sccache", "--start-server", env=sccache_environment, building_local_deps=building_local_deps,
                                     extra_flatpak_args=[share_network_option], start_sccache=False)
 
             # Forward sccache server env vars to sccache clients.
@@ -969,16 +965,11 @@
             pkg_config_path = self.build_path
         sandbox_environment["PKG_CONFIG_PATH"] = pkg_config_path
 
-        if not building_gst and args[0] != "sccache":
-            # Merge gst-build env vars in sandbox environment, without overriding previously set PATH values.
-            gst_env = self.setup_gstbuild(building)
-            for var_name in list(gst_env.keys()):
-                if var_name not in sandbox_environment:
-                    sandbox_environment[var_name] = gst_env[var_name]
-                else:
-                    contents = gst_env[var_name]
-                    if var_name.endswith('PATH'):
-                        sandbox_environment[var_name] = "%s:%s" % (sandbox_environment[var_name], contents)
+        if not building_local_deps and args[0] != "sccache":
+            # Merge local dependencies build env vars in sandbox environment, without overriding
+            # previously set PATH values.
+            local_env = self.setup_local_deps(building)
+            sandbox_environment = self._merge_env_variables(sandbox_environment, local_env)
 
         for envvar, value in sandbox_environment.items():
             flatpak_command.append("--env=%s=%s" % (envvar, value))
@@ -1218,7 +1209,7 @@
                 self.user_command.append("--cmakeargs=%s" % self.cmakeargs)
 
             return self.run_in_sandbox(*self.user_command + self.extra_command_args)
-        elif not self.update and not self.build_gst and not self.regenerate_toolchains:
+        elif not self.update and not self.build_local_deps and not self.regenerate_toolchains:
             return self.run_in_sandbox()
 
         return 0

Added: trunk/Tools/flatpak/local-projects/meson.build (0 => 292390)


--- trunk/Tools/flatpak/local-projects/meson.build	                        (rev 0)
+++ trunk/Tools/flatpak/local-projects/meson.build	2022-04-05 10:55:51 UTC (rev 292390)
@@ -0,0 +1,9 @@
+project('webkit-local-deps', 'c',
+        version : '0.1.0')
+
+foreach project_name: get_option('subprojects').split(',')
+  if project_name != ''
+    message ('Adding local subproject ' + project_name)
+    subproj = subproject(project_name, required: true)
+  endif
+endforeach

Added: trunk/Tools/flatpak/local-projects/meson_options.txt (0 => 292390)


--- trunk/Tools/flatpak/local-projects/meson_options.txt	                        (rev 0)
+++ trunk/Tools/flatpak/local-projects/meson_options.txt	2022-04-05 10:55:51 UTC (rev 292390)
@@ -0,0 +1 @@
+option('subprojects', type : 'string', value : '', description : 'Comma-separated project names')

Added: trunk/Tools/flatpak/local-projects/subprojects/gstreamer-full.wrap (0 => 292390)


--- trunk/Tools/flatpak/local-projects/subprojects/gstreamer-full.wrap	                        (rev 0)
+++ trunk/Tools/flatpak/local-projects/subprojects/gstreamer-full.wrap	2022-04-05 10:55:51 UTC (rev 292390)
@@ -0,0 +1,3 @@
+[wrap-git]
+url = ""
+revision = head

Added: trunk/Tools/flatpak/local-projects/subprojects/libsoup.wrap (0 => 292390)


--- trunk/Tools/flatpak/local-projects/subprojects/libsoup.wrap	                        (rev 0)
+++ trunk/Tools/flatpak/local-projects/subprojects/libsoup.wrap	2022-04-05 10:55:51 UTC (rev 292390)
@@ -0,0 +1,3 @@
+[wrap-git]
+url = ""
+revision = head
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to