diff options
author | finnball <finn.ball@codethink.com> | 2018-05-14 11:33:35 +0100 |
---|---|---|
committer | finnball <finn.ball@codethink.com> | 2018-05-14 14:10:38 +0100 |
commit | aa0964bc061388b6404bab40d1fbc84de5b010ec (patch) | |
tree | 7d6119a26f3b54fbfc74c8aea038809dda351d13 | |
parent | b9dea6663be401c5afe8494332328509b9425098 (diff) | |
download | buildstream-kill_element_normal_name.tar.gz |
Removed element.normal_name.kill_element_normal_name
This fixes issue #288.
-rw-r--r-- | buildstream/_artifactcache/artifactcache.py | 5 | ||||
-rw-r--r-- | buildstream/_artifactcache/ostreecache.py | 2 | ||||
-rw-r--r-- | buildstream/_artifactcache/tarcache.py | 6 | ||||
-rw-r--r-- | buildstream/_loader/loader.py | 2 | ||||
-rw-r--r-- | buildstream/_stream.py | 10 | ||||
-rw-r--r-- | buildstream/element.py | 24 | ||||
-rw-r--r-- | buildstream/plugins/elements/import.py | 2 |
7 files changed, 24 insertions, 27 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py index 9cc281524..ae7d23e48 100644 --- a/buildstream/_artifactcache/artifactcache.py +++ b/buildstream/_artifactcache/artifactcache.py @@ -97,9 +97,12 @@ class ArtifactCache(): valid_chars = string.digits + string.ascii_letters + '-._' element_name = ''.join([ x if x in valid_chars else '_' - for x in element.normal_name + for x in element.name ]) + if element_name.endswith('.bst'): + element_name = element_name[:-4] + assert key is not None # assume project and element names are not allowed to contain slashes diff --git a/buildstream/_artifactcache/ostreecache.py b/buildstream/_artifactcache/ostreecache.py index c802fc2e2..3424c7b14 100644 --- a/buildstream/_artifactcache/ostreecache.py +++ b/buildstream/_artifactcache/ostreecache.py @@ -100,7 +100,7 @@ class OSTreeCache(ArtifactCache): # Extracting a nonexistent artifact is a bug assert rev, "Artifact missing for {}".format(ref) - dest = os.path.join(self.extractdir, element._get_project().name, element.normal_name, rev) + dest = os.path.join(self.extractdir, element._get_project().name, element.name, rev) if os.path.isdir(dest): # artifact has already been extracted return dest diff --git a/buildstream/_artifactcache/tarcache.py b/buildstream/_artifactcache/tarcache.py index 10ae9d008..3b8f0243b 100644 --- a/buildstream/_artifactcache/tarcache.py +++ b/buildstream/_artifactcache/tarcache.py @@ -46,7 +46,7 @@ class TarCache(ArtifactCache): return os.path.isfile(path) def commit(self, element, content, keys): - os.makedirs(os.path.join(self.tardir, element._get_project().name, element.normal_name), exist_ok=True) + os.makedirs(os.path.join(self.tardir, element._get_project().name, element.name), exist_ok=True) with utils._tempdir() as temp: for key in keys: @@ -75,7 +75,7 @@ class TarCache(ArtifactCache): with utils._tempdir(dir=self.extractdir) as tmpdir: _Tar.extract(os.path.join(self.tardir, path), tmpdir) - os.makedirs(os.path.join(self.extractdir, element._get_project().name, element.normal_name), + os.makedirs(os.path.join(self.extractdir, element._get_project().name, element.name), exist_ok=True) try: os.rename(os.path.join(tmpdir, key), dest) @@ -105,7 +105,7 @@ class TarCache(ArtifactCache): # def _tarpath(element, key): project = element._get_project() - return os.path.join(project.name, element.normal_name, key + '.tar.bz2') + return os.path.join(project.name, element.name, key + '.tar.bz2') # A helper class that contains tar archive/extract functions diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py index e0ceb4fb9..25839390f 100644 --- a/buildstream/_loader/loader.py +++ b/buildstream/_loader/loader.py @@ -497,7 +497,7 @@ class Loader(): # Stage sources os.makedirs(self._context.builddir, exist_ok=True) - basedir = tempfile.mkdtemp(prefix="{}-".format(element.normal_name), dir=self._context.builddir) + basedir = tempfile.mkdtemp(prefix="{}-".format(element.name), dir=self._context.builddir) element._stage_sources_at(basedir, mount_workspaces=False) # Load the project diff --git a/buildstream/_stream.py b/buildstream/_stream.py index cdef69094..0142c10a3 100644 --- a/buildstream/_stream.py +++ b/buildstream/_stream.py @@ -617,7 +617,7 @@ class Stream(): self._message(MessageType.INFO, "Bundling sources for target {}".format(target.name)) # Find the correct filename for the compression algorithm - tar_location = os.path.join(directory, target.normal_name + ".tar") + tar_location = os.path.join(directory, target.name + ".tar") if compression != "none": tar_location += "." + compression @@ -641,7 +641,7 @@ class Stream(): # Create a temporary directory to build the source tree in builddir = self._context.builddir - prefix = "{}-".format(target.normal_name) + prefix = "{}-".format(target.name) with TemporaryDirectory(prefix=prefix, dir=builddir) as tempdir: source_directory = os.path.join(tempdir, 'source') @@ -661,7 +661,7 @@ class Stream(): self._write_element_sources(tempdir, elements) self._write_build_script(tempdir, elements) self._collect_sources(tempdir, tar_location, - target.normal_name, compression) + target.name, compression) ############################################################# # Scheduler API forwarding # @@ -958,7 +958,7 @@ class Stream(): def _write_element_sources(self, directory, elements): for element in elements: source_dir = os.path.join(directory, "source") - element_source_dir = os.path.join(source_dir, element.normal_name) + element_source_dir = os.path.join(source_dir, element.name) element._stage_sources_at(element_source_dir) @@ -967,7 +967,7 @@ class Stream(): module_string = "" for element in elements: - module_string += shlex.quote(element.normal_name) + " " + module_string += shlex.quote(element.name) + " " script_path = os.path.join(directory, "build.sh") diff --git a/buildstream/element.py b/buildstream/element.py index 70bee42e6..9d9c94033 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -196,14 +196,6 @@ class Element(Plugin): super().__init__(meta.name, context, project, meta.provenance, "element") - self.normal_name = os.path.splitext(self.name.replace(os.sep, '-'))[0] - """A normalized element name - - This is the original element without path separators or - the extension, it's used mainly for composing log file names - and creating directory names and such. - """ - self.__runtime_dependencies = [] # Direct runtime dependency Elements self.__build_dependencies = [] # Direct build dependency Elements self.__sources = [] # List of Sources @@ -348,7 +340,7 @@ class Element(Plugin): generated script is run: - All element variables have been exported. - - The cwd is `self.get_variable('build_root')/self.normal_name`. + - The cwd is `self.get_variable('build_root')/self.name`. - $PREFIX is set to `self.get_variable('install_root')`. - The directory indicated by $PREFIX is an empty directory. @@ -1419,7 +1411,7 @@ class Element(Plugin): # Explicitly clean it up, keep the build dir around if exceptions are raised os.makedirs(context.builddir, exist_ok=True) - rootdir = tempfile.mkdtemp(prefix="{}-".format(self.normal_name), dir=context.builddir) + rootdir = tempfile.mkdtemp(prefix="{}-".format(self.name), dir=context.builddir) # Cleanup the build directory on explicit SIGTERM def cleanup_rootdir(): @@ -1750,7 +1742,7 @@ class Element(Plugin): # os.makedirs(context.builddir, exist_ok=True) with utils._tempdir(dir=context.builddir, prefix='workspace-{}' - .format(self.normal_name)) as temp: + .format(self.name)) as temp: for source in self.sources(): source._init_workspace(temp) @@ -1778,7 +1770,7 @@ class Element(Plugin): variable_string += "{0}={1} ".format(var, val) script = script_template.format( - name=self.normal_name, + name=self.name, build_root=self.get_variable('build-root'), install_root=self.get_variable('install-root'), variables=variable_string, @@ -1786,7 +1778,7 @@ class Element(Plugin): ) os.makedirs(directory, exist_ok=True) - script_path = os.path.join(directory, "build-" + self.normal_name) + script_path = os.path.join(directory, "build-" + self.name) with self.timed_activity("Writing build script", silent_nested=True): with utils.save_file_atomic(script_path, "w") as script_file: @@ -2002,7 +1994,9 @@ class Element(Plugin): logfile = "{key}-{action}.{pid}.log".format( key=key, action=action, pid=pid) - directory = os.path.join(context.logdir, project.name, self.normal_name) + element_name = (self.name[:-4] if self.name.endswith('.bst') else self.name) + '.log' + + directory = os.path.join(context.logdir, project.name, element_name) os.makedirs(directory, exist_ok=True) return os.path.join(directory, logfile) @@ -2073,7 +2067,7 @@ class Element(Plugin): else: os.makedirs(context.builddir, exist_ok=True) - rootdir = tempfile.mkdtemp(prefix="{}-".format(self.normal_name), dir=context.builddir) + rootdir = tempfile.mkdtemp(prefix="{}-".format(self.name), dir=context.builddir) # Recursive contextmanager... with self.__sandbox(rootdir, stdout=stdout, stderr=stderr, config=config) as sandbox: diff --git a/buildstream/plugins/elements/import.py b/buildstream/plugins/elements/import.py index 747455d70..72a7390a9 100644 --- a/buildstream/plugins/elements/import.py +++ b/buildstream/plugins/elements/import.py @@ -103,7 +103,7 @@ class ImportElement(BuildElement): commands = [] # The directory to grab - inputdir = os.path.join(build_root, self.normal_name, self.source.lstrip(os.sep)) + inputdir = os.path.join(build_root, self.name, self.source.lstrip(os.sep)) inputdir = inputdir.rstrip(os.sep) # The output target directory |