From fcea0f5140f840db4f6cd5b5dbb134ee3719b151 Mon Sep 17 00:00:00 2001 From: mpeterv Date: Sun, 20 Mar 2016 22:20:08 +0300 Subject: [PATCH] Add --no-readline flag --- hererocks.py | 47 ++++++++++++++++++++++++++++++++++++----------- test.sh | 2 +- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/hererocks.py b/hererocks.py index 85c40ec..b17a51c 100755 --- a/hererocks.py +++ b/hererocks.py @@ -386,6 +386,9 @@ class Lua(Program): if opts.cflags is not None: options.append(("cflags", opts.cflags)) + if opts.no_readline: + options.append(("readline", "false")) + if options: self.version_suffix += " (" + (", ".join( opt + ": " + value for opt, value in options)) + ")" @@ -518,6 +521,12 @@ class RioLua(Lua): else: 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): return self.version[:3] @@ -557,20 +566,34 @@ class RioLua(Lua): else: cc = "gcc" - if opts.target == "linux" or opts.target == "freebsd": - cflags = ["-DLUA_USE_LINUX"] + if opts.target in ["linux", "freebsd", "macosx"]: + 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 self.major_version == "5.1": - lflags = ["-Wl,-E -ldl -lreadline -lhistory -lncurses"] - else: - lflags = ["-Wl,-E -ldl -lreadline"] + lflags = ["-Wl,-E -ldl"] + + if not opts.no_readline: + 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: - lflags = ["-Wl,-E -lreadline"] - elif opts.target == "macosx": - cflags = ["-DLUA_USE_MACOSX -DLUA_USE_READLINE"] - lflags = ["-lreadline"] - cc = "cc" + lflags = [] + cc = "cc" + + if not opts.no_readline: + lflags.append("-lreadline") else: lflags = [] @@ -905,6 +928,8 @@ def main(): help="Pass additional options to C compiler when building Lua or LuaJIT.") parser.add_argument("--target", help="Use 'make TARGET' when building standard Lua.", 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", # help="Cache downloads in 'DOWNLOADS' directory.", help=argparse.SUPPRESS, default=get_default_cache()) diff --git a/test.sh b/test.sh index a209252..2bb10c1 100755 --- a/test.sh +++ b/test.sh @@ -20,7 +20,7 @@ luarocks make hererocks-test | grep "2\.1" 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 "(function(...) assert(arg == nil) end)()" lua -e "assert(math.mod == nil)"