Skip to content

Commit e7b131b

Browse files
authored
Merge pull request #992 from zapta/main
Added PART-INDEX.json schema version check to the Xilinx chipdb on-de…
2 parents 705e3f4 + 499cf82 commit e7b131b

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

apio/managers/xilinx_chipdb.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
from apio.managers.downloader import FileDownloader
1818
from apio.managers.unpacker import FileUnpacker
1919

20+
EXPECTED_SCHEMA_VERSION = 5
21+
2022

2123
def chipdb_file_on_demand(
2224
apio_ctx: ApioContext,
@@ -33,10 +35,21 @@ def chipdb_file_on_demand(
3335
parts_index_path = openxc7_dir / "PARTS-INDEX.json"
3436
with open(parts_index_path, encoding="utf-8") as f:
3537
json_data = json.load(f)
36-
parts_index = json_data["parts"]
38+
39+
# -- Verify that the index has a schema we understand.
40+
actual_schema_version = (
41+
json_data["schema"] if "schema" in json_data else "Unknown"
42+
)
43+
if actual_schema_version != EXPECTED_SCHEMA_VERSION:
44+
cerror(
45+
f"Unexpected schema version {actual_schema_version}, "
46+
f"expected {EXPECTED_SCHEMA_VERSION}"
47+
)
48+
sys.exit(1)
3749

3850
# -- Lookup information for the yosys_part.
39-
if yosys_part not in parts_index:
51+
parts = json_data["parts"]
52+
if yosys_part not in parts:
4053
cerror(f"No such xilinx yosys part {yosys_part}")
4154
cout(
4255
f"See {str(parts_index_path)} for the list of "
@@ -45,7 +58,7 @@ def chipdb_file_on_demand(
4558
)
4659
sys.exit(1)
4760

48-
part_info = parts_index[yosys_part]
61+
part_info = parts[yosys_part]
4962

5063
if not part_info["generated"]:
5164
cerror(f"Yosys xilinx part {yosys_part} exists but not generated")

0 commit comments

Comments
 (0)