Add --no-readline flag

This commit is contained in:
mpeterv 2016-03-20 22:20:08 +03:00
parent fcc45f9b7a
commit fcea0f5140
2 changed files with 37 additions and 12 deletions

View File

@ -386,6 +386,9 @@ class Lua(Program):
if opts.cflags is not None: if opts.cflags is not None:
options.append(("cflags", opts.cflags)) options.append(("cflags", opts.cflags))
if opts.no_readline:
options.append(("readline", "false"))
if options: if options:
self.version_suffix += " (" + (", ".join( self.version_suffix += " (" + (", ".join(
opt + ": " + value for opt, value in options)) + ")" opt + ": " + value for opt, value in options)) + ")"
@ -518,6 +521,12 @@ class RioLua(Lua):
else: else:
self.dll_file = None self.dll_file = None
def set_identifiers(self):
super(RioLua, self).set_identifiers()
if self.identifiers is not None:
self.identifiers.append(str(not opts.no_readline))
def major_version_from_version(self): def major_version_from_version(self):
return self.version[:3] return self.version[:3]
@ -557,20 +566,34 @@ class RioLua(Lua):
else: else:
cc = "gcc" cc = "gcc"
if opts.target == "linux" or opts.target == "freebsd": if opts.target in ["linux", "freebsd", "macosx"]:
cflags = ["-DLUA_USE_LINUX"] cflags = ["-DLUA_USE_POSIX -DLUA_USE_DLOPEN"]
if self.major_version == "5.2":
cflags.append("-DLUA_USE_STRTODHEX -DLUA_USE_AFORMAT -DLUA_USE_LONGLONG")
if not opts.no_readline:
cflags.append("-DLUA_USE_READLINE")
if opts.target == "linux": if opts.target == "linux":
if self.major_version == "5.1": lflags = ["-Wl,-E -ldl"]
lflags = ["-Wl,-E -ldl -lreadline -lhistory -lncurses"]
else: if not opts.no_readline:
lflags = ["-Wl,-E -ldl -lreadline"] if self.major_version == "5.1":
lflags.append("-lreadline -lhistory -lncurses")
else:
lflags.append("-lreadline")
elif opts.target == "freebsd":
lflags = []
if not opts.no_readline:
lflags.append("-Wl,-E -lreadline")
else: else:
lflags = ["-Wl,-E -lreadline"] lflags = []
elif opts.target == "macosx": cc = "cc"
cflags = ["-DLUA_USE_MACOSX -DLUA_USE_READLINE"]
lflags = ["-lreadline"] if not opts.no_readline:
cc = "cc" lflags.append("-lreadline")
else: else:
lflags = [] lflags = []
@ -905,6 +928,8 @@ def main():
help="Pass additional options to C compiler when building Lua or LuaJIT.") help="Pass additional options to C compiler when building Lua or LuaJIT.")
parser.add_argument("--target", help="Use 'make TARGET' when building standard Lua.", parser.add_argument("--target", help="Use 'make TARGET' when building standard Lua.",
default=get_default_lua_target()) default=get_default_lua_target())
parser.add_argument("--no-readline", help="Don't use readline library when building standard Lua.",
action="store_true", default=False)
parser.add_argument("--downloads", parser.add_argument("--downloads",
# help="Cache downloads in 'DOWNLOADS' directory.", # help="Cache downloads in 'DOWNLOADS' directory.",
help=argparse.SUPPRESS, default=get_default_cache()) help=argparse.SUPPRESS, default=get_default_cache())

View File

@ -20,7 +20,7 @@ luarocks make
hererocks-test | grep "2\.1" hererocks-test | grep "2\.1"
rm test/here -rf rm test/here -rf
$HEREROCKS -l 5.1 --compat=none $HEREROCKS -l 5.1 --compat=none --no-readline
lua -e "assert(not pcall(string.gfind, '', '.'))" lua -e "assert(not pcall(string.gfind, '', '.'))"
lua -e "(function(...) assert(arg == nil) end)()" lua -e "(function(...) assert(arg == nil) end)()"
lua -e "assert(math.mod == nil)" lua -e "assert(math.mod == nil)"