2010-05-06 01:09:40 +00:00
|
|
|
import os, sys, shutil, string
|
2010-05-06 01:09:21 +00:00
|
|
|
|
2009-10-18 01:27:33 +00:00
|
|
|
# Helper: "normalize" a name to make it a suitable C macro name
|
|
|
|
def cnorm( name ):
|
|
|
|
name = name.replace( '-', '' )
|
|
|
|
name = name.replace( ' ', '' )
|
|
|
|
return name.upper()
|
|
|
|
|
2009-02-23 13:56:21 +00:00
|
|
|
# List of toolchains
|
|
|
|
toolchain_list = {
|
|
|
|
'arm-gcc' : {
|
|
|
|
'compile' : 'arm-elf-gcc',
|
|
|
|
'link' : 'arm-elf-ld',
|
|
|
|
'asm' : 'arm-elf-as',
|
|
|
|
'bin' : 'arm-elf-objcopy',
|
EXPERIMENTAL FEATURE: romfs compression/precompilation.
Added another "romfs" parameter to SConstruct. It can take one of 3 values:
- "verbatim" (default): copy all the files from the eLua romfs/ directory to the binary image (exactly what happened until now)
- "compress": use LuaSrcDiet (http://luaforge.net/projects/luasrcdiet, now included in the eLua distribution) to "compress" the source code by using different tricks (shorter identifiers, removing comments and EOLS, and so on). The output is still a compilable Lua file (although in most case it looks completely different from the original) which is copied in the eLua binary image instead of the original Lua file. The compression obtained by using this method seems to be very good in practice, thus it will save flash when needed.
- "compile": use the eLua cross compiler (that must be built first by running 'scons -f cross-lua.py') to precompile the Lua files to bytecode, and write the bytecode to the image instead of the source file. This way, one can save both time (the scripts don't need to be compiled anymore) and RAM (for the same reason, especially since the Lua parser uses the stack a lot, which can lead to very nasty and hard to diagnose stack overflow bugs). It will be even more useful in the future, when (hopefully) more and more Lua bytecode data structures will be available directly from Flash (without having to copy them RAM as it happens now). It might also decrease the romfs memory footprint, but then again, it might not; it pretty much depends on the Lua programs included in the romfs.
2009-12-02 19:33:03 +00:00
|
|
|
'size' : 'arm-elf-size',
|
|
|
|
'cross_cpumode' : 'little',
|
|
|
|
'cross_lua' : 'float_arm 64',
|
|
|
|
'cross_lualong' : 'int 32'
|
2009-02-23 13:56:21 +00:00
|
|
|
},
|
2009-03-05 22:48:08 +00:00
|
|
|
'arm-eabi-gcc' : {
|
2009-03-05 22:47:58 +00:00
|
|
|
'compile' : 'arm-eabi-gcc',
|
|
|
|
'link' : 'arm-eabi-ld',
|
|
|
|
'asm' : 'arm-eabi-as',
|
|
|
|
'bin' : 'arm-eabi-objcopy',
|
EXPERIMENTAL FEATURE: romfs compression/precompilation.
Added another "romfs" parameter to SConstruct. It can take one of 3 values:
- "verbatim" (default): copy all the files from the eLua romfs/ directory to the binary image (exactly what happened until now)
- "compress": use LuaSrcDiet (http://luaforge.net/projects/luasrcdiet, now included in the eLua distribution) to "compress" the source code by using different tricks (shorter identifiers, removing comments and EOLS, and so on). The output is still a compilable Lua file (although in most case it looks completely different from the original) which is copied in the eLua binary image instead of the original Lua file. The compression obtained by using this method seems to be very good in practice, thus it will save flash when needed.
- "compile": use the eLua cross compiler (that must be built first by running 'scons -f cross-lua.py') to precompile the Lua files to bytecode, and write the bytecode to the image instead of the source file. This way, one can save both time (the scripts don't need to be compiled anymore) and RAM (for the same reason, especially since the Lua parser uses the stack a lot, which can lead to very nasty and hard to diagnose stack overflow bugs). It will be even more useful in the future, when (hopefully) more and more Lua bytecode data structures will be available directly from Flash (without having to copy them RAM as it happens now). It might also decrease the romfs memory footprint, but then again, it might not; it pretty much depends on the Lua programs included in the romfs.
2009-12-02 19:33:03 +00:00
|
|
|
'size' : 'arm-eabi-size',
|
|
|
|
'cross_cpumode' : 'little',
|
|
|
|
'cross_lua' : 'float 64',
|
|
|
|
'cross_lualong' : 'int 32'
|
2009-03-05 22:47:58 +00:00
|
|
|
},
|
2009-02-24 22:09:22 +00:00
|
|
|
'codesourcery' : {
|
2009-02-23 13:56:21 +00:00
|
|
|
'compile' : 'arm-none-eabi-gcc',
|
|
|
|
'link' : 'arm-none-eabi-ld',
|
|
|
|
'asm' : 'arm-none-eabi-as',
|
|
|
|
'bin' : 'arm-none-eabi-objcopy',
|
EXPERIMENTAL FEATURE: romfs compression/precompilation.
Added another "romfs" parameter to SConstruct. It can take one of 3 values:
- "verbatim" (default): copy all the files from the eLua romfs/ directory to the binary image (exactly what happened until now)
- "compress": use LuaSrcDiet (http://luaforge.net/projects/luasrcdiet, now included in the eLua distribution) to "compress" the source code by using different tricks (shorter identifiers, removing comments and EOLS, and so on). The output is still a compilable Lua file (although in most case it looks completely different from the original) which is copied in the eLua binary image instead of the original Lua file. The compression obtained by using this method seems to be very good in practice, thus it will save flash when needed.
- "compile": use the eLua cross compiler (that must be built first by running 'scons -f cross-lua.py') to precompile the Lua files to bytecode, and write the bytecode to the image instead of the source file. This way, one can save both time (the scripts don't need to be compiled anymore) and RAM (for the same reason, especially since the Lua parser uses the stack a lot, which can lead to very nasty and hard to diagnose stack overflow bugs). It will be even more useful in the future, when (hopefully) more and more Lua bytecode data structures will be available directly from Flash (without having to copy them RAM as it happens now). It might also decrease the romfs memory footprint, but then again, it might not; it pretty much depends on the Lua programs included in the romfs.
2009-12-02 19:33:03 +00:00
|
|
|
'size' : 'arm-none-eabi-size',
|
|
|
|
'cross_cpumode' : 'little',
|
|
|
|
'cross_lua' : 'float 64',
|
|
|
|
'cross_lualong' : 'int 32'
|
2009-02-23 13:56:21 +00:00
|
|
|
},
|
|
|
|
'avr32-gcc' : {
|
|
|
|
'compile' : 'avr32-gcc',
|
|
|
|
'link' : 'avr32-ld',
|
|
|
|
'asm' : 'avr32-as',
|
|
|
|
'bin' : 'avr32-objcopy',
|
EXPERIMENTAL FEATURE: romfs compression/precompilation.
Added another "romfs" parameter to SConstruct. It can take one of 3 values:
- "verbatim" (default): copy all the files from the eLua romfs/ directory to the binary image (exactly what happened until now)
- "compress": use LuaSrcDiet (http://luaforge.net/projects/luasrcdiet, now included in the eLua distribution) to "compress" the source code by using different tricks (shorter identifiers, removing comments and EOLS, and so on). The output is still a compilable Lua file (although in most case it looks completely different from the original) which is copied in the eLua binary image instead of the original Lua file. The compression obtained by using this method seems to be very good in practice, thus it will save flash when needed.
- "compile": use the eLua cross compiler (that must be built first by running 'scons -f cross-lua.py') to precompile the Lua files to bytecode, and write the bytecode to the image instead of the source file. This way, one can save both time (the scripts don't need to be compiled anymore) and RAM (for the same reason, especially since the Lua parser uses the stack a lot, which can lead to very nasty and hard to diagnose stack overflow bugs). It will be even more useful in the future, when (hopefully) more and more Lua bytecode data structures will be available directly from Flash (without having to copy them RAM as it happens now). It might also decrease the romfs memory footprint, but then again, it might not; it pretty much depends on the Lua programs included in the romfs.
2009-12-02 19:33:03 +00:00
|
|
|
'size' : 'avr32-size',
|
|
|
|
'cross_cpumode' : 'big',
|
|
|
|
'cross_lua' : 'float 64',
|
|
|
|
'cross_lualong' : 'int 32'
|
2009-02-23 13:56:21 +00:00
|
|
|
},
|
|
|
|
'i686-gcc' : {
|
|
|
|
'compile' : 'i686-elf-gcc',
|
|
|
|
'link' : 'i686-elf-ld',
|
|
|
|
'asm' : 'nasm',
|
|
|
|
'bin' : 'i686-elf-objcopy',
|
EXPERIMENTAL FEATURE: romfs compression/precompilation.
Added another "romfs" parameter to SConstruct. It can take one of 3 values:
- "verbatim" (default): copy all the files from the eLua romfs/ directory to the binary image (exactly what happened until now)
- "compress": use LuaSrcDiet (http://luaforge.net/projects/luasrcdiet, now included in the eLua distribution) to "compress" the source code by using different tricks (shorter identifiers, removing comments and EOLS, and so on). The output is still a compilable Lua file (although in most case it looks completely different from the original) which is copied in the eLua binary image instead of the original Lua file. The compression obtained by using this method seems to be very good in practice, thus it will save flash when needed.
- "compile": use the eLua cross compiler (that must be built first by running 'scons -f cross-lua.py') to precompile the Lua files to bytecode, and write the bytecode to the image instead of the source file. This way, one can save both time (the scripts don't need to be compiled anymore) and RAM (for the same reason, especially since the Lua parser uses the stack a lot, which can lead to very nasty and hard to diagnose stack overflow bugs). It will be even more useful in the future, when (hopefully) more and more Lua bytecode data structures will be available directly from Flash (without having to copy them RAM as it happens now). It might also decrease the romfs memory footprint, but then again, it might not; it pretty much depends on the Lua programs included in the romfs.
2009-12-02 19:33:03 +00:00
|
|
|
'size' : 'i686-elf-size',
|
|
|
|
'cross_cpumode' : 'little',
|
|
|
|
'cross_lua' : 'float 64',
|
|
|
|
'cross_lualong' : 'int 32'
|
2009-02-23 13:56:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-05 22:48:08 +00:00
|
|
|
# Toolchain Aliases
|
|
|
|
toolchain_list['devkitarm'] = toolchain_list['arm-eabi-gcc']
|
|
|
|
|
2009-02-23 13:56:21 +00:00
|
|
|
# List of platform/CPU/toolchains combinations
|
|
|
|
# The first toolchain in the toolchains list is the default one
|
|
|
|
# (the one that will be used if none is specified)
|
|
|
|
platform_list = {
|
2009-03-05 22:48:08 +00:00
|
|
|
'at91sam7x' : { 'cpus' : [ 'AT91SAM7X256', 'AT91SAM7X512' ], 'toolchains' : [ 'arm-gcc', 'codesourcery', 'devkitarm', 'arm-eabi-gcc' ] },
|
2009-08-03 18:37:38 +00:00
|
|
|
'lm3s' : { 'cpus' : [ 'LM3S8962', 'LM3S6965', 'LM3S6918', 'LM3S9B92' ], 'toolchains' : [ 'arm-gcc', 'codesourcery', 'devkitarm', 'arm-eabi-gcc' ] },
|
2009-03-05 22:48:08 +00:00
|
|
|
'str9' : { 'cpus' : [ 'STR912FAW44' ], 'toolchains' : [ 'arm-gcc', 'codesourcery', 'devkitarm', 'arm-eabi-gcc' ] },
|
2009-02-23 13:56:21 +00:00
|
|
|
'i386' : { 'cpus' : [ 'I386' ], 'toolchains' : [ 'i686-gcc' ] },
|
Modified Robert's 'linux' platform:
- code cleanup
- the platform is now named 'sim'. You build it like this:
$ scons cpu=linux
The idea is to support more than one host OS by changing the "cpu" variable
above (for example cpu=osx, or cpu=win32). Also, a crude "host interface" was
defined in hostif.h. In theory, a host OS should only implement that interface
in order to run the eLua simulator. The implementation must reside in a file
called hostif_{os}.c (in this case hostif_linux.c). Too bad I don't have a MAC,
I would've loved to try this :)
REMEMBER: whem implementing a host interface, you CAN NOT rely on your regular
libc! You'll have to rewrite the syscalls (see host.c for an example on how to
do this in Linux).
- after you build it, don't start it directly, use the new "run_elua_sim.sh"
script to run it. It will set the terminal to raw mode, no echo, so it will
behave more like "traditional" eLua (even hangman.lua will run in this mode :) ).
Remember to run in on an ANSI capable terminal (although most of them support
ANSI emulation nowadays).
- you can exit from the simulator with "exit". You can't do this with CTRL+C if
you run it with "run_elua_sim.sh".
All in all, this looks pretty good and it's an excellent test platform. It will
do wonders when we integrate our own libc and we won't be able to figure out why
it doesn't work :)
2009-05-12 14:09:29 +00:00
|
|
|
'sim' : { 'cpus' : [ 'LINUX' ], 'toolchains' : [ 'i686-gcc' ] },
|
2009-03-05 22:48:08 +00:00
|
|
|
'lpc288x' : { 'cpus' : [ 'LPC2888' ], 'toolchains' : [ 'arm-gcc', 'codesourcery', 'devkitarm', 'arm-eabi-gcc' ] },
|
|
|
|
'str7' : { 'cpus' : [ 'STR711FR2' ], 'toolchains' : [ 'arm-gcc', 'codesourcery', 'devkitarm', 'arm-eabi-gcc' ] },
|
|
|
|
'stm32' : { 'cpus' : [ 'STM32F103ZE', 'STM32F103RE' ], 'toolchains' : [ 'arm-gcc', 'codesourcery', 'devkitarm', 'arm-eabi-gcc' ] },
|
2009-10-31 11:41:34 +00:00
|
|
|
'avr32' : { 'cpus' : [ 'AT32UC3A0512' ], 'toolchains' : [ 'avr32-gcc' ] },
|
2010-01-05 03:40:12 +00:00
|
|
|
'lpc24xx' : { 'cpus' : [ 'LPC2468' ], 'toolchains' : [ 'arm-gcc', 'codesourcery', 'devkitarm', 'arm-eabi-gcc' ] },
|
|
|
|
'lpc17xx' : { 'cpus' : [ 'LPC1768' ], 'toolchains' : [ 'arm-gcc', 'codesourcery', 'devkitarm', 'arm-eabi-gcc' ] }
|
2009-02-23 13:56:21 +00:00
|
|
|
}
|
2008-08-27 20:05:09 +00:00
|
|
|
|
2008-09-01 13:21:06 +00:00
|
|
|
# List of board/CPU combinations
|
2008-12-13 23:31:40 +00:00
|
|
|
board_list = { 'SAM7-EX256' : [ 'AT91SAM7X256', 'AT91SAM7X512' ],
|
2008-08-27 20:05:09 +00:00
|
|
|
'EK-LM3S8962' : [ 'LM3S8962' ],
|
|
|
|
'EK-LM3S6965' : [ 'LM3S6965' ],
|
2009-08-03 18:37:38 +00:00
|
|
|
'EK-LM3S9B92' : [ 'LM3S9B92' ],
|
2009-02-25 21:29:40 +00:00
|
|
|
'STR9-COMSTICK' : [ 'STR912FAW44' ],
|
2009-10-18 01:27:33 +00:00
|
|
|
'STR-E912' : [ 'STR912FAW44' ],
|
2008-08-27 20:05:09 +00:00
|
|
|
'PC' : [ 'I386' ],
|
Modified Robert's 'linux' platform:
- code cleanup
- the platform is now named 'sim'. You build it like this:
$ scons cpu=linux
The idea is to support more than one host OS by changing the "cpu" variable
above (for example cpu=osx, or cpu=win32). Also, a crude "host interface" was
defined in hostif.h. In theory, a host OS should only implement that interface
in order to run the eLua simulator. The implementation must reside in a file
called hostif_{os}.c (in this case hostif_linux.c). Too bad I don't have a MAC,
I would've loved to try this :)
REMEMBER: whem implementing a host interface, you CAN NOT rely on your regular
libc! You'll have to rewrite the syscalls (see host.c for an example on how to
do this in Linux).
- after you build it, don't start it directly, use the new "run_elua_sim.sh"
script to run it. It will set the terminal to raw mode, no echo, so it will
behave more like "traditional" eLua (even hangman.lua will run in this mode :) ).
Remember to run in on an ANSI capable terminal (although most of them support
ANSI emulation nowadays).
- you can exit from the simulator with "exit". You can't do this with CTRL+C if
you run it with "run_elua_sim.sh".
All in all, this looks pretty good and it's an excellent test platform. It will
do wonders when we integrate our own libc and we won't be able to figure out why
it doesn't work :)
2009-05-12 14:09:29 +00:00
|
|
|
'SIM' : [ 'LINUX' ],
|
2008-10-02 21:21:39 +00:00
|
|
|
'LPC-H2888' : [ 'LPC2888' ],
|
2008-11-08 07:14:51 +00:00
|
|
|
'MOD711' : [ 'STR711FR2' ],
|
2008-12-13 23:31:40 +00:00
|
|
|
'STM3210E-EVAL' : [ 'STM32F103ZE' ],
|
2009-02-23 13:56:21 +00:00
|
|
|
'ATEVK1100' : [ 'AT32UC3A0512' ],
|
2009-02-23 15:28:56 +00:00
|
|
|
'ET-STM32' : [ 'STM32F103RE' ],
|
2009-10-31 11:41:34 +00:00
|
|
|
'EAGLE-100' : [ 'LM3S6918' ],
|
2010-01-05 03:40:12 +00:00
|
|
|
'ELUA-PUC' : ['LPC2468' ],
|
|
|
|
'MBED' : ['LPC1768']
|
2008-08-02 17:52:11 +00:00
|
|
|
}
|
2008-08-14 07:38:30 +00:00
|
|
|
|
2010-05-06 01:09:40 +00:00
|
|
|
cpu_list = sum([board_list[i] for i in board_list],[])
|
|
|
|
|
|
|
|
|
2009-02-21 23:02:39 +00:00
|
|
|
# ROMFS file list "groups"
|
2009-02-27 10:57:58 +00:00
|
|
|
# To include a file in a ROMFS build, include it in a group here (or create one
|
|
|
|
# if you need) and make sure the group is included on your platform's file_list
|
|
|
|
# definition (right after this).
|
2009-02-21 23:02:39 +00:00
|
|
|
romfs = { 'bisect' : [ 'bisect.lua' ],
|
|
|
|
'hangman' : [ 'hangman.lua' ],
|
|
|
|
'lhttpd' : [ 'index.pht', 'lhttpd.lua', 'test.lua' ],
|
|
|
|
'led' : [ 'led.lua' ],
|
|
|
|
'piano' : [ 'piano.lua' ],
|
|
|
|
'pwmled' : [ 'pwmled.lua' ],
|
|
|
|
'tvbgone' : [ 'tvbgone.lua', 'codes.bin' ],
|
|
|
|
'hello' : [ 'hello.lua' ],
|
|
|
|
'info' : [ 'info.lua' ],
|
|
|
|
'morse' : [ 'morse.lua' ],
|
|
|
|
'dualpwm' : [ 'dualpwm.lua' ],
|
|
|
|
'adcscope' : [ 'adcscope.lua' ],
|
2009-03-21 19:59:49 +00:00
|
|
|
'adcpoll' : [ 'adcpoll.lua' ],
|
2009-08-19 19:18:45 +00:00
|
|
|
'life' : [ 'life.lua' ],
|
2009-10-13 02:14:27 +00:00
|
|
|
'logo' : ['logo.lua', 'logo.bin' ],
|
2010-02-03 12:32:18 +00:00
|
|
|
'pong' : [ 'pong.lua' ],
|
2009-10-13 02:14:27 +00:00
|
|
|
'spaceship' : [ 'spaceship.lua' ],
|
2009-11-20 12:15:20 +00:00
|
|
|
'tetrives' : [ 'tetrives.lua' ],
|
2010-06-22 14:13:05 +00:00
|
|
|
'snake' : [ 'snake.lua' ],
|
|
|
|
'pachube' : [ 'pachube_demo.lua' ]
|
2009-02-21 23:02:39 +00:00
|
|
|
}
|
|
|
|
|
2009-01-08 15:20:05 +00:00
|
|
|
# List of board/romfs data combinations
|
|
|
|
file_list = { 'SAM7-EX256' : [ 'bisect', 'hangman' , 'led', 'piano', 'hello', 'info', 'morse' ],
|
2010-06-22 14:13:05 +00:00
|
|
|
'EK-LM3S8962' : [ 'lhttpd','bisect', 'led', 'pachube' ],
|
2010-02-15 22:26:15 +00:00
|
|
|
'EK-LM3S6965' : [ 'bisect', 'hangman', 'pong', 'led', 'piano', 'pwmled', 'hello', 'info', 'morse', 'adcscope', 'adcpoll', 'logo', 'tetrives' ],
|
2010-01-25 23:43:05 +00:00
|
|
|
'EK-LM3S9B92' : [ 'bisect', 'hangman', 'led', 'pwmled', 'hello', 'info', 'adcscope','adcpoll', 'life' ],
|
2009-01-08 15:20:05 +00:00
|
|
|
'STR9-COMSTICK' : [ 'bisect', 'hangman', 'led', 'hello', 'info' ],
|
2009-10-18 01:27:33 +00:00
|
|
|
'STR-E912' : [ 'bisect', 'hangman', 'led', 'hello', 'info', 'piano' ],
|
2009-03-23 21:07:49 +00:00
|
|
|
'PC' : [ 'bisect', 'hello', 'info', 'life', 'hangman' ],
|
Modified Robert's 'linux' platform:
- code cleanup
- the platform is now named 'sim'. You build it like this:
$ scons cpu=linux
The idea is to support more than one host OS by changing the "cpu" variable
above (for example cpu=osx, or cpu=win32). Also, a crude "host interface" was
defined in hostif.h. In theory, a host OS should only implement that interface
in order to run the eLua simulator. The implementation must reside in a file
called hostif_{os}.c (in this case hostif_linux.c). Too bad I don't have a MAC,
I would've loved to try this :)
REMEMBER: whem implementing a host interface, you CAN NOT rely on your regular
libc! You'll have to rewrite the syscalls (see host.c for an example on how to
do this in Linux).
- after you build it, don't start it directly, use the new "run_elua_sim.sh"
script to run it. It will set the terminal to raw mode, no echo, so it will
behave more like "traditional" eLua (even hangman.lua will run in this mode :) ).
Remember to run in on an ANSI capable terminal (although most of them support
ANSI emulation nowadays).
- you can exit from the simulator with "exit". You can't do this with CTRL+C if
you run it with "run_elua_sim.sh".
All in all, this looks pretty good and it's an excellent test platform. It will
do wonders when we integrate our own libc and we won't be able to figure out why
it doesn't work :)
2009-05-12 14:09:29 +00:00
|
|
|
'SIM' : [ 'bisect', 'hello', 'info', 'life', 'hangman' ],
|
2009-01-08 15:20:05 +00:00
|
|
|
'LPC-H2888' : [ 'bisect', 'hangman', 'led', 'hello', 'info' ],
|
2009-01-11 20:43:02 +00:00
|
|
|
'MOD711' : [ 'bisect', 'hangman', 'led', 'hello', 'info', 'dualpwm' ],
|
2009-01-08 15:20:05 +00:00
|
|
|
'STM3210E-EVAL' : [ 'bisect', 'hello', 'info' ],
|
2009-02-23 13:56:21 +00:00
|
|
|
'ATEVK1100' : [ 'bisect', 'hangman', 'led', 'hello', 'info' ],
|
2009-07-08 23:40:12 +00:00
|
|
|
'ET-STM32' : [ 'hello', 'hangman', 'info', 'bisect','adcscope','adcpoll', 'dualpwm', 'pwmled' ],
|
2009-10-31 11:41:34 +00:00
|
|
|
'EAGLE-100' : [ 'bisect', 'hangman', 'lhttpd', 'led', 'hello', 'info' ],
|
2010-01-05 03:40:12 +00:00
|
|
|
'ELUA-PUC' : [ 'bisect', 'hangman', 'led', 'hello', 'info', 'pwmled' ],
|
2010-07-12 20:56:54 +00:00
|
|
|
'MBED' : [ 'bisect', 'hangman', 'hello', 'info', 'led', 'pwmled', 'dualpwm', 'life', 'adcscope','adcpoll' ],
|
2009-11-02 17:44:35 +00:00
|
|
|
}
|
2009-01-08 15:20:05 +00:00
|
|
|
|
2010-06-14 20:28:32 +00:00
|
|
|
comp = Environment( tools = [],
|
|
|
|
OBJSUFFIX = ".o",
|
2010-05-10 23:05:55 +00:00
|
|
|
PROGSUFFIX = ".elf",
|
|
|
|
ENV = os.environ,
|
2010-06-14 20:28:32 +00:00
|
|
|
CPPDEFINES = {} )
|
|
|
|
|
|
|
|
if comp['PLATFORM'] == 'win32':
|
|
|
|
Tool('mingw')(comp)
|
|
|
|
else:
|
|
|
|
Tool('default')(comp)
|
2010-05-06 01:09:21 +00:00
|
|
|
|
2010-05-06 01:09:40 +00:00
|
|
|
# Replacement for standard EnumVariable functionality to derive case from original list
|
|
|
|
class InsensitiveString(object):
|
|
|
|
def __init__(self, s):
|
|
|
|
self.s = s
|
|
|
|
def __cmp__(self, other):
|
|
|
|
return cmp(self.s.lower(), other.lower())
|
|
|
|
|
|
|
|
def _validator(key, val, env, vals):
|
|
|
|
if not val in vals:
|
|
|
|
raise SCons.Errors.UserError(
|
|
|
|
'Invalid value for option %s: %s' % (key, val))
|
|
|
|
|
|
|
|
def MatchEnumVariable(key, help, default, allowed_values, map={}):
|
|
|
|
help = '%s (%s)' % (help, string.join(allowed_values, '|'))
|
|
|
|
|
|
|
|
validator = lambda key, val, env, vals=allowed_values: \
|
|
|
|
_validator(key, InsensitiveString(val), env, vals)
|
|
|
|
|
|
|
|
converter = lambda val, map=map: \
|
|
|
|
map.get(val, allowed_values[allowed_values.index(InsensitiveString(val))])
|
|
|
|
|
|
|
|
return (key, help, default, validator, converter)
|
|
|
|
|
|
|
|
|
|
|
|
# Add Configurable Variables
|
2010-07-29 03:34:21 +00:00
|
|
|
vars = Variables()
|
2010-05-06 01:09:40 +00:00
|
|
|
|
2010-05-11 21:34:09 +00:00
|
|
|
vars.AddVariables(
|
|
|
|
MatchEnumVariable('target',
|
|
|
|
'build "regular" float lua or integer-only "lualong"',
|
|
|
|
'lua',
|
|
|
|
allowed_values = [ 'lua', 'lualong' ] ),
|
|
|
|
MatchEnumVariable('cpu',
|
|
|
|
'build for the specified CPU (board will be inferred, if possible)',
|
|
|
|
'auto',
|
|
|
|
allowed_values = cpu_list + [ 'auto' ] ),
|
|
|
|
MatchEnumVariable('allocator',
|
|
|
|
'select memory allocator',
|
|
|
|
'auto',
|
|
|
|
allowed_values=[ 'newlib', 'multiple', 'simple', 'auto' ] ),
|
|
|
|
MatchEnumVariable('board',
|
|
|
|
'selects board for target (cpu will be inferred)',
|
|
|
|
'auto',
|
|
|
|
allowed_values=board_list.keys() + [ 'auto' ] ),
|
|
|
|
MatchEnumVariable('toolchain',
|
|
|
|
'specifies toolchain to use (auto=search for usable toolchain)',
|
|
|
|
'auto',
|
|
|
|
allowed_values=toolchain_list.keys() + [ 'auto' ] ),
|
|
|
|
BoolVariable( 'optram',
|
|
|
|
'enables Lua Tiny RAM enhancements',
|
|
|
|
True ),
|
|
|
|
MatchEnumVariable('boot',
|
|
|
|
'boot mode, standard will boot to shell, luarpc boots to an rpc server',
|
|
|
|
'standard',
|
|
|
|
allowed_values=[ 'standard' , 'luarpc' ] ),
|
|
|
|
MatchEnumVariable('romfs',
|
|
|
|
'ROMFS compilation mode',
|
|
|
|
'verbatim',
|
2010-06-24 23:20:00 +00:00
|
|
|
allowed_values=[ 'verbatim' , 'compress', 'compile' ] ) )
|
2010-05-06 01:09:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
vars.Update(comp)
|
|
|
|
|
|
|
|
if not GetOption( 'help' ):
|
|
|
|
|
|
|
|
conf = Configure(comp)
|
|
|
|
|
|
|
|
# Variants: board = <board>
|
|
|
|
# cpu = <cpuname>
|
|
|
|
# board = <board> cpu=<cpuname>
|
|
|
|
if comp['board'] == 'auto' and comp['cpu'] == 'auto':
|
|
|
|
print "Must specifiy board, cpu, or both"
|
2010-05-06 01:09:21 +00:00
|
|
|
Exit( -1 )
|
2010-05-06 01:09:40 +00:00
|
|
|
elif comp['board'] != 'auto' and comp['cpu'] != 'auto':
|
|
|
|
# Check if the board, cpu pair is correct
|
|
|
|
if not comp['cpu'] in board_list[ comp['board'] ]:
|
|
|
|
print "Invalid CPU %s for board %s" % ( comp['cpu'], comp['board'] )
|
|
|
|
Exit( -1 )
|
|
|
|
elif comp['board'] != 'auto':
|
|
|
|
# Find CPU
|
|
|
|
comp['cpu'] = board_list[ comp['board'] ][ 0 ]
|
|
|
|
else:
|
|
|
|
# cpu = <cputype>
|
|
|
|
# Find board name
|
|
|
|
for b, v in board_list.items():
|
|
|
|
if comp['cpu'] in v:
|
|
|
|
comp['board'] = b
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
print "CPU %s not found" % comp['cpu']
|
|
|
|
Exit( -1 )
|
|
|
|
|
|
|
|
# Look for the given CPU in the list of platforms
|
|
|
|
platform = None
|
|
|
|
for p, v in platform_list.items():
|
|
|
|
if comp['cpu'] in v[ 'cpus' ]:
|
|
|
|
platform = p
|
2008-09-01 13:21:06 +00:00
|
|
|
break
|
|
|
|
else:
|
2010-05-06 01:09:40 +00:00
|
|
|
print "Unknown CPU %s" % comp['cpu']
|
|
|
|
print "List of accepted CPUs: "
|
|
|
|
for p, v in platform_list.items():
|
|
|
|
print " ", p, "-->",
|
|
|
|
for cpu in v[ 'cpus' ]:
|
|
|
|
print cpu,
|
|
|
|
print
|
2010-05-10 23:05:55 +00:00
|
|
|
Exit( -1 )
|
2008-09-01 13:21:06 +00:00
|
|
|
|
2010-05-06 01:09:40 +00:00
|
|
|
# Check the toolchain
|
|
|
|
if comp['toolchain'] != 'auto':
|
|
|
|
if not comp['toolchain'] in platform_list[ platform ][ 'toolchains' ]:
|
|
|
|
print "Invalid toolchain '%s' for CPU '%s'" % ( comp['toolchain'], comp['cpu'] )
|
|
|
|
Exit( -1 )
|
|
|
|
toolset = toolchain_list[ comp['toolchain'] ]
|
2010-05-12 16:59:30 +00:00
|
|
|
comp[ 'CC' ] = toolset[ 'compile' ]
|
|
|
|
comp[ 'AS' ] = toolset[ 'compile' ]
|
2010-05-06 01:09:40 +00:00
|
|
|
else:
|
2010-05-10 23:05:55 +00:00
|
|
|
# if 'auto' try to match a working toolchain with target
|
|
|
|
usable_chains = [toolchain_list[ toolchain ][ 'compile' ] for toolchain in platform_list[ platform ]['toolchains']]
|
|
|
|
comp['CC'] = comp.Detect( usable_chains )
|
2010-05-12 16:59:30 +00:00
|
|
|
if comp['CC']:
|
2010-05-10 23:05:55 +00:00
|
|
|
comp['toolchain'] = platform_list[ platform ]['toolchains'][usable_chains.index(comp['CC'])]
|
2010-05-10 23:06:09 +00:00
|
|
|
comp['AS'] = comp['CC']
|
2010-05-06 01:09:40 +00:00
|
|
|
toolset = toolchain_list[ comp['toolchain'] ]
|
2010-05-10 23:05:55 +00:00
|
|
|
else:
|
|
|
|
print "Unable to find usable toolchain in your path."
|
|
|
|
print "List of accepted toolchains (for %s):" % ( comp['cpu'] )
|
|
|
|
print ', '.join(usable_chains)
|
2010-05-06 01:09:40 +00:00
|
|
|
Exit( -1 )
|
|
|
|
|
2010-05-12 16:59:30 +00:00
|
|
|
if not conf.CheckCC():
|
|
|
|
print "Test compile failed with selected toolchain: %s" % (comp['toolchain'])
|
|
|
|
Exit( -1 )
|
|
|
|
|
2010-05-06 01:09:40 +00:00
|
|
|
# CPU/allocator mapping (if allocator not specified)
|
|
|
|
if comp['allocator'] == 'auto':
|
|
|
|
if comp['board'] in ['LPC-H2888', 'ATEVK1100', 'MBED']:
|
|
|
|
comp['allocator'] = 'multiple'
|
|
|
|
else:
|
|
|
|
comp['allocator'] = 'newlib'
|
|
|
|
|
|
|
|
# Build the compilation command now
|
|
|
|
compcmd = ''
|
|
|
|
if comp['romfs'] == 'compile':
|
|
|
|
# First check for luac.cross in the current directory
|
|
|
|
if not os.path.isfile( "luac.cross" ):
|
|
|
|
print "The eLua cross compiler was not found."
|
|
|
|
print "Build it by running 'scons -f cross-lua.py'"
|
|
|
|
Exit( -1 )
|
2010-06-24 23:20:00 +00:00
|
|
|
compcmd = os.path.join( os.getcwd(), 'luac.cross -ccn %s -cce %s -o %%s -s %%s' % ( toolset[ 'cross_%s' % comp['target'] ], toolset[ 'cross_cpumode' ] ) )
|
2010-05-06 01:09:40 +00:00
|
|
|
elif comp['romfs'] == 'compress':
|
|
|
|
compcmd = 'lua luasrcdiet.lua --quiet --maximum --opt-comments --opt-whitespace --opt-emptylines --opt-eols --opt-strings --opt-numbers --opt-locals -o %s %s'
|
|
|
|
|
|
|
|
# User report
|
|
|
|
if not GetOption( 'clean' ):
|
|
|
|
print
|
|
|
|
print "*********************************"
|
|
|
|
print "Compiling eLua ..."
|
|
|
|
print "CPU: ", comp['cpu']
|
|
|
|
print "Board: ", comp['board']
|
|
|
|
print "Platform: ", platform
|
|
|
|
print "Allocator: ", comp['allocator']
|
|
|
|
print "Boot Mode: ", comp['boot']
|
|
|
|
print "Target: ", comp['target']
|
|
|
|
print "Toolchain: ", comp['toolchain']
|
|
|
|
print "ROMFS mode: ", comp['romfs']
|
|
|
|
print "*********************************"
|
2008-08-02 17:52:11 +00:00
|
|
|
print
|
2008-08-16 22:27:02 +00:00
|
|
|
|
2010-05-06 01:09:40 +00:00
|
|
|
output = 'elua_' + comp['target'] + '_' + comp['cpu'].lower()
|
2010-05-10 23:05:55 +00:00
|
|
|
|
2010-05-11 21:34:09 +00:00
|
|
|
comp.Append(CPPDEFINES = { 'ELUA_CPU' : comp['cpu'],
|
|
|
|
'ELUA_BOARD' : comp['board'],
|
|
|
|
'ELUA_PLATFORM' : platform.upper() } )
|
2010-05-10 23:05:55 +00:00
|
|
|
comp.Append(CPPDEFINES = {'__BUFSIZ__' : 128})
|
2010-05-11 21:34:09 +00:00
|
|
|
|
2010-05-06 01:09:40 +00:00
|
|
|
# Also make the above into direct defines (to use in conditional C code)
|
2010-05-11 21:34:09 +00:00
|
|
|
conf.env.Append(CPPDEFINES = ["ELUA_CPU_" + cnorm( comp['cpu'] ), "ELUA_BOARD_" + cnorm( comp['board'] ), "ELUA_PLATFORM_" + cnorm( platform )])
|
2010-05-10 23:05:55 +00:00
|
|
|
|
2010-05-06 01:09:40 +00:00
|
|
|
if comp['allocator'] == 'multiple':
|
2010-05-11 21:34:09 +00:00
|
|
|
conf.env.Append(CPPDEFINES = ['USE_MULTIPLE_ALLOCATOR'])
|
2010-05-06 01:09:40 +00:00
|
|
|
elif comp['allocator'] == 'simple':
|
2010-05-11 21:34:09 +00:00
|
|
|
conf.env.Append(CPPDEFINES = ['USE_SIMPLE_ALLOCATOR'])
|
2010-05-06 01:09:40 +00:00
|
|
|
|
|
|
|
if comp['boot'] == 'luarpc':
|
2010-05-11 21:34:09 +00:00
|
|
|
conf.env.Append(CPPDEFINES = ['ELUA_BOOT_RPC'])
|
2010-05-06 01:09:40 +00:00
|
|
|
|
|
|
|
# Special macro definitions for the SYM target
|
|
|
|
if platform == 'sim':
|
2010-05-11 21:34:09 +00:00
|
|
|
conf.env.Append(CPPDEFINES = ['ELUA_SIMULATOR',"ELUA_SIM_" + cnorm( comp['cpu'] ) ] )
|
2010-05-06 01:09:40 +00:00
|
|
|
|
|
|
|
# Lua source files and include path
|
|
|
|
lua_files = """lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c
|
|
|
|
lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c lauxlib.c lbaselib.c
|
|
|
|
ldblib.c liolib.c lmathlib.c loslib.c ltablib.c lstrlib.c loadlib.c linit.c lua.c lrotable.c legc.c"""
|
|
|
|
|
2010-05-10 23:05:55 +00:00
|
|
|
lua_full_files = " " + " ".join( [ "src/lua/%s" % name for name in lua_files.split() ] )
|
|
|
|
|
|
|
|
comp.Append(CPPPATH = ['inc', 'inc/newlib', 'inc/remotefs', 'src/lua'])
|
|
|
|
if comp['target'] == 'lualong':
|
2010-05-11 21:34:09 +00:00
|
|
|
conf.env.Append(CPPDEFINES = ['LUA_NUMBER_INTEGRAL'])
|
2010-05-10 23:05:55 +00:00
|
|
|
|
2010-05-11 21:34:09 +00:00
|
|
|
conf.env.Append(CPPPATH = ['src/modules', 'src/platform/%s' % platform])
|
|
|
|
conf.env.Append(CPPDEFINES = {"LUA_OPTIMIZE_MEMORY" : ( comp['optram'] != 0 and 2 or 0 ) } )
|
2010-05-06 01:09:40 +00:00
|
|
|
|
|
|
|
# Additional libraries
|
|
|
|
local_libs = ''
|
|
|
|
|
|
|
|
# Application files
|
|
|
|
app_files = " src/main.c src/romfs.c src/semifs.c src/xmodem.c src/shell.c src/term.c src/common.c src/buf.c src/elua_adc.c src/dlmalloc.c src/salloc.c src/luarpc_elua_uart.c "
|
|
|
|
|
|
|
|
# Newlib related files
|
|
|
|
newlib_files = " src/newlib/devman.c src/newlib/stubs.c src/newlib/genstd.c src/newlib/stdtcp.c"
|
|
|
|
|
|
|
|
# UIP files
|
|
|
|
uip_files = "uip_arp.c uip.c uiplib.c dhcpc.c psock.c resolv.c"
|
|
|
|
uip_files = " src/elua_uip.c " + " ".join( [ "src/uip/%s" % name for name in uip_files.split() ] )
|
2010-05-10 23:05:55 +00:00
|
|
|
comp.Append(CPPPATH = ['src/uip'])
|
2010-05-06 01:09:40 +00:00
|
|
|
|
|
|
|
# FatFs files
|
|
|
|
app_files = app_files + "src/elua_mmc.c src/mmcfs.c src/fatfs/ff.c src/fatfs/ccsbcs.c "
|
2010-05-10 23:05:55 +00:00
|
|
|
comp.Append(CPPPATH = ['src/fatfs'])
|
2010-05-06 01:09:40 +00:00
|
|
|
|
|
|
|
# Lua module files
|
2010-07-21 20:21:55 +00:00
|
|
|
module_names = "pio.c spi.c tmr.c pd.c uart.c term.c pwm.c lpack.c bit.c net.c cpu.c adc.c can.c luarpc.c bitarray.c elua.c i2c.c"
|
2010-05-06 01:09:40 +00:00
|
|
|
module_files = " " + " ".join( [ "src/modules/%s" % name for name in module_names.split() ] )
|
|
|
|
|
|
|
|
# Remote file system files
|
|
|
|
rfs_names = "remotefs.c client.c elua_os_io.c elua_rfs.c"
|
|
|
|
rfs_files = " " + " ".join( [ "src/remotefs/%s" % name for name in rfs_names.split() ] )
|
|
|
|
|
|
|
|
# Optimizer flags (speed or size)
|
2010-05-10 23:05:55 +00:00
|
|
|
comp.Append(CCFLAGS = ['-Os','-fomit-frame-pointer'])
|
2010-05-06 01:09:40 +00:00
|
|
|
#opt += " -ffreestanding"
|
|
|
|
#opt += " -fconserve-stack" # conserve stack at potential speed cost, >=GCC4.4
|
|
|
|
|
|
|
|
# Toolset data (filled by each platform in part)
|
|
|
|
tools = {}
|
|
|
|
|
|
|
|
# We get platform-specific data by executing the platform script
|
|
|
|
execfile( "src/platform/%s/conf.py" % platform )
|
|
|
|
|
|
|
|
# Complete file list
|
2010-05-10 23:05:55 +00:00
|
|
|
source_files = Split( app_files + specific_files + newlib_files + uip_files + lua_full_files + module_files + rfs_files )
|
2010-05-06 01:09:21 +00:00
|
|
|
|
2010-05-06 01:09:40 +00:00
|
|
|
comp = conf.Finish()
|
|
|
|
|
|
|
|
# Make ROM File System first
|
|
|
|
if not GetOption( 'clean' ):
|
|
|
|
print "Building ROM File System..."
|
|
|
|
romdir = "romfs"
|
|
|
|
flist = []
|
|
|
|
for sample in file_list[ comp['board'] ]:
|
|
|
|
flist += romfs[ sample ]
|
|
|
|
# Automatically includes the autorun.lua file in the ROMFS
|
|
|
|
if os.path.isfile( os.path.join( romdir, 'autorun.lua' ) ):
|
|
|
|
flist += [ 'autorun.lua' ]
|
|
|
|
# Automatically includes platform specific Lua module
|
|
|
|
if os.path.isfile( os.path.join( romdir, comp['board'] + '.lua' ) ):
|
|
|
|
flist += [comp['board'] + '.lua']
|
|
|
|
import mkfs
|
|
|
|
mkfs.mkfs( romdir, "romfiles", flist, comp['romfs'], compcmd )
|
|
|
|
print
|
|
|
|
if os.path.exists( "inc/romfiles.h" ):
|
|
|
|
os.remove( "inc/romfiles.h" )
|
|
|
|
shutil.move( "romfiles.h", "inc/" )
|
|
|
|
if os.path.exists( "src/fs.o" ):
|
|
|
|
os.remove( "src/fs.o" )
|
|
|
|
|
|
|
|
# comp.TargetSignatures( 'content' )
|
|
|
|
# comp.SourceSignatures( 'MD5' )
|
|
|
|
comp[ 'INCPREFIX' ] = "-I"
|
2010-05-10 23:05:55 +00:00
|
|
|
Default( comp.Program( target = output, source = source_files ) )
|
2010-05-06 01:09:40 +00:00
|
|
|
Decider( 'MD5-timestamp' )
|
|
|
|
|
|
|
|
# Programming target
|
|
|
|
prog = Environment( BUILDERS = { 'program' : Builder( action = Action ( tools[ platform ][ 'progfunc' ] ) ) }, ENV = os.environ )
|
|
|
|
prog.program( "prog", output + ".elf" )
|
2010-05-10 23:05:55 +00:00
|
|
|
|
|
|
|
Help(vars.GenerateHelpText(comp))
|