Import node-fibers-0.6.4.

This extension provides a fiber/coroutine implementation for nodejs.  It
also ships with a futures implementation that wraps existing nodejs
async functions, allowing synchronous style code that handles exceptions
properly and doesn't block the nodejs event loop.

OK sthen@
This commit is contained in:
jeremy 2012-04-03 18:46:03 +00:00
parent 8894e9819d
commit 19d897862e
9 changed files with 188 additions and 0 deletions

View File

@ -0,0 +1,34 @@
# $OpenBSD: Makefile,v 1.1.1.1 2012/04/03 18:46:03 jeremy Exp $
# Currently node itself is only for amd64 and i386, but
# the coroutine library this uses only works on amd64
# and i386, so even if other arches are supported by node
# later, this extension will only support these arches.
ONLY_FOR_ARCHS= amd64 i386
COMMENT = fiber/coroutine support for nodejs
VERSION = 0.6.4
NPM_NAME = fibers
CATEGORIES = devel
MAINTAINER = Jeremy Evans <jeremy@openbsd.org>
HOMEPAGE = https://github.com/laverdet/node-fibers
# MIT
PERMIT_PACKAGE_CDROM = Yes
PERMIT_PACKAGE_FTP = Yes
PERMIT_DISTFILES_CDROM = Yes
PERMIT_DISTFILES_FTP = Yes
MODULES = www/node
CONFIGURE_STYLE = npm ext
USE_GMAKE = Yes
SUBST_VARS = CFLAGS
pre-configure:
${SUBST_CMD} ${WRKDIST}/src/platform.mk
.include <bsd.port.mk>

View File

@ -0,0 +1,5 @@
MD5 (fibers-0.6.4.tgz) = rY5cv97tO9sO4qtP2DlRnA==
RMD160 (fibers-0.6.4.tgz) = 9Mw3D9B2GnzrH/kdBgG0j0yjo7E=
SHA1 (fibers-0.6.4.tgz) = K3Zl0he9gGtWSByhkHg8j9P1FZs=
SHA256 (fibers-0.6.4.tgz) = jrIeMPCP1V/VqQnRKKT5vwb13ni9xJelSNTQJxWqLmA=
SIZE (fibers-0.6.4.tgz) = 25553

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-fibers_js,v 1.1.1.1 2012/04/03 18:46:03 jeremy Exp $
Don't check mtimes against process, as it appears to break things
and should not be a problem with ports.
--- fibers.js.orig Wed Feb 1 13:54:47 2012
+++ fibers.js Wed Feb 1 13:55:09 2012
@@ -1,13 +1,2 @@
-var fs = require('fs'), path = require('path');
-
-if (fs.statSync(process.execPath).mtime >
- fs.statSync(require.resolve('./src/fibers')).mtime) {
- throw new Error(
- '`node` has a newer mtime than `fiber`; it is possible your build is out of date. This ' +
- 'could happen if you upgrade node. Try `npm rebuild fibers` to rebuild. If that doesn\'t ' +
- 'work you could consider running `touch ' + __dirname + 'src/fibers` and maybe there won\'t ' +
- 'be a problem.');
-}
-
// Injects `Fiber` and `yield` in to global
require('./src/fibers');

View File

@ -0,0 +1,20 @@
$OpenBSD: patch-package_json,v 1.1.1.1 2012/04/03 18:46:03 jeremy Exp $
--- package.json.orig Wed Jan 4 21:24:45 2012
+++ package.json Sun Apr 1 19:33:55 2012
@@ -8,14 +8,14 @@
"author": "Marcel Laverdet <marcel@laverdet.com> (https://github.com/laverdet/)",
"main": "fibers",
"scripts": {
- "install": "make clean all"
+ "install": "gmake clean all"
},
"man": "./man/fibers.1",
"repository": {
"type": "git",
"url": "git://github.com/laverdet/node-fibers.git"
},
- "os": ["macos", "linux"],
+ "os": ["macos", "linux", "openbsd"],
"engines": {
"node": ">=0.5.2"
}

View File

@ -0,0 +1,22 @@
$OpenBSD: patch-src_Makefile,v 1.1.1.1 2012/04/03 18:46:03 jeremy Exp $
--- src/Makefile.orig Wed Jan 4 21:24:45 2012
+++ src/Makefile Wed Feb 1 14:25:00 2012
@@ -9,6 +9,9 @@ endif
ifeq ($(NODE_PLATFORM), darwin)
CPP_NODEFLAGS = -bundle -undefined dynamic_lookup
endif
+ifeq ($(NODE_PLATFORM), openbsd)
+ CPP_NODEFLAGS = -fPIC -shared -Wl,-Bdynamic
+endif
all: fibers.node
@@ -19,7 +22,7 @@ coroutine.o: coroutine.cc
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -fPIC -c -o $@ $^
fibers.node: fibers.cc coroutine.o libcoro.o
- $(CXX) $(CPP_NODEFLAGS) $(CPPFLAGS) $^ -o $@ -lpthread
+ $(CXX) $(CPP_NODEFLAGS) $(CPPFLAGS) $^ -o $@ -pthread
clean:
-$(RM) fibers.node libcoro.o coroutine.o

View File

@ -0,0 +1,30 @@
$OpenBSD: patch-src_platform_mk,v 1.1.1.1 2012/04/03 18:46:03 jeremy Exp $
Enable build on OpenBSD and respect CFLAGS.
--- src/platform.mk.orig Wed Jan 4 21:24:45 2012
+++ src/platform.mk Tue Feb 7 14:04:54 2012
@@ -1,13 +1,13 @@
# I know nothing about scons, waf, or autoconf. Sorry.
NODE_PREFIX := $(shell echo "console.log(require('path').dirname(require('path').dirname(process.execPath)))" | node)
NODE_PLATFORM := $(shell echo "console.log(process.platform.replace('2', ''))" | node)
-NODE_BITS := $(shell file `echo "console.log(process.execPath)" | node` | egrep -o '[0-9]{2}-bit' | cut -c-2)
+NODE_BITS := $(shell file `echo "console.log(process.arch.replace(/ia|x/, ''))" | node`)
CPPFLAGS = -Wall -Wno-deprecated-declarations -I$(NODE_PREFIX)/include -I$(NODE_PREFIX)/include/node
ifdef DEBUG
CPPFLAGS += -ggdb -O0
else
- CPPFLAGS += -g -O3 -minline-all-stringops
+ CPPFLAGS += -g -I${LOCALBASE}/include -I${LOCALBASE}/include/node ${CFLAGS} -minline-all-stringops
endif
ifeq ($(NODE_BITS), )
@@ -30,4 +30,7 @@ endif
ifeq ($(NODE_PLATFORM), darwin)
# UCONTEXT in os x = hangs & segfaults :(
CPPFLAGS += -DCORO_SJLJ
+endif
+ifeq ($(NODE_PLATFORM), openbsd)
+ CPPFLAGS += -DCORO_ASM
endif

View File

@ -0,0 +1,9 @@
$OpenBSD: patch-test_sh,v 1.1.1.1 2012/04/03 18:46:03 jeremy Exp $
--- test.sh.orig Wed Feb 1 13:47:26 2012
+++ test.sh Wed Feb 1 13:47:37 2012
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
for ii in `ls test`
do echo -n $ii': '
OUTPUT=$(NODE_PATH=`pwd` node test/$ii 2>&1)

View File

@ -0,0 +1,4 @@
This extension provides a fiber/coroutine implementation for nodejs. It
also ships with a futures implementation that wraps existing nodejs
async functions, allowing synchronous style code that handles exceptions
properly and doesn't block the nodejs event loop.

View File

@ -0,0 +1,43 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2012/04/03 18:46:03 jeremy Exp $
lib/node_modules/
lib/node_modules/fibers/
lib/node_modules/fibers/.npmignore
lib/node_modules/fibers/LICENSE
lib/node_modules/fibers/Makefile
lib/node_modules/fibers/README.md
lib/node_modules/fibers/fibers.js
lib/node_modules/fibers/future.js
lib/node_modules/fibers/package.json
lib/node_modules/fibers/src/
lib/node_modules/fibers/src/Makefile
lib/node_modules/fibers/src/coroutine.cc
lib/node_modules/fibers/src/coroutine.h
lib/node_modules/fibers/src/coroutine.o
lib/node_modules/fibers/src/fibers.cc
@bin lib/node_modules/fibers/src/fibers.node
lib/node_modules/fibers/src/libcoro/
lib/node_modules/fibers/src/libcoro.o
lib/node_modules/fibers/src/libcoro/LICENSE
lib/node_modules/fibers/src/libcoro/README
lib/node_modules/fibers/src/libcoro/conftest.c
lib/node_modules/fibers/src/libcoro/coro.c
lib/node_modules/fibers/src/libcoro/coro.h
lib/node_modules/fibers/src/platform.mk
lib/node_modules/fibers/src/platform.mk.beforesubst
lib/node_modules/fibers/test/
lib/node_modules/fibers/test.sh
lib/node_modules/fibers/test/already-running.js
lib/node_modules/fibers/test/bad-context.js
lib/node_modules/fibers/test/child-process.js
lib/node_modules/fibers/test/current.js
lib/node_modules/fibers/test/exec.js
lib/node_modules/fibers/test/exit.js
lib/node_modules/fibers/test/fibonacci.js
lib/node_modules/fibers/test/finish-multiple.js
lib/node_modules/fibers/test/future.js
lib/node_modules/fibers/test/illegal-yield.js
lib/node_modules/fibers/test/pool.js
lib/node_modules/fibers/test/process-title.js
lib/node_modules/fibers/test/stack-overflow.js
lib/node_modules/fibers/test/started.js
lib/node_modules/fibers/test/unwind.js