OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [cpu/] [export.py] - Blame information for rev 8

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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
    print ("The files copied are necessary and sufficient to include with your project.")
27
    exit(-1)
28
 
29
dest = sys.argv[1]
30
total = 0
31
 
32
if not os.path.exists(dest):
33
    print ("ERROR: Destination folder does not exist!")
34
    exit(-1)
35
 
36
if not os.path.isdir(dest):
37
    print ("ERROR: Destination is not a directory!")
38
    exit(-1)
39
 
40
with open('top-level-files.txt') as f:
41
    files = f.read().splitlines()
42
 
43
with open('copyleft.txt') as f:
44
    copyleft = f.read()
45
 
46
# Read and copy each file from the list of input files
47
for infile in files:
48
    if infile.startswith('+'):
49
        infile = infile[2:]
50
    if infile.startswith('Files='):
51
        files = int(infile[6:])
52
        if total != files:
53
            print ("ERROR: Incorrect number of files copied!")
54
            exit(-1)
55
        else:
56
            print ("\nDone copying {0} files.".format(files))
57
    if not os.path.isfile(infile):
58
        continue
59
    name = os.path.basename(infile)
60
    print ('Copying', infile)
61
    with open(dest + '/' + name, 'wt') as f:
62
        f.write(copyleft)
63
        with open(infile) as g:
64
            f.write(g.read())
65
    total += 1

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.