#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
#
|
#
|
# This script exports all core A-Z80 Verilog files to a destination of your choice.
|
# This script exports all core A-Z80 Verilog files to a destination of your choice.
|
# The files copied are necessary and sufficient to include with your custom project.
|
# The files copied are necessary and sufficient to include with your custom project.
|
#
|
#
|
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
# Copyright (C) 2014, 2016 Goran Devic, www.baltazarstudios.com
|
# Copyright (C) 2014, 2016 Goran Devic, www.baltazarstudios.com
|
#
|
#
|
# This program is free software; you can redistribute it and/or modify it
|
# This program is free software; you can redistribute it and/or modify it
|
# under the terms of the GNU General Public License as published by the Free
|
# under the terms of the GNU General Public License as published by the Free
|
# Software Foundation; either version 2 of the License, or (at your option)
|
# Software Foundation; either version 2 of the License, or (at your option)
|
# any later version.
|
# any later version.
|
#
|
#
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
# more details.
|
# more details.
|
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
import sys
|
import sys
|
import os
|
import os
|
from shutil import copyfile
|
from shutil import copyfile
|
|
|
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
print ("\nUsage: export.py <destination-folder>\n")
|
print ("\nUsage: export.py <destination-folder>\n")
|
print ("Copies all core A-Z80 Verilog files to a destination of your choice.")
|
print ("Copies all core A-Z80 Verilog files to a destination of your choice.")
|
print ("The files copied are necessary and sufficient to include with your project.")
|
print ("The files copied are necessary and sufficient to include with your project.\n")
|
|
print ("Note for the users of Lattice FPGA toolset: instead of data_pins.v, manually")
|
|
print ("copy and use data_pins_lattice.v file instead.")
|
exit(-1)
|
exit(-1)
|
|
|
dest = sys.argv[1]
|
dest = sys.argv[1]
|
total = 0
|
total = 0
|
|
|
if not os.path.exists(dest):
|
if not os.path.exists(dest):
|
print ("ERROR: Destination folder does not exist!")
|
print ("ERROR: Destination folder does not exist!")
|
exit(-1)
|
exit(-1)
|
|
|
if not os.path.isdir(dest):
|
if not os.path.isdir(dest):
|
print ("ERROR: Destination is not a directory!")
|
print ("ERROR: Destination is not a directory!")
|
exit(-1)
|
exit(-1)
|
|
|
with open('top-level-files.txt') as f:
|
with open('top-level-files.txt') as f:
|
files = f.read().splitlines()
|
files = f.read().splitlines()
|
|
|
with open('copyleft.txt') as f:
|
with open('copyleft.txt') as f:
|
copyleft = f.read()
|
copyleft = f.read()
|
|
|
# Read and copy each file from the list of input files
|
# Read and copy each file from the list of input files
|
for infile in files:
|
for infile in files:
|
if infile.startswith('+'):
|
if infile.startswith('+'):
|
infile = infile[2:]
|
infile = infile[2:]
|
if infile.startswith('Files='):
|
if infile.startswith('Files='):
|
files = int(infile[6:])
|
files = int(infile[6:])
|
if total != files:
|
if total != files:
|
print ("ERROR: Incorrect number of files copied!")
|
print ("ERROR: Incorrect number of files copied!")
|
exit(-1)
|
exit(-1)
|
else:
|
else:
|
print ("\nDone copying {0} files.".format(files))
|
print ("\nDone copying {0} files.".format(files))
|
if not os.path.isfile(infile):
|
if not os.path.isfile(infile):
|
continue
|
continue
|
name = os.path.basename(infile)
|
name = os.path.basename(infile)
|
print ('Copying', infile)
|
print ('Copying', infile)
|
with open(dest + '/' + name, 'wt') as f:
|
with open(dest + '/' + name, 'wt') as f:
|
f.write(copyleft)
|
f.write(copyleft)
|
with open(infile) as g:
|
with open(infile) as g:
|
f.write(g.read())
|
f.write(g.read())
|
total += 1
|
total += 1
|
|
|