C内核按库功能拆解,编译结果缓存区构建,编译过程与已有缓存结果对照功能实现
This commit is contained in:
1 parent
aa4951b14e
commit
151e6e4b97
30 files changed
+4856
-604
No files matched your search
@@ -0,0 +1,25 @@
|
||||
"""Read the diagnostic kernel translation unit before test-only injection.
|
||||
|
||||
Only component module C includes are expanded. Header includes and the
|
||||
amalgamation linkage switch remain for the ordinary C preprocessor to handle.
|
||||
An older, unsplit kernels.c is returned unchanged.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
|
||||
NATIVE = Path(__file__).resolve().parents[1] / "native"
|
||||
_SOURCE_INCLUDE = re.compile(r'^[ \t]*#[ \t]*include[ \t]+"([^"\n]+\.c)"[ \t]*$', re.MULTILINE)
|
||||
|
||||
|
||||
def native_kernel_source(native: Path = NATIVE) -> str:
|
||||
entry = native / "components/kernels.c"
|
||||
modules = (native / "components/modules").resolve()
|
||||
|
||||
def expand(match: re.Match[str]) -> str:
|
||||
source = (entry.parent / match[1]).resolve()
|
||||
if not source.is_relative_to(modules):
|
||||
return match[0]
|
||||
return source.read_text(encoding="utf-8")
|
||||
|
||||
return _SOURCE_INCLUDE.sub(expand, entry.read_text(encoding="utf-8"))
|
||||
Reference in new issue
Block a user