mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
b6e7ade77c
- new shell command: mem - new module: bit (for bit operations) - removed UARTx, TMRx, SPIx, PWMx constants from the respectives modules, as they only waste memory space. But now the same modules will return an error (via luaL_error) if an invalid resource ID is used. Note that this does not apply to PIO, since PIO uses special encodings for ports/pins. - new methods in pio: port and pin to return the port/pin encoded in a pio value.
111 lines
3.7 KiB
Python
111 lines
3.7 KiB
Python
import os, sys
|
|
target = ARGUMENTS.get( 'target', 'lua' ).lower()
|
|
cputype = ARGUMENTS.get( 'cpu', 'at91sam7x256' ).lower()
|
|
allocator = ARGUMENTS.get( 'allocator', '' ).lower()
|
|
|
|
# List of platform/CPU combinations
|
|
cpu_list = { 'at91sam7x' : [ 'at91sam7x256', 'at91sam7x512' ],
|
|
'lm3s' : [ 'lm3s8962', 'lm3s6965' ],
|
|
'str9' : [ 'str912fw44' ],
|
|
'i386' : [ 'i386' ],
|
|
'lpc288x' : [ 'lpc2888' ]
|
|
}
|
|
|
|
platform = None
|
|
# Look for the given CPU in the list of platforms
|
|
for p, v in cpu_list.items():
|
|
if cputype in v:
|
|
platform = p
|
|
break
|
|
else:
|
|
print "Unknown CPU %s" % cputype
|
|
print "List of accepted CPUs: "
|
|
for p, v in cpu_list.items():
|
|
print " ", p, "-->",
|
|
for cpu in v:
|
|
print cpu,
|
|
print
|
|
sys.exit( -1 )
|
|
|
|
# CPU/allocator mapping (if allocator not specified)
|
|
if allocator == '':
|
|
if cputype in [ 'lpc2888' ]:
|
|
allocator = 'multiple'
|
|
else:
|
|
allocator = 'newlib'
|
|
elif allocator not in [ 'newlib', 'multiple' ]:
|
|
print "Unknown allocator", allocator
|
|
print "Allocator can be either 'newlib' or 'multiple'"
|
|
sys.exit( -1 )
|
|
|
|
|
|
output = 'elua_' + target + '_' + cputype
|
|
cdefs = '-D%s' % cputype
|
|
if allocator == 'multiple':
|
|
cdefs = cdefs + " -DUSE_MULTIPLE_ALLOCATOR"
|
|
|
|
# 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"""
|
|
if target == 'lualong':
|
|
lua_full_files = " " + " ".join( [ "src/lualong/%s" % name for name in lua_files.split() ] )
|
|
local_include = "-Iinc -Iinc/newlib -Isrc/lualong"
|
|
cdefs = cdefs + ' -DLUA_INTONLY'
|
|
elif target == 'lua':
|
|
lua_full_files = " " + " ".join( [ "src/lua/%s" % name for name in lua_files.split() ] )
|
|
local_include = "-Iinc -Iinc/newlib -Isrc/lua"
|
|
else:
|
|
print "Invalid target", target
|
|
sys.exit( 1 )
|
|
local_include = local_include + " -Isrc/modules -Isrc/platform/%s" % platform
|
|
|
|
# Additional libraries
|
|
local_libs = ''
|
|
|
|
# Application files
|
|
app_files = " src/romfs.c src/main.c src/xmodem.c src/shell.c src/term.c src/dlmalloc.c"
|
|
|
|
# Newlib related files
|
|
newlib_files = " src/newlib/devman.c src/newlib/stubs.c src/newlib/genstd.c"
|
|
|
|
# Lua module files
|
|
module_files = """ src/modules/pio.c src/modules/spi.c src/modules/tmr.c src/modules/pd.c src/modules/uart.c
|
|
src/modules/term.c src/modules/pwm.c src/modules/lpack.c src/modules/bit.c"""
|
|
|
|
# Optimizer flags (speed or size)
|
|
#opt = "-O3"
|
|
opt = "-Os -fomit-frame-pointer"
|
|
|
|
# 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
|
|
source_files = specific_files + newlib_files + app_files + lua_full_files + module_files
|
|
|
|
# Make filesystem first
|
|
if not GetOption( 'clean' ):
|
|
print "Building filesystem..."
|
|
import mkfs
|
|
mkfs.mkfs( "files", "luatest" )
|
|
os.system( "mv -f luatest.h inc/" )
|
|
os.system( "rm -f src/fs.o" )
|
|
|
|
# Env for building the program
|
|
comp = Environment( CCCOM = tools[ platform ][ 'cccom' ],
|
|
ASCOM = tools[ platform ][ 'ascom' ],
|
|
LINKCOM = tools[ platform ][ 'linkcom' ],
|
|
OBJSUFFIX = ".o",
|
|
PROGSUFFIX = ".elf",
|
|
ENV = os.environ )
|
|
comp.TargetSignatures( 'content' )
|
|
comp.SourceSignatures( 'MD5' )
|
|
Default( comp.Program( output, Split( source_files ) ) )
|
|
|
|
# Programming target
|
|
prog = Environment( BUILDERS = { 'program' : Builder( action = Action ( tools[ platform ][ 'progfunc' ] ) ) }, ENV = os.environ )
|
|
prog.program( "prog", output + ".elf" )
|