brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 3ea0298 Raw
53 lines · python
1#!/usr/bin/env python32# ===-- clear-release-notes.py  ---------------------------------------------===#3#4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5# See https://llvm.org/LICENSE.txt for license information.6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7#8# ===------------------------------------------------------------------------===#9#10# Clear release notes, which is needed when bumping trunk version.11#12# ===------------------------------------------------------------------------===#13 14import argparse15from pathlib import Path16 17 18def process_file(fpath: Path) -> None:19    # ReleaseNotes.rst/.md -> ReleaseNotesTemplate.txt20    template_path = fpath.with_name(f"{fpath.stem}Template.txt")21    fpath.write_text(template_path.read_text(), newline="\n")22    print(f"{fpath} updated.")23 24 25if __name__ == "__main__":26    parser = argparse.ArgumentParser()27    parser.add_argument(28        "-s",29        "--source-root",30        default=None,31        help="LLVM source root (/path/llvm-project). Defaults to the "32        "llvm-project the script is located in.",33    )34 35    args = parser.parse_args()36 37    # Find llvm-project root38    source_root = Path(__file__).resolve().parents[3]39 40    if args.source_root:41        source_root = Path(args.source_root).resolve()42 43    files_to_update = (44        "clang/docs/ReleaseNotes.rst",45        "clang-tools-extra/docs/ReleaseNotes.rst",46        "flang/docs/ReleaseNotes.md",47        "lld/docs/ReleaseNotes.rst",48        "llvm/docs/ReleaseNotes.md",49    )50 51    for f in files_to_update:52        process_file(source_root / f)53