Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa79e57f49 | ||
|
|
04a19743ed | ||
|
|
0f7d5e186d |
10
.travis.yml
10
.travis.yml
@ -1,5 +1,13 @@
|
|||||||
language: python
|
language: python
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- gcc-4.8
|
||||||
|
- g++-4.8
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: linux
|
- os: linux
|
||||||
@ -12,6 +20,8 @@ matrix:
|
|||||||
language: generic
|
language: generic
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
- export CXX=g++-4.8
|
||||||
|
- export CC=gcc-4.8
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install python; fi
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install python; fi
|
||||||
- pip install pyflakes pep8 coverage coveralls nose
|
- pip install pyflakes pep8 coverage coveralls nose
|
||||||
|
|
||||||
|
|||||||
135
hererocks.py
135
hererocks.py
@ -599,9 +599,8 @@ class Lua(Program):
|
|||||||
self.add_package_paths_redefines()
|
self.add_package_paths_redefines()
|
||||||
self.add_compat_cflags_and_redefines()
|
self.add_compat_cflags_and_redefines()
|
||||||
|
|
||||||
@staticmethod
|
def major_version_from_source(self):
|
||||||
def major_version_from_source():
|
with open(self.lua_h_path()) as lua_h:
|
||||||
with open(os.path.join("src", "lua.h")) as lua_h:
|
|
||||||
for line in lua_h:
|
for line in lua_h:
|
||||||
match = re.match(r"^\s*#define\s+LUA_VERSION_NUM\s+50(\d)\s*$", line)
|
match = re.match(r"^\s*#define\s+LUA_VERSION_NUM\s+50(\d)\s*$", line)
|
||||||
|
|
||||||
@ -683,15 +682,21 @@ class Lua(Program):
|
|||||||
"#define LUA_CPATH_DEFAULT \"{}\"".format(package_cpath)
|
"#define LUA_CPATH_DEFAULT \"{}\"".format(package_cpath)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def luaconf_h_path(self):
|
||||||
|
return os.path.join("src", "luaconf.h")
|
||||||
|
|
||||||
|
def lua_h_path(self):
|
||||||
|
return os.path.join("src", "lua.h")
|
||||||
|
|
||||||
def patch_redefines(self):
|
def patch_redefines(self):
|
||||||
redefines = "\n".join(self.redefines)
|
redefines = "\n".join(self.redefines)
|
||||||
|
|
||||||
with open(os.path.join("src", "luaconf.h"), "rb") as luaconf_h:
|
with open(self.luaconf_h_path(), "rb") as luaconf_h:
|
||||||
luaconf_src = luaconf_h.read()
|
luaconf_src = luaconf_h.read()
|
||||||
|
|
||||||
body, _, tail = luaconf_src.rpartition(b"#endif")
|
body, _, tail = luaconf_src.rpartition(b"#endif")
|
||||||
|
|
||||||
with open(os.path.join("src", "luaconf.h"), "wb") as luaconf_h:
|
with open(self.luaconf_h_path(), "wb") as luaconf_h:
|
||||||
luaconf_h.write(body)
|
luaconf_h.write(body)
|
||||||
luaconf_h.write(redefines.encode("UTF-8"))
|
luaconf_h.write(redefines.encode("UTF-8"))
|
||||||
luaconf_h.write(b"\n#endif")
|
luaconf_h.write(b"\n#endif")
|
||||||
@ -1391,6 +1396,95 @@ class LuaJIT(Lua):
|
|||||||
|
|
||||||
copy_dir("jit", jitlib_path)
|
copy_dir("jit", jitlib_path)
|
||||||
|
|
||||||
|
class Ravi(Lua):
|
||||||
|
name = "ravi"
|
||||||
|
title = "Ravi"
|
||||||
|
downloads = "https://github.com/dibyendumajumdar/ravi/archive"
|
||||||
|
win32_zip = False
|
||||||
|
default_repo = "https://github.com/dibyendumajumdar/ravi"
|
||||||
|
versions = [
|
||||||
|
"0.15.1",
|
||||||
|
]
|
||||||
|
translations = {
|
||||||
|
"0": "0.15.1",
|
||||||
|
"0.15": "0.15.1",
|
||||||
|
"^": "0.15.1",
|
||||||
|
"latest": "0.15.1"
|
||||||
|
}
|
||||||
|
checksums = {
|
||||||
|
"ravi-0.15.1.tar.gz" : "c42b4540a37f763904895f7fb5757f0ce0e5185e7c3e5316eb056a1ac505134d",
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_download_url(self):
|
||||||
|
return self.downloads + "/" + self.fixed_version + ".tar.gz"
|
||||||
|
|
||||||
|
def luaconf_h_path(self):
|
||||||
|
return os.path.join("include", "luaconf.h")
|
||||||
|
|
||||||
|
def lua_h_path(self):
|
||||||
|
return os.path.join("include", "lua.h")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def major_version_from_version():
|
||||||
|
return "5.3"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_version_suffix():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def set_compat(self):
|
||||||
|
self.compat = "default"
|
||||||
|
|
||||||
|
def add_compat_cflags_and_redefines(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def make(self):
|
||||||
|
os.mkdir("build")
|
||||||
|
os.chdir("build")
|
||||||
|
run("cmake", "-DCMAKE_BUILD_TYPE=Release", "..")
|
||||||
|
run("make")
|
||||||
|
os.chdir("..")
|
||||||
|
|
||||||
|
def make_install(self):
|
||||||
|
for d in ["bin", "lib", "include"]:
|
||||||
|
path = os.path.join(opts.location, d)
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.mkdir(path)
|
||||||
|
|
||||||
|
shutil.copy(
|
||||||
|
os.path.join("build", exe("ravi")),
|
||||||
|
os.path.join(opts.location, "bin", exe("ravi")),
|
||||||
|
)
|
||||||
|
|
||||||
|
so_file = "libravi.so"
|
||||||
|
shutil.copy(
|
||||||
|
os.path.join("build", so_file),
|
||||||
|
os.path.join(opts.location, "lib", so_file),
|
||||||
|
)
|
||||||
|
|
||||||
|
lua_file = os.path.join(opts.location, "bin", exe("lua"))
|
||||||
|
with open(lua_file, "w") as lua_exe:
|
||||||
|
lua_exe.write(
|
||||||
|
"""#!/bin/sh
|
||||||
|
export LD_LIBRARY_PATH="{lib_dir}:$LD_LIBRARY_PATH"
|
||||||
|
exec "{exe}" "$@\"""".format(
|
||||||
|
lib_dir=os.path.join(opts.location, "lib"),
|
||||||
|
exe=os.path.join(opts.location, "bin", exe("ravi")))
|
||||||
|
)
|
||||||
|
# chmod +x
|
||||||
|
st = os.stat(lua_file)
|
||||||
|
os.chmod(lua_file, st.st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
|
||||||
|
|
||||||
|
for header in os.listdir("include"):
|
||||||
|
shutil.copy(
|
||||||
|
os.path.join("include", header),
|
||||||
|
os.path.join(opts.location, "include", header),
|
||||||
|
)
|
||||||
|
|
||||||
|
if os.name == "nt":
|
||||||
|
pass
|
||||||
|
# TODO
|
||||||
|
|
||||||
class LuaRocks(Program):
|
class LuaRocks(Program):
|
||||||
name = "luarocks"
|
name = "luarocks"
|
||||||
title = "LuaRocks"
|
title = "LuaRocks"
|
||||||
@ -1471,7 +1565,8 @@ class LuaRocks(Program):
|
|||||||
vs_short_version, vs_year, " Win64" if vs_arch == "x64" else "")
|
vs_short_version, vs_year, " Win64" if vs_arch == "x64" else "")
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
lua_identifiers = self.all_identifiers.get("lua", self.all_identifiers.get("LuaJIT"))
|
lua_identifiers = self.all_identifiers.get("lua", self.all_identifiers.get(
|
||||||
|
"LuaJIT", self.all_identifiers.get("ravi")))
|
||||||
|
|
||||||
if lua_identifiers is None:
|
if lua_identifiers is None:
|
||||||
sys.exit("Error: can't install LuaRocks: Lua is not present in {}".format(opts.location))
|
sys.exit("Error: can't install LuaRocks: Lua is not present in {}".format(opts.location))
|
||||||
@ -1748,6 +1843,9 @@ def main(argv=None):
|
|||||||
"Versions 2.0.0 - 2.1.0-beta2 are supported. "
|
"Versions 2.0.0 - 2.1.0-beta2 are supported. "
|
||||||
"When installing from the LuaJIT main git repo its URI can be left out, "
|
"When installing from the LuaJIT main git repo its URI can be left out, "
|
||||||
"so that '@458a40b' installs from a commit and '@' installs from the master branch.")
|
"so that '@458a40b' installs from a commit and '@' installs from the master branch.")
|
||||||
|
parser.add_argument(
|
||||||
|
"--ravi", help="Version of Ravi to install. "
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-r", "--luarocks", help="Version of LuaRocks to install. "
|
"-r", "--luarocks", help="Version of LuaRocks to install. "
|
||||||
"As with Lua, a version number (in range 2.0.8 - 2.4.0), '^', git URI with reference or "
|
"As with Lua, a version number (in range 2.0.8 - 2.4.0), '^', git URI with reference or "
|
||||||
@ -1814,13 +1912,13 @@ def main(argv=None):
|
|||||||
|
|
||||||
global opts
|
global opts
|
||||||
opts = parser.parse_args(argv)
|
opts = parser.parse_args(argv)
|
||||||
if not opts.lua and not opts.luajit and not opts.luarocks and not opts.show:
|
if not opts.lua and not opts.luajit and not opts.ravi and not opts.luarocks and not opts.show:
|
||||||
parser.error("nothing to do")
|
parser.error("nothing to do")
|
||||||
|
|
||||||
if opts.lua and opts.luajit:
|
if len([impl for impl in (opts.lua, opts.luajit, opts.ravi) if impl]) > 1:
|
||||||
parser.error("can't install both PUC-Rio Lua and LuaJIT")
|
parser.error("can't install several Lua implementations")
|
||||||
|
|
||||||
if (opts.lua or opts.luajit or opts.luarocks) and opts.show:
|
if (opts.lua or opts.luajit or opts.ravi or opts.luarocks) and opts.show:
|
||||||
parser.error("can't both install and show")
|
parser.error("can't both install and show")
|
||||||
|
|
||||||
if opts.show:
|
if opts.show:
|
||||||
@ -1830,7 +1928,7 @@ def main(argv=None):
|
|||||||
if all_identifiers:
|
if all_identifiers:
|
||||||
print("Programs installed in {}:".format(opts.location))
|
print("Programs installed in {}:".format(opts.location))
|
||||||
|
|
||||||
for program in [RioLua, LuaJIT, LuaRocks]:
|
for program in [RioLua, LuaJIT, Ravi, LuaRocks]:
|
||||||
if program.name in all_identifiers:
|
if program.name in all_identifiers:
|
||||||
show_identifiers(all_identifiers[program.name])
|
show_identifiers(all_identifiers[program.name])
|
||||||
else:
|
else:
|
||||||
@ -1865,6 +1963,8 @@ def main(argv=None):
|
|||||||
if opts.lua:
|
if opts.lua:
|
||||||
if "LuaJIT" in identifiers:
|
if "LuaJIT" in identifiers:
|
||||||
del identifiers["LuaJIT"]
|
del identifiers["LuaJIT"]
|
||||||
|
if "Ravi" in identifiers:
|
||||||
|
del identifiers["Ravi"]
|
||||||
|
|
||||||
if RioLua(opts.lua).update_identifiers(identifiers):
|
if RioLua(opts.lua).update_identifiers(identifiers):
|
||||||
save_installed_identifiers(identifiers)
|
save_installed_identifiers(identifiers)
|
||||||
@ -1874,12 +1974,25 @@ def main(argv=None):
|
|||||||
if opts.luajit:
|
if opts.luajit:
|
||||||
if "lua" in identifiers:
|
if "lua" in identifiers:
|
||||||
del identifiers["lua"]
|
del identifiers["lua"]
|
||||||
|
if "Ravi" in identifiers:
|
||||||
|
del identifiers["Ravi"]
|
||||||
|
|
||||||
if LuaJIT(opts.luajit).update_identifiers(identifiers):
|
if LuaJIT(opts.luajit).update_identifiers(identifiers):
|
||||||
save_installed_identifiers(identifiers)
|
save_installed_identifiers(identifiers)
|
||||||
|
|
||||||
os.chdir(start_dir)
|
os.chdir(start_dir)
|
||||||
|
|
||||||
|
if opts.ravi:
|
||||||
|
if "lua" in identifiers:
|
||||||
|
del identifiers["lua"]
|
||||||
|
if "LuaJIT" in identifiers:
|
||||||
|
del identifiers["LuaJIT"]
|
||||||
|
|
||||||
|
if Ravi(opts.ravi).update_identifiers(identifiers):
|
||||||
|
save_installed_identifiers(identifiers)
|
||||||
|
|
||||||
|
os.chdir(start_dir)
|
||||||
|
|
||||||
if opts.luarocks:
|
if opts.luarocks:
|
||||||
if LuaRocks(opts.luarocks).update_identifiers(identifiers):
|
if LuaRocks(opts.luarocks).update_identifiers(identifiers):
|
||||||
save_installed_identifiers(identifiers)
|
save_installed_identifiers(identifiers)
|
||||||
|
|||||||
@ -99,6 +99,17 @@ class TestCLI(unittest.TestCase):
|
|||||||
self.assertHererocksSuccess([
|
self.assertHererocksSuccess([
|
||||||
"--luajit", "latest", "--compat", "5.2", "--cflags=-DLUA_USE_APICHECK", "--target", "vs"])
|
"--luajit", "latest", "--compat", "5.2", "--cflags=-DLUA_USE_APICHECK", "--target", "vs"])
|
||||||
|
|
||||||
|
def test_install_latest_ravi_with_latest_luarocks(self):
|
||||||
|
self.assertHererocksSuccess(["--ravi", "latest", "--luarocks", "latest", "--verbose"])
|
||||||
|
self.assertSuccess(["lua", "-v"], ["Ravi 5.3.2"])
|
||||||
|
self.assertSuccess(["lua", "-e", "local t: table = {}"])
|
||||||
|
|
||||||
|
self.assertSuccess(["luarocks", "--version"])
|
||||||
|
self.assertSuccess(["luarocks", "make", os.path.join("test", "hererocks-test-scm-1.rockspec")])
|
||||||
|
self.assertSuccess(["hererocks-test"], ["Ravi 5.3"])
|
||||||
|
|
||||||
|
self.assertHererocksSuccess(["--ravi", "latest", "--luarocks", "latest"], ["already installed"])
|
||||||
|
|
||||||
def test_cached_lua_5_2_build(self):
|
def test_cached_lua_5_2_build(self):
|
||||||
self.assertHererocksSuccess(
|
self.assertHererocksSuccess(
|
||||||
["--lua", "5.2", "--builds", os.path.join("test", "builds")],
|
["--lua", "5.2", "--builds", os.path.join("test", "builds")],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user