aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/bootstrapper/bootstrap.py
blob: 4cd1fc7bc5c71f19199d6eeb5e55d3d5eedbc4a3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

from __future__ import print_function

import sys

from windows_gnu import WindowsGnuBootstrapper
from windows_msvc import WindowsMsvcBootstrapper


class Bootstrapper(object):
    """Main class that performs system bootstrap."""

    def __init__(self, context):
        self.instance = None
        cls = None
        args = {}

        if sys.platform.startswith('msys'):
            cls = WindowsGnuBootstrapper

        elif sys.platform.startswith('win32'):
            cls = WindowsMsvcBootstrapper

        if cls is None:
            sys.exit('Bootstrap support is not yet available for your OS.')

        self.instance = cls(**args)
        self.instance.context = context

    def bootstrap(self, interactive=False, force=False):
        self.instance.interactive = interactive
        self.instance.force = force

        if force:
            self.instance.install_system_packages()
        else:
            self.instance.ensure_system_packages()