Permalink
Browse files

updated for Lua 5.1, cleaned up the Makefile, added make install

  • Loading branch information...
1 parent 0ed438c commit 75c4c52f13a6c3441c823d6af33aff8537f5e17c @slact slact committed Apr 26, 2008
Showing with 51 additions and 37 deletions.
  1. +3 −0 ext/lua/INSTALL
  2. +29 −13 ext/lua/Makefile
  3. 0 ext/lua/{lsyck.c → syck.c}
  4. +18 −18 ext/lua/test.lua
  5. +1 −6 ext/lua/yaml.lua
View
@@ -0,0 +1,3 @@
+Edit Makefile as needed, run make, make install. rejoice.
+
+You'll need the syck library, if you haven't already got it. You can find it at http://whytheluckystiff.net/syck/
View
@@ -1,28 +1,44 @@
# change these to reflect your Lua installation
-LUA=/usr/
-LUAINC= $(LUA)/include/lua50
-LUALIB= $(LUA)/lib
-LUABIN= $(LUA)/bin
+# Default installation prefix
+PREFIX=/home/leop/local
+
+# System's libraries directory (where binary libraries are installed)
+LUA_LIBDIR= $(PREFIX)/lib/lua/5.1
+
+# System's lua directory (where Lua libraries are installed)
+LUA_DIR= $(PREFIX)/share/lua/5.1
+
+LUAINC= $(PREFIX)/include
+LUALIB= $(PREFIX)/lib
+LUABIN= $(PREFIX)/bin
CFLAGS= $(INCS) $(WARN)
WARN= -Wall
INCS= -I$(LUAINC)
-LIBS=-lsyck
-
-MYNAME= syck
-MYLIB= l$(MYNAME)
+LIBS=-lsyck -L$(LUALIB)
-OBJS= $(MYLIB).o
+MYNAME=syck
+OBJS= $(MYNAME).o
+T= $(MYNAME).so
-T= $(MYLIB).so
+all: $T test
-all: $T
+install:
+ cp -f ./syck.so $(LUA_LIBDIR)
+ cp -f ./yaml.lua $(LUA_DIR)
-test: $T
+uninstall:
+ rm -f $(LUA_DIR)/yaml.lua
+ rm -f $(LUA_LIBDIR)/syck.so
+
+test: $t
$(LUABIN)/lua test.lua
+ @echo "built and tested successfully. run make install to install, or just move the libs manually"
$T: $(OBJS)
$(CC) -o $@ -shared $(OBJS) $(LIBS)
clean:
- rm -f $(OBJS) $T core core.* a.out
+ rm -f $(OBJS) $T core core.* a.out test.dump
+
+ready:
File renamed without changes.
View
@@ -7,24 +7,24 @@ lunit.import "all"
local testcase = lunit.TestCase("LuaYAML Testcases")
function testcase.test_load()
- assert_error(function() syck.load() end)
- assert_nil(syck.load("--- "))
- assert_true(syck.load("--- true"))
- assert_false(syck.load("--- false"))
- assert_equal(10, syck.load("--- 10"))
- local t = syck.load("--- \n- 5\n- 10\n- 15")
+ assert_error(function() yaml.load() end)
+ assert_nil(yaml.load("--- "))
+ assert_true(yaml.load("--- true"))
+ assert_false(yaml.load("--- false"))
+ assert_equal(10, yaml.load("--- 10"))
+ local t = yaml.load("--- \n- 5\n- 10\n- 15")
assert_equal(5, t[1])
assert_equal(10, t[2])
assert_equal(15, t[3])
- local t = syck.load("--- \n- one\n- two\n- three")
+ local t = yaml.load("--- \n- one\n- two\n- three")
assert_equal("one", t[1])
assert_equal("two", t[2])
assert_equal("three", t[3])
- local t = syck.load("--- \nthree: 15\ntwo: 10\none: 5")
+ local t = yaml.load("--- \nthree: 15\ntwo: 10\none: 5")
assert_equal(5, t.one)
assert_equal(10, t.two)
assert_equal(15, t.three)
- local t = syck.load("--- \nints: \n - 1\n - 2\n - 3\nmaps: \n three: 3\n two: 2\n one: 1\nstrings: \n - one\n - two\n - three")
+ local t = yaml.load("--- \nints: \n - 1\n - 2\n - 3\nmaps: \n three: 3\n two: 2\n one: 1\nstrings: \n - one\n - two\n - three")
assert_equal(1, t.ints[1])
assert_equal(2, t.ints[2])
assert_equal(3, t.ints[3])
@@ -37,20 +37,20 @@ function testcase.test_load()
end
function testcase.test_dump()
- assert_equal("--- \n", syck.dump(nil))
- assert_equal("--- hey\n", syck.dump("hey"))
- assert_equal("--- 5\n", syck.dump(5))
- assert_equal("--- true\n", syck.dump(true))
- assert_equal("--- false\n", syck.dump(false))
- assert_equal("--- \n- 5\n- 6\n- 7\n", syck.dump({5, 6, 7}))
+ assert_equal("--- \n", yaml.dump(nil))
+ assert_equal("--- hey\n", yaml.dump("hey"))
+ assert_equal("--- 5\n", yaml.dump(5))
+ assert_equal("--- true\n", yaml.dump(true))
+ assert_equal("--- false\n", yaml.dump(false))
+ assert_equal("--- \n- 5\n- 6\n- 7\n", yaml.dump({5, 6, 7}))
local str = "--- \n- \n - 1\n - 2\n - 3\n- \n - 6\n - 7\n - 8\n"
- assert_equal(str, syck.dump({{1, 2, 3}, {6, 7, 8}}))
+ assert_equal(str, yaml.dump({{1, 2, 3}, {6, 7, 8}}))
local str = "--- \n- \n - 1\n - 2\n - 3\n- \n - one\n - two\n - three\n"
- assert_equal(str, syck.dump({{1, 2, 3}, {"one", "two", "three"}}))
+ assert_equal(str, yaml.dump({{1, 2, 3}, {"one", "two", "three"}}))
local str = "--- \none: 1\nthree: 3\ntwo: 2\n"
- assert_equal(str, syck.dump({one=1, two=2, three=3}))
+ assert_equal(str, yaml.dump({one=1, two=2, three=3}))
end
function testcase.test_file()
View
@@ -1,11 +1,6 @@
-- borrow from lposix
--
-local function so(x)
- local SOPATH= os.getenv"LUA_SOPATH" or "./"
- assert(loadlib(SOPATH.."l"..x..".so","luaopen_"..x))()
-end
-
-so"syck"
+require "syck"
yaml = {}

0 comments on commit 75c4c52

Please sign in to comment.