aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-06-28 23:07:03 -0400
committerRob Austein <sra@hactrn.net>2016-06-28 23:07:03 -0400
commitc07e57d9bd3f5fad8eb36dcda5144a0a2b6224e9 (patch)
treeb755b0647d984d5c5f3c120f196de1c15dcda9a3
parent731c5de44a9c4a87c6922e6152ef4a89f6e62815 (diff)
Tweak build-shadow-tree.py to adjust an existing tree as well as creating a new one.
Original design intent was that the build tree be created once then left alone, but this turns out to be short-sighted: we really don't want to have to re-synthesize all of the Verilog code just because somebody added a new C file to the firmware.
-rw-r--r--Makefile4
-rwxr-xr-xbuild-shadow-tree.py16
2 files changed, 14 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 5d62630..0ff5e25 100644
--- a/Makefile
+++ b/Makefile
@@ -58,9 +58,7 @@ sandblast: clean
firmware: shadow ${FIRMWARE_TARBALL}
-shadow: build
-
-build:
+shadow:
./build-shadow-tree.py
${FIRMWARE_TARBALL}: ${BITSTREAM} $(sort ${ELVES} ${ELVES:.elf=.bin})
diff --git a/build-shadow-tree.py b/build-shadow-tree.py
index e86ba85..378797f 100755
--- a/build-shadow-tree.py
+++ b/build-shadow-tree.py
@@ -17,14 +17,16 @@ import os
source_root = "source"
build_root = "build"
-os.mkdir(build_root)
+if not os.path.isdir(build_root):
+ os.mkdir(build_root)
for source_head, dirs, files in os.walk(source_root):
build_head = build_root + source_head[len(source_root):]
for dn in dirs:
d = os.path.join(build_head, dn)
- os.mkdir(d)
+ if not os.path.isdir(d):
+ os.mkdir(d)
for fn in files:
if fn == ".git":
@@ -33,4 +35,12 @@ for source_head, dirs, files in os.walk(source_root):
s = os.path.join(source_head, fn)
s = os.path.abspath(s)
s = os.path.relpath(s, build_head)
- os.symlink(s, d)
+ if not os.path.islink(d):
+ os.symlink(s, d)
+
+ for extra in set(os.listdir(build_head)) - set(dirs) - set(files):
+ d = os.path.join(build_head, extra)
+ if os.path.islink(d):
+ os.unlink(d)
+ elif os.path.isdir(d) and not os.listdir(d):
+ os.rmdir(d)