aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/build.py
diff options
context:
space:
mode:
authorAleksey Filippov <alekseyf@google.com>2018-03-13 17:56:33 +0000
committerAleksey Filippov <alekseyf@google.com>2018-04-16 22:51:34 +0100
commitcb761718f0fad4a6ee6396149d03c5b6b1586f44 (patch)
treedfbdf4729c9d25b5f1128e7b6a7812d230a3d4c5 /mesonbuild/build.py
parentc58dd64f8e947f4659bcbc47d75e86e65043e714 (diff)
downloadmeson-cb761718f0fad4a6ee6396149d03c5b6b1586f44.zip
meson-cb761718f0fad4a6ee6396149d03c5b6b1586f44.tar.gz
meson-cb761718f0fad4a6ee6396149d03c5b6b1586f44.tar.bz2
Generate target id based on subdirectory instead of subproject
Allows creation of targets with same name in different subdirectories. Closes #2861 and closes #1867
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r--mesonbuild/build.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 47c40a2..e707053 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -310,11 +310,16 @@ a hard error in the future.''' % name)
def get_id(self):
# This ID must also be a valid file name on all OSs.
# It should also avoid shell metacharacters for obvious
- # reasons.
- base = self.name + self.type_suffix()
- if self.subproject == '':
- return base
- return self.subproject + '@@' + base
+ # reasons. '@' is not used as often as '_' in source code names.
+ # In case of collisions consider using checksums.
+ # FIXME replace with assert when slash in names is prohibited
+ name_part = self.name.replace('/', '@').replace('\\', '@')
+ assert not has_path_sep(self.type_suffix())
+ myid = name_part + self.type_suffix()
+ if self.subdir:
+ subdir_part = self.subdir.replace('/', '@').replace('\\', '@')
+ myid = subdir_part + '@@' + myid
+ return myid
def process_kwargs(self, kwargs):
if 'build_by_default' in kwargs: