tools/gen_module_code: atomically rewrite the generated files
The gen_module rule in rules.mk is marked as .PHONY, so make will execute it whenever it is mentioned. This results in gen_module_code being executed 64 times for a Juno build.
However in heavily parallel builds there's a good chance that gen_module_code is writing a file whilst the compiler is reading it because make also doesn't know what files are generated by gen_module_code.
The correct fix is to adjust the Makefiles so that the dependencies are correct but this isn't trivial, so band-aid the problem by atomically writing the generated files.
Change-Id: I82d44f9ea6537a91002e1f80de8861d208571630 Signed-off-by: Ross Burton ross.burton@arm.com