13
13
from typing import TYPE_CHECKING , Any
14
14
15
15
from . import __version__
16
+ from ._compat .builtins import ExceptionGroup
16
17
from ._logging import logger
17
18
from ._shutil import Run
18
19
from .errors import CMakeConfigError , CMakeNotFoundError , FailedLiveProcessError
20
+ from .file_api .query import stateless_query
21
+ from .file_api .reply import load_reply_dir
19
22
from .program_search import Program , best_program , get_cmake_program , get_cmake_programs
20
23
21
24
if TYPE_CHECKING :
25
28
from packaging .version import Version
26
29
27
30
from ._compat .typing import Self
31
+ from .file_api .model .index import Index
28
32
29
33
__all__ = ["CMake" , "CMaker" ]
30
34
@@ -83,6 +87,8 @@ class CMaker:
83
87
init_cache_file : Path = dataclasses .field (init = False , default = Path ())
84
88
env : dict [str , str ] = dataclasses .field (init = False , default_factory = os .environ .copy )
85
89
single_config : bool = not sysconfig .get_platform ().startswith ("win" )
90
+ file_api : Index | None = None
91
+ _file_api_query : Path = dataclasses .field (init = False )
86
92
87
93
def __post_init__ (self ) -> None :
88
94
self .init_cache_file = self .build_dir / "CMakeInit.txt"
@@ -97,6 +103,8 @@ def __post_init__(self) -> None:
97
103
msg = f"build directory { self .build_dir } must be a (creatable) directory"
98
104
raise CMakeConfigError (msg )
99
105
106
+ # TODO: This could be stateful instead
107
+ self ._file_api_query = stateless_query (self .build_dir )
100
108
skbuild_info = self .build_dir / ".skbuild-info.json"
101
109
stale = False
102
110
@@ -253,6 +261,13 @@ def configure(
253
261
msg = "CMake configuration failed"
254
262
raise FailedLiveProcessError (msg ) from None
255
263
264
+ try :
265
+ if self ._file_api_query .exists ():
266
+ self .file_api = load_reply_dir (self ._file_api_query )
267
+ except ExceptionGroup as exc :
268
+ logger .warning ("Could not parse CMake file-api" )
269
+ logger .debug (str (exc ))
270
+
256
271
def _compute_build_args (
257
272
self ,
258
273
* ,
0 commit comments