Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use CMake instead of make-common, add note about YAJL 1.0.9 being a

requirement.
  • Loading branch information...
commit aa96ce42ae65c124a467346eb0bb1c4ab1db5510 1 parent 4c67f8f
@brimworks authored
View
45 CMakeLists.txt
@@ -0,0 +1,45 @@
+# Copyright (C) 2007-2009 LuaDist.
+# Submitted by David Manura
+# Redistribution and use of this file is allowed according to the
+# terms of the MIT license.
+# For details see the COPYRIGHT file distributed with LuaDist.
+# Please note that the package source code is licensed under its own
+# license.
+
+PROJECT(lua-yajl C)
+CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
+
+# Basic configurations
+ SET(INSTALL_CMOD share/lua/cmod CACHE PATH "Directory to install Lua binary modules (configure lua via LUA_CPATH)")
+# / configs
+
+# Find yajl
+ FIND_LIBRARY (YAJL_LIBRARY NAMES yajl)
+ FIND_PATH (YAJL_INCLUDE_DIR yajl/yajl_parse.h
+ ) # Find header
+ INCLUDE(FindPackageHandleStandardArgs)
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(yajl DEFAULT_MSG YAJL_LIBRARY YAJL_INCLUDE_DIR)
+# / Find yajl
+
+# Find lua
+ FIND_PACKAGE(Lua51 REQUIRED)
+# / Find lua
+
+# Define how to build yajl.so
+ INCLUDE_DIRECTORIES(${YAJL_INCLUDE_DIR} ${LUA_INCLUDE_DIR})
+ ADD_LIBRARY(cmod_yajl MODULE
+ lua_yajl.c yajl.def)
+ SET_TARGET_PROPERTIES(cmod_yajl PROPERTIES PREFIX "")
+ SET_TARGET_PROPERTIES(cmod_yajl PROPERTIES OUTPUT_NAME yajl)
+ TARGET_LINK_LIBRARIES(cmod_yajl ${LUA_LIBRARIES} ${YAJL_LIBRARY})
+# / build yajl.so
+
+# Define how to test yajl.so:
+ INCLUDE(CTest)
+ FIND_PROGRAM(LUA NAMES lua lua.bat)
+ ADD_TEST(basic ${LUA} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua ${CMAKE_CURRENT_SOURCE_DIR}/ ${CMAKE_CURRENT_BINARY_DIR}/)
+# / test yajl.so
+
+# Where to install stuff
+ INSTALL (TARGETS cmod_yajl DESTINATION ${INSTALL_CMOD})
+# / Where to install.
View
4 Makefile
@@ -1,4 +0,0 @@
-SRC:=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
-include $(or $(shell make-common),$(error make-common is not on your PATH!))
-
-include $(SRC)/module.mk
View
28 README
@@ -25,25 +25,13 @@
* THE SOFTWARE.
**********************************************************************
-BUILDING:
- Download make-common, yajl, and lua-yajl from:
- http://github.com/brimworks/
- Run:
- export PATH="$PATH:/path/to/common/build-dir/bin"
- for d in make-common yajl lua-yajl; do
- cd $d && make BUILD=/path/to/common/build-dir
- done
+To use this library, you need yajl version 1.0.9 or newer, get it here:
+ http://lloyd.github.com/yajl/
-NOTES:
+To build this library, you need CMake, get it here:
+ http://www.cmake.org/cmake/resources/software.html
- * lua-yajl currently depends on a fork of YAJL that provides
- support for custom printer function when generating JSON and uses
- the make-common build system because I prefer it. The original
- YAJL can be downloaded here:
-
- http://lloyd.github.com/yajl/
-
- * To load the library, do one of these two things:
+Loading the library:
If you built the library as a loadable package
[local] yajl = require 'yajl'
@@ -52,7 +40,9 @@ NOTES:
the function "luaopen_yajl(L)". It will create a table with the yajl
functions and leave it on the stack.
- * JSON integers and floating points are handled with the 'double' C
+NOTE ON LARGE NUMBERS:
+
+ JSON integers and floating points are handled with the 'double' C
type, which is normally the native number format for Lua. We do
NOT currently do error handling if a number is outside of range,
instead the number will be truncated as specified by the strtod()
@@ -60,7 +50,7 @@ NOTES:
support for custom error handlers if a double can not accurately
represent the JSON number. (want to write this support!?)
--- yajl table (result of require 'yajl') --
+-- yajl functions --
yajl.null
View
3  lua_yajl.c
@@ -613,8 +613,9 @@ static int js_generator_value(lua_State *L) {
}
if ( is_array ) {
+ int i;
js_generator_open_array(L);
- for ( int i=1; i <= max; i++ ) {
+ for ( i=1; i <= max; i++ ) {
lua_pushinteger(L, i);
lua_gettable(L, 2);
View
30 module.mk
@@ -1,30 +0,0 @@
-_pwd := $(pwd)
-
-include $(make-common.dir)/tool/cc.mk
-include $(make-common.dir)/tool/lua.mk
-include $(make-common.dir)/layout.mk
-
-_lib := $(lua.c.lib.dir)/yajl.so
-_objs := $(call cc.c.to.o,$(addprefix $(_pwd)/, \
- lua_yajl.c \
-))
-
-all: | $(_lib)
-$(_lib): cc.libs += lua yajl
-$(_lib): cc.objs := $(_objs)
-$(_lib): $(_objs)
- $(cc.so.rule)
-
-# How to run lua_yajl tests:
-.PHONY: lua_yajl.test
-test: | lua_yajl.test
-
-lua ?= lua
-lua_yajl.test: | $(_lib)
-lua_yajl.test: lua.path += $(_pwd)
-lua_yajl.test: $(wildcard $(_pwd)/test*)
- @mkdir -p $(tmp.dir)
- cd $(tmp.dir); for t in $<; do \
- echo "TESTING: $$t"; \
- env -i $(lua.run) $(lua) $$t; \
- done
View
4 test.lua
@@ -1,5 +1,9 @@
print "1..5"
+local src_dir, build_dir = ...
+package.path = src_dir .. "?.lua;" .. package.path
+package.cpath = build_dir .. "?.so;" .. package.cpath
+
local tap = require("tap")
local yajl = require("yajl")
local ok = tap.ok
View
2  yajl.def
@@ -0,0 +1,2 @@
+EXPORTS
+luaopen_yajl
Please sign in to comment.
Something went wrong with that request. Please try again.