Skip to content
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...
1 parent a3dd13c commit 41d9fad85070f354b097b8be9aa34bd588314cdb @rrthomas rrthomas committed Oct 4, 2012
View
1 .gitignore
@@ -5,3 +5,4 @@
ChangeLog
*.zip
release-notes
+/*.rockspec
View
25 Makefile
@@ -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
49 mkrockspecs.lua
@@ -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
125 rockspecs.lua
@@ -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
26 src/common.mak
@@ -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
17 src/defaults.mak
@@ -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
39 src/gnu/Makefile
@@ -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
38 src/oniguruma/Makefile
@@ -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)
View
38 src/pcre/Makefile
@@ -1,38 +0,0 @@
-# makefile for rex_pcre library
-
-include ../defaults.mak
-
-# === USER SETTINGS ===
-# ===========================================================================
-
-# These are default values.
-INC =
-LIB = -lpcre
-
-# If the default settings don't work for your system,
-# try to uncomment and edit the settings below.
-#INC =
-#LIB = -lpcre
-
-# Target name
-REGNAME = pcre
-
-# ===========================================================================
-# === END OF USER SETTINGS ===
-
-OBJ = lpcre.o lpcre_f.o ../common.o
-
-include ../common.mak
-
-# static PCRE regexp library binding
-ar_pcre: $(TRG_AR)
-
-# dynamic PCRE regexp library binding
-so_pcre: $(TRG_SO)
-
-# Dependencies
-lpcre.o: lpcre.c ../common.h ../algo.h
-lpcre_f.o: lpcre_f.c ../common.h
-../common.o: ../common.c ../common.h
-
-# (End of Makefile)
View
48 src/posix/Makefile
@@ -1,48 +0,0 @@
-# makefile for rex_posix 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.
-#INC =
-#LIB = -lc
-
-# WARNING:
-# If you want to use a POSIX regex library that is not the system
-# default, make sure you set both the INC and LIB variables correctly,
-# as if a header file and library are used which do not match, you may
-# well get segmentation faults (or worse).
-
-# The following lines work for the rxspencer library, when installed
-# under /usr (note the above warning!)
-#INC = -I/usr/include/rxspencer
-#LIB = -lrxspencer
-
-# Target name
-REGNAME = posix
-
-# ===========================================================================
-# === END OF USER SETTINGS ===
-
-OBJ = lposix.o ../common.o
-
-include ../common.mak
-
-# static POSIX regexp library binding
-ar_posix: $(TRG_AR)
-
-# dynamic POSIX regexp library binding
-so_posix: $(TRG_SO)
-
-# Dependencies
-lposix.o: lposix.c ../common.h ../algo.h
-../common.o: ../common.c ../common.h
-
-# (End of Makefile)
View
43 src/tre/Makefile
@@ -1,43 +0,0 @@
-# makefile for rex_tre library
-
-include ../defaults.mak
-
-# === USER SETTINGS ===
-# ===========================================================================
-
-# These are default values.
-INC =
-LIB = -ltre
-
-# If the default settings don't work for your system,
-# try to uncomment and edit the settings below.
-#INC = -I/usr/include
-#LIB = -lc
-
-# WARNING:
-# Make sure you set both the INC and LIB variables correctly, as
-# otherwise you risk using a header file and library that do not
-# match, and you may well get segmentation faults (or worse).
-
-# Target name
-REGNAME = tre
-
-# ===========================================================================
-# === END OF USER SETTINGS ===
-
-OBJ = ltre.o ../common.o # ltre_w.o
-
-include ../common.mak
-
-# static TRE regexp library binding
-ar_tre: $(TRG_AR)
-
-# dynamic TRE regexp library binding
-so_tre: $(TRG_SO)
-
-# Dependencies
-ltre.o: ltre.c ../common.h ../algo.h
-ltre_w.o: ltre_w.c ../common.h ../algo.h
-../common.o: ../common.c ../common.h
-
-# (End of Makefile)
View
0 test/onig_sets.lua → test/oniguruma_sets.lua
File renamed without changes.
View
12 test/runtest.lua
@@ -52,12 +52,12 @@ local function test_library (libname, setfile, verbose)
end
local avail_tests = {
- posix = { lib = "rex_posix", "common_sets", "posix_sets" },
- gnu = { lib = "rex_gnu", "common_sets", "emacs_sets", "gnu_sets" },
- onig = { lib = "rex_onig", "common_sets", "onig_sets", },
- pcre = { lib = "rex_pcre", "common_sets", "pcre_sets", "pcre_sets2", },
- spencer = { lib = "rex_spencer", "common_sets", "posix_sets", "spencer_sets" },
- tre = { lib = "rex_tre", "common_sets", "posix_sets", "spencer_sets", --[["tre_sets"]] },
+ posix = { lib = "rex_posix", "common_sets", "posix_sets" },
+ gnu = { lib = "rex_gnu", "common_sets", "emacs_sets", "gnu_sets" },
+ oniguruma = { lib = "rex_onig", "common_sets", "oniguruma_sets", },
+ pcre = { lib = "rex_pcre", "common_sets", "pcre_sets", "pcre_sets2", },
+ spencer = { lib = "rex_spencer", "common_sets", "posix_sets", "spencer_sets" },
+ tre = { lib = "rex_tre", "common_sets", "posix_sets", "spencer_sets", --[["tre_sets"]] },
}
do
View
26 windows/mingw/Makefile
@@ -1,26 +0,0 @@
-# Makefile for lrexlib
-
-MKFILES = \
- rex_gnu.mak \
- rex_onig.mak \
- rex_pcre.mak \
- rex_spencer.mak \
- rex_tre.mak
-
-LOOP = @for %%d in ($(MKFILES)) do $(MAKE) -f %%d
-
-all: build test
-
-build:
- $(LOOP)
-
-test:
- $(LOOP) test
-
-install:
- $(LOOP) install
-
-clean:
- del *.o *.def *.dll
-
-.PHONY: all build test install clean
View
64 windows/mingw/_mingw.mak
@@ -1,64 +0,0 @@
-# Use with GNU Make.
-
-# User Settings ------------------------------------------------------------
-
-# Target Lua version (51 for Lua 5.1; 52 for Lua 5.2).
-LUAVERSION = 51
-
-# INSTALLPATH : Path to install the built DLL.
-# LUADLL : Name of Lua DLL to link to (.dll should be omitted).
-# LUAEXE : Name of Lua interpreter.
-# LUAINC : Path of Lua include files.
-
-ifeq ($(LUAVERSION),51)
- INSTALLPATH = s:\exe\lib32\lua51
- LUADLL = lua5.1
- LUAEXE = lua.exe
- LUAINC = s:\progr\work\system\include\lua51
- MYCFLAGS += -DREX_CREATEGLOBALVAR
-else
- INSTALLPATH = s:\exe\lib32\lua52
- LUADLL = lua52
- LUAEXE = lua52.exe
- LUAINC = s:\progr\work\system\include\lua52
-# MYCFLAGS += -DREX_CREATEGLOBALVAR
-endif
-
-# --------------------------------------------------------------------------
-
-BIN = $(PROJECT).dll
-BININSTALL = $(INSTALLPATH)\$(BIN)
-CC = gcc
-CFLAGS = -W -Wall -O2 $(INCS) -DREX_OPENLIB=luaopen_$(PROJECT) \
- -DREX_LIBNAME=\"$(PROJECT)\" $(MYCFLAGS)
-DEFFILE = $(PROJECT).def
-EXPORTED = luaopen_$(PROJECT)
-INCS = -I$(LUAINC) $(MYINCS)
-LIBS = -l$(LUADLL) $(MYLIBS) -s
-SRCPATH = ..\..\src
-TESTPATH = ..\..\test
-
-.PHONY: all install test clean
-
-vpath %.c $(SRCPATH);$(SRCPATH)\$(PROJDIR)
-vpath %.h $(SRCPATH);$(SRCPATH)\$(PROJDIR)
-
-all: $(BIN)
-
-clean:
- del $(OBJ) $(BIN) $(DEFFILE)
-
-install: $(BININSTALL)
-
-test:
- cd $(TESTPATH) && $(LUAEXE) runtest.lua $(TESTNAME) -d$(CURDIR)
-
-$(BIN): $(OBJ) $(DEFFILE)
- $(CC) $(DEFFILE) $(OBJ) $(LIBS) -o $@ -shared
-
-$(DEFFILE):
- echo EXPORTS > $@
- for %%d in ($(EXPORTED)) do echo %%d>> $@
-
-$(BININSTALL): $(BIN)
- copy /Y $< $@
View
13 windows/mingw/docs.mak
@@ -1,13 +0,0 @@
-# Documentation Makefile
-
-APP = rst2html.py
-CP = "copy /y"
-RM = del
-IDX = ..\README.rst
-
-ALLVAR = APP=$(APP) CP=$(CP) RM=$(RM) IDX=$(IDX)
-
-.PHONY: all clean
-
-all clean:
- cd ..\..\doc && $(MAKE) $(ALLVAR) $@
View
18 windows/mingw/rex_gnu.mak
@@ -1,18 +0,0 @@
-# Project: rex_gnu
-
-# User Settings ------------------------------------------------------------
-# path of GNU include files
-REGEXINC = s:\progr\work\system\include\gnuregex
-# --------------------------------------------------------------------------
-
-PROJECT = rex_gnu
-MYINCS = -I$(REGEXINC)
-MYLIBS = -lregex2
-OBJ = lgnu.o common.o
-PROJDIR = gnu
-TESTNAME = gnu
-
-include _mingw.mak
-
-lgnu.o : common.h algo.h
-common.o : common.h
View
19 windows/mingw/rex_onig.mak
@@ -1,19 +0,0 @@
-# Project: rex_onig
-
-# User Settings ------------------------------------------------------------
-# path of Oniguruma include files
-REGEXINC = s:\progr\work\system\include
-# --------------------------------------------------------------------------
-
-PROJECT = rex_onig
-MYINCS = -I$(REGEXINC)
-MYLIBS = -lonig -Wl,--enable-auto-import
-OBJ = lonig.o lonig_f.o common.o
-PROJDIR = oniguruma
-TESTNAME = onig
-
-include _mingw.mak
-
-lonig.o : common.h algo.h
-lonig_f.o : common.h
-common.o : common.h
View
19 windows/mingw/rex_pcre.mak
@@ -1,19 +0,0 @@
-# Project: rex_pcre
-
-# User Settings ------------------------------------------------------------
-# path of PCRE include files
-REGEXINC = s:\progr\work\system\include
-# --------------------------------------------------------------------------
-
-PROJECT = rex_pcre
-MYINCS = -I$(REGEXINC)
-MYLIBS = -lpcre
-OBJ = lpcre.o lpcre_f.o common.o
-PROJDIR = pcre
-TESTNAME = pcre
-
-include _mingw.mak
-
-lpcre.o : common.h algo.h
-lpcre_f.o : common.h
-common.o : common.h
View
18 windows/mingw/rex_spencer.mak
@@ -1,18 +0,0 @@
-# Project: rex_spencer
-
-# User Settings ------------------------------------------------------------
-# path of Spencer's include files
-REGEXINC = s:\progr\work\system\include\rxspencer
-# --------------------------------------------------------------------------
-
-PROJECT = rex_spencer
-MYINCS = -I$(REGEXINC)
-MYLIBS = -lrxspencer
-OBJ = lposix.o common.o
-PROJDIR = posix
-TESTNAME = spencer
-
-include _mingw.mak
-
-lposix.o : common.h algo.h
-common.o : common.h
View
26 windows/mingw/rex_tre.mak
@@ -1,26 +0,0 @@
-# Project: rex_tre
-
-# User Settings ------------------------------------------------------------
-# path of TRE include files
-REGEXINC = s:\progr\work\system\include
-# --------------------------------------------------------------------------
-
-PROJECT = rex_tre
-MYINCS = -I$(REGEXINC)
-MYLIBS = -ltre
-OBJ = ltre.o common.o
-PROJDIR = tre
-TESTNAME = tre
-
-# Uncomment the following line to add wide-character functions (in alpha state).
-# ADDWIDECHARFUNCS = 1
-ifdef ADDWIDECHARFUNCS
- OBJ += ltre_w.o
- MYCFLAGS += -DREX_ADDWIDECHARFUNCS
-endif
-
-include _mingw.mak
-
-ltre.o : common.h algo.h
-ltre_w.o : common.h algo.h
-common.o : common.h

0 comments on commit 41d9fad

Please sign in to comment.
Something went wrong with that request. Please try again.