make: add clean action
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 14 Apr 2014 15:21:34 +0000 (17:21 +0200)
committerSebastien Bourdeauducq <sb@m-labs.hk>
Thu, 17 Apr 2014 17:32:31 +0000 (19:32 +0200)
make.py

diff --git a/make.py b/make.py
index f08fd4d19820699fe6d024f09efe04f73f175f55..0b866e52fbbf4ada57a7eeea13a6e78ded5bfd6c 100755 (executable)
--- a/make.py
+++ b/make.py
@@ -18,6 +18,7 @@ MiSoC - a high performance and small footprint SoC based on Migen.
 This program builds and/or loads MiSoC components.
 One or several actions can be specified:
 
+clean           delete previous build(s).
 build-bitstream build FPGA bitstream. Implies build-bios on targets with
                 integrated BIOS.
 build-headers   build software header files with CSR/IRQ/SDRAM_PHY definitions.
@@ -28,7 +29,7 @@ load-bitstream  load bitstream into volatile storage.
 flash-bitstream load bitstream into non-volatile storage.
 flash-bios      load BIOS into non-volatile storage.
 
-all             build-bitstream, build-bios, flash-bitstream, flash-bios.
+all             clean, build-bitstream, build-bios, flash-bitstream, flash-bios.
 
 Load/flash actions use the existing outputs, and do not trigger new builds.
 """)
@@ -91,7 +92,7 @@ if __name__ == "__main__":
        soc.finalize()
 
        # decode actions
-       action_list = ["build-bitstream", "build-headers", "build-csr-csv", "build-bios",
+       action_list = ["clean", "build-bitstream", "build-headers", "build-csr-csv", "build-bios",
                "load-bitstream", "flash-bitstream", "flash-bios", "all"]
        actions = {k: False for k in action_list}
        for action in args.action:
@@ -119,6 +120,7 @@ Subtarget: {}
 
        # dependencies
        if actions["all"]:
+               actions["clean"] = True
                actions["build-bitstream"] = True
                actions["build-bios"] = True
                actions["flash-bitstream"] = True
@@ -128,6 +130,9 @@ Subtarget: {}
        if actions["build-bios"]:
                actions["build-headers"] = True
 
+       if actions["clean"]:
+               subprocess.call(["rm", "-rf", "build/*"])
+
        if actions["build-headers"]:
                boilerplate = """/*
  * Platform:  {}