Permalink
Browse files

Replace build systems with LuaRocks.

A single Makefile remains to take care of tests, distribution, release
and documentation.

As a result, rockspecs are automatically generated for all lrexlib
flavours (previously, only POSIX and PCRE were available).
  • Loading branch information...
rrthomas committed Oct 4, 2012
1 parent a3dd13c commit 41d9fad85070f354b097b8be9aa34bd588314cdb
View
@@ -5,3 +5,4 @@
ChangeLog
*.zip
release-notes
+/*.rockspec
View
@@ -1,33 +1,22 @@
# Makefile for lrexlib
-# See src/*/Makefile and src/defaults.mak for user-definable settings
-
-include src/defaults.mak
+# See src/*/Makefile for user-definable settings
REGNAMES = gnu pcre posix oniguruma tre
PROJECT = lrexlib
-VERSION = $(V).$(MINORV)
+VERSION = 2.6.0
PROJECT_VERSIONED = $(PROJECT)-$(VERSION)
DISTFILE = $(PROJECT_VERSIONED).zip
-all:
- @for i in $(REGNAMES); do \
- make -C src/$$i; \
- done
- @make -C doc
-
-check: all
+check:
@for i in $(REGNAMES); do \
- make -C src/$$i check; \
+ cd src/$$i && LUA_PATH="../../test/?.lua;$(LUA_PATH)" $(LUA) ../../test/runtest.lua -d. $$i && cd ../..; \
done
-clean:
- @for i in $(REGNAMES); do \
- make -C src/$$i clean; \
- done
- @make -C doc clean
+doc:
+ @make -C doc
-dist: all
+dist: doc
git2cl > ChangeLog
cd .. && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT) -x "lrexlib/.git/*" "*.gitignore" "*.o" "*.a" "*.so" "*.so.*" "*.zip" "*SciTE.properties" "*scite.properties" && mv $(DISTFILE) $(PROJECT) && cd $(PROJECT) && unzip $(DISTFILE) && mv $(PROJECT) $(PROJECT_VERSIONED) && rm -f $(DISTFILE) && zip $(DISTFILE) -r $(PROJECT_VERSIONED) && rm -rf $(PROJECT_VERSIONED)
View
12 NEWS
@@ -1,3 +1,15 @@
+2012-10-04 Release 2.7.0
+
+ * Added support for searching raw memory buffers (e.g. made with
+ alien).
+ * Fixed possible invalid code generation in C (thanks, Michael
+ Tautschnig).
+ * Generate LuaRock rockspecs for all modules.
+ * Greatly simplify UNIX build system, relying on LuaRocks.
+ * Allow POSIX REG_STARTEND to be used on any system supporting it.
+ * Add a test set for POSIX regex engine (thanks, Enrico Tassi).
+ * Simplify some code.
+
2012-04-13 Release 2.6.0
* Added support for Lua 5.2.
View
@@ -0,0 +1,49 @@
+-- Generate the rockspecs
+
+require "std"
+
+if select ("#", ...) < 2 then
+ io.stderr:write "Usage: mkrockspecs VERSION MD5SUM\n"
+ os.exit ()
+end
+
+version = select (1, ...)
+md5sum = select (2, ...)
+
+function format (x, indent)
+ indent = indent or ""
+ if type (x) == "table" then
+ local s = "{\n"
+ for i, v in pairs (x) do
+ if type (i) ~= "number" then
+ s = s..indent..i.." = "..format (v, indent.." ")..",\n"
+ end
+ end
+ for i, v in ipairs (x) do
+ s = s..indent..format (v, indent.." ")..",\n"
+ end
+ return s..indent:sub(1, -3).."}"
+ elseif type (x) == "string" then
+ return string.format ("%q", x)
+ else
+ return tostring (x)
+ end
+end
+
+for f, spec in pairs (loadfile ("rockspecs.lua") ()) do
+ if f ~= "default" then
+ local specfile = "lrexlib-"..f:lower ().."-"..version.."-1.rockspec"
+ h = io.open (specfile, "w")
+ assert (h)
+ flavour = f -- a global, visible in loadfile
+ local specs = loadfile ("rockspecs.lua") () -- reload to get current flavour interpolated
+ local spec = table.merge (specs.default, specs[f])
+ local s = ""
+ for i, v in pairs (spec) do
+ s = s..i.." = "..format (v, " ").."\n"
+ end
+ h:write (s)
+ h:close ()
+ os.execute ("luarocks lint " .. specfile)
+ end
+end
View
@@ -0,0 +1,125 @@
+local flavours = {"PCRE", "POSIX", "oniguruma", "TRE", "GNU"}
+
+-- Rockspec data
+
+-- Variables to be interpolated:
+--
+-- flavour: regex library
+-- version
+-- md5sum: checksum of distribution tarball
+
+-- When Lua 5.1 support is dropped, use an env argument with loadfile
+-- instead of wrapping in a table
+return {
+
+default = {
+ package="Lrexlib-"..flavour,
+ version=version.."-1",
+ source = {
+ url = "https://github.com/downloads/rrthomas/lrexlib/lrexlib-"..version..".zip",
+ md5 = md5sum
+ },
+ description = {
+ summary = "Regular expression library binding ("..flavour.." flavour).",
+ detailed = [[
+ Lrexlib is a regular expression library for Lua 5.1, which
+ provides bindings for several regular expression libraries.
+ This rock provides the ]]..flavour..[[ bindings.
+ ]],
+ homepage = "http://github.com/rrthomas/lrexlib",
+ license = "MIT/X11"
+ },
+ dependencies = {
+ "lua >= 5.1"
+ },
+},
+
+PCRE = {
+ external_dependencies = {
+ PCRE = {
+ header = "pcre.h",
+ library = "pcre"
+ }
+ },
+ build = {
+ type = "builtin",
+ modules = {
+ rex_pcre = {
+ sources = {"src/common.c", "src/pcre/lpcre.c", "src/pcre/lpcre_f.c"},
+ libraries = {"pcre"},
+ incdirs = {"$(PCRE_INCDIR)"},
+ libdirs = {"$(PCRE_LIBDIR)"}
+ }
+ }
+ }
+},
+
+POSIX = {
+ external_dependencies = {
+ POSIX = {
+ header = "regex.h",
+ }
+ },
+ build = {
+ type = "builtin",
+ modules = {
+ rex_posix = {"src/common.c", "src/posix/lposix.c"}
+ }
+ }
+},
+
+oniguruma = {
+ external_dependencies = {
+ ONIG = {
+ header = "oniguruma.h",
+ library = "onig"
+ }
+ },
+ build = {
+ type = "builtin",
+ modules = {
+ rex_onig = {
+ sources = {"src/common.c", "src/oniguruma/lonig.c", "src/oniguruma/lonig_f.c"},
+ libraries = {"onig"},
+ incdirs = {"$(ONIG_INCDIR)"},
+ libdirs = {"$(ONIG_LIBDIR)"}
+ }
+ }
+ }
+},
+
+TRE = {
+ external_dependencies = {
+ TRE = {
+ header = "tre/tre.h",
+ library = "tre"
+ }
+ },
+ build = {
+ type = "builtin",
+ modules = {
+ rex_tre = {
+ sources = {"src/common.c", "src/tre/ltre.c" --[[, "src/tre/tre_w.c"]]},
+ libraries = {"tre"},
+ incdirs = {"$(TRE_INCDIR)"},
+ libdirs = {"$(TRE_LIBDIR)"}
+ }
+ }
+ }
+},
+
+GNU = {
+ external_dependencies = {
+ GNU = {
+ header = "regex.h",
+ }
+ },
+ build = {
+ type = "builtin",
+ modules = {
+ rex_posix = {"src/common.c", "src/gnu/lgnu.c"}
+ }
+ }
+},
+
+} -- close wrapper table
View
@@ -1,26 +0,0 @@
-# Rules for lrexlib
-
-TRG = rex_$(REGNAME)
-DEFS = -DREX_OPENLIB=luaopen_$(TRG) -DREX_LIBNAME=\"$(TRG)\"
-CFLAGS = $(MYCFLAGS) $(DEFS) $(INC)
-TRG_AR = lib$(TRG).a
-TRG_SO = $(TRG).so
-LD = $(CC)
-LDFLAGS= -shared
-# For Darwin:
-#LDFLAGS= -bundle -undefined dynamic_lookup
-
-all: $(TRG_AR) $(TRG_SO)
-
-$(TRG_AR): $(OBJ)
- $(AR) $@ $^
-
-$(TRG_SO): $(OBJ)
- $(LD) -o $@.$V $(LDFLAGS) $^ $(LIB) $(LIB_LUA)
- ln -fs $@.$V $@
-
-clean:
- rm -f $(OBJ) $(TRG_AR) $(TRG_SO)*
-
-check: all
- LUA_PATH="../../test/?.lua;$(LUA_PATH)" $(LUA) ../../test/runtest.lua -d. $(REGNAME)
View
@@ -1,17 +0,0 @@
-# default settings for lrexlib
-
-V = 2.6
-MINORV = 0
-
-LUA = lua
-INC_LUA =
-LIB_LUA =
-
-# If the default settings don't work for your system,
-# try to uncomment and edit the settings below.
-#INC_LUA = -I/usr/include/lua5.1
-#LIB_LUA = -llua
-
-MYCFLAGS = -fPIC -W -Wall $(INC_LUA) $(INC_PCRE)
-AR = ar rcu
-CC = gcc
View
@@ -1,39 +0,0 @@
-# makefile for rex_gnu library
-
-include ../defaults.mak
-
-# === USER SETTINGS ===
-# ===========================================================================
-
-# These are default values.
-INC =
-LIB =
-
-# If the default settings don't work for your system,
-# try to uncomment and edit the settings below.
-# The default settings below work with a libgnu.a in the current directory,
-# copied from any libgnu.a built with the regex module.
-#INC = -I. -DREX_GNU_INCLUDE='"regex.h"'
-#LIB = -L. -lgnu
-
-# Regex library name
-REGNAME = gnu
-
-# ===========================================================================
-# === END OF USER SETTINGS ===
-
-OBJ = lgnu.o ../common.o
-
-include ../common.mak
-
-# static GNU regexp library binding
-ar_gnu: $(TRG_AR)
-
-# dynamic GNU regexp library binding
-so_gnu: $(TRG_SO)
-
-# Dependencies
-lgnu.o: lgnu.c ../common.h ../algo.h
-../common.o: ../common.c ../common.h
-
-# (End of Makefile)
View
@@ -1,38 +0,0 @@
-# makefile for rex_onig library
-
-include ../defaults.mak
-
-# === USER SETTINGS ===
-# ===========================================================================
-
-# These are default values.
-INC =
-LIB = -lonig
-
-# If the default settings don't work for your system,
-# try to uncomment and edit the settings below.
-#INC =
-#LIB = -lonig
-
-# Target name
-REGNAME = onig
-
-# ===========================================================================
-# === END OF USER SETTINGS ===
-
-OBJ = lonig.o lonig_f.o ../common.o
-
-include ../common.mak
-
-# static Oniguruma regexp library binding
-ar_onig: $(TRG_AR)
-
-# dynamic Oniguruma regexp library binding
-so_onig: $(TRG_SO)
-
-# Dependencies
-lonig.o: lonig.c ../common.h ../algo.h
-lonig_f.o: lonig_f.c ../common.h
-../common.o: ../common.c ../common.h
-
-# (End of Makefile)
Oops, something went wrong.

0 comments on commit 41d9fad

Please sign in to comment.