1 |
8 |
gdevic |
#!/usr/bin/env python3
|
2 |
|
|
#
|
3 |
|
|
# This script exports all core A-Z80 Verilog files to a destination of your choice.
|
4 |
|
|
# The files copied are necessary and sufficient to include with your custom project.
|
5 |
|
|
#
|
6 |
|
|
#-------------------------------------------------------------------------------
|
7 |
|
|
# Copyright (C) 2014, 2016 Goran Devic, www.baltazarstudios.com
|
8 |
|
|
#
|
9 |
|
|
# This program is free software; you can redistribute it and/or modify it
|
10 |
|
|
# under the terms of the GNU General Public License as published by the Free
|
11 |
|
|
# Software Foundation; either version 2 of the License, or (at your option)
|
12 |
|
|
# any later version.
|
13 |
|
|
#
|
14 |
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
15 |
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
16 |
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
17 |
|
|
# more details.
|
18 |
|
|
#-------------------------------------------------------------------------------
|
19 |
|
|
import sys
|
20 |
|
|
import os
|
21 |
|
|
from shutil import copyfile
|
22 |
|
|
|
23 |
|
|
if len(sys.argv) != 2:
|
24 |
|
|
print ("\nUsage: export.py <destination-folder>\n")
|
25 |
|
|
print ("Copies all core A-Z80 Verilog files to a destination of your choice.")
|
26 |
13 |
gdevic |
print ("The files copied are necessary and sufficient to include with your project.\n")
|
27 |
|
|
print ("Note for the users of Lattice FPGA toolset: instead of data_pins.v, manually")
|
28 |
|
|
print ("copy and use data_pins_lattice.v file instead.")
|
29 |
8 |
gdevic |
exit(-1)
|
30 |
|
|
|
31 |
|
|
dest = sys.argv[1]
|
32 |
|
|
total = 0
|
33 |
|
|
|
34 |
|
|
if not os.path.exists(dest):
|
35 |
|
|
print ("ERROR: Destination folder does not exist!")
|
36 |
|
|
exit(-1)
|
37 |
|
|
|
38 |
|
|
if not os.path.isdir(dest):
|
39 |
|
|
print ("ERROR: Destination is not a directory!")
|
40 |
|
|
exit(-1)
|
41 |
|
|
|
42 |
|
|
with open('top-level-files.txt') as f:
|
43 |
|
|
files = f.read().splitlines()
|
44 |
|
|
|
45 |
|
|
with open('copyleft.txt') as f:
|
46 |
|
|
copyleft = f.read()
|
47 |
|
|
|
48 |
|
|
# Read and copy each file from the list of input files
|
49 |
|
|
for infile in files:
|
50 |
|
|
if infile.startswith('+'):
|
51 |
|
|
infile = infile[2:]
|
52 |
|
|
if infile.startswith('Files='):
|
53 |
|
|
files = int(infile[6:])
|
54 |
|
|
if total != files:
|
55 |
|
|
print ("ERROR: Incorrect number of files copied!")
|
56 |
|
|
exit(-1)
|
57 |
|
|
else:
|
58 |
|
|
print ("\nDone copying {0} files.".format(files))
|
59 |
|
|
if not os.path.isfile(infile):
|
60 |
|
|
continue
|
61 |
|
|
name = os.path.basename(infile)
|
62 |
|
|
print ('Copying', infile)
|
63 |
|
|
with open(dest + '/' + name, 'wt') as f:
|
64 |
|
|
f.write(copyleft)
|
65 |
|
|
with open(infile) as g:
|
66 |
|
|
f.write(g.read())
|
67 |
|
|
total += 1
|