|
6 | 6 |
|
7 | 7 | + # Object dependencies set via set_source_files_properties(... OBJECT_DEPENDS ...), |
8 | 8 | + # mapping the source file to the files its compilation depends on |
9 | | -+ self.object_depends: T.Dict[str, T.List[str]] = {} |
| 9 | ++ self.object_depends: T.Dict[Path, T.List[str]] = {} |
10 | 10 | + |
11 | 11 | # T.List of targes that were added with add_custom_command to generate files |
12 | 12 | self.custom_targets: T.List[CMakeGeneratorTarget] = [] |
13 | 13 |
|
14 | | -@@ -120,6 +124,7 @@ |
15 | | - 'add_custom_target': self._cmake_add_custom_target, |
16 | | - 'set_property': self._cmake_set_property, |
17 | | - 'set_target_properties': self._cmake_set_target_properties, |
18 | | -+ 'set_source_files_properties': self._cmake_set_source_files_properties, |
19 | | - 'target_compile_definitions': self._cmake_target_compile_definitions, |
20 | | - 'target_compile_options': self._cmake_target_compile_options, |
21 | | - 'target_include_directories': self._cmake_target_include_directories, |
22 | | -@@ -605,6 +610,33 @@ |
| 14 | +@@ -525,9 +529,10 @@ |
| 15 | + else: |
| 16 | + tgt.properties[identifier] = value |
23 | 17 |
|
24 | | - self.targets[i].properties[name] = value |
| 18 | +- def do_source(src: str) -> None: |
| 19 | +- if identifier != 'HEADER_FILE_ONLY' or not self._str_to_bool(value): |
| 20 | +- return |
| 21 | ++ def resolve_source(src: str) -> Path: |
| 22 | ++ src_p = Path(src) |
| 23 | ++ if src_p.is_absolute(): |
| 24 | ++ return src_p |
25 | 25 |
|
26 | | -+ def _cmake_set_source_files_properties(self, tline: CMakeTraceLine) -> None: |
27 | | -+ # DOC: https://cmake.org/cmake/help/latest/command/set_source_files_properties.html |
28 | | -+ args = list(tline.args) |
29 | | -+ |
30 | | -+ sources: T.List[str] = [] |
31 | | -+ idx = 0 |
32 | | -+ while idx < len(args) and args[idx] != 'PROPERTIES': |
33 | | -+ if args[idx] in {'DIRECTORY', 'TARGET_DIRECTORY'}: |
34 | | -+ # skip the scope arguments |
35 | | -+ idx += 1 |
36 | | -+ while idx < len(args) and args[idx] not in {'DIRECTORY', 'TARGET_DIRECTORY', 'PROPERTIES'}: |
37 | | -+ idx += 1 |
38 | | -+ continue |
39 | | -+ sources += args[idx].split(';') |
40 | | -+ idx += 1 |
41 | | -+ |
42 | | -+ object_depends: T.List[str] = [] |
43 | | -+ idx += 1 |
44 | | -+ while idx + 1 < len(args): |
45 | | -+ if args[idx] == 'OBJECT_DEPENDS': |
46 | | -+ object_depends += args[idx + 1].split(';') |
47 | | -+ idx += 2 |
48 | | -+ |
49 | | -+ if object_depends: |
50 | | -+ for i in sources: |
51 | | -+ self.object_depends.setdefault(i, []).extend(object_depends) |
52 | | -+ |
53 | | - def _cmake_add_dependencies(self, tline: CMakeTraceLine) -> None: |
54 | | - # DOC: https://cmake.org/cmake/help/latest/command/add_dependencies.html |
55 | | - args = list(tline.args) |
| 26 | + current_src_dir = self.var_to_str('MESON_PS_CMAKE_CURRENT_SOURCE_DIR') |
| 27 | + if not current_src_dir: |
| 28 | +@@ -537,12 +542,14 @@ |
| 29 | + ''')) |
| 30 | + current_src_dir = '.' |
| 31 | + |
| 32 | +- cur_p = Path(current_src_dir) |
| 33 | +- src_p = Path(src) |
| 34 | ++ return Path(current_src_dir) / src_p |
| 35 | + |
| 36 | +- if not src_p.is_absolute(): |
| 37 | +- src_p = cur_p / src_p |
| 38 | +- self.explicit_headers.add(src_p) |
| 39 | ++ def do_source(src: str) -> None: |
| 40 | ++ if identifier == 'HEADER_FILE_ONLY': |
| 41 | ++ if self._str_to_bool(value): |
| 42 | ++ self.explicit_headers.add(resolve_source(src)) |
| 43 | ++ elif identifier == 'OBJECT_DEPENDS': |
| 44 | ++ self.object_depends.setdefault(resolve_source(src), []).extend(value) |
| 45 | + |
| 46 | + if scope == 'TARGET': |
| 47 | + for i in targets: |
56 | 48 | --- a/mesonbuild/cmake/interpreter.py |
57 | 49 | +++ b/mesonbuild/cmake/interpreter.py |
58 | | -@@ -382,6 +382,21 @@ |
| 50 | +@@ -382,6 +382,18 @@ |
59 | 51 | elif self.type.upper() not in ['EXECUTABLE', 'OBJECT_LIBRARY']: |
60 | 52 | mlog.warning('CMake: Target', mlog.bold(self.cmake_name), 'not found in CMake trace. This can lead to build errors') |
61 | 53 |
|
|
68 | 60 | + p = x if x.is_absolute() else self.src_dir / x |
69 | 61 | + src_keys.add(p.resolve().as_posix()) |
70 | 62 | + for src, deps in trace.object_depends.items(): |
71 | | -+ src_path = Path(src) |
72 | | -+ if not src_path.is_absolute(): |
73 | | -+ continue |
74 | | -+ if src_path.resolve().as_posix() in src_keys: |
| 63 | ++ if src.resolve().as_posix() in src_keys: |
75 | 64 | + self.depends_raw += deps |
76 | 65 | + |
77 | 66 | temp = [] |
78 | 67 | for cmd in self.link_libraries: |
79 | 68 | # Let meson handle this arcane magic |
80 | | -@@ -503,7 +518,14 @@ |
| 69 | +@@ -503,7 +515,14 @@ |
81 | 70 | for arg in self.depends_raw: |
82 | 71 | dep_tgt = output_target_map.target(arg) |
83 | 72 | if dep_tgt: |
|
93 | 82 |
|
94 | 83 | def process_object_libs(self, obj_target_list: T.List['ConverterTarget'], linker_workaround: bool) -> None: |
95 | 84 | # Try to detect the object library(s) from the generated input sources |
96 | | -@@ -1131,12 +1153,24 @@ |
| 85 | +@@ -1131,12 +1150,24 @@ |
97 | 86 | if i.name not in processed: |
98 | 87 | process_target(i) |
99 | 88 | objec_libs += [extract_tgt(i)] |
|
0 commit comments