Commit 37eb4fbf 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.

WIP not all tests pass, and I've removed artifacts from the integration cache
which may or may not be sensible.

Part of #870
parent d212cdfa
Loading
Loading
Loading
Loading
Loading
+32 −6
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.insert(0, 'tmpdir', os.path.join(defaults['rootcachedir'], 'tmp'))
        defaults.insert(0, '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.
            #
@@ -290,7 +316,7 @@ class Context():
        return self._artifactcache

    # add_project():
    #

    # Add a project to the context.
    #
    # Args:
@@ -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()
+1 −0
Original line number Diff line number Diff line
@@ -227,6 +227,7 @@ class App():
                click.echo("", err=True)
                click.echo("    bst init", err=True)

            traceback.print_tb(sys.exc_info()[2])
            self._error_exit(e, "Error loading project")

        except BstError as e:
+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
+8 −8
Original line number Diff line number Diff line
@@ -60,10 +60,10 @@ class IntegrationCache():

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


@pytest.fixture(scope='session')
@@ -82,10 +82,10 @@ def integration_cache(request):

    # Clean up the artifacts after each test run - we only want to
    # cache sources between runs
    try:
        shutil.rmtree(cache.artifacts)
    except FileNotFoundError:
        pass
    # try:
    #     shutil.rmtree(cache.artifacts)
    # except FileNotFoundError:
    #     pass


#################################################
+2 −2
Original line number Diff line number Diff line
@@ -68,8 +68,8 @@ def test_push_pull(cli, tmpdir, datafiles):
        # Now we've pushed, delete the user's local artifact cache
        # directory and try to redownload it from the share
        #
        artifacts = os.path.join(cli.directory, 'artifacts')
        shutil.rmtree(artifacts)
        cas = os.path.join(cli.directory, 'cas')
        shutil.rmtree(cas)

        # Assert that nothing is cached locally anymore
        state = cli.get_element_state(project, 'target.bst')
Loading