Commit 12920046 authored by Jim MacArthur's avatar Jim MacArthur
Browse files

Merge branch 'jmac/cas_virtual_directory' into 'master'

CAS-backed virtual directory implementation

See merge request !481
parents 00762442 136deb2e
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ if "_BST_COMPLETION" not in os.environ:
    from .sandbox import Sandbox, SandboxFlags
    from .plugin import Plugin
    from .source import Source, SourceError, Consistency, SourceFetcher
    from .element import Element, ElementError, Scope
    from .element import Element, ElementError
    from .element_enums import Scope
    from .buildelement import BuildElement
    from .scriptelement import ScriptElement
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import os
import string
from collections import Mapping, namedtuple

from ..element import _KeyStrength
from ..element_enums import _KeyStrength
from .._exceptions import ArtifactError, ImplError, LoadError, LoadErrorReason
from .._message import Message, MessageType
from .. import utils
+3 −36
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@ import stat
import copy
from collections import Mapping, OrderedDict
from contextlib import contextmanager
from enum import Enum
import tempfile
import shutil

@@ -98,41 +97,9 @@ from .plugin import CoreWarnings
from .sandbox._config import SandboxConfig

from .storage.directory import Directory
from .storage._filebaseddirectory import FileBasedDirectory, VirtualDirectoryError


# _KeyStrength():
#
# Strength of cache key
#
class _KeyStrength(Enum):

    # Includes strong cache keys of all build dependencies and their
    # runtime dependencies.
    STRONG = 1

    # Includes names of direct build dependencies but does not include
    # cache keys of dependencies.
    WEAK = 2


class Scope(Enum):
    """Types of scope for a given element"""

    ALL = 1
    """All elements which the given element depends on, following
    all elements required for building. Including the element itself.
    """

    BUILD = 2
    """All elements required for building the element, including their
    respective run dependencies. Not including the given element itself.
    """

    RUN = 3
    """All elements required for running the element. Including the element
    itself.
    """
from .storage._filebaseddirectory import FileBasedDirectory
from .storage.directory import VirtualDirectoryError
from .element_enums import _KeyStrength, Scope


class ElementError(BstError):
+61 −0
Original line number Diff line number Diff line
#
#  Copyright (C) 2018 Bloomberg LP
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
#
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library. If not, see <http://www.gnu.org/licenses/>.
#
#  Authors:
#        Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
#        Jim MacArthur <jim.macarthur@codethink.co.uk>

"""
Element - Globally visible enumerations
=======================================

"""

from enum import Enum


# _KeyStrength():
#
# Strength of cache key
#
class _KeyStrength(Enum):

    # Includes strong cache keys of all build dependencies and their
    # runtime dependencies.
    STRONG = 1

    # Includes names of direct build dependencies but does not include
    # cache keys of dependencies.
    WEAK = 2


class Scope(Enum):
    """Types of scope for a given element"""

    ALL = 1
    """All elements which the given element depends on, following
    all elements required for building. Including the element itself.
    """

    BUILD = 2
    """All elements required for building the element, including their
    respective run dependencies. Not including the given element itself.
    """

    RUN = 3
    """All elements required for running the element. Including the element
    itself.
    """
+4 −2
Original line number Diff line number Diff line
@@ -32,8 +32,10 @@ from .._fuse import SafeHardlinks
class Mount():
    def __init__(self, sandbox, mount_point, safe_hardlinks):
        scratch_directory = sandbox._get_scratch_directory()
        # Getting external_directory here is acceptable as we're part of the sandbox code.
        root_directory = sandbox.get_virtual_directory().external_directory
        # Getting _get_underlying_directory() here is acceptable as
        # we're part of the sandbox code. This will fail if our
        # directory is CAS-based.
        root_directory = sandbox.get_virtual_directory()._get_underlying_directory()

        self.mount_point = mount_point
        self.safe_hardlinks = safe_hardlinks
Loading