2021-01-02 15:10:28 +08:00
|
|
|
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
|
2018-10-08 04:52:23 +08:00
|
|
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
2016-05-12 12:22:25 +08:00
|
|
|
#
|
2018-10-08 04:52:23 +08:00
|
|
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
|
|
|
2021-06-16 08:50:04 +08:00
|
|
|
import glob
|
2016-05-07 06:33:26 +08:00
|
|
|
import os
|
|
|
|
from spack import *
|
|
|
|
|
2016-08-10 16:50:00 +08:00
|
|
|
|
2020-08-31 08:16:53 +08:00
|
|
|
class LuaLuajit(MakefilePackage):
|
2016-05-07 06:33:26 +08:00
|
|
|
"""Flast flexible JITed lua"""
|
|
|
|
homepage = "http://www.luajit.org"
|
2020-08-31 08:16:53 +08:00
|
|
|
url = "http://luajit.org/download/LuaJIT-2.0.5.tar.gz"
|
2016-05-07 06:33:26 +08:00
|
|
|
|
2020-08-31 08:16:53 +08:00
|
|
|
version('2.1.0-beta3', sha256='1ad2e34b111c802f9d0cdf019e986909123237a28c746b21295b63c9e785d9c3')
|
|
|
|
version('2.0.5', sha256='874b1f8297c697821f561f9b73b57ffd419ed8f4278c82e05b48806d30c1e979', preferred=True)
|
2019-10-11 13:44:41 +08:00
|
|
|
version('2.0.4', sha256='620fa4eb12375021bef6e4f237cbd2dd5d49e56beb414bee052c746beef1807d')
|
2016-05-07 06:33:26 +08:00
|
|
|
|
2020-08-31 08:16:53 +08:00
|
|
|
conflicts('@:2.0.5', when='target=aarch64:')
|
|
|
|
|
2021-06-16 08:50:04 +08:00
|
|
|
variant('lualinks', default=False, description="add symlinks to make lua-luajit a drop-in lua replacement")
|
|
|
|
|
|
|
|
provides("lua-lang", when="+lualinks")
|
|
|
|
|
|
|
|
@run_after("install")
|
|
|
|
def install_links(self):
|
|
|
|
if not self.spec.satisfies("+lualinks"):
|
|
|
|
return
|
|
|
|
|
|
|
|
with working_dir(self.prefix.bin):
|
|
|
|
luajit = os.readlink(self.prefix.bin.luajit)
|
|
|
|
symlink(luajit, "lua")
|
|
|
|
|
|
|
|
with working_dir(self.prefix.include):
|
|
|
|
luajit_include_subdirs = glob.glob(
|
|
|
|
os.path.join(self.prefix.include, "luajit*"))
|
|
|
|
assert len(luajit_include_subdirs) == 1
|
|
|
|
symlink(luajit_include_subdirs[0], "lua")
|
|
|
|
|
|
|
|
with working_dir(self.prefix.lib):
|
|
|
|
luajit_libnames = glob.glob(
|
|
|
|
os.path.join(self.prefix.lib, "libluajit*.so*"))
|
|
|
|
real_lib = next(
|
|
|
|
lib for lib in luajit_libnames
|
|
|
|
if os.path.isfile(lib) and not os.path.islink(lib)
|
|
|
|
)
|
|
|
|
symlink(real_lib, "liblua.so")
|
|
|
|
|
2020-08-31 08:16:53 +08:00
|
|
|
@property
|
|
|
|
def headers(self):
|
|
|
|
hdrs = find_headers('luajit', self.prefix.include, recursive=True)
|
|
|
|
hdrs.directories = os.path.dirname(hdrs[0])
|
|
|
|
return hdrs or None
|
|
|
|
|
|
|
|
def edit(self, spec, prefix):
|
|
|
|
makefile = FileFilter('Makefile')
|
|
|
|
makefile.filter('PREFIX= .*', 'PREFIX = {0}'.format(prefix))
|
|
|
|
src_makefile = FileFilter(join_path('src', 'Makefile'))
|
|
|
|
src_makefile.filter(
|
|
|
|
'^DEFAULT_CC = .*',
|
|
|
|
'DEFAULT_CC = {0}'.format(spack_cc))
|
|
|
|
src_makefile.filter(
|
|
|
|
'^DYNAMIC_CC = .*',
|
|
|
|
'DYNAMIC_CC = $(CC) {0}'.format(self.compiler.cc_pic_flag))
|
2016-05-07 06:33:26 +08:00
|
|
|
# Linking with the C++ compiler is a dirty hack to deal with the fact
|
|
|
|
# that unwinding symbols are not included by libc, this is necessary
|
|
|
|
# on some platforms for the final link stage to work
|
2020-08-31 08:16:53 +08:00
|
|
|
src_makefile.filter(
|
|
|
|
'^TARGET_LD = .*',
|
|
|
|
'TARGET_LD = {0}'.format(spack_cxx))
|