|
|
@@ -21,6 +21,7 @@ if str(ROOT) not in sys.path:
|
|
|
from tools.package_archive import encode, finalize, read_archive, write_archive
|
|
|
|
|
|
PRODUCTS = {"6400-v2", "mrdimm-chamber"}
|
|
|
+DEFAULT_PROTOCOL_DOC = Path("docs/CPLD_通讯协议v2.0.md")
|
|
|
|
|
|
|
|
|
def digest(data: bytes) -> str:
|
|
|
@@ -113,6 +114,8 @@ def main(argv=None) -> int:
|
|
|
parser.add_argument("--review-dir", type=Path, required=True)
|
|
|
parser.add_argument("--related-repo", action="append", default=[], metavar="NAME=PATH")
|
|
|
parser.add_argument("--hardware-file", action="append", type=Path, default=[])
|
|
|
+ parser.add_argument("--protocol-doc", type=Path, default=None,
|
|
|
+ help="Maintained protocol document to bundle at release root and inside archives (defaults to docs/CPLD_通讯协议v2.0.md if present)")
|
|
|
parser.add_argument("--hardware-status", type=Path, required=True,
|
|
|
help="actual connection/programming/test result JSON, including NOT_RUN when unavailable")
|
|
|
args = parser.parse_args(argv)
|
|
|
@@ -198,9 +201,27 @@ def main(argv=None) -> int:
|
|
|
raise ValueError("conflicting hardware file: " + key)
|
|
|
hardware[key] = data
|
|
|
start = (ROOT / f"docs/releases/v{version}.md").read_bytes()
|
|
|
+ protocol_doc_path = args.protocol_doc.resolve() if args.protocol_doc is not None else (ROOT / DEFAULT_PROTOCOL_DOC)
|
|
|
+ protocol_doc_bytes = None
|
|
|
+ if protocol_doc_path.is_file():
|
|
|
+ protocol_doc_bytes = protocol_doc_path.read_bytes()
|
|
|
+ try:
|
|
|
+ proto_rel = protocol_doc_path.relative_to(ROOT.resolve()).as_posix()
|
|
|
+ except ValueError:
|
|
|
+ proto_rel = protocol_doc_path.name
|
|
|
+ run["protocol_doc"] = {
|
|
|
+ "file": protocol_doc_path.name,
|
|
|
+ "source_path": proto_rel,
|
|
|
+ "sha256": digest(protocol_doc_bytes),
|
|
|
+ "size_bytes": len(protocol_doc_bytes),
|
|
|
+ }
|
|
|
+ elif args.protocol_doc is not None:
|
|
|
+ parser.error("missing --protocol-doc: " + str(protocol_doc_path))
|
|
|
common = {"START-HERE.zh-CN.md": start, "RUN.json": encode(run),
|
|
|
"EXCLUSIONS.json": encode({"excluded": ["working untracked user files except explicit --hardware-file inputs", "tool databases and vvp/vcd/fst intermediates", "ignored caches", "Git local config (including remote credentials)"],
|
|
|
"source_scope": "All Git-tracked working files; explicit hardware originals included with repository-relative paths preserved; committed history in history/*.bundle"})}
|
|
|
+ if protocol_doc_bytes is not None:
|
|
|
+ common[protocol_doc_path.name] = protocol_doc_bytes
|
|
|
tag = f"v{version}-{identity['commit'][:8]}"
|
|
|
results = [
|
|
|
package(out / f"Prod2U-Source-{tag}.zip", {**sources, **hardware, **common}, {"kind": "source", "version": version}),
|
|
|
@@ -214,6 +235,8 @@ def main(argv=None) -> int:
|
|
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
|
target.write_bytes(data)
|
|
|
(out / "START-HERE.zh-CN.md").write_bytes(start)
|
|
|
+ if protocol_doc_bytes is not None:
|
|
|
+ (out / protocol_doc_path.name).write_bytes(protocol_doc_bytes)
|
|
|
(out / "RUN.json").write_bytes(encode(run))
|
|
|
(out / "PACKAGE-RESULTS.json").write_bytes(encode(results))
|
|
|
inventory = [{"path": p.relative_to(out).as_posix(), "sha256": digest(p.read_bytes()), "size_bytes": p.stat().st_size}
|