Minor tweaks to luac.cross for SDK 1.4 support
plus Add extra logic to handle different loci path in luac.cross for handling 32 bit or great hex integers Also add a helpfull hint in the build tool to point out the Lua and lfs depencencies.
This commit is contained in:
parent
307323d1ff
commit
0beee5c1ae
|
@ -1,9 +1,20 @@
|
||||||
|
//#include "user_interface.h"
|
||||||
|
#include "user_config.h"
|
||||||
|
|
||||||
|
#ifdef LUA_CROSS_COMPILER
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#define ICACHE_RODATA_ATTR
|
||||||
|
#define TRUE 1
|
||||||
|
#define FALSE 0
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#include "c_stdlib.h"
|
#include "c_stdlib.h"
|
||||||
#include "c_stdio.h"
|
|
||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
#include "c_string.h"
|
#include "c_string.h"
|
||||||
#include "user_interface.h"
|
|
||||||
#include "user_config.h"
|
|
||||||
|
|
||||||
// const char *lua_init_value = "print(\"Hello world\")";
|
// const char *lua_init_value = "print(\"Hello world\")";
|
||||||
const char *lua_init_value = "@init.lua";
|
const char *lua_init_value = "@init.lua";
|
||||||
|
@ -21,7 +32,6 @@ const char *c_getenv(const char *__string)
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure there is enough memory before real malloc, otherwise malloc will panic and reset
|
// make sure there is enough memory before real malloc, otherwise malloc will panic and reset
|
||||||
// void *c_malloc(size_t __size){
|
// void *c_malloc(size_t __size){
|
||||||
// if(__size>system_get_free_heap_size()){
|
// if(__size>system_get_free_heap_size()){
|
||||||
|
@ -43,7 +53,8 @@ const char *c_getenv(const char *__string)
|
||||||
// // NODE_ERR("free1: %d\n", system_get_free_heap_size());
|
// // NODE_ERR("free1: %d\n", system_get_free_heap_size());
|
||||||
// os_free(p);
|
// os_free(p);
|
||||||
// // NODE_ERR("-free1: %d\n", system_get_free_heap_size());
|
// // NODE_ERR("-free1: %d\n", system_get_free_heap_size());
|
||||||
// }
|
// }c_stdlib.s
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// int c_rand(void){
|
// int c_rand(void){
|
||||||
|
@ -55,9 +66,8 @@ const char *c_getenv(const char *__string)
|
||||||
// }
|
// }
|
||||||
#include <_ansi.h>
|
#include <_ansi.h>
|
||||||
//#include <reent.h>
|
//#include <reent.h>
|
||||||
#include <string.h>
|
|
||||||
//#include "mprec.h"
|
//#include "mprec.h"
|
||||||
|
#endif
|
||||||
double powersOf10[] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = /* Table giving binary powers of 10. Entry */
|
double powersOf10[] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = /* Table giving binary powers of 10. Entry */
|
||||||
{
|
{
|
||||||
10., /* is 10^2^i. Used to convert decimal */
|
10., /* is 10^2^i. Used to convert decimal */
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "lvm.h"
|
#include "lvm.h"
|
||||||
#ifndef LUA_CROSS_COMPILER
|
#ifndef LUA_CROSS_COMPILER
|
||||||
#include "flash_api.h"
|
#include "flash_api.h"
|
||||||
|
#else
|
||||||
|
#include <limits.h>
|
||||||
#endif
|
#endif
|
||||||
const TValue luaO_nilobject_ = {LUA_TVALUE_NIL};
|
const TValue luaO_nilobject_ = {LUA_TVALUE_NIL};
|
||||||
|
|
||||||
|
@ -96,7 +98,21 @@ int luaO_str2d (const char *s, lua_Number *result) {
|
||||||
*result = lua_str2number(s, &endptr);
|
*result = lua_str2number(s, &endptr);
|
||||||
if (endptr == s) return 0; /* conversion failed */
|
if (endptr == s) return 0; /* conversion failed */
|
||||||
if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
|
if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */
|
||||||
|
#if defined(LUA_CROSS_COMPILER)
|
||||||
|
{
|
||||||
|
long lres = strtoul(s, &endptr, 16);
|
||||||
|
#if LONG_MAX != 2147483647L
|
||||||
|
if (lres & ~0xffffffffL)
|
||||||
|
*result = cast_num(-1);
|
||||||
|
else if (lres & 0x80000000L)
|
||||||
|
*result = cast_num(lres | ~0x7fffffffL);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
*result = cast_num(lres);
|
||||||
|
}
|
||||||
|
#else
|
||||||
*result = cast_num(c_strtoul(s, &endptr, 16));
|
*result = cast_num(c_strtoul(s, &endptr, 16));
|
||||||
|
#endif
|
||||||
if (*endptr == '\0') return 1; /* most common case */
|
if (*endptr == '\0') return 1; /* most common case */
|
||||||
while (isspace(cast(unsigned char, *endptr))) endptr++;
|
while (isspace(cast(unsigned char, *endptr))) endptr++;
|
||||||
if (*endptr != '\0') return 0; /* invalid trailing characters? */
|
if (*endptr != '\0') return 0; /* invalid trailing characters? */
|
||||||
|
|
|
@ -390,7 +390,9 @@ typedef struct __lua_load{
|
||||||
|
|
||||||
int lua_main( int argc, char **argv );
|
int lua_main( int argc, char **argv );
|
||||||
|
|
||||||
|
#ifndef LUA_CROSS_COMPILER
|
||||||
void lua_handle_input (bool force);
|
void lua_handle_input (bool force);
|
||||||
|
#endif
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
|
* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved.
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
#define c_strpbrk strpbrk
|
#define c_strpbrk strpbrk
|
||||||
#define c_strrchr strrchr
|
#define c_strrchr strrchr
|
||||||
#define c_strstr strstr
|
#define c_strstr strstr
|
||||||
#define c_strtod strtod
|
double c_strtod(const char *__n, char **__end_PTR);
|
||||||
#define c_strtoul strtoul
|
#define c_strtoul strtoul
|
||||||
#define c_ungetc ungetc
|
#define c_ungetc ungetc
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,20 @@ local b = require "tools.build"
|
||||||
local builder = b.new_builder( ".build/cross-lua" )
|
local builder = b.new_builder( ".build/cross-lua" )
|
||||||
local utils = b.utils
|
local utils = b.utils
|
||||||
local sf = string.format
|
local sf = string.format
|
||||||
|
|
||||||
|
if not (_VERSION == "Lua 5.1" and pcall(require,"lfs")) then
|
||||||
|
print [[
|
||||||
|
|
||||||
|
cross_lua.lua must be run within Lua 5.1 and it requires the Lua Filesystem to be installed.
|
||||||
|
On most *nix distrubitions youwill find a packages lua-5.1 and lua-filesystem, or
|
||||||
|
alternalively you can install lua-rocks and use the Rocks package manager to install lfs.
|
||||||
|
]]
|
||||||
|
os.exit(1)
|
||||||
|
end
|
||||||
builder:init( args )
|
builder:init( args )
|
||||||
builder:set_build_mode( builder.BUILD_DIR_LINEARIZED )
|
builder:set_build_mode( builder.BUILD_DIR_LINEARIZED )
|
||||||
|
|
||||||
local output = 'luac.cross'
|
local output = 'luac.cross'
|
||||||
local cdefs = '-DLUA_CROSS_COMPILER -O2'
|
local cdefs = '-DLUA_CROSS_COMPILER'
|
||||||
|
|
||||||
-- Lua source files and include path
|
-- Lua source files and include path
|
||||||
local lua_files = [[
|
local lua_files = [[
|
||||||
|
@ -17,6 +26,7 @@ local lua_files = [[
|
||||||
ltm.c lundump.c lvm.c lzio.c
|
ltm.c lundump.c lvm.c lzio.c
|
||||||
luac_cross/luac.c luac_cross/loslib.c luac_cross/print.c
|
luac_cross/luac.c luac_cross/loslib.c luac_cross/print.c
|
||||||
../modules/linit.c
|
../modules/linit.c
|
||||||
|
../libc/c_stdlib.c
|
||||||
]]
|
]]
|
||||||
lua_files = lua_files:gsub( "\n" , "" )
|
lua_files = lua_files:gsub( "\n" , "" )
|
||||||
local lua_full_files = utils.prepend_path( lua_files, "app/lua" )
|
local lua_full_files = utils.prepend_path( lua_files, "app/lua" )
|
||||||
|
|
Loading…
Reference in New Issue