Changeset 261607 in webkit


Ignore:
Timestamp:
May 13, 2020 1:57:55 AM (4 years ago)
Author:
Philippe Normand
Message:

[Flatpak SDK] Craft a custom sccache config file from SDK toolchains
https://bugs.webkit.org/show_bug.cgi?id=211781

Reviewed by Carlos Alberto Lopez Perez.

Optionally generate a sccache config file and use it when building WebKit.

  • Scripts/webkitpy/thirdparty/init.py:

(AutoinstallImportHook.find_module):
(AutoinstallImportHook._install_toml):

  • flatpak/flatpakutils.py:

(WebkitFlatpak.load_from_args):
(WebkitFlatpak.init):
(WebkitFlatpak.clean_args):
(WebkitFlatpak.host_path_to_sandbox_path):
(WebkitFlatpak.run_in_sandbox):
(WebkitFlatpak.main):
(WebkitFlatpak.save_config):
(WebkitFlatpak):
(WebkitFlatpak.pack_toolchain):
(WebkitFlatpak.setup_icecc): Deleted.

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r261605 r261607  
     12020-05-13  Philippe Normand  <pnormand@igalia.com>
     2
     3        [Flatpak SDK] Craft a custom sccache config file from SDK toolchains
     4        https://bugs.webkit.org/show_bug.cgi?id=211781
     5
     6        Reviewed by Carlos Alberto Lopez Perez.
     7
     8        Optionally generate a sccache config file and use it when building WebKit.
     9
     10        * Scripts/webkitpy/thirdparty/__init__.py:
     11        (AutoinstallImportHook.find_module):
     12        (AutoinstallImportHook._install_toml):
     13        * flatpak/flatpakutils.py:
     14        (WebkitFlatpak.load_from_args):
     15        (WebkitFlatpak.__init__):
     16        (WebkitFlatpak.clean_args):
     17        (WebkitFlatpak.host_path_to_sandbox_path):
     18        (WebkitFlatpak.run_in_sandbox):
     19        (WebkitFlatpak.main):
     20        (WebkitFlatpak.save_config):
     21        (WebkitFlatpak):
     22        (WebkitFlatpak.pack_toolchain):
     23        (WebkitFlatpak.setup_icecc): Deleted.
     24
    1252020-05-13  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
    226
  • trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py

    r260657 r261607  
    129129        elif '.html5lib' in fullname:
    130130            self._install_html5lib()
     131        elif '.toml' in fullname:
     132            self._install_toml()
    131133
    132134    def _install_six(self):
     
    324326            self.install_binary(full_firefox_url, 'geckodriver')
    325327
     328    def _install_toml(self):
     329        toml_dir = self._fs.join(_AUTOINSTALLED_DIR, "toml")
     330        installer = AutoInstaller(prepend_to_search_path=True, target_dir=toml_dir)
     331        installer.install(url="https://files.pythonhosted.org/packages/b9/19/5cbd78eac8b1783671c40e34bb0fa83133a06d340a38b55c645076d40094/toml-0.10.0.tar.gz", url_subpath="toml-0.10.0/toml")
     332
    326333    def _install(self, url, url_subpath=None, target_name=None):
    327334        installer = AutoInstaller(target_dir=_AUTOINSTALLED_DIR)
  • trunk/Tools/flatpak/flatpakutils.py

    r261605 r261607  
    3838from webkitpy.port.factory import PortFactory
    3939from webkitpy.common.system.logutils import configure_logging
     40import webkitpy.thirdparty.autoinstalled.toml
     41import toml
    4042
    4143try:
     
    418420                             dest="user_command")
    419421        general.add_argument('--available', action='store_true', dest="check_available", help='Check if required dependencies are available.'),
    420         general.add_argument("--use-icecream", dest="use_icecream", help="Use the distributed icecream (icecc) compiler.", action="store_true")
    421         general.add_argument("-r", "--regenerate-toolchains", dest="regenerate_toolchains", action="store_true",
     422        general.add_argument("--repo", help="Filesystem absolute path to the Flatpak repository to use", dest="user_repo")
     423
     424        distributed_build_options = parser.add_argument_group("Distributed building")
     425        distributed_build_options.add_argument("--use-icecream", dest="use_icecream", help="Use the distributed icecream (icecc) compiler.", action="store_true")
     426        distributed_build_options.add_argument("-r", "--regenerate-toolchains", dest="regenerate_toolchains", action="store_true",
    422427                             help="Regenerate IceCC distribuable toolchain archives")
    423         general.add_argument("--repo", help="Filesystem absolute path to the Flatpak repository to use", dest="user_repo")
     428        distributed_build_options.add_argument("-t", "--sccache-token", dest="sccache_token",
     429                                               help="sccache authentication token")
     430        distributed_build_options.add_argument("-s", "--sccache-scheduler", dest="sccache_scheduler", default='https://sccache.igalia.com',
     431                                               help="sccache scheduler URL")
    424432
    425433        debugoptions = parser.add_argument_group("Debugging")
     
    476484        self.icc_version = {}
    477485        self.regenerate_toolchains = False
     486        self.sccache_token = ""
     487        self.sccache_scheduler = ""
    478488
    479489    def execute_command(self, args, stdout=None, stderr=None):
     
    521531        self.build_path = os.path.join(self.build_root, self.platform, self.build_type)
    522532        self.config_file = os.path.join(self.flatpak_build_path, 'webkit_flatpak_config.json')
     533        self.sccache_config_file = os.path.join(self.flatpak_build_path, 'sccache.toml')
    523534
    524535        Console.quiet = self.quiet
     
    607618                return True
    608619        return False
     620
     621    def host_path_to_sandbox_path(self, host_path):
     622        # For now this supports only files in the WebKit path
     623        return host_path.replace(self.source_root, self.sandbox_source_root)
    609624
    610625    def run_in_sandbox(self, *args, **kwargs):
     
    769784            flatpak_command.append(share_network_option)
    770785
     786            if os.path.isfile(self.sccache_config_file) and not self.regenerate_toolchains and "SCCACHE_CONF" not in os.environ.keys():
     787                sandbox_environment["SCCACHE_CONF"] = self.host_path_to_sandbox_path(self.sccache_config_file)
     788
    771789        override_sccache_server_port = os.environ.get("WEBKIT_SCCACHE_SERVER_PORT")
    772790        if override_sccache_server_port:
     
    837855        if regenerate_toolchains:
    838856            self.icc_version = {}
    839             self.setup_icecc("gcc", "g++")
    840             self.setup_icecc("clang", "clang++")
    841             self.save_config()
     857            toolchains = self.pack_toolchain(("gcc", "g++"), {"/usr/bin/c++": "/usr/bin/g++"})
     858            toolchains.extend(self.pack_toolchain(("clang", "clang++"), {"/usr/bin/clang++": "/usr/bin/clang++"}))
     859            self.save_config(toolchains)
    842860
    843861        return self.setup_dev_env()
     
    855873        return os.path.exists(self.flatpak_build_path)
    856874
    857     def save_config(self):
     875    def save_config(self, toolchains):
    858876        with open(self.config_file, 'w') as config:
    859877            json_config = {'icecc_version': self.icc_version}
    860878            json.dump(json_config, config)
    861879
    862     def setup_icecc(self, *compilers):
     880        if not self.sccache_token:
     881            Console.message("No authentication token provided. Re-run this with the -t option if an sccache token was provided to you. Skipping sccache configuration for now.")
     882            return
     883
     884        with open(self.sccache_config_file, 'w') as config:
     885            sccache_config = {'dist': {'scheduler_url': self.sccache_scheduler,
     886                                       'auth': {'type': 'token',
     887                                                'token': self.sccache_token},
     888                                       'toolchains': toolchains}}
     889            toml.dump(sccache_config, config)
     890            Console.message("Created %s sccache config file. It will automatically be used when building WebKit", self.sccache_config_file)
     891
     892    def pack_toolchain(self, compilers, path_mapping):
    863893        with tempfile.NamedTemporaryFile() as tmpfile:
    864894            command = ['icecc', '--build-native']
     
    876906            Console.message("Created %s self-contained toolchain archive", archive_filename)
    877907
     908            sccache_toolchains = []
     909            for (compiler_executable, archive_compiler_executable) in path_mapping.iteritems():
     910                item = {'type': 'path_override',
     911                        'compiler_executable': compiler_executable,
     912                        'archive': archive_filename,
     913                        'archive_compiler_executable': archive_compiler_executable}
     914                sccache_toolchains.append(item)
     915            return sccache_toolchains
     916
    878917    def setup_dev_env(self):
    879918        if not os.path.exists(os.path.join(self.flatpak_build_path, "runtime", "org.webkit.Sdk")) or self.update:
Note: See TracChangeset for help on using the changeset viewer.