4949 },
5050 "lld" : {"bolt" , "cross-project-tests" },
5151 # TODO(issues/132795): LLDB should be enabled on clang changes.
52- "clang" : {"clang-tools-extra" , "compiler-rt" , "cross-project-tests" },
53- "clang-tools-extra" : {"libc" },
52+ "clang" : {"clang-tools-extra" , "cross-project-tests" },
5453 "mlir" : {"flang" },
5554 # Test everything if ci scripts are changed.
5655 # FIXME: Figure out what is missing and add here.
5756 ".ci" : {"llvm" , "clang" , "lld" , "lldb" },
5857}
5958
60- DEPENDENT_RUNTIMES_TO_TEST = {"clang" : {"libcxx" , "libcxxabi" , "libunwind" }}
59+ # This mapping describes runtimes that should be enabled for a specific project,
60+ # but not necessarily run for testing. The only case of this currently is lldb
61+ # which needs some runtimes enabled for tests.
62+ DEPENDENT_RUNTIMES_TO_BUILD = {"lldb" : {"libcxx" , "libcxxabi" , "libunwind" }}
63+
64+ # This mapping describes runtimes that should be tested when the key project is
65+ # touched.
66+ DEPENDENT_RUNTIMES_TO_TEST = {
67+ "clang" : {"compiler-rt" },
68+ }
69+ DEPENDENT_RUNTIMES_TO_TEST_MULTICONFIG = {
70+ "llvm" : {"libcxx" , "libcxxabi" , "libunwind" },
71+ "clang" : {"libcxx" , "libcxxabi" , "libunwind" },
72+ ".ci" : {"libcxx" , "libcxxabi" , "libunwind" },
73+ }
6174
6275EXCLUDE_LINUX = {
6376 "cross-project-tests" , # TODO(issues/132796): Tests are failing.
8699 "cross-project-tests" ,
87100 "flang" ,
88101 "libc" ,
89- "libcxx" ,
90- "libcxxabi" ,
91- "libunwind" ,
92102 "lldb" ,
93103 "openmp" ,
94104 "polly" ,
115125 "polly" : "check-polly" ,
116126}
117127
118- RUNTIMES = {"libcxx" , "libcxxabi" , "libunwind" }
128+ RUNTIMES = {"libcxx" , "libcxxabi" , "libunwind" , "compiler-rt" , "libc" }
119129
120130
121- def _add_dependencies (projects : Set [str ]) -> Set [str ]:
131+ def _add_dependencies (projects : Set [str ], runtimes : Set [ str ] ) -> Set [str ]:
122132 projects_with_dependents = set (projects )
123133 current_projects_count = 0
124134 while current_projects_count != len (projects_with_dependents ):
@@ -127,9 +137,32 @@ def _add_dependencies(projects: Set[str]) -> Set[str]:
127137 if project not in PROJECT_DEPENDENCIES :
128138 continue
129139 projects_with_dependents .update (PROJECT_DEPENDENCIES [project ])
140+ for runtime in runtimes :
141+ if runtime not in PROJECT_DEPENDENCIES :
142+ continue
143+ projects_with_dependents .update (PROJECT_DEPENDENCIES [runtime ])
130144 return projects_with_dependents
131145
132146
147+ def _exclude_projects (current_projects : Set [str ], platform : str ) -> Set [str ]:
148+ new_project_set = set (current_projects )
149+ if platform == "Linux" :
150+ for to_exclude in EXCLUDE_LINUX :
151+ if to_exclude in new_project_set :
152+ new_project_set .remove (to_exclude )
153+ elif platform == "Windows" :
154+ for to_exclude in EXCLUDE_WINDOWS :
155+ if to_exclude in new_project_set :
156+ new_project_set .remove (to_exclude )
157+ elif platform == "Darwin" :
158+ for to_exclude in EXCLUDE_MAC :
159+ if to_exclude in new_project_set :
160+ new_project_set .remove (to_exclude )
161+ else :
162+ raise ValueError ("Unexpected platform." )
163+ return new_project_set
164+
165+
133166def _compute_projects_to_test (modified_projects : Set [str ], platform : str ) -> Set [str ]:
134167 projects_to_test = set ()
135168 for modified_project in modified_projects :
@@ -147,25 +180,14 @@ def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set
147180 ):
148181 continue
149182 projects_to_test .add (dependent_project )
150- if platform == "Linux" :
151- for to_exclude in EXCLUDE_LINUX :
152- if to_exclude in projects_to_test :
153- projects_to_test .remove (to_exclude )
154- elif platform == "Windows" :
155- for to_exclude in EXCLUDE_WINDOWS :
156- if to_exclude in projects_to_test :
157- projects_to_test .remove (to_exclude )
158- elif platform == "Darwin" :
159- for to_exclude in EXCLUDE_MAC :
160- if to_exclude in projects_to_test :
161- projects_to_test .remove (to_exclude )
162- else :
163- raise ValueError ("Unexpected platform." )
183+ projects_to_test = _exclude_projects (projects_to_test , platform )
164184 return projects_to_test
165185
166186
167- def _compute_projects_to_build (projects_to_test : Set [str ]) -> Set [str ]:
168- return _add_dependencies (projects_to_test )
187+ def _compute_projects_to_build (
188+ projects_to_test : Set [str ], runtimes : Set [str ]
189+ ) -> Set [str ]:
190+ return _add_dependencies (projects_to_test , runtimes )
169191
170192
171193def _compute_project_check_targets (projects_to_test : Set [str ]) -> Set [str ]:
@@ -177,20 +199,36 @@ def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
177199 return check_targets
178200
179201
180- def _compute_runtimes_to_test (projects_to_test : Set [str ]) -> Set [str ]:
202+ def _compute_runtimes_to_test (modified_projects : Set [str ], platform : str ) -> Set [str ]:
181203 runtimes_to_test = set ()
182- for project_to_test in projects_to_test :
183- if project_to_test not in DEPENDENT_RUNTIMES_TO_TEST :
204+ for modified_project in modified_projects :
205+ if modified_project not in DEPENDENT_RUNTIMES_TO_TEST :
184206 continue
185- runtimes_to_test .update (DEPENDENT_RUNTIMES_TO_TEST [project_to_test ])
186- return runtimes_to_test
207+ runtimes_to_test .update (DEPENDENT_RUNTIMES_TO_TEST [modified_project ])
208+ return _exclude_projects ( runtimes_to_test , platform )
187209
188210
189- def _compute_runtime_check_targets (runtimes_to_test : Set [str ]) -> Set [str ]:
190- check_targets = set ()
191- for runtime_to_test in runtimes_to_test :
192- check_targets .add (PROJECT_CHECK_TARGETS [runtime_to_test ])
193- return check_targets
211+ def _compute_runtimes_to_test_multiconfig (
212+ modified_projects : Set [str ], platform : str
213+ ) -> Set [str ]:
214+ runtimes_to_test = set ()
215+ for modified_project in modified_projects :
216+ if modified_project not in DEPENDENT_RUNTIMES_TO_TEST_MULTICONFIG :
217+ continue
218+ runtimes_to_test .update (
219+ DEPENDENT_RUNTIMES_TO_TEST_MULTICONFIG [modified_project ]
220+ )
221+ return _exclude_projects (runtimes_to_test , platform )
222+
223+
224+ def _compute_runtimes_to_build (
225+ runtimes_to_test : Set [str ], modified_projects : Set [str ], platform : str
226+ ) -> Set [str ]:
227+ runtimes_to_build = set (runtimes_to_test )
228+ for modified_project in modified_projects :
229+ if modified_project in DEPENDENT_RUNTIMES_TO_BUILD :
230+ runtimes_to_build .update (DEPENDENT_RUNTIMES_TO_BUILD [modified_project ])
231+ return _exclude_projects (runtimes_to_build , platform )
194232
195233
196234def _get_modified_projects (modified_files : list [str ]) -> Set [str ]:
@@ -214,19 +252,31 @@ def _get_modified_projects(modified_files: list[str]) -> Set[str]:
214252def get_env_variables (modified_files : list [str ], platform : str ) -> Set [str ]:
215253 modified_projects = _get_modified_projects (modified_files )
216254 projects_to_test = _compute_projects_to_test (modified_projects , platform )
217- projects_to_build = _compute_projects_to_build (projects_to_test )
255+ runtimes_to_test = _compute_runtimes_to_test (modified_projects , platform )
256+ runtimes_to_test_multiconfig = _compute_runtimes_to_test_multiconfig (
257+ modified_projects , platform
258+ )
259+ runtimes_to_build = _compute_runtimes_to_build (
260+ runtimes_to_test | runtimes_to_test_multiconfig , modified_projects , platform
261+ )
262+ projects_to_build = _compute_projects_to_build (projects_to_test , runtimes_to_build )
218263 projects_check_targets = _compute_project_check_targets (projects_to_test )
219- runtimes_to_test = _compute_runtimes_to_test (projects_to_test )
220- runtimes_check_targets = _compute_runtime_check_targets (runtimes_to_test )
264+ runtimes_check_targets = _compute_project_check_targets (runtimes_to_test )
265+ runtimes_check_targets_multiconfig = _compute_project_check_targets (
266+ runtimes_to_test_multiconfig
267+ )
221268 # We use a semicolon to separate the projects/runtimes as they get passed
222269 # to the CMake invocation and thus we need to use the CMake list separator
223270 # (;). We use spaces to separate the check targets as they end up getting
224271 # passed to ninja.
225272 return {
226273 "projects_to_build" : ";" .join (sorted (projects_to_build )),
227274 "project_check_targets" : " " .join (sorted (projects_check_targets )),
228- "runtimes_to_build" : ";" .join (sorted (runtimes_to_test )),
275+ "runtimes_to_build" : ";" .join (sorted (runtimes_to_build )),
229276 "runtimes_check_targets" : " " .join (sorted (runtimes_check_targets )),
277+ "runtimes_check_targets_multiconfig" : " " .join (
278+ sorted (runtimes_check_targets_multiconfig )
279+ ),
230280 }
231281
232282
0 commit comments