From 0f7d5e186d1acc4840f52c5b9c7f864ec29c2fa2 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sun, 17 Apr 2016 23:02:38 +0300 Subject: [PATCH 01/13] add Ravi support --- .travis.yml | 10 ++++ hererocks.py | 128 ++++++++++++++++++++++++++++++++++++++++++++--- test/cli_test.py | 11 ++++ 3 files changed, 141 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2002c14..3d36171 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,13 @@ language: python +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.8 + - g++-4.8 + matrix: include: - os: linux @@ -12,6 +20,8 @@ matrix: language: generic install: + - export CXX=g++-4.8 + - export CC=gcc-4.8 - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install python; fi - pip install pyflakes pep8 coverage coveralls nose diff --git a/hererocks.py b/hererocks.py index 8c50f28..03f7f10 100755 --- a/hererocks.py +++ b/hererocks.py @@ -13,6 +13,7 @@ import shutil import stat import string +import stat import subprocess import sys import tarfile @@ -683,15 +684,18 @@ def add_package_paths_redefines(self): "#define LUA_CPATH_DEFAULT \"{}\"".format(package_cpath) ]) + def luaconf_h_path(self): + return os.path.join("src", "luaconf.h") + def patch_redefines(self): 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() 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(redefines.encode("UTF-8")) luaconf_h.write(b"\n#endif") @@ -1391,6 +1395,95 @@ def make_install(self): 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/archive" + versions = [ + "0.15.1", + ] + translations = { + "0.15": "0.15.1", + "^": "0.15.1", + "latest": "0.15.1" + } + checksums = { + "ravi-0.15.1.tar.gz" : "c42b4540a37f763904895f7fb5757f0ce0e5185e7c3e5316eb056a1ac505134d", + } + + def __init__(self, version): + super(Ravi, self).__init__(version) + + 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") + + @staticmethod + def major_version_from_version(): + return "5.3" + + @staticmethod + def set_version_suffix(): + pass + + def set_compat(self): + self.compat = "5.2" + + 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)s:$LD_LIBRARY_PATH" +exec "%(exe)s" "$@" """ % { + "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): name = "luarocks" title = "LuaRocks" @@ -1471,7 +1564,10 @@ def get_cmake_generator(lua_identifiers): vs_short_version, vs_year, " Win64" if vs_arch == "x64" else "") def build(self): - lua_identifiers = self.all_identifiers.get("lua", self.all_identifiers.get("LuaJIT")) + lua_identifiers = any( + self.all_identifiers.get(name) + for name in ["lua", "LuaJIT", "ravi"] + ) if lua_identifiers is None: sys.exit("Error: can't install LuaRocks: Lua is not present in {}".format(opts.location)) @@ -1748,6 +1844,9 @@ def main(argv=None): "Versions 2.0.0 - 2.1.0-beta2 are supported. " "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.") + parser.add_argument( + "--ravi", help="Version of Ravi to install. " + ) parser.add_argument( "-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 " @@ -1814,13 +1913,13 @@ def main(argv=None): global opts 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") - if opts.lua and opts.luajit: - parser.error("can't install both PUC-Rio Lua and LuaJIT") + if len([impl for impl in (opts.lua, opts.luajit, opts.ravi) if impl]) > 1: + 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") if opts.show: @@ -1830,7 +1929,7 @@ def main(argv=None): if all_identifiers: 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: show_identifiers(all_identifiers[program.name]) else: @@ -1865,6 +1964,8 @@ def main(argv=None): if opts.lua: if "LuaJIT" in identifiers: del identifiers["LuaJIT"] + if "Ravi" in identifiers: + del identifiers["Ravi"] if RioLua(opts.lua).update_identifiers(identifiers): save_installed_identifiers(identifiers) @@ -1874,12 +1975,23 @@ def main(argv=None): if opts.luajit: if "lua" in identifiers: del identifiers["lua"] + if "Ravi" in identifiers: + del identifiers["Ravi"] if LuaJIT(opts.luajit).update_identifiers(identifiers): save_installed_identifiers(identifiers) os.chdir(start_dir) + if opts.ravi: + if "lua" in identifiers: + del identifiers["lua"] + if "LuaJIT" in identifiers: + del identifiers["LuaJIT"] + + identifiers_changed = Ravi(opts.ravi).update_identifiers(identifiers) + os.chdir(start_dir) + if opts.luarocks: if LuaRocks(opts.luarocks).update_identifiers(identifiers): save_installed_identifiers(identifiers) diff --git a/test/cli_test.py b/test/cli_test.py index 250cd0a..a0ef2a2 100644 --- a/test/cli_test.py +++ b/test/cli_test.py @@ -99,6 +99,17 @@ def test_install_luajit_with_compat_with_apicheck(self): self.assertHererocksSuccess([ "--luajit", "latest", "--compat", "5.2", "--cflags=-DLUA_USE_APICHECK", "--target", "vs"]) + def test_install_latest_luajit_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.2"]) + + self.assertHererocksSuccess(["--ravi", "latest", "--luarocks", "latest"], ["already installed"]) + def test_cached_lua_5_2_build(self): self.assertHererocksSuccess( ["--lua", "5.2", "--builds", os.path.join("test", "builds")], From 04a19743ed343292f3ffced5111da23dd7ae1775 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Fri, 14 Oct 2016 11:21:18 +0300 Subject: [PATCH 02/13] Fixes and updates for Ravi --- hererocks.py | 40 +++++++++++++++++++++------------------- test/cli_test.py | 4 ++-- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/hererocks.py b/hererocks.py index 03f7f10..e51b713 100755 --- a/hererocks.py +++ b/hererocks.py @@ -13,7 +13,6 @@ import shutil import stat import string -import stat import subprocess import sys import tarfile @@ -600,9 +599,8 @@ def __init__(self, version): self.add_package_paths_redefines() self.add_compat_cflags_and_redefines() - @staticmethod - def major_version_from_source(): - with open(os.path.join("src", "lua.h")) as lua_h: + def major_version_from_source(self): + with open(self.lua_h_path()) as lua_h: for line in lua_h: match = re.match(r"^\s*#define\s+LUA_VERSION_NUM\s+50(\d)\s*$", line) @@ -687,6 +685,9 @@ def add_package_paths_redefines(self): 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): redefines = "\n".join(self.redefines) @@ -1400,11 +1401,12 @@ class Ravi(Lua): title = "Ravi" downloads = "https://github.com/dibyendumajumdar/ravi/archive" win32_zip = False - default_repo = "https://github.com/dibyendumajumdar/ravi/archive" + 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" @@ -1413,15 +1415,15 @@ class Ravi(Lua): "ravi-0.15.1.tar.gz" : "c42b4540a37f763904895f7fb5757f0ce0e5185e7c3e5316eb056a1ac505134d", } - def __init__(self, version): - super(Ravi, self).__init__(version) - 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" @@ -1431,7 +1433,7 @@ def set_version_suffix(): pass def set_compat(self): - self.compat = "5.2" + self.compat = "default" def add_compat_cflags_and_redefines(self): pass @@ -1464,11 +1466,10 @@ def make_install(self): with open(lua_file, "w") as lua_exe: lua_exe.write( """#!/bin/sh -export LD_LIBRARY_PATH="%(lib_dir)s:$LD_LIBRARY_PATH" -exec "%(exe)s" "$@" """ % { - "lib_dir": os.path.join(opts.location, "lib"), - "exe": os.path.join(opts.location, "bin", exe("ravi")), - } +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) @@ -1564,10 +1565,9 @@ def get_cmake_generator(lua_identifiers): vs_short_version, vs_year, " Win64" if vs_arch == "x64" else "") def build(self): - lua_identifiers = any( - self.all_identifiers.get(name) - for name in ["lua", "LuaJIT", "ravi"] - ) + lua_identifiers = self.all_identifiers.get("lua", + self.all_identifiers.get("LuaJIT", + self.all_identifiers.get("ravi"))) if lua_identifiers is None: sys.exit("Error: can't install LuaRocks: Lua is not present in {}".format(opts.location)) @@ -1989,7 +1989,9 @@ def main(argv=None): if "LuaJIT" in identifiers: del identifiers["LuaJIT"] - identifiers_changed = Ravi(opts.ravi).update_identifiers(identifiers) + if Ravi(opts.ravi).update_identifiers(identifiers): + save_installed_identifiers(identifiers) + os.chdir(start_dir) if opts.luarocks: diff --git a/test/cli_test.py b/test/cli_test.py index a0ef2a2..51bf131 100644 --- a/test/cli_test.py +++ b/test/cli_test.py @@ -99,14 +99,14 @@ def test_install_luajit_with_compat_with_apicheck(self): self.assertHererocksSuccess([ "--luajit", "latest", "--compat", "5.2", "--cflags=-DLUA_USE_APICHECK", "--target", "vs"]) - def test_install_latest_luajit_with_latest_luarocks(self): + 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.2"]) + self.assertSuccess(["hererocks-test"], ["Ravi 5.3"]) self.assertHererocksSuccess(["--ravi", "latest", "--luarocks", "latest"], ["already installed"]) From fa79e57f49a816353b5f40c335287dc8b687ef7c Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Fri, 14 Oct 2016 22:56:18 +0300 Subject: [PATCH 03/13] Fix pep8 errors --- hererocks.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hererocks.py b/hererocks.py index e51b713..03b3003 100755 --- a/hererocks.py +++ b/hererocks.py @@ -1468,8 +1468,8 @@ def make_install(self): """#!/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"))) + lib_dir=os.path.join(opts.location, "lib"), + exe=os.path.join(opts.location, "bin", exe("ravi"))) ) # chmod +x st = os.stat(lua_file) @@ -1565,9 +1565,8 @@ def get_cmake_generator(lua_identifiers): vs_short_version, vs_year, " Win64" if vs_arch == "x64" else "") def build(self): - lua_identifiers = self.all_identifiers.get("lua", - self.all_identifiers.get("LuaJIT", - self.all_identifiers.get("ravi"))) + lua_identifiers = self.all_identifiers.get("lua", self.all_identifiers.get( + "LuaJIT", self.all_identifiers.get("ravi"))) if lua_identifiers is None: sys.exit("Error: can't install LuaRocks: Lua is not present in {}".format(opts.location)) From 68476f80affeaf79c02f11d04949cddf63dc88ab Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sat, 15 Oct 2016 18:58:38 +0300 Subject: [PATCH 04/13] do not try to install Python on OSX OSX build fails because Python is already installed: https://travis-ci.org/mpeterv/hererocks/jobs/167770746 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3d36171..d204a03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,6 @@ matrix: install: - export CXX=g++-4.8 - export CC=gcc-4.8 - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install python; fi - pip install pyflakes pep8 coverage coveralls nose script: From 156c78f0c7bfb0044e00686e0322d210af554c0e Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sat, 15 Oct 2016 19:09:36 +0300 Subject: [PATCH 05/13] run `cmake --build` instead of `make` The former is cross-platform equivalent. Should fix failure in Windows: https://ci.appveyor.com/project/mpeterv/hererocks/build/1.0.179/job/q34tijuxavqlellj --- hererocks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hererocks.py b/hererocks.py index 03b3003..ddef18e 100755 --- a/hererocks.py +++ b/hererocks.py @@ -1442,7 +1442,7 @@ def make(self): os.mkdir("build") os.chdir("build") run("cmake", "-DCMAKE_BUILD_TYPE=Release", "..") - run("make") + run("cmake", "--build", ".", "--config", "Release") os.chdir("..") def make_install(self): From 5d68d75dd585ce8621dd1c7c834dc6f37393b406 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sat, 15 Oct 2016 19:54:01 +0300 Subject: [PATCH 06/13] implement installation of binaries on Windows --- hererocks.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hererocks.py b/hererocks.py index ddef18e..c6b3638 100755 --- a/hererocks.py +++ b/hererocks.py @@ -319,6 +319,13 @@ def remove_read_only_or_reraise(func, path, exc_info): def remove_dir(path): shutil.rmtree(path, onerror=remove_read_only_or_reraise) +def find_in_dir(filename, root): + for directory, _, files in os.walk(root): + for f in files: + if f == filename: + return os.path.join(directory, f) + raise Exception("Unable to find %s in %s" % (filename, root)) + clever_http_git_whitelist = [ "http://github.com/", "https://github.com/", "http://bitbucket.com/", "https://bitbucket.com/" @@ -1452,14 +1459,16 @@ def make_install(self): os.mkdir(path) shutil.copy( - os.path.join("build", exe("ravi")), + find_in_dir(exe("ravi"), "build"), os.path.join(opts.location, "bin", exe("ravi")), ) - so_file = "libravi.so" + so_extension = ".dll" if os.name == "nt" else ".so" + so_dir = "bin" if os.name == "nt" else "lib" + so_file = "libravi" + so_extension shutil.copy( - os.path.join("build", so_file), - os.path.join(opts.location, "lib", so_file), + find_in_dir(so_file, "build"), + os.path.join(opts.location, so_dir, so_file), ) lua_file = os.path.join(opts.location, "bin", exe("lua")) From 456e6771afce2833ca7181ae6f8f6e66e4b6ac20 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sat, 15 Oct 2016 19:56:40 +0300 Subject: [PATCH 07/13] copy ravi.exe to lua.exe on Windows --- hererocks.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/hererocks.py b/hererocks.py index c6b3638..f4f77ab 100755 --- a/hererocks.py +++ b/hererocks.py @@ -1471,18 +1471,29 @@ def make_install(self): os.path.join(opts.location, so_dir, 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 + if os.name == "nt": + # copy binary to "lua.exe" + shutil.copy( + os.path.join(opts.location, "bin", exe("ravi")), + os.path.join(opts.location, "bin", exe("lua")), + ) + else: + # create shell wrapper + 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"))) +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, ) - # 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( From f364315eed0cc7206a76735287f09e4831f19342 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sat, 15 Oct 2016 20:15:52 +0300 Subject: [PATCH 08/13] use luarocks 2.3.0 in ravi test luarocks 2.4.0 fails Lua version check on Windows for "Ravi 5.3" https://ci.appveyor.com/project/mpeterv/hererocks/build/1.0.185/job/dad6rh2cg84y4fhu --- test/cli_test.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/cli_test.py b/test/cli_test.py index 51bf131..caeb1e7 100644 --- a/test/cli_test.py +++ b/test/cli_test.py @@ -99,8 +99,9 @@ def test_install_luajit_with_compat_with_apicheck(self): self.assertHererocksSuccess([ "--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"]) + def test_install_latest_ravi_with_luarocks_2_3_0(self): + # luarocks 2.4.0 fails Lua version check on Windows for "Ravi 5.3" + self.assertHererocksSuccess(["--ravi", "latest", "--luarocks", "2.3.0", "--verbose"]) self.assertSuccess(["lua", "-v"], ["Ravi 5.3.2"]) self.assertSuccess(["lua", "-e", "local t: table = {}"]) @@ -108,7 +109,7 @@ def test_install_latest_ravi_with_latest_luarocks(self): 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"]) + self.assertHererocksSuccess(["--ravi", "latest", "--luarocks", "2.3.0"], ["already installed"]) def test_cached_lua_5_2_build(self): self.assertHererocksSuccess( From aa52d211c941c0a1fab0f3fdc8428499dfe74600 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sat, 15 Oct 2016 20:22:15 +0300 Subject: [PATCH 09/13] travis: do not set CC and CXX on OSX See https://travis-ci.org/mpeterv/hererocks/jobs/167913287 --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d204a03..07fcefa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,7 @@ matrix: language: generic install: - - export CXX=g++-4.8 - - export CC=gcc-4.8 + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CXX=g++-4.8; export CC=gcc-4.8; fi - pip install pyflakes pep8 coverage coveralls nose script: From e042a328d0b9c1f6db95a098f6e88d8a3f1f3bac Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sat, 15 Oct 2016 20:54:32 +0300 Subject: [PATCH 10/13] install libravi.{dll.a|lib} on Windows --- hererocks.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/hererocks.py b/hererocks.py index f4f77ab..bab3e8b 100755 --- a/hererocks.py +++ b/hererocks.py @@ -1463,21 +1463,27 @@ def make_install(self): os.path.join(opts.location, "bin", exe("ravi")), ) - so_extension = ".dll" if os.name == "nt" else ".so" - so_dir = "bin" if os.name == "nt" else "lib" - so_file = "libravi" + so_extension - shutil.copy( - find_in_dir(so_file, "build"), - os.path.join(opts.location, so_dir, so_file), - ) - if os.name == "nt": + shutil.copy( + find_in_dir("libravi.dll", "build"), + os.path.join(opts.location, "bin", "libravi.dll"), + ) + lib_ext = "lib" if using_cl() else "dll.a" + lib_file = "libravi." + lib_ext + shutil.copy( + find_in_dir(lib_file, "build"), + os.path.join(opts.location, "lib", lib_file), + ) # copy binary to "lua.exe" shutil.copy( os.path.join(opts.location, "bin", exe("ravi")), os.path.join(opts.location, "bin", exe("lua")), ) else: + shutil.copy( + find_in_dir("libravi.so", "build"), + os.path.join(opts.location, "lib", "libravi.so"), + ) # create shell wrapper lua_file = os.path.join(opts.location, "bin", exe("lua")) with open(lua_file, "w") as lua_exe: @@ -1501,10 +1507,6 @@ def make_install(self): os.path.join(opts.location, "include", header), ) - if os.name == "nt": - pass - # TODO - class LuaRocks(Program): name = "luarocks" title = "LuaRocks" From b300b34723777b625da000e37568ce98688bb075 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sat, 15 Oct 2016 21:06:04 +0300 Subject: [PATCH 11/13] setup Visual Studio for Ravi --- hererocks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hererocks.py b/hererocks.py index bab3e8b..38b2bde 100755 --- a/hererocks.py +++ b/hererocks.py @@ -1963,7 +1963,7 @@ def main(argv=None): global temp_dir temp_dir = tempfile.mkdtemp() - if (opts.lua or opts.luajit) and os.name == "nt" and argv is None and using_cl(): + if (opts.lua or opts.luajit or opts.ravi) and os.name == "nt" and argv is None and using_cl(): setup_vs(opts.target) start_dir = os.getcwd() From ca174ce6ed281d9cc42c01bf3f91334941211533 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sat, 15 Oct 2016 21:21:07 +0300 Subject: [PATCH 12/13] install libravi.dylib on macosx --- hererocks.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hererocks.py b/hererocks.py index 38b2bde..7ef0d6a 100755 --- a/hererocks.py +++ b/hererocks.py @@ -1468,11 +1468,11 @@ def make_install(self): find_in_dir("libravi.dll", "build"), os.path.join(opts.location, "bin", "libravi.dll"), ) - lib_ext = "lib" if using_cl() else "dll.a" - lib_file = "libravi." + lib_ext + arch_ext = "lib" if using_cl() else "dll.a" + arch_file = "libravi." + arch_ext shutil.copy( - find_in_dir(lib_file, "build"), - os.path.join(opts.location, "lib", lib_file), + find_in_dir(arch_file, "build"), + os.path.join(opts.location, "lib", arch_file), ) # copy binary to "lua.exe" shutil.copy( @@ -1480,9 +1480,11 @@ def make_install(self): os.path.join(opts.location, "bin", exe("lua")), ) else: + dll_ext = "dylib" if opts.target == "macosx" else "so" + dll_file = "libravi." + dll_ext shutil.copy( - find_in_dir("libravi.so", "build"), - os.path.join(opts.location, "lib", "libravi.so"), + find_in_dir(dll_file, "build"), + os.path.join(opts.location, "lib", dll_file), ) # create shell wrapper lua_file = os.path.join(opts.location, "bin", exe("lua")) @@ -1490,6 +1492,7 @@ def make_install(self): lua_exe.write( '''#!/bin/sh export LD_LIBRARY_PATH="{lib_dir}:$LD_LIBRARY_PATH" +export DYLD_LIBRARY_PATH="{lib_dir}:$DYLD_LIBRARY_PATH" exec "{exe}" "$@"'''.format( lib_dir=os.path.join(opts.location, "lib"), exe=os.path.join(opts.location, "bin", exe("ravi"))) From ef78653747cbd6ba2589e5ef05f92585f42ef172 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sat, 15 Oct 2016 21:41:56 +0300 Subject: [PATCH 13/13] use proper cmake generator for ravi --- hererocks.py | 62 ++++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/hererocks.py b/hererocks.py index 7ef0d6a..ab2f3c5 100755 --- a/hererocks.py +++ b/hererocks.py @@ -570,6 +570,22 @@ def set_identifiers(self): self.identifiers["repo"] = self.repo self.identifiers["commit"] = self.commit + self.identifiers["target"] = opts.target + + if using_cl(): + cl_help = get_output("cl") + cl_version = re.search(r"(1[56789])\.\d+", cl_help) + cl_arch = re.search(r"(x(?:86)|(?:64))", cl_help) + + if not cl_version or not cl_arch: + sys.exit("Error: couldn't determine cl.exe version and architecture") + + cl_version = cl_version.group(1) + cl_arch = cl_arch.group(1) + + self.identifiers["vs year"] = cl_version_to_vs_year[cl_version] + self.identifiers["vs arch"] = cl_arch + def update_identifiers(self, all_identifiers): self.all_identifiers = all_identifiers installed_identifiers = all_identifiers.get(self.name) @@ -585,6 +601,18 @@ def update_identifiers(self, all_identifiers): all_identifiers[self.name] = self.identifiers return True + @staticmethod + def get_cmake_generator(lua_identifiers): + lua_target = lua_identifiers["target"] + if lua_target == "mingw": + return "MinGW Makefiles" + elif lua_target.startswith("vs"): + vs_year = lua_identifiers["vs year"] + vs_arch = lua_identifiers["vs arch"] + vs_short_version = vs_year_to_version[vs_year][:-2] + return "Visual Studio {} 20{}{}".format( + vs_short_version, vs_year, " Win64" if vs_arch == "x64" else "") + class Lua(Program): def __init__(self, version): super(Lua, self).__init__(version) @@ -619,26 +647,11 @@ def major_version_from_source(self): def set_identifiers(self): super(Lua, self).set_identifiers() - self.identifiers["target"] = opts.target self.identifiers["compat"] = self.compat self.identifiers["c flags"] = opts.cflags or "" self.identifiers["location"] = opts.location self.identifiers["major version"] = self.major_version - if using_cl(): - cl_help = get_output("cl") - cl_version = re.search(r"(1[56789])\.\d+", cl_help) - cl_arch = re.search(r"(x(?:86)|(?:64))", cl_help) - - if not cl_version or not cl_arch: - sys.exit("Error: couldn't determine cl.exe version and architecture") - - cl_version = cl_version.group(1) - cl_arch = cl_arch.group(1) - - self.identifiers["vs year"] = cl_version_to_vs_year[cl_version] - self.identifiers["vs arch"] = cl_arch - def add_options_to_version_suffix(self): options = [] @@ -1446,9 +1459,13 @@ def add_compat_cflags_and_redefines(self): pass def make(self): + cmake_generator = self.get_cmake_generator(self.identifiers) os.mkdir("build") os.chdir("build") - run("cmake", "-DCMAKE_BUILD_TYPE=Release", "..") + args = ["-DCMAKE_BUILD_TYPE=Release", ".."] + if cmake_generator is not None: + args = ["-G", cmake_generator] + args + run("cmake", *args) run("cmake", "--build", ".", "--config", "Release") os.chdir("..") @@ -1576,19 +1593,6 @@ def is_luarocks_2_0(self): return False - @staticmethod - def get_cmake_generator(lua_identifiers): - lua_target = lua_identifiers["target"] - - if lua_target == "mingw": - return "MinGW Makefiles" - elif lua_target.startswith("vs"): - vs_year = lua_identifiers["vs year"] - vs_arch = lua_identifiers["vs arch"] - vs_short_version = vs_year_to_version[vs_year][:-2] - return "Visual Studio {} 20{}{}".format( - vs_short_version, vs_year, " Win64" if vs_arch == "x64" else "") - def build(self): lua_identifiers = self.all_identifiers.get("lua", self.all_identifiers.get( "LuaJIT", self.all_identifiers.get("ravi")))