1 # ===----------------------------------------------------------------------===##
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 # See https://llvm.org/LICENSE.txt for license information.
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 # ===----------------------------------------------------------------------===##
9 # This configuration builds the C++23 std module.
10 # It is build when the current lit configuration supports modules.
12 # TODO MODULES Evaluate whether this file can be removed when CMake supports
18 import libcxx.test.params, libcxx.test.config, libcxx.test.dsl
21 def getSubstitution(substitution, config):
22 for orig, replacement in config.substitutions:
23 if orig == substitution:
25 raise ValueError("Substitution {} is not in the config.".format(substitution))
28 def appendToSubstitution(substitutions, key, value):
29 return [(k, v + " " + value) if k == key else (k, v) for (k, v) in substitutions]
32 std = getSubstitution("%{cxx_std}", config)
44 and not "libcpp-has-no-std-modules" in config.available_features
45 and not "clang-modules-build" in config.available_features
47 build = os.path.join(config.test_exec_root, "__config_module__")
48 config.substitutions = appendToSubstitution(
51 "-fprebuilt-module-path="
52 + os.path.join(config.test_exec_root, "__config_module__/CMakeFiles/std.dir"),
55 cmake = getSubstitution("%{cmake}", config)
56 flags = getSubstitution("%{flags}", config)
57 if "c++experimental" in config.available_features:
58 flags = f"{flags} -D_LIBCPP_ENABLE_EXPERIMENTAL"
60 subprocess.check_call(
61 [cmake, f"-DCMAKE_CXX_STANDARD={std}", f"-DCMAKE_CXX_FLAGS={flags}", build],
64 subprocess.check_call([cmake, "--build", build, "--", "-v"], env={})
65 config.substitutions = appendToSubstitution(
68 os.path.join(build, "libc++std.a"),