mirror of
https://github.com/AdaCore/langkit.git
synced 2026-02-12 12:28:12 -08:00
40 lines
1.3 KiB
Plaintext
40 lines
1.3 KiB
Plaintext
## vim: filetype=makopython
|
|
|
|
@classmethod
|
|
def from_directories(cls, directories: list[str]) -> UnitProvider:
|
|
"""
|
|
Return a unit provider that will look for units in the given list of
|
|
directories. Note that the current directory is implicitly looked at
|
|
first.
|
|
"""
|
|
# Create a NULL-terminated array of strings
|
|
c_strings = [
|
|
ctypes.c_char_p(
|
|
_coerce_bytes("directories", d, "a list of bytes strings")
|
|
)
|
|
for d in directories
|
|
]
|
|
c_array_type = ctypes.c_char_p * (len(directories) + 1)
|
|
c_array = c_array_type()
|
|
for i, c_str in enumerate(c_strings):
|
|
c_array[i] = c_str
|
|
c_array[-1] = None
|
|
|
|
c_array_ptr = ctypes.pointer(c_array)
|
|
directories_arg = ctypes.cast(
|
|
c_array_ptr, ctypes.POINTER(ctypes.c_char_p)
|
|
)
|
|
|
|
c_value = _create_default_provider(directories_arg)
|
|
return _CUnitProvider(c_value)
|
|
|
|
@classmethod
|
|
def from_lkt_path(cls) -> UnitProvider:
|
|
"""
|
|
Return a unit provider created from the ``LKT_PATH`` environment
|
|
variable.
|
|
"""
|
|
return cls.from_directories(
|
|
os.environ.get("LKT_PATH", "").split(os.path.pathsep)
|
|
)
|