Skip to content

Commit

Permalink
dev-lua/lua-bit32: add libcompat52 version
Browse files Browse the repository at this point in the history
Signed-off-by: Conrad Kostecki <conrad@kostecki.com>
  • Loading branch information
ConiKost committed Oct 10, 2020
1 parent 4f35256 commit 9715e98
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev-lua/lua-bit32/Manifest
@@ -1 +1,2 @@
DIST lua-compat52-0.3.tar.gz 22407 BLAKE2B f8fa3aba2aab85b701c688a771e59b664c6541d1048c8e9d9a846e4458fffff451fba40f72f5e6d4310f533d860269e07f5135d3f44aa1b61de9755df8c2834a SHA512 b6b70162d5b25e3cc646613ee62a8f136903b4e0ae749285105429cce0e5d3eebc3295aa98749239651dd67d5ee55199172267cefb1588969093770a7e82ac96
DIST lua-compat53-0.9.tar.gz 53599 BLAKE2B 7d9efe0afb49c40a68b1d6c28f975080b3331e07d0aa788e0f1f77d5c360504a5cac9cca4e6074b2c64aa7ad8934df3fe2609ff8009db52b046b2f639b670213 SHA512 bec15b6e95cb5cc775785515eba1f094e453059a0ba1eefa433d328b823378b7f48d9c7a34080ad77478cffb2008bead93418f809793afa6021e6046562acc58
25 changes: 25 additions & 0 deletions dev-lua/lua-bit32/files/lua-bit32-5.3.0-add-tests.patch
@@ -0,0 +1,25 @@
From 7e2b0b5e5f55cac22fbd9237bf1c354df134802c Mon Sep 17 00:00:00 2001
From: Philipp Janda <siffiejoe@gmx.net>
Date: Thu, 9 Jul 2020 01:24:17 +0200
Subject: [PATCH] Add bit32 library

---
tests/test-bit32.lua | 9 ++
1 file changed, 9 insertions(+)
create mode 100755 tests/test-bit32.lua

diff --git a/tests/test-bit32.lua b/tests/test-bit32.lua
new file mode 100755
index 0000000..cc91e52
--- /dev/null
+++ b/tests/test-bit32.lua
@@ -0,0 +1,9 @@
+#!/usr/bin/env lua
+
+local bit32 = require("bit32")
+
+
+assert(bit32.bnot(0) == 2^32-1)
+assert(bit32.band(1, 3, 5) == 1)
+assert(bit32.bor(1, 3, 5) == 7)
+
50 changes: 50 additions & 0 deletions dev-lua/lua-bit32/lua-bit32-5.3.0.ebuild
@@ -0,0 +1,50 @@
# Copyright 2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit toolchain-funcs

DESCRIPTION="Backported Lua bit manipulation library"
HOMEPAGE="https://github.com/keplerproject/lua-compat-5.2"
# Wierd upstream version descisions...
# Result tarball may be reused for future lua-compat52 package
LUA_COMPAT_V=0.3
SRC_URI="https://github.com/keplerproject/lua-compat-5.2/archive/v${LUA_COMPAT_V}.tar.gz -> lua-compat52-${LUA_COMPAT_V}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
IUSE="test"

RESTRICT="!test? ( test )"

# Strictly for lua 5.1
DEPEND="dev-lang/lua:0="
RDEPEND="${DEPEND}"
BDEPEND="virtual/pkgconfig"

S="${WORKDIR}/lua-compat-5.2-${LUA_COMPAT_V}"

PATCHES=( "${FILESDIR}/${PN}-5.3.0-add-tests.patch" )

src_compile() {
# TODO maybe sometime there will be luarocks eclass...
compile="$(tc-getCC) ${CFLAGS} ${LDFLAGS} -fPIC -I/usr/include -c lbitlib.c -o lbitlib.o -DLUA_COMPAT_BITLIB -Ic-api"
einfo "${compile}"
eval "${compile}" || die

link="$(tc-getCC) -shared ${LDFLAGS} -o bit32.so lbitlib.o"
einfo "${link}"
eval "${link}" || die
}

src_test() {
LUA_CPATH=./?.so lua tests/test-bit32.lua || die
}

src_install() {
exeinto $($(tc-getPKG_CONFIG) --variable INSTALL_CMOD lua)
doexe bit32.so
dodoc README.md
}

0 comments on commit 9715e98

Please sign in to comment.