23 lines
623 B
Python
Executable File
23 lines
623 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Check core source files before invoking Cargo."""
|
|
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parents[1])
|
|
root = parser.parse_args().root.resolve()
|
|
missing = [
|
|
name
|
|
for name in ("Cargo.toml", "build.rs", "src/lib.rs", "src/main.rs")
|
|
if not (root / name).is_file()
|
|
]
|
|
if missing:
|
|
parser.exit(2, f"Source preflight failed: missing {', '.join(missing)}\n")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|