scripts/generate_rust_analyzer.py
Source file repositories/reference/linux-study-clean/scripts/generate_rust_analyzer.py
File Facts
- System
- Linux kernel
- Corpus path
scripts/generate_rust_analyzer.py- Extension
.py- Size
- 12774 bytes
- Lines
- 409
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: scripts
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
"""generate_rust_analyzer - Generates the `rust-project.json` file for `rust-analyzer`.
"""
import argparse
import json
import logging
import os
import pathlib
import subprocess
import sys
from typing import Dict, Iterable, List, Literal, Optional, TypedDict
def invoke_rustc(args: List[str]) -> str:
return subprocess.check_output(
[os.environ["RUSTC"]] + args,
stdin=subprocess.DEVNULL,
).decode('utf-8').strip()
def args_crates_cfgs(cfgs: List[str]) -> Dict[str, List[str]]:
crates_cfgs = {}
for cfg in cfgs:
crate, vals = cfg.split("=", 1)
crates_cfgs[crate] = vals.split()
return crates_cfgs
def args_crates_envs(envs: List[str]) -> Dict[str, Dict[str, str]]:
crates_envs = {}
for env in envs:
crate, vals = env.split("=", 1)
crates_envs[crate] = dict(v.split("=", 1) for v in vals.split())
return crates_envs
class Dependency(TypedDict):
crate: int
name: str
class Source(TypedDict):
include_dirs: List[str]
exclude_dirs: List[str]
class Crate(TypedDict):
display_name: str
root_module: str
is_workspace_member: bool
deps: List[Dependency]
cfg: List[str]
edition: str
env: Dict[str, str]
class ProcMacroCrate(Crate):
is_proc_macro: Literal[True]
proc_macro_dylib_path: str # `pathlib.Path` is not JSON serializable.
class CrateWithGenerated(Crate):
source: Source
def generate_crates(
srctree: pathlib.Path,
objtree: pathlib.Path,
sysroot_src: pathlib.Path,
external_src: Optional[pathlib.Path],
Annotation
- Atlas domain: Support Tooling And Documentation / scripts.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.