| 
									
										
										
										
											2014-05-18 23:38:59 +03:00
										 |  |  | # Copyright (C) Ivan Kravets <me@ikravets.com> | 
					
						
							|  |  |  | # See LICENSE for details. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | """
 | 
					
						
							|  |  |  |     Builder for Texas Instruments | 
					
						
							|  |  |  |     Tiva C Series ARM Cortex-M4 microcontrollers. | 
					
						
							|  |  |  | """
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from os.path import join | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-18 20:11:52 +02:00
										 |  |  | from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default, | 
					
						
							|  |  |  |                           DefaultEnvironment, SConscript) | 
					
						
							| 
									
										
										
										
											2014-07-27 22:42:04 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 23:38:59 +03:00
										 |  |  | env = DefaultEnvironment() | 
					
						
							| 
									
										
										
										
											2015-02-23 21:02:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py"))) | 
					
						
							| 
									
										
										
										
											2014-05-18 23:38:59 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | env.Replace( | 
					
						
							| 
									
										
										
										
											2015-02-04 20:23:50 +02:00
										 |  |  |     UPLOADER=join("$PIOPACKAGES_DIR", "tool-lm4flash", "lm4flash"), | 
					
						
							|  |  |  |     UPLOADCMD="$UPLOADER $SOURCES" | 
					
						
							| 
									
										
										
										
											2014-05-18 23:38:59 +03:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | env.Append( | 
					
						
							| 
									
										
										
										
											2015-02-18 20:11:52 +02:00
										 |  |  |     LINKFLAGS=[ | 
					
						
							|  |  |  |         "-nostartfiles", | 
					
						
							|  |  |  |         "-nostdlib" | 
					
						
							|  |  |  |     ] | 
					
						
							| 
									
										
										
										
											2014-05-18 23:38:59 +03:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Target: Build executable and linkable firmware | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-09 12:22:24 +02:00
										 |  |  | target_elf = env.BuildFirmware() | 
					
						
							| 
									
										
										
										
											2014-05-18 23:38:59 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Target: Build the .bin file | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-27 22:42:04 +03:00
										 |  |  | if "uploadlazy" in COMMAND_LINE_TARGETS: | 
					
						
							| 
									
										
										
										
											2015-02-18 20:21:20 +02:00
										 |  |  |     target_firm = join("$BUILD_DIR", "firmware.bin") | 
					
						
							| 
									
										
										
										
											2014-07-27 22:42:04 +03:00
										 |  |  | else: | 
					
						
							| 
									
										
										
										
											2015-02-18 20:21:20 +02:00
										 |  |  |     target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) | 
					
						
							| 
									
										
										
										
											2014-05-18 23:38:59 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-09 19:57:39 +02:00
										 |  |  | # | 
					
						
							|  |  |  | # Target: Print binary size | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") | 
					
						
							|  |  |  | AlwaysBuild(target_size) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 23:38:59 +03:00
										 |  |  | # | 
					
						
							|  |  |  | # Target: Upload firmware | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-18 20:21:20 +02:00
										 |  |  | upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD") | 
					
						
							| 
									
										
										
										
											2014-05-18 23:38:59 +03:00
										 |  |  | AlwaysBuild(upload) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Target: Define targets | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-18 20:21:20 +02:00
										 |  |  | Default([target_firm, target_size]) |