Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dgram
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Phillips committed Aug 2, 2012
2 parents efeadb1 + aef0f61 commit 44e4750
Show file tree
Hide file tree
Showing 710 changed files with 2,048 additions and 44,531 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,3 +9,4 @@ options.gypi
*.xcodeproj
out/
*.swp
*.dist
5 changes: 4 additions & 1 deletion .gitmodules
Expand Up @@ -12,10 +12,13 @@
url = https://github.com/lloyd/yajl.git
[submodule "deps/zlib"]
path = deps/zlib
url = https://github.com/creationix/zlib.git
url = https://github.com/luvit/zlib.git
[submodule "deps/openssl"]
path = deps/openssl
url = https://github.com/luvit/openssl.git
[submodule "deps/luacrypto"]
path = deps/luacrypto
url = http://github.com/luvit/luacrypto
[submodule "tools/gyp"]
path = tools/gyp
url = https://github.com/luvit/gyp.git
48 changes: 48 additions & 0 deletions ChangeLog
@@ -1,3 +1,51 @@
* Changes between 0.4.0 to 0.5.0

API Changes

* http module has been largely refactored/rewritten to be node-like.

New Features

* New http module - posts, chunking, and headers now work (Ryan Phillips)
* New https module - leverages the new http submodule (Ryan Phillips)
* Improved fiber module (Tim Caswell)

* Changes between 0.3.1 to 0.4.0

API Changes

* dns.isIPv* has been renamed and moved to net.*

New Features

* Memory usage improvements (Ryan Phillips, Paul Querna, Brandon Philips, Tim Caswell)
* Callback State infrastructure (Brandon Philips)
* TLS Ticketing (Michael Kandrashoff)
* Reference counting (Tim Caswell)
* Improve timers (Ryan Phillips)
* Add os.clock (Tadeusz Wojcik)
* process.pid (Michael Kandrashoff)

Upgrade

* zlib (Paul Querna)
* OpenSSL w/ Skinny Option (Paul Querna)

Bug Fixes

* C89 Improvements (Antal Szabó)
* Assertion fixes (Antal Szabó)
* url.parse parseQueryString (Tomaz Muraus)
* process.spawn environment passing on windows (Ryan Phillips)
* Solaris build fixes (Ben Noordhuis)
* DNS IPv6 resolving (Ryan Phillips)
* TCP Connect IPv6 (Ryan Phillips)
* TLS Fixes (Brandon Philips)
* TLS Tests (Brandon Philips)
* Various Windows fixes (Brandon Philips, Ryan Phillips)
* luv_zlib uninitialized variable (Paul Querna)
* Use gyp submodule (Brandon Philips)

* Changes between 0.3.0 to 0.3.1

Bug Fixes
Expand Down
62 changes: 49 additions & 13 deletions Makefile
Expand Up @@ -46,11 +46,12 @@ export Q=
MAKEFLAGS+=-e

LDFLAGS+=-L${BUILDDIR}
LIBS += ${ZLIBDIR}/libz.a \
LIBS += -lluvit \
${ZLIBDIR}/libz.a \
${YAJLDIR}/yajl.a \
${UVDIR}/uv.a \
${LUADIR}/src/libluajit.a \
-lluvit -lm -ldl -lpthread
-lm -ldl -lpthread
ifeq (${USE_SYSTEM_SSL},1)
CFLAGS+=-Wall -w
CPPFLAGS+=$(shell pkg-config --cflags openssl)
Expand Down Expand Up @@ -206,6 +207,8 @@ clean:
${MAKE} -C ${YAJLDIR} clean
${MAKE} -C ${UVDIR} distclean
${MAKE} -C examples/native clean
-rm ${ZLIBDIR}/*.o
-rm ${CRYPTODIR}/src/lcrypto.o
rm -rf build bundle

install: all
Expand All @@ -225,15 +228,40 @@ install: all
cp -r ${UVDIR}/include/* ${INCDIR}/uv/
cp src/*.h ${INCDIR}/

bundle: build/luvit ${BUILDDIR}/libluvit.a
uninstall:
test -f ${BINDIR}/luvit && rm -f ${BINDIR}/luvit
test -d ${LIBDIR} && rm -rf ${LIBDIR}
test -d ${INCDIR} && rm -rf ${INCDIR}

bundle: bundle/luvit

bundle/luvit: build/luvit ${BUILDDIR}/libluvit.a
build/luvit tools/bundler.lua
$(CC) --std=c89 -D_GNU_SOURCE -g -Wall -Werror -DBUNDLE -c src/luvit_exports.c -o bundle/luvit_exports.o -I${HTTPDIR} -I${UVDIR}/include -I${LUADIR}/src -I${YAJLDIR}/src/api -I${YAJLDIR}/src -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHTTP_VERSION=\"${HTTP_VERSION}\" -DUV_VERSION=\"${UV_VERSION}\" -DYAJL_VERSIONISH=\"${YAJL_VERSION}\" -DLUVIT_VERSION=\"${VERSION}\" -DLUAJIT_VERSION=\"${LUAJIT_VERSION}\"
$(CC) --std=c89 -D_GNU_SOURCE -g -Wall -Werror -DBUNDLE -c src/luvit_main.c -o bundle/luvit_main.o -I${HTTPDIR} -I${UVDIR}/include -I${LUADIR}/src -I${YAJLDIR}/src/api -I${YAJLDIR}/src -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHTTP_VERSION=\"${HTTP_VERSION}\" -DUV_VERSION=\"${UV_VERSION}\" -DYAJL_VERSIONISH=\"${YAJL_VERSION}\" -DLUVIT_VERSION=\"${VERSION}\" -DLUAJIT_VERSION=\"${LUAJIT_VERSION}\"
$(CC) ${LDFLAGS} -g -o bundle/luvit ${BUILDDIR}/libluvit.a `ls bundle/*.o` ${LIBS}
$(CC) ${LDFLAGS} -g -o bundle/luvit ${BUILDDIR}/libluvit.a `ls bundle/*.o` ${LIBS} ${CRYPTODIR}/src/lcrypto.o

# Test section

test: test-lua test-install test-uninstall

test: ${BUILDDIR}/luvit
test-lua: ${BUILDDIR}/luvit
cd tests && ../${BUILDDIR}/luvit runner.lua

ifeq ($(MAKECMDGOALS),test)
DESTDIR=test_install
endif

test-install: install
test -f ${BINDIR}/luvit
test -d ${INCDIR}
test -d ${LIBDIR}

test-uninstall: uninstall
test ! -f ${BINDIR}/luvit
test ! -d ${INCDIR}
test ! -d ${LIBDIR}

api: api.markdown

api.markdown: $(wildcard lib/*.lua)
Expand All @@ -243,21 +271,29 @@ DIST_DIR?=${HOME}/luvit.io/dist
DIST_NAME=luvit-${VERSION}
DIST_FOLDER=${DIST_DIR}/${VERSION}/${DIST_NAME}
DIST_FILE=${DIST_FOLDER}.tar.gz
tarball:
dist_build:
sed -e 's/^VERSION=.*/VERSION=${VERSION}/' \
-e 's/^LUAJIT_VERSION=.*/LUAJIT_VERSION=${LUAJIT_VERSION}/' \
-e 's/^UV_VERSION=.*/UV_VERSION=${UV_VERSION}/' \
-e 's/^HTTP_VERSION=.*/HTTP_VERSION=${HTTP_VERSION}/' \
-e 's/^YAJL_VERSION=.*/YAJL_VERSION=${YAJL_VERSION}/' < Makefile > Makefile.dist
sed -e 's/LUVIT_VERSION=".*/LUVIT_VERSION=\"${VERSION}\"'\'',/' \
-e 's/LUAJIT_VERSION=".*/LUAJIT_VERSION=\"${LUAJIT_VERSION}\"'\'',/' \
-e 's/UV_VERSION=".*/UV_VERSION=\"${UV_VERSION}\"'\'',/' \
-e 's/HTTP_VERSION=".*/HTTP_VERSION=\"${HTTP_VERSION}\"'\'',/' \
-e 's/YAJL_VERSIONISH=".*/YAJL_VERSIONISH=\"${YAJL_VERSION}\"'\'',/' < luvit.gyp > luvit.gyp.dist

tarball: dist_build
rm -rf ${DIST_FOLDER} ${DIST_FILE}
mkdir -p ${DIST_DIR}
git clone . ${DIST_FOLDER}
cp deps/gitmodules.local ${DIST_FOLDER}/.gitmodules
cd ${DIST_FOLDER} ; git submodule update --init
find ${DIST_FOLDER} -name ".git*" | xargs rm -r
sed -e 's/^VERSION=.*/VERSION=${VERSION}/' \
-e 's/^LUAJIT_VERSION=.*/LUAJIT_VERSION=${LUAJIT_VERSION}/' \
-e 's/^UV_VERSION=.*/UV_VERSION=${UV_VERSION}/' \
-e 's/^HTTP_VERSION=.*/HTTP_VERSION=${HTTP_VERSION}/' \
-e 's/^YAJL_VERSION=.*/YAJL_VERSION=${YAJL_VERSION}/' < ${DIST_FOLDER}/Makefile > ${DIST_FOLDER}/Makefile.patched
mv ${DIST_FOLDER}/Makefile.patched ${DIST_FOLDER}/Makefile
mv Makefile.dist ${DIST_FOLDER}/Makefile
mv luvit.gyp.dist ${DIST_FOLDER}/luvit.gyp
tar -czf ${DIST_FILE} -C ${DIST_DIR}/${VERSION} ${DIST_NAME}
rm -rf ${DIST_FOLDER}

.PHONY: test install all api.markdown bundle tarball
.PHONY: test install uninstall all api.markdown bundle tarball

28 changes: 27 additions & 1 deletion README.markdown
Expand Up @@ -7,7 +7,7 @@ architecture and dependencies and seeing how it fits in the Lua language.

This project is still under heavy development, but it's showing promise. In
initial benchmarking with a hello world server, this is between 2 and 4 times
faster than node.js. Version 0.2.0 is the first stable release.
faster than node.js. Version 0.5.0 is the latest release version.

Do you have a question/want to learn more? Make sure to check out the [mailing
list](http://groups.google.com/group/luvit/) and drop by our IRC channel, #luvit
Expand All @@ -31,6 +31,32 @@ end):listen(8080)
print("Server listening at http://localhost:8080/")
```

### Building from git

Grab a copy of the source code:

`git clone https://github.com/luvit/luvit.git --recursive`

To use the gyp build system run:

```
cd luvit
./configure
make -C out
tools/build.py test
./out/Debug/luvit
```

To use the Makefile build system (for embedded systems without python)
run:

```
cd luvit
make
make test
./build/luvit
```

## Debugging

Luvit contains an extremely useful debug API. Lua contains a stack which is used
Expand Down
2 changes: 1 addition & 1 deletion api.markdown
Expand Up @@ -158,7 +158,7 @@ Half-closes the socket. i.e., it sends a FIN packet. It is possible the
server will still send some data.

If `data` is specified, it is equivalent to calling
`socket:write(data)` followed by `socket.end()`.
`socket:write(data)` followed by `socket:finish()`.

#### Socket:initialize(options)

Expand Down
5 changes: 5 additions & 0 deletions common.gypi
Expand Up @@ -125,6 +125,11 @@
[ 'OS=="freebsd"', {
'ldflags': [ '-lm' ],
}],
[ 'OS=="solaris"', {
'defines': [ '__EXTENSIONS__' ],
'ldflags!': [ '-Wl,-E' ], # solaris ld doesn't have --export-dynamic
'libraries': [ '-lm' ],
}],
],
}],
['OS=="mac"', {
Expand Down
6 changes: 6 additions & 0 deletions configure
Expand Up @@ -38,6 +38,11 @@ parser.add_option("--without-ssl",
dest="without_ssl",
help="Disable SSL Support")

parser.add_option("--without-fat",
action="store_true",
dest="skinny",
help="Compile in Skinny mode, removing less commonly used features, but reducing footprint.")

(options, args) = parser.parse_args()


Expand Down Expand Up @@ -100,6 +105,7 @@ def configure_luvit(o):
o['variables']['host_arch'] = host_arch()
o['variables']['target_arch'] = options.arch if options.arch else target_arch()
o['variables']['without_ssl'] = 'true' if options.without_ssl else 'false'
o['variables']['luvit_skinny'] = 'true' if options.skinny else 'false'

t_os = gyp.common.GetFlavor({})
t_arch = o['variables']['target_arch']
Expand Down
3 changes: 3 additions & 0 deletions deps/gitmodules.local
Expand Up @@ -19,3 +19,6 @@
[submodule "deps/openssl"]
path = deps/openssl
url = ../deps/openssl/.git
[submodule "tools/gyp"]
path = tools/gyp
url = ../tools/gyp/.git
2 changes: 1 addition & 1 deletion deps/luajit
Submodule luajit updated from 018792 to dd9e7a
74 changes: 60 additions & 14 deletions deps/luajit.gyp
Expand Up @@ -9,7 +9,7 @@
'asm_format': 'machasm',
'lj_vm': '<(INTERMEDIATE_DIR)/luajit/src/lj_vm.s',
}],
['OS == "linux" or OS == "freebsd"', {
['OS == "linux" or OS == "freebsd" or OS == "solaris"', {
'asm_format': 'elfasm',
'lj_vm': '<(INTERMEDIATE_DIR)/luajit/src/lj_vm.s',
}]
Expand Down Expand Up @@ -77,14 +77,14 @@
{
'destination': '<(PRODUCT_DIR)/lua/jit',
'files': [
'../deps/luajit/lib/bc.lua',
'../deps/luajit/lib/bcsave.lua',
'../deps/luajit/lib/dis_arm.lua',
'../deps/luajit/lib/dis_ppc.lua',
'../deps/luajit/lib/dis_x86.lua',
'../deps/luajit/lib/dis_x64.lua',
'../deps/luajit/lib/dump.lua',
'../deps/luajit/lib/v.lua',
'../deps/luajit/src/jit/bc.lua',
'../deps/luajit/src/jit/bcsave.lua',
'../deps/luajit/src/jit/dis_arm.lua',
'../deps/luajit/src/jit/dis_ppc.lua',
'../deps/luajit/src/jit/dis_x86.lua',
'../deps/luajit/src/jit/dis_x64.lua',
'../deps/luajit/src/jit/dump.lua',
'../deps/luajit/src/jit/v.lua',
]
}],
},
Expand Down Expand Up @@ -248,15 +248,34 @@
}
],
},
{
'target_name': 'minilua',
'type': 'executable',
'sources': [
'luajit/src/host/minilua.c',
],
'include_dirs': [
'<(INTERMEDIATE_DIR)',
'luajit/src',
],
},
{
'target_name': 'buildvm',
'type': 'executable',
'dependencies': [
'minilua',
],
'sources': [
'luajit/src/buildvm.c',
'luajit/src/buildvm_asm.c',
'luajit/src/buildvm_peobj.c',
'luajit/src/buildvm_lib.c',
'luajit/src/buildvm_fold.c',
'luajit/src/host/buildvm.c',
'luajit/src/host/buildvm_asm.c',
'luajit/src/host/buildvm_peobj.c',
'luajit/src/host/buildvm_lib.c',
'luajit/src/host/buildvm_fold.c',
'<(INTERMEDIATE_DIR)/buildvm_arch.h',
],
'include_dirs': [
'<(INTERMEDIATE_DIR)',
'luajit/src',
],
'rules': [
{
Expand All @@ -276,6 +295,33 @@
'message': 'dynasm <(RULE_INPUT_PATH)'
}
],
'actions': [
{
'action_name': 'generate_host_buildvm_arch',
'outputs': ['<(INTERMEDIATE_DIR)/buildvm_arch.h'],
'inputs': [ '<(PRODUCT_DIR)/minilua' ],
'variables': {
'conditions': [
['target_arch == "ia32" or target_arch == "x64"', {
'DASM_ARCH': 'x86'
}],
['target_arch == "arm"', {
'DASM_ARCH': 'arm'
}],
['target_arch == "x64" and OS != "win"', {
'DASM_FLAGS': ['-D', 'P64']
}],
['OS == "win"', {
'DASM_FLAGS': ['-D', 'WIN', '-L']
}],
],
'DASM_FLAGS': [ '-D', 'JIT', '-D', 'FPU' ],
},
'action': [
'<(PRODUCT_DIR)/minilua', 'luajit/dynasm/dynasm.lua', '<@(DASM_FLAGS)', '-o', '<(INTERMEDIATE_DIR)/buildvm_arch.h', 'luajit/src/vm_<(DASM_ARCH).dasc'
]
},
],
},
],
}
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl
Submodule openssl updated 1 files
+79 −64 openssl.gyp
1 change: 1 addition & 0 deletions deps/yajl.gyp
Expand Up @@ -61,6 +61,7 @@
'<(SHARED_INTERMEDIATE_DIR)/yajl/yajl_version.h',
],
'action': [
'python',
'../tools/lame_sed.py',
'<@(_inputs)',
'<@(_outputs)',
Expand Down
2 changes: 1 addition & 1 deletion deps/zlib
Submodule zlib updated 1 files
+2 −0 zlib.gyp
3 changes: 3 additions & 0 deletions examples/exit-code.lua
@@ -0,0 +1,3 @@
-- exit luvit with exit code 3 in the event of a pre-mature
-- event loop exit
process.exitCode = 3

0 comments on commit 44e4750

Please sign in to comment.