ports/149983: [new port] devel/lua-alien: Lua -> C FFI
Anonymous
swell.k at gmail.com
Thu Aug 26 09:30:12 UTC 2010
>Number: 149983
>Category: ports
>Synopsis: [new port] devel/lua-alien: Lua -> C FFI
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Thu Aug 26 09:30:12 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Anonymous
>Release: FreeBSD 9.0-CURRENT amd64
>Organization:
>Environment:
-fno-stack-protector is just a reminder for ports/138228 or anyone who
has smth like SSP_CFLAGS from bsd.sys.mk
>Description:
Unlike alien rock[1] the port uses system libffi. And I've changed
install paths a bit to prevent possible filename collisions with games,
other FFIs or if someone ports it to a different version of lua.
The only rock that depends on alien seems to be fbclient. And I'm not
interested in firebird client so the port'll likely remain a leaf.
[1] http://luarocks.org/repositories/rocks/alien-0.5.0-1.rockspec
---
Alien lets a Lua application call load dynamic libraries and call C
functions in a portable way, using libffi.
WWW: http://alien.luaforge.net/
>How-To-Repeat:
Example of a propeller using nanosleep(2):
%%
require 'alien'
local timespec = alien.defstruct {
{ 'sec', 'long' },
{ 'nsec', 'long' },
}
local def = alien.default
def.nanosleep:types('int', 'pointer', 'pointer')
function nanosleep(seconds, nanoseconds)
local t = timespec:new()
t.sec, t.nsec = seconds, nanoseconds
return def.nanosleep(t(), nil)
end
function propeller()
local prop_sym = { '/', '-', '\\', '|' }
local function prop_iter(a, i)
i = i < #a and i + 1 or 1
return i, a[i]
end
return prop_iter, prop_sym, 1
end
io.write('waiting...')
for i,v in propeller() do
io.write(v .. '\b')
io.flush()
nanosleep(0, 1)
end
%%
There are a few more examples in EXAMPLESDIR and one test in DATADIR/tests.
>Fix:
--- a.diff begins here ---
Index: Mk/bsd.lua.mk
===================================================================
RCS file: /a/.cvsup/ports/Mk/bsd.lua.mk,v
retrieving revision 1.19
diff -u -p -r1.19 bsd.lua.mk
--- Mk/bsd.lua.mk 25 Aug 2008 20:20:50 -0000 1.19
+++ Mk/bsd.lua.mk 26 Aug 2010 06:33:09 -0000
@@ -39,7 +39,7 @@
# Other components (modules):
# 5.0 - app, compat51, dfui, filename, gettext,
# posix, pty, socket.
-# 5.1 - filename, gettext, posix, pty, socket.
+# 5.1 - alien, filename, gettext, posix, pty, socket.
# The available dependency types are:
# build - Requires component for building.
# lib - Requires component for building and running.
@@ -150,7 +150,8 @@ _LUA_Definitions_Done= yes
#
_LUA_COMPS_ALL= lua tolua toluaxx ruby \
- app compat51 dfui filename gettext posix pty socket
+ alien app compat51 dfui filename gettext posix \
+ pty socket
_LUA_DEP_TYPES_ALL= build lib run
_LUA_VERS_ALL= 4.0 5.0 5.1
_LUA_PLIST_ALL= LUA_VER LUA_VER_SH LUA_VER_STR LUA_PREFIX LUA_SUBDIR
@@ -191,6 +192,7 @@ _LUA_PORT_socket_5.0= net/lua50-luasocke
_LUA_PORT_lua_5.1= lang/lua
_LUA_DEPTYPE_lua_5.1= lib
+_LUA_PORT_alien_5.1= devel/lua-alien
_LUA_PORT_filename_5.1= devel/lua-filename
_LUA_PORT_gettext_5.1= devel/lua-gettext
_LUA_PORT_posix_5.1= devel/lua-posix
Index: devel/Makefile
===================================================================
RCS file: /a/.cvsup/ports/devel/Makefile,v
retrieving revision 1.4016
diff -u -p -r1.4016 Makefile
--- devel/Makefile 19 Aug 2010 14:43:59 -0000 1.4016
+++ devel/Makefile 26 Aug 2010 06:33:48 -0000
@@ -937,6 +937,7 @@
SUBDIR += love
SUBDIR += lpc21isp
SUBDIR += lrmi
+ SUBDIR += lua-alien
SUBDIR += lua-bitlib
SUBDIR += lua-filename
SUBDIR += lua-gettext
Index: devel/lua-alien/Makefile
===================================================================
RCS file: devel/lua-alien/Makefile
diff -N devel/lua-alien/Makefile
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ devel/lua-alien/Makefile 26 Aug 2010 08:44:19 -0000
@@ -0,0 +1,65 @@
+# New ports collection makefile for: lua-alien
+# Date created: 24 Aug 2010
+# Whom: Anonymous
+#
+# $FreeBSD$
+#
+
+PORTNAME= alien
+PORTVERSION= 0.5.0
+CATEGORIES= devel
+MASTER_SITES= http://alien.luaforge.net/
+PKGNAMEPREFIX= ${LUA_PKGNAMEPREFIX}
+
+MAINTAINER= swell.k at gmail.com
+COMMENT= Lua -> C FFI
+
+LIB_DEPENDS= ffi.5:${PORTSDIR}/devel/libffi
+
+LICENSE= MIT
+USE_LUA= 5.1
+
+CFLAGS+= -I${LOCALBASE}/include -I${LUA_INCDIR} \
+ -DBSD -fPIC -fno-stack-protector
+LDFLAGS+= -L${LOCALBASE}/lib -L${LUA_LIBDIR} -llua -shared
+MAKE_ENV+= LIB_OPTION="${LDFLAGS}" LIB_EXT=".so" LUA="${LUA_CMD}"
+
+# add lua prefix in pkgname
+.for p in data: docs:doc/ examples:examples/
+${p:C/:.*//:U}DIR_REL= share/${p:C/.*://}${LUA_PKGNAMEPREFIX}${PORTNAME}
+${p:C/:.*//:U}DIR= ${PREFIX}/${${p:C/:.*//:U}DIR_REL}
+.endfor
+
+post-extract: .SILENT
+ ${RM} -rf ${WRKSRC}/libffi
+ ${FIND} ${WRKSRC} -type f -name .git-darcs-dir -delete
+
+post-patch: .SILENT
+ ${REINPLACE_CMD} '1s|.*|#! ${LUA_CMD}|' ${WRKSRC}/src/constants
+ ${REINPLACE_CMD} -i '' \
+ -e 's|/usr/lib|${PREFIX}/lib|' \
+ -e '/luarocks/d' \
+ ${WRKSRC}/samples/*.lua ${WRKSRC}/tests/*.lua
+
+do-install:
+ ${MKDIR} ${LUA_MODLIBDIR}/${PORTNAME}
+.for f in core.so struct.so
+ ${INSTALL_PROGRAM} ${WRKSRC}/src/alien/${f} \
+ ${LUA_MODLIBDIR}/${PORTNAME}
+.endfor
+ ${INSTALL_DATA} ${WRKSRC}/src/alien.lua ${LUA_MODSHAREDIR}
+.if !defined(NOPORTDATA)
+ ${MKDIR} ${DATADIR}
+ ${INSTALL_PROGRAM} ${WRKSRC}/src/constants ${DATADIR}
+ ${TAR} cf - -C${WRKSRC} tests | ${TAR} xof - -C${DATADIR}
+.endif
+.if !defined(NOPORTDOCS)
+ ${MKDIR} ${DOCSDIR}
+ ${TAR} cf - -C${WRKSRC}/doc . | ${TAR} xof - -C${DOCSDIR}
+.endif
+.if !defined(NOPORTEXAMPLES)
+ ${MKDIR} ${EXAMPLESDIR}
+ ${TAR} cf - -C${WRKSRC}/samples . | ${TAR} xof - -C${EXAMPLESDIR}
+.endif
+
+.include <bsd.port.mk>
Index: devel/lua-alien/distinfo
===================================================================
RCS file: devel/lua-alien/distinfo
diff -N devel/lua-alien/distinfo
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ devel/lua-alien/distinfo 24 Aug 2010 08:34:19 -0000
@@ -0,0 +1,3 @@
+MD5 (alien-0.5.0.tar.gz) = d6b265798f6d610d4651d054f601d468
+SHA256 (alien-0.5.0.tar.gz) = a8ab957f1ced1242f4264a3d8b6ef4617a045900ea60b9e57a6abb0a6bd043c3
+SIZE (alien-0.5.0.tar.gz) = 766042
Index: devel/lua-alien/pkg-descr
===================================================================
RCS file: devel/lua-alien/pkg-descr
diff -N devel/lua-alien/pkg-descr
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ devel/lua-alien/pkg-descr 25 Aug 2010 08:08:41 -0000
@@ -0,0 +1,4 @@
+Alien lets a Lua application call load dynamic libraries and call C
+functions in a portable way, using libffi.
+
+WWW: http://alien.luaforge.net/
Index: devel/lua-alien/pkg-plist
===================================================================
RCS file: devel/lua-alien/pkg-plist
diff -N devel/lua-alien/pkg-plist
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ devel/lua-alien/pkg-plist 26 Aug 2010 08:30:57 -0000
@@ -0,0 +1,17 @@
+%%LUA_MODLIBDIR%%/alien/core.so
+%%LUA_MODLIBDIR%%/alien/struct.so
+%%PORTDATA%%%%DATADIR%%/constants
+%%PORTDATA%%%%DATADIR%%/tests/alientest.c
+%%PORTDATA%%%%DATADIR%%/tests/libalientest.so
+%%PORTDATA%%%%DATADIR%%/tests/test_alien.lua
+%%PORTDOCS%%%%DOCSDIR%%/alien.md
+%%PORTDOCS%%%%DOCSDIR%%/index.html
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/gtk.lua
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/libc.lua
+%%PORTEXAMPLES%%%%EXAMPLESDIR%%/string_array.lua
+%%LUA_MODSHAREDIR%%/alien.lua
+ at dirrm %%LUA_MODLIBDIR%%/alien
+%%PORTDATA%%@dirrm %%DATADIR%%/tests
+%%PORTDATA%%@dirrm %%DATADIR%%
+%%PORTDOCS%%@dirrm %%DOCSDIR%%
+%%PORTEXAMPLES%%@dirrm %%EXAMPLESDIR%%
Index: devel/lua-alien/files/patch-Makefile
===================================================================
RCS file: devel/lua-alien/files/patch-Makefile
diff -N devel/lua-alien/files/patch-Makefile
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ devel/lua-alien/files/patch-Makefile 24 Aug 2010 10:33:44 -0000
@@ -0,0 +1,31 @@
+--- Makefile~
++++ Makefile
+@@ -1,22 +1,14 @@
+
+ all: src/alien/core.so src/alien/struct.so tests/libalientest$(LIB_EXT)
+
+-src/alien/core.o: src/alien/core.c libffi/include/ffi.h
+- $(CC) -c $(CFLAGS) -Ilibffi/include -o src/alien/core.o src/alien/core.c
++src/alien/core.o: src/alien/core.c
++ $(CC) -c $(CFLAGS) -o src/alien/core.o src/alien/core.c
+
+-libffi/include/ffi.h:
+- cat executables | xargs chmod +x
+- cd libffi && ./configure --disable-shared CC=gcc
+-
+-libffi/Makefile:
+- cat executables | xargs chmod +x
+- cd libffi && ./configure --disable-shared CC=gcc
++src/alien/struct.o: src/alien/struct.c
++ $(CC) -c $(CFLAGS) -o src/alien/struct.o src/alien/struct.c
+
+-libffi/.libs/libffi.a: libffi/Makefile
+- cd libffi && make CC=gcc
+-
+-src/alien/core.so: src/alien/core.o libffi/.libs/libffi.a
+- export MACOSX_DEPLOYMENT_TARGET=10.3; $(CC) $(LIB_OPTION) -o src/alien/core.so src/alien/core.o -lgcc -Llibffi/.libs -lffi
++src/alien/core.so: src/alien/core.o
++ export MACOSX_DEPLOYMENT_TARGET=10.3; $(CC) $(LIB_OPTION) -o src/alien/core.so src/alien/core.o -lgcc -lffi
+
+ src/alien/struct.so: src/alien/struct.o
+ export MACOSX_DEPLOYMENT_TARGET=10.3; $(CC) $(LIB_OPTION) -o src/alien/struct.so src/alien/struct.o
--- a.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list