Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail loading subprojects if subprojects_dir is in a subdirectory #2943

Merged
merged 4 commits into from
Feb 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions mesonbuild/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import os, sys, shutil, uuid
import re, shlex
from collections import namedtuple
from pathlib import PurePath

import importlib

Expand Down Expand Up @@ -1962,7 +1963,7 @@ def func_warning(self, node, args, kwargs):
@noKwargs
def func_error(self, node, args, kwargs):
self.validate_arguments(args, 1, [str])
raise InterpreterException('Error encountered: ' + args[0])
raise InterpreterException('Problem encountered: ' + args[0])

def detect_compilers(self, lang, need_cross_compiler):
cross_comp = None
Expand Down Expand Up @@ -2339,10 +2340,10 @@ def dependency_fallback(self, name, kwargs):
raise
# If the subproject execution failed in a non-fatal way, don't raise an
# exception; let the caller handle things.
except:
except Exception as e:
mlog.log('Also couldn\'t find a fallback subproject in',
mlog.bold(os.path.join(self.subproject_dir, dirname)),
'for the dependency', mlog.bold(name))
'for the dependency', mlog.bold(name), '\nReason:', str(e))
return None
dep = self.get_subproject_dep(name, dirname, varname, kwargs.get('required', True))
if not dep:
Expand Down Expand Up @@ -2963,11 +2964,16 @@ def run(self):
def evaluate_subproject_info(self, path_from_source_root, subproject_dirname):
depth = 0
subproj_name = ''
segs = path_from_source_root.split(os.path.sep)
while segs and segs[0] == subproject_dirname:
depth += 1
subproj_name = segs[1]
segs = segs[2:]
segs = PurePath(path_from_source_root).parts
segs_spd = PurePath(subproject_dirname).parts
while segs and segs[0] == segs_spd[0]:
if len(segs_spd) == 1:
subproj_name = segs[1]
segs = segs[2:]
depth += 1
else:
segs_spd = segs_spd[1:]
segs = segs[1:]
return (depth, subproj_name)

# Check that the indicated file is within the same subproject
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
int func2();

#if defined _WIN32 || defined __CYGWIN__
#define DLL_PUBLIC __declspec(dllexport)
#else
#if defined __GNUC__
#define DLL_PUBLIC __attribute__ ((visibility("default")))
#else
#pragma message ("Compiler does not support symbol visibility.")
#define DLL_PUBLIC
#endif
#endif

int DLL_PUBLIC func() { return func2(); }

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project('alpha project', 'c', subproject_dir: 'var/subprojects')

b = subproject('beta')
l = shared_library('a', 'a.c', link_with : b.get_variable('lb'))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#if defined _WIN32 || defined __CYGWIN__
#define DLL_PUBLIC __declspec(dllexport)
#else
#if defined __GNUC__
#define DLL_PUBLIC __attribute__ ((visibility("default")))
#else
#pragma message ("Compiler does not support symbol visibility.")
#define DLL_PUBLIC
#endif
#endif

int DLL_PUBLIC func2() {
return 42;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project('beta project', 'c')

lb = shared_library('b', 'b.c')
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project('gamma project', 'c', subproject_dir: 'contrib/subprojects')

a = subproject('alpha')
lib = a.get_variable('l')

exe = executable('prog', 'prog.c', link_with : lib)
test('basic', exe)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
int func();

int main(int argc, char **argv) {
return func() == 42 ? 0 : 1;
}