aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/cmake
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2019-06-07 20:38:56 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2019-06-09 01:18:53 +0300
commit69005d6b1db5e0bf9cbf5b9c4bb3b5d6a346aadb (patch)
treefef72445645ee2a2567b138a2d87282ff9572173 /mesonbuild/cmake
parent431a9ea664798c5e7b5063426fc92e58fd003038 (diff)
downloadmeson-69005d6b1db5e0bf9cbf5b9c4bb3b5d6a346aadb.zip
meson-69005d6b1db5e0bf9cbf5b9c4bb3b5d6a346aadb.tar.gz
meson-69005d6b1db5e0bf9cbf5b9c4bb3b5d6a346aadb.tar.bz2
cmake: Minor fixes to handle some CMake specific behavior
Now, all source files are ignored that are not part of the language of the target. This is also what CMake does. Additionally it is now supported to build source files that are generated inside the build directory.
Diffstat (limited to 'mesonbuild/cmake')
-rw-r--r--mesonbuild/cmake/interpreter.py38
1 files changed, 25 insertions, 13 deletions
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py
index 406723f..ec17906 100644
--- a/mesonbuild/cmake/interpreter.py
+++ b/mesonbuild/cmake/interpreter.py
@@ -22,7 +22,7 @@ from ..build import Build
from ..environment import Environment
from ..mparser import Token, BaseNode, CodeBlockNode, FunctionNode, ArrayNode, ArgumentNode, AssignmentNode, BooleanNode, StringNode, IdNode, MethodNode
from ..backend.backends import Backend
-from ..compilers.compilers import obj_suffixes
+from ..compilers.compilers import lang_suffixes, header_suffixes, obj_suffixes
from ..dependencies.base import CMakeDependency, ExternalProgram
from subprocess import Popen, PIPE, STDOUT
from typing import List, Dict, Optional
@@ -57,8 +57,6 @@ target_type_map = {
skip_targets = ['UTILITY']
-skip_input_extensions = ['.rule']
-
blacklist_compiler_flags = [
'/W1', '/W2', '/W3', '/W4', '/Wall',
'/O1', '/O2', '/Ob', '/Od', '/Og', '/Oi', '/Os', '/Ot', '/Ox', '/Oy', '/Ob0',
@@ -184,23 +182,37 @@ class ConverterTarget:
self.link_libraries = temp
# Make paths relative
- def rel_path(x: str) -> str:
+ def rel_path(x: str, is_header: bool) -> Optional[str]:
if not os.path.isabs(x):
x = os.path.normpath(os.path.join(self.src_dir, x))
+ if not os.path.exists(x) and not any([x.endswith(y) for y in obj_suffixes]):
+ mlog.warning('CMake: path', mlog.bold(x), 'does not exist. Ignoring. This can lead to build errors')
+ return None
+ if os.path.isabs(x) and os.path.commonpath([x, self.env.get_build_dir()]) == self.env.get_build_dir():
+ if is_header:
+ return os.path.relpath(x, os.path.join(self.env.get_build_dir(), subdir))
+ else:
+ return os.path.relpath(x, root_src_dir)
if os.path.isabs(x) and os.path.commonpath([x, root_src_dir]) == root_src_dir:
return os.path.relpath(x, root_src_dir)
- if os.path.isabs(x) and os.path.commonpath([x, self.env.get_build_dir()]) == self.env.get_build_dir():
- return os.path.relpath(x, os.path.join(self.env.get_build_dir(), subdir))
return x
build_dir_rel = os.path.relpath(self.build_dir, os.path.join(self.env.get_build_dir(), subdir))
- self.includes = list(set([rel_path(x) for x in set(self.includes)] + [build_dir_rel]))
- self.sources = [rel_path(x) for x in self.sources]
- self.generated = [rel_path(x) for x in self.generated]
-
- # Filter out CMake rule files
- self.sources = [x for x in self.sources if not any([x.endswith(y) for y in skip_input_extensions])]
- self.generated = [x for x in self.generated if not any([x.endswith(y) for y in skip_input_extensions])]
+ self.includes = list(set([rel_path(x, True) for x in set(self.includes)] + [build_dir_rel]))
+ self.sources = [rel_path(x, False) for x in self.sources]
+ self.generated = [rel_path(x, False) for x in self.generated]
+
+ self.includes = [x for x in self.includes if x is not None]
+ self.sources = [x for x in self.sources if x is not None]
+ self.generated = [x for x in self.generated if x is not None]
+
+ # Filter out files that are not supported by the language
+ supported = list(header_suffixes) + list(obj_suffixes)
+ for i in self.languages:
+ supported += list(lang_suffixes[i])
+ supported = ['.{}'.format(x) for x in supported]
+ self.sources = [x for x in self.sources if any([x.endswith(y) for y in supported])]
+ self.generated = [x for x in self.generated if any([x.endswith(y) for y in supported])]
# Make sure '.' is always in the include directories
if '.' not in self.includes: