From ff51f2196f39da034151b54da3088c0d70ae4eee Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Thu, 21 May 2015 22:31:10 +0300 Subject: [PATCH] Make extract_objects work with subdirectories. --- backends.py | 7 ++++--- test cases/common/25 object extraction/meson.build | 7 ++++--- test cases/common/25 object extraction/src/lib.c | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 test cases/common/25 object extraction/src/lib.c diff --git a/backends.py b/backends.py index e3468982c..88f144dc8 100644 --- a/backends.py +++ b/backends.py @@ -167,11 +167,12 @@ class Backend(): targetdir = self.get_target_private_dir(extobj.target) suffix = '.' + self.environment.get_object_suffix() for osrc in extobj.srclist: - osrc = osrc.fname + osrc_base = osrc.fname if not self.source_suffix_in_objs: - osrc = '.'.join(osrc.split('.')[:-1]) + osrc_base = '.'.join(osrc.split('.')[:-1]) + objbase = os.path.join(osrc.subdir, osrc.fname).replace('/', '_').replace('\\', '_') objname = os.path.join(proj_dir_to_build_root, - targetdir, os.path.basename(osrc) + suffix) + targetdir, os.path.basename(objbase) + suffix) result.append(objname) return result diff --git a/test cases/common/25 object extraction/meson.build b/test cases/common/25 object extraction/meson.build index 0a17c6006..7c5ab900b 100644 --- a/test cases/common/25 object extraction/meson.build +++ b/test cases/common/25 object extraction/meson.build @@ -3,10 +3,11 @@ project('object extraction', 'c') if meson.is_unity() message('Skipping extraction test because this is a Unity build.') else - lib = shared_library('somelib', 'lib.c') + lib1 = shared_library('somelib', 'src/lib.c') + lib2 = shared_library('somelib2', 'lib.c') - obj1 = lib.extract_objects('lib.c') - obj2 = lib.extract_objects(['lib.c']) + obj1 = lib1.extract_objects('src/lib.c') + obj2 = lib2.extract_objects(['lib.c']) e1 = executable('main 1', 'main.c', objects : obj1) e2 = executable('main 2', 'main.c', objects : obj2) diff --git a/test cases/common/25 object extraction/src/lib.c b/test cases/common/25 object extraction/src/lib.c new file mode 100644 index 000000000..652f4eb13 --- /dev/null +++ b/test cases/common/25 object extraction/src/lib.c @@ -0,0 +1,3 @@ +int func() { + return 42; +}