| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
import sys |
| 27 |
import urllib.request |
| 28 |
from pathlib import Path |
| 29 |
|
| 30 |
DEST = Path(__file__).resolve().parent / "vera-rtl" |
| 31 |
RAW = "https://raw.githubusercontent.com/X16Community/vera-module" |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
COMMIT = "45cc1f053376dae12173ea63612820e4d289c0da" |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
COMMIT_PSG = "6e8bea68a5a04687149e27b1b7b3726fb01405f4" |
| 49 |
|
| 50 |
FILES = ( |
| 51 |
("fpga/source/top.v", COMMIT), |
| 52 |
("fpga/source/graphics/layer_renderer.v", COMMIT), |
| 53 |
("fpga/source/graphics/sprite_renderer.v", COMMIT), |
| 54 |
("fpga/source/palette_ram.mem", COMMIT), |
| 55 |
("fpga/source/audio/audio_fifo.v", COMMIT), |
| 56 |
("fpga/source/audio/pcm.v", COMMIT), |
| 57 |
("fpga/source/audio/audio.v", COMMIT), |
| 58 |
("fpga/source/audio/psg.v", COMMIT_PSG), |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
("fpga/source/vram_if.v", COMMIT), |
| 63 |
("fpga/source/main_ram.v", COMMIT), |
| 64 |
("fpga/source/video/video_vga.v", COMMIT), |
| 65 |
("fpga/source/graphics/composer.v", COMMIT), |
| 66 |
("fpga/source/graphics/layer_line_buffer.v", COMMIT), |
| 67 |
("fpga/source/addr_data.v", COMMIT), |
| 68 |
) |
| 69 |
|
| 70 |
|
| 71 |
def manifest(): |
| 72 |
return "".join(f"{Path(p).name} {ref}\n" for p, ref in FILES) |
| 73 |
|
| 74 |
|
| 75 |
def get(url, path): |
| 76 |
if path.exists(): |
| 77 |
print(f" have {path.name}") |
| 78 |
return True |
| 79 |
path.parent.mkdir(parents=True, exist_ok=True) |
| 80 |
try: |
| 81 |
with urllib.request.urlopen(url) as r: |
| 82 |
data = r.read() |
| 83 |
except Exception as e: |
| 84 |
print(f" FAILED {path.name}: {e}", file=sys.stderr) |
| 85 |
return False |
| 86 |
path.write_bytes(data) |
| 87 |
print(f" got {path.name} ({len(data)} bytes)") |
| 88 |
return True |
| 89 |
|
| 90 |
|
| 91 |
def main(): |
| 92 |
print(f"VERA RTL -> {DEST}") |
| 93 |
for p, ref in FILES: |
| 94 |
print(f" {Path(p).name:16} {ref[:8]}") |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
stamp = DEST / "COMMIT" |
| 101 |
want = manifest() |
| 102 |
have = stamp.read_text() if stamp.exists() else None |
| 103 |
if have is not None and have != want: |
| 104 |
print(" pins moved: discarding the fetched copy") |
| 105 |
for p, _ in FILES: |
| 106 |
(DEST / Path(p).name).unlink(missing_ok=True) |
| 107 |
stamp.unlink(missing_ok=True) |
| 108 |
|
| 109 |
ok = True |
| 110 |
for p, ref in FILES: |
| 111 |
|
| 112 |
ok &= get(f"{RAW}/{ref}/{p}", DEST / Path(p).name) |
| 113 |
if not ok: |
| 114 |
return 1 |
| 115 |
stamp.write_text(want) |
| 116 |
return 0 |
| 117 |
|
| 118 |
|
| 119 |
if __name__ == "__main__": |
| 120 |
sys.exit(main()) |