From cb761718f0fad4a6ee6396149d03c5b6b1586f44 Mon Sep 17 00:00:00 2001 From: Aleksey Filippov Date: Tue, 13 Mar 2018 17:56:33 +0000 Subject: Generate target id based on subdirectory instead of subproject Allows creation of targets with same name in different subdirectories. Closes #2861 and closes #1867 --- mesonbuild/build.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'mesonbuild/build.py') 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: -- cgit v1.1