Use proper names for output files on mingw
This commit is contained in:
parent
7ac6ec305d
commit
296ad46d06
62
hererocks.py
62
hererocks.py
@ -257,12 +257,30 @@ def apply_compat(lua_path, nominal_version, is_luajit, compat):
|
|||||||
elif compat == "5.1":
|
elif compat == "5.1":
|
||||||
patch_build_option(lua_path, " -DLUA_COMPAT_5_2", " -DLUA_COMPAT_5_1")
|
patch_build_option(lua_path, " -DLUA_COMPAT_5_2", " -DLUA_COMPAT_5_1")
|
||||||
|
|
||||||
|
def check_subdir(path, subdir):
|
||||||
|
path = os.path.join(path, subdir)
|
||||||
|
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.mkdir(path)
|
||||||
|
|
||||||
|
return path
|
||||||
|
|
||||||
|
def move_files(path, *files):
|
||||||
|
for src in files:
|
||||||
|
dst = os.path.join(path, os.path.basename(src))
|
||||||
|
|
||||||
|
# On Windows os.rename will fail if destination exists.
|
||||||
|
if os.path.exists(dst):
|
||||||
|
os.remove(dst)
|
||||||
|
|
||||||
|
os.rename(src, dst)
|
||||||
|
|
||||||
class LuaBuilder(object):
|
class LuaBuilder(object):
|
||||||
def __init__(self, target, lua, compat):
|
def __init__(self, target, lua, compat):
|
||||||
self.target = target
|
self.target = target
|
||||||
self.lua = lua
|
self.lua = lua
|
||||||
self.compat = compat
|
self.compat = compat
|
||||||
self.set_build_vars()
|
self.set_params()
|
||||||
|
|
||||||
def get_compat_cflags(self):
|
def get_compat_cflags(self):
|
||||||
if self.lua == "5.1":
|
if self.lua == "5.1":
|
||||||
@ -282,7 +300,7 @@ class LuaBuilder(object):
|
|||||||
else:
|
else:
|
||||||
return "-DLUA_COMPAT_5_2"
|
return "-DLUA_COMPAT_5_2"
|
||||||
|
|
||||||
def set_build_vars(self):
|
def set_params(self):
|
||||||
if self.lua == "5.3":
|
if self.lua == "5.3":
|
||||||
self.cc = "gcc -std=gnu99"
|
self.cc = "gcc -std=gnu99"
|
||||||
else:
|
else:
|
||||||
@ -290,6 +308,9 @@ class LuaBuilder(object):
|
|||||||
|
|
||||||
self.ar = "ar rcu"
|
self.ar = "ar rcu"
|
||||||
self.ranlib = "ranlib"
|
self.ranlib = "ranlib"
|
||||||
|
self.arch_file = "liblua.a"
|
||||||
|
self.lua_file = "lua"
|
||||||
|
self.luac_file = "luac"
|
||||||
|
|
||||||
if self.target == "linux" or self.target == "freebsd":
|
if self.target == "linux" or self.target == "freebsd":
|
||||||
self.cflags = "-DLUA_USE_LINUX"
|
self.cflags = "-DLUA_USE_LINUX"
|
||||||
@ -308,6 +329,9 @@ class LuaBuilder(object):
|
|||||||
elif self.target == "mingw":
|
elif self.target == "mingw":
|
||||||
self.ar = self.cc + " -shared -o"
|
self.ar = self.cc + " -shared -o"
|
||||||
self.ranlib = "strip --strip-unneeded"
|
self.ranlib = "strip --strip-unneeded"
|
||||||
|
self.arch_file = "lua5" + self.lua[2] + ".dll"
|
||||||
|
self.lua_file += ".exe"
|
||||||
|
self.luac_file += ".exe"
|
||||||
self.cflags = "-DLUA_BUILD_AS_DLL"
|
self.cflags = "-DLUA_BUILD_AS_DLL"
|
||||||
self.lflags = "-s"
|
self.lflags = "-s"
|
||||||
else:
|
else:
|
||||||
@ -359,35 +383,17 @@ class LuaBuilder(object):
|
|||||||
bases.append(base)
|
bases.append(base)
|
||||||
|
|
||||||
lib_obj_files = self.compile_bases(lib_bases, verbose)
|
lib_obj_files = self.compile_bases(lib_bases, verbose)
|
||||||
run_command(verbose, self.get_arch_cmd(lib_obj_files, "liblua.a"))
|
run_command(verbose, self.get_arch_cmd(lib_obj_files, self.arch_file))
|
||||||
run_command(verbose, self.get_index_cmd("liblua.a"))
|
run_command(verbose, self.get_index_cmd(self.arch_file))
|
||||||
|
|
||||||
lua_obj_files = self.compile_bases(lua_bases, verbose)
|
lua_obj_files = self.compile_bases(lua_bases, verbose)
|
||||||
run_command(verbose, self.get_link_cmd(lua_obj_files, "liblua.a", "lua"))
|
run_command(verbose, self.get_link_cmd(lua_obj_files, self.arch_file, self.lua_file))
|
||||||
|
|
||||||
luac_obj_files = self.compile_bases(luac_bases, verbose)
|
luac_obj_files = self.compile_bases(luac_bases, verbose)
|
||||||
run_command(verbose, self.get_link_cmd(luac_obj_files, "liblua.a", "luac"))
|
run_command(verbose, self.get_link_cmd(luac_obj_files, self.arch_file, self.luac_file))
|
||||||
|
|
||||||
def check_subdir(path, subdir):
|
def install(self, target_dir):
|
||||||
path = os.path.join(path, subdir)
|
move_files(check_subdir(target_dir, "bin"), self.lua_file, self.luac_file)
|
||||||
|
|
||||||
if not os.path.exists(path):
|
|
||||||
os.mkdir(path)
|
|
||||||
|
|
||||||
return path
|
|
||||||
|
|
||||||
def move_files(path, *files):
|
|
||||||
for src in files:
|
|
||||||
dst = os.path.join(path, os.path.basename(src))
|
|
||||||
|
|
||||||
# On Windows os.rename will fail if destination exists.
|
|
||||||
if os.path.exists(dst):
|
|
||||||
os.remove(dst)
|
|
||||||
|
|
||||||
os.rename(src, dst)
|
|
||||||
|
|
||||||
def install_lua_files(target_dir):
|
|
||||||
move_files(check_subdir(target_dir, "bin"), "lua", "luac")
|
|
||||||
|
|
||||||
lua_hpp = "lua.hpp"
|
lua_hpp = "lua.hpp"
|
||||||
|
|
||||||
@ -395,7 +401,7 @@ def install_lua_files(target_dir):
|
|||||||
lua_hpp = "../etc/lua.hpp"
|
lua_hpp = "../etc/lua.hpp"
|
||||||
|
|
||||||
move_files(check_subdir(target_dir, "include"), "lua.h", "luaconf.h", "lualib.h", "lauxlib.h", lua_hpp)
|
move_files(check_subdir(target_dir, "include"), "lua.h", "luaconf.h", "lualib.h", "lauxlib.h", lua_hpp)
|
||||||
move_files(check_subdir(target_dir, "lib"), "liblua.a")
|
move_files(check_subdir(target_dir, "lib"), self.arch_file)
|
||||||
|
|
||||||
def install_lua(target_dir, lua_version, is_luajit, compat, verbose, temp_dir):
|
def install_lua(target_dir, lua_version, is_luajit, compat, verbose, temp_dir):
|
||||||
lua_path = fetch(luajit_versions if is_luajit else lua_versions, lua_version, verbose, temp_dir)
|
lua_path = fetch(luajit_versions if is_luajit else lua_versions, lua_version, verbose, temp_dir)
|
||||||
@ -422,7 +428,7 @@ def install_lua(target_dir, lua_version, is_luajit, compat, verbose, temp_dir):
|
|||||||
builder = LuaBuilder(get_lua_target(), nominal_version, compat)
|
builder = LuaBuilder(get_lua_target(), nominal_version, compat)
|
||||||
builder.build(verbose)
|
builder.build(verbose)
|
||||||
print("Installing Lua")
|
print("Installing Lua")
|
||||||
install_lua_files(target_dir)
|
builder.install(target_dir)
|
||||||
|
|
||||||
def install_luarocks(target_dir, luarocks_version, verbose, temp_dir):
|
def install_luarocks(target_dir, luarocks_version, verbose, temp_dir):
|
||||||
fetch(luarocks_versions, luarocks_version, verbose, temp_dir)
|
fetch(luarocks_versions, luarocks_version, verbose, temp_dir)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user