|
|
@@ -38,6 +38,9 @@ SOURCE_PATHS = (
|
|
|
"src/rtl/prod2u_p4_i2c_stop_start_read.v",
|
|
|
"src/top/prod2u_p4_normal_v3_top.v",
|
|
|
)
|
|
|
+PROTOCOL_PATH = Path("docs/prod2u-door-temp-protocol.zh-CN.md")
|
|
|
+REQUIREMENTS_PATH = Path("projects/prod2u-door-temp/requirements.zh-CN.md")
|
|
|
+VERIFICATION_TARGETS_PATH = Path("config/prod2u_p4_verification_targets_v1.json")
|
|
|
|
|
|
|
|
|
def new_run_id() -> str:
|
|
|
@@ -128,6 +131,7 @@ def create_unverified_package(
|
|
|
commit: str,
|
|
|
run_id: str,
|
|
|
output_root: Path,
|
|
|
+ td_receipt: Path | None = None,
|
|
|
) -> Path:
|
|
|
if not COMMIT_RE.fullmatch(commit):
|
|
|
raise ValueError("commit must be 8 lowercase hexadecimal characters")
|
|
|
@@ -147,12 +151,33 @@ def create_unverified_package(
|
|
|
package_project = package / "project.json"
|
|
|
shutil.copy2(bitstream, package_bitstream)
|
|
|
shutil.copy2(project, package_project)
|
|
|
+ repo = _repo_root()
|
|
|
+ artifacts = {
|
|
|
+ "protocol.md": repo / PROTOCOL_PATH,
|
|
|
+ "requirements.zh-CN.md": repo / REQUIREMENTS_PATH,
|
|
|
+ "verification_targets.json": repo / VERIFICATION_TARGETS_PATH,
|
|
|
+ }
|
|
|
+ for name, source in artifacts.items():
|
|
|
+ if not source.is_file():
|
|
|
+ raise FileNotFoundError(f"package source is missing: {source}")
|
|
|
+ shutil.copy2(source, package / name)
|
|
|
+ _write_json(package / "source_manifest.json", build_source_manifest(repo))
|
|
|
+ if td_receipt is not None:
|
|
|
+ receipt = Path(td_receipt)
|
|
|
+ if not receipt.is_file():
|
|
|
+ raise FileNotFoundError(f"TD receipt is missing: {receipt}")
|
|
|
+ shutil.copy2(receipt, package / "td_receipt.json")
|
|
|
(package / "project_config_sha256.txt").write_text(
|
|
|
sha256_file(package_project) + "\n", encoding="ascii", newline="\n"
|
|
|
)
|
|
|
(package / "bitstream_sha256.txt").write_text(
|
|
|
sha256_file(package_bitstream) + "\n", encoding="ascii", newline="\n"
|
|
|
)
|
|
|
+ file_sha256 = {
|
|
|
+ path.relative_to(package).as_posix(): sha256_file(path)
|
|
|
+ for path in sorted(package.iterdir())
|
|
|
+ if path.is_file() and path.name != "package_manifest.json"
|
|
|
+ }
|
|
|
manifest = {
|
|
|
"schema": "prod2u-simple-package-manifest-v1",
|
|
|
"status": "UNVERIFIED",
|
|
|
@@ -164,6 +189,13 @@ def create_unverified_package(
|
|
|
"bitstream_sha256": sha256_file(package_bitstream),
|
|
|
"project": "project.json",
|
|
|
"project_sha256": sha256_file(package_project),
|
|
|
+ "td_receipt": "td_receipt.json" if td_receipt is not None else None,
|
|
|
+ "td_receipt_sha256": (
|
|
|
+ sha256_file(package / "td_receipt.json")
|
|
|
+ if td_receipt is not None
|
|
|
+ else None
|
|
|
+ ),
|
|
|
+ "file_sha256": file_sha256,
|
|
|
"hardware_validation": "not_run",
|
|
|
}
|
|
|
_write_json(package / "package_manifest.json", manifest)
|
|
|
@@ -187,6 +219,7 @@ def main() -> int:
|
|
|
package.add_argument("--commit", required=True)
|
|
|
package.add_argument("--run-id", required=True)
|
|
|
package.add_argument("--output-root", type=Path, default=Path("dist"))
|
|
|
+ package.add_argument("--td-receipt", type=Path)
|
|
|
args = parser.parse_args()
|
|
|
if args.command == "run-id":
|
|
|
print(new_run_id())
|
|
|
@@ -201,6 +234,7 @@ def main() -> int:
|
|
|
commit=args.commit,
|
|
|
run_id=args.run_id,
|
|
|
output_root=args.output_root,
|
|
|
+ td_receipt=args.td_receipt,
|
|
|
))
|
|
|
return 0
|
|
|
|