-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
105 lines (86 loc) · 3.18 KB
/
build.py
File metadata and controls
105 lines (86 loc) · 3.18 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Python-EDA
# Copyright (C) 2018 Luke Cole
#
# 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 Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import os
import shutil
if len(sys.argv) < 3:
print ("Usage: %s output_dir_symbols output_dir_footprints\n" % sys.argv[0])
exit()
output_dir_symbols = sys.argv[1]
output_dir_footprints = sys.argv[2]
symbols_dir = 'symbols'
tsv_dir = 'tsv'
sym_dir = 'sym'
if not os.path.isdir(output_dir_symbols):
os.mkdir(output_dir_symbols)
sym_dir_full = os.path.join(symbols_dir, sym_dir)
sym_files = os.listdir(sym_dir_full)
for f in sym_files:
sym_file = os.path.join(sym_dir_full, f)
if (os.path.isfile(sym_file)):
print ("mv %s %s" % (sym_file, output_dir_symbols))
shutil.copy(sym_file, output_dir_symbols)
tsv_dir_full = os.path.join(symbols_dir, tsv_dir)
# Determine which command exists: tragesym or lepton-tragesym
command = None
if shutil.which("tragesym"):
command = "tragesym"
elif shutil.which("lepton-tragesym"):
command = "lepton-tragesym"
else:
raise EnvironmentError("Neither 'tragesym' nor 'lepton-tragesym' is available in the system PATH.")
# Process the TSV files
f = []
for (dirpath, dirname, filenames) in os.walk(tsv_dir_full):
for f in filenames:
if ".tsv" in f:
print(f)
sym_file = os.path.splitext(f)[0] + ".sym"
sym_file = os.path.join(output_dir_symbols, sym_file)
tsv_file = os.path.join(tsv_dir_full, f)
if os.path.isfile(tsv_file):
try:
cmd = f"{command} {tsv_file} {sym_file}"
print(cmd)
os.system(cmd)
except Exception as e:
print(f"Error processing {tsv_file}: {e}")
break
footprints_dir = 'footprints'
fp_gen_dir = 'gen'
fp_dir = 'fp'
if not os.path.isdir(output_dir_footprints):
os.mkdir(output_dir_footprints)
fp_dir_full = os.path.join(footprints_dir, fp_dir)
fp_files = os.listdir(fp_dir_full)
for f in fp_files:
fp_file = os.path.join(fp_dir_full, f)
if (os.path.isfile(fp_file)):
print ("mv %s %s" % (fp_file, output_dir_footprints))
shutil.copy(fp_file, output_dir_footprints)
fp_gen_full = os.path.join(footprints_dir, fp_gen_dir)
f = []
for (dirpath, dirname, filenames) in os.walk(fp_gen_full):
for f in filenames:
if "mk_" in f:
fp_gen_file = os.path.join(fp_gen_full, f)
if (os.path.isfile(fp_gen_file)):
cmd = "python %s" % (fp_gen_file)
print (cmd)
os.system(cmd)
cmd = "mv *.fp %s" % (output_dir_footprints)
print (cmd)
os.system(cmd) # TODO: make multi-platform