Prevent extraction of objects from subprojects.

pull/155/head
Jussi Pakkanen 10 years ago
parent 83aa2262e3
commit ec74616bbd
  1. 13
      interpreter.py
  2. 4
      test cases/failing/16 extract object subdir/meson.build
  3. 3
      test cases/failing/16 extract object subdir/src/first/lib_first.c
  4. 1
      test cases/failing/16 extract object subdir/src/first/meson.build
  5. 1
      test cases/failing/16 extract object subdir/src/meson.build
  6. 5
      test cases/failing/16 extract object subdir/tst/first/exe_first.c
  7. 4
      test cases/failing/16 extract object subdir/tst/first/meson.build
  8. 1
      test cases/failing/16 extract object subdir/tst/meson.build

@ -1650,7 +1650,7 @@ class Interpreter():
elif targetholder is JarHolder:
targetclass = build.Jar
else:
print(targetholder)
mlog.debug('Unknown target type:', str(targetholder))
raise RuntimeError('Unreachable code')
target = targetclass(name, self.subdir, is_cross, sources, objs, self.environment, kwargs)
l = targetholder(target)
@ -1770,8 +1770,19 @@ class Interpreter():
if not isinstance(obj, InterpreterObject):
raise InvalidArguments('Variable "%s" is not callable.' % object_name)
(args, kwargs) = self.reduce_arguments(args)
if method_name == 'extract_objects':
self.validate_extraction(obj.held_object)
return obj.method_call(method_name, args, kwargs)
def validate_extraction(self, buildtarget):
if self.subproject_dir == '':
if buildtarget.subdir.startswith(self.subproject_dir):
raise InterpreterException('Tried to extract objects from a subproject target.')
else:
lead = '/'.join(self.subdir.split('/')[0:2])
if not buildtarget.subdir.startswith(lead):
raise InterpreterException('Tried to extract objects from a different subproject target.')
def array_method_call(self, obj, method_name, args):
if method_name == 'contains':
return self.check_contains(obj, args)

@ -0,0 +1,4 @@
project('Extract objects from subdirs.', 'c')
subdir('src')
subdir('tst')

@ -0,0 +1 @@
first_lib = shared_library('first_lib', 'lib_first.c')

@ -0,0 +1,5 @@
int first(void);
int main() {
return first() - 1001;
}

@ -0,0 +1,4 @@
first_exe = executable('first_exe', 'exe_first.c',
objects : first_lib.extract_objects('lib_first.c'))
test('first_test', first_exe)
Loading…
Cancel
Save