@@ -146,66 +146,7 @@ test: examples
146146 --target-dir=target --workspace
147147 echo ' [ SUCCESS ] libtock-rs tests pass'
148148
149- # Helper functions to define make targets to build for specific (flash, ram,
150- # target) compilation tuples.
151- #
152- # Inspiration from these answers:
153- # - https://stackoverflow.com/a/50357925
154- # - https://stackoverflow.com/a/9458230
155- #
156- # To create a compilation target for a specific architecture with specific flash
157- # and RAM addresses, use `fixed-target`:
158- #
159- # ```
160- # $(call fixed-target, F=0x00030000 R=0x20008000 T=thumbv7em-none-eabi A=cortex-m4)
161- # ```
162- #
163- # The "arguments" if you will are:
164- # - F = Flash Address: The address in flash the app is compiled for.
165- # - R = RAM Address: The address in RAM the app is compiled for.
166- # - T = Target: The cargo target to compile for.
167- # - A = Architecture: The Tock architecture name the target corresponds to.
168- #
169- # This technique uses two make variables internally to keep track of state:
170- # - `ELF_TARGETS`: This is the list of unique targets for each compilation
171- # tuple. Each target invokes `cargo build` with the specified settings.
172- # - `ELF_LIST`: The is a list of .elf paths of the generated elfs (one per
173- # compilation tuple). This is passed to `elf2tab` to generate the output .tab
174- # file.
175- #
176- # Internally, what `fixed-target` does is define a new make target named the
177- # join of all of the F/R/T/A variables (with the `=` characters removed) and
178- # then assigns target variables to that new target to represent the compilation
179- # tuple values.
180- concat = $(subst =,,$(subst $(eval ) ,,$1) )
181- fixed-target = $(foreach A,$1,$(eval $(call concat,$1) : $A) ) $(eval ELF_TARGETS += $(call concat,$1) )
182-
183- $(call fixed-target, F=0x00030000 R=0x20008000 T=thumbv7em-none-eabi A=cortex-m4)
184- $(call fixed-target, F=0x00038000 R=0x20010000 T=thumbv7em-none-eabi A=cortex-m4)
185-
186- $(call fixed-target, F=0x00040000 R=0x10002000 T=thumbv7em-none-eabi A=cortex-m4)
187- $(call fixed-target, F=0x00048000 R=0x1000a000 T=thumbv7em-none-eabi A=cortex-m4)
188-
189- $(call fixed-target, F=0x00040000 R=0x20008000 T=thumbv7em-none-eabi A=cortex-m4)
190- $(call fixed-target, F=0x00042000 R=0x2000a000 T=thumbv7em-none-eabi A=cortex-m4)
191- $(call fixed-target, F=0x00048000 R=0x20010000 T=thumbv7em-none-eabi A=cortex-m4)
192-
193- $(call fixed-target, F=0x00080000 R=0x20006000 T=thumbv7em-none-eabi A=cortex-m4)
194- $(call fixed-target, F=0x00088000 R=0x2000e000 T=thumbv7em-none-eabi A=cortex-m4)
195-
196- $(call fixed-target, F=0x403b0000 R=0x3fca2000 T=riscv32imc-unknown-none-elf A=rv32imc)
197- $(call fixed-target, F=0x40440000 R=0x3fcaa000 T=riscv32imc-unknown-none-elf A=rv32imc)
198-
199- $(call fixed-target, F=0x80100000 R=0x80300000 T=riscv32imac-unknown-none-elf A=rv32imac)
200- $(call fixed-target, F=0x80110000 R=0x80310000 T=riscv32imac-unknown-none-elf A=rv32imac)
201- $(call fixed-target, F=0x80130000 R=0x80330000 T=riscv32imac-unknown-none-elf A=rv32imac)
202- $(call fixed-target, F=0x80180000 R=0x80380000 T=riscv32imac-unknown-none-elf A=rv32imac)
203-
204- $(call fixed-target, F=0x10020000 R=0x20004000 T=thumbv6m-none-eabi A=cortex-m0)
205- $(call fixed-target, F=0x10028000 R=0x2000c000 T=thumbv6m-none-eabi A=cortex-m0)
206-
207- $(call fixed-target, F=0x10040000 R=0x20020000 T=thumbv8m.main-none-eabi A=cortex-m33)
208- $(call fixed-target, F=0x10060000 R=0x20028000 T=thumbv8m.main-none-eabi A=cortex-m33)
149+ include Targets.mk
209150
210151$(ELF_TARGETS ) : toolchain
211152 LIBTOCK_LINKER_FLASH=$(F ) LIBTOCK_LINKER_RAM=$(R ) cargo build --example $(EXAMPLE ) $(features ) --target=$(T ) $(release )
0 commit comments