fix all subproject using wrap-file broken

subproject using wrap-file is broken since commit (68bd64c Prevent
projects from directly grabbing files from other subprojects. )

subproject with wrap-file usually have version number after name

- **sproj_name** is `zlib-1.2.8` according to `directory = zlib-1.2.8`
of zlib.wrap
- but **self.subproject** `zlib`
pull/2497/head
liugang 7 years ago committed by Jussi Pakkanen
parent 3f18e3b89f
commit 36d85db5d4
  1. 6
      mesonbuild/interpreter.py
  2. 3
      test cases/common/162 wrap file should not failed/meson.build
  3. 1
      test cases/common/162 wrap file should not failed/subprojects/packagecache/zlib-1.2.8-8-wrap.zip
  4. 1
      test cases/common/162 wrap file should not failed/subprojects/packagecache/zlib-1.2.8.tar.gz
  5. 0
      test cases/common/162 wrap file should not failed/subprojects/zlib-1.2.8/foo.c
  6. 2
      test cases/common/162 wrap file should not failed/subprojects/zlib-1.2.8/meson.build
  7. 10
      test cases/common/162 wrap file should not failed/subprojects/zlib.wrap

@ -1373,6 +1373,9 @@ class Interpreter(InterpreterBase):
self.coredata = self.environment.get_coredata() self.coredata = self.environment.get_coredata()
self.backend = backend self.backend = backend
self.subproject = subproject self.subproject = subproject
# Subproject directory is usually the name of the subproject, but can
# be different for dependencies provided by wrap files.
self.subproject_directory_name = subdir.split(os.path.sep)[-1]
self.subproject_dir = subproject_dir self.subproject_dir = subproject_dir
self.option_file = os.path.join(self.source_root, self.subdir, 'meson_options.txt') self.option_file = os.path.join(self.source_root, self.subdir, 'meson_options.txt')
self.load_root_meson_file() self.load_root_meson_file()
@ -2785,7 +2788,6 @@ different subdirectory.
super().run() super().run()
mlog.log('Build targets in project:', mlog.bold(str(len(self.build.targets)))) mlog.log('Build targets in project:', mlog.bold(str(len(self.build.targets))))
# Check that the indicated file is within the same subproject # Check that the indicated file is within the same subproject
# as we currently are. This is to stop people doing # as we currently are. This is to stop people doing
# nasty things like: # nasty things like:
@ -2816,7 +2818,7 @@ different subdirectory.
if num_sps > 1: if num_sps > 1:
raise InterpreterException('Sandbox violation: Tried to grab file %s from a nested subproject.' % segments[-1]) raise InterpreterException('Sandbox violation: Tried to grab file %s from a nested subproject.' % segments[-1])
sproj_name = segments[segments.index(self.subproject_dir) + 1] sproj_name = segments[segments.index(self.subproject_dir) + 1]
if sproj_name != self.subproject: if sproj_name != self.subproject_directory_name:
raise InterpreterException('Sandbox violation: Tried to grab file %s from a different subproject.' % segments[-1]) raise InterpreterException('Sandbox violation: Tried to grab file %s from a different subproject.' % segments[-1])
def source_strings_to_files(self, sources): def source_strings_to_files(self, sources):

@ -0,0 +1,3 @@
project('mainproj', 'c')
subproject('zlib')

@ -0,0 +1,2 @@
project('shared lib', 'c')
shared_library('foo', 'foo.c')

@ -0,0 +1,10 @@
[wrap-file]
directory = zlib-1.2.8
source_url = http://zlib.net/fossils/zlib-1.2.8.tar.gz
source_filename = zlib-1.2.8.tar.gz
source_hash = 36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d
patch_url = https://wrapdb.mesonbuild.com/v1/projects/zlib/1.2.8/8/get_zip
patch_filename = zlib-1.2.8-8-wrap.zip
patch_hash = 17c52a0e0c59ce926d3959005d5cd8178c6c7e2c9a4a1304279a8320c955ac60
Loading…
Cancel
Save