Commit 2bca083d authored by Raoul Hidalgo Charman's avatar Raoul Hidalgo Charman
Browse files

rootcachedir: new dir option that's base to other dirs

builddir and artifactdir now give deprecation warnings.
Appropriate tests are updated to reflect new directory structure.

Part of #870
parent 528e8ed7
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ docs:
  variables:
    BST_FORCE_SESSION_REBUILD: 1
  script:
  - tree "$(INTEGRATION_CACHE)"
  - env BST_SOURCE_CACHE="$(pwd)/cache/integration-cache/sources" tox -e docs
  - mv doc/build/html public
  except:
+30 −4
Original line number Diff line number Diff line
@@ -58,12 +58,21 @@ class Context():
        # Filename indicating which configuration file was used, or None for the defaults
        self.config_origin = None

        # The directory under which other directories are based
        self.rootcachedir = None

        # The directory where various sources are stored
        self.sourcedir = None

        # The directory where build sandboxes will be created
        self.builddir = None

        # The directory for CAS
        self.casdir = None

        # The directory for temporary files
        self.tmpdir = None

        # Default root location for workspaces
        self.workspacedir = None

@@ -188,13 +197,30 @@ class Context():
            user_config = _yaml.load(config)
            _yaml.composite(defaults, user_config)

        # Give deprecation warnings
        if defaults.get('builddir'):
            print("builddir is deprecated, use rootcachedir")
        else:
            defaults['builddir'] = os.path.join(defaults['rootcachedir'], 'build')

        if defaults.get('artifactdir'):
            print("artifactdir is deprecated, use rootcachedir")
        else:
            defaults['artifactdir'] = os.path.join(defaults['rootcachedir'], 'artifacts')

        _yaml.node_validate(defaults, [
            'sourcedir', 'builddir', 'artifactdir', 'logdir',
            'rootcachedir', 'sourcedir', 'builddir', 'artifactdir', 'logdir',
            'scheduler', 'artifacts', 'logging', 'projects',
            'cache', 'prompt', 'workspacedir', 'remote-execution'
            'cache', 'prompt', 'workspacedir', 'remote-execution',
        ])

        for directory in ['sourcedir', 'builddir', 'artifactdir', 'logdir', 'workspacedir']:
        # add directories not set by users
        defaults['tmpdir'] = os.path.join(defaults['rootcachedir'], 'tmp')
        defaults['casdir'] = os.path.join(defaults['rootcachedir'], 'cas')

        for directory in ['rootcachedir', 'sourcedir', 'builddir',
                          'artifactdir', 'logdir', 'workspacedir', 'casdir',
                          'tmpdir']:
            # Allow the ~ tilde expansion and any environment variables in
            # path specification in the config files.
            #
@@ -654,7 +680,7 @@ class Context():

    def get_cascache(self):
        if self._cascache is None:
            self._cascache = CASCache(self.artifactdir)
            self._cascache = CASCache(self.rootcachedir)
        return self._cascache

    # guess_element()
+2 −5
Original line number Diff line number Diff line
@@ -13,11 +13,8 @@
# Location to store sources
sourcedir: ${XDG_CACHE_HOME}/buildstream/sources

# Location to perform builds
builddir: ${XDG_CACHE_HOME}/buildstream/build

# Location to store local binary artifacts
artifactdir: ${XDG_CACHE_HOME}/buildstream/artifacts
# Root location for other directories in the cache
rootcachedir: ${XDG_CACHE_HOME}/buildstream

# Location to store build logs
logdir: ${XDG_CACHE_HOME}/buildstream/logs
+7 −3
Original line number Diff line number Diff line
@@ -53,15 +53,15 @@ def pytest_runtest_setup(item):
class IntegrationCache():

    def __init__(self, cache):
        cache = os.path.abspath(cache)
        self.root = os.path.abspath(cache)

        # Use the same sources every time
        self.sources = os.path.join(cache, 'sources')
        self.sources = os.path.join(self.root, 'sources')

        # Create a temp directory for the duration of the test for
        # the artifacts directory
        try:
            self.artifacts = tempfile.mkdtemp(dir=cache, prefix='artifacts-')
            self.artifacts = tempfile.mkdtemp(dir=self.root, prefix='artifacts-')
        except OSError as e:
            raise AssertionError("Unable to create test directory !") from e

@@ -86,6 +86,10 @@ def integration_cache(request):
        shutil.rmtree(cache.artifacts)
    except FileNotFoundError:
        pass
    try:
        shutil.rmtree(os.path.join(cache.root, 'cas'))
    except FileNotFoundError:
        pass


#################################################
+1 −1
Original line number Diff line number Diff line
@@ -403,7 +403,7 @@ def test_extract_expiry(cli, datafiles, tmpdir):
    # Now we should have a directory for the cached target2.bst, which
    # replaced target.bst in the cache, we should not have a directory
    # for the target.bst
    refsdir = os.path.join(project, 'cache', 'artifacts', 'cas', 'refs', 'heads')
    refsdir = os.path.join(project, 'cache', 'cas', 'refs', 'heads')
    refsdirtest = os.path.join(refsdir, 'test')
    refsdirtarget = os.path.join(refsdirtest, 'target')
    refsdirtarget2 = os.path.join(refsdirtest, 'target2')
Loading