summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-09-08 20:09:33 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-09-08 20:09:33 +0100
commitf0613b4cc5763d3de7dd65b89e6b4f9d3c6e6190 (patch)
treea5843b2cc60ead660dd2dd424c07600737b20eed
parent8d03cfc784b8b168d9910df456d6794df53b561f (diff)
downloadgall-f0613b4cc5763d3de7dd65b89e6b4f9d3c6e6190.tar.gz
GALL: Allow for optional git2 support
-rw-r--r--.gitignore3
-rw-r--r--Makefile16
-rw-r--r--lib/gall/ll.lua14
-rw-r--r--test/test-gall.lua10
4 files changed, 34 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index cc2e872..9e8fae7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
*~
luacov.*.out
-
test/test_repo
-lib/gall/git2.so
+lib/gall/ll/git2.so
diff --git a/Makefile b/Makefile
index dffc489..f5e2a5c 100644
--- a/Makefile
+++ b/Makefile
@@ -15,21 +15,22 @@ install:
cp lib/$${MOD} $(INST_ROOT)/$${MOD}; \
done
-LUA := LUA_PATH="$(shell pwd)/lib/?.lua;$(shell pwd)/extras/luacov/src/?.lua;;" lua$(LUA_VER)
+LUA := LUA_CPATH="$(shell pwd)/lib/?.so;;" LUA_PATH="$(shell pwd)/lib/?.lua;$(shell pwd)/extras/luacov/src/?.lua;;" lua$(LUA_VER)
cmodule: try-cmodule
try-cmodule:
-@$(MAKE) --no-print-directory do-cmodule
-do-cmodule: lib/gall/git2.so
+do-cmodule: lib/gall/ll/git2.so
-lib/gall/git2.so: luagit2/build/git2.so
+lib/gall/ll/git2.so: luagit2/build/git2.so
+ mkdir -p lib/gall/ll
cp $< $@
luagit2/build/git2.so: libgit2/build/gall-install-stamp
mkdir -p luagit2/build
- cd luagit2/build && PKG_CONFIG_PATH="$(shell pwd)/libgit2/build/gall-install/lib/pkgconfig:$(PKG_CONFIG_PATH)" cmake -DCMAKE_C_FLAGS="$${CMAKE_C_FLAGS} -Dluaopen_git2=luaopen_gall_git2" -DCMAKE_MODULE_LINKER_FLAGS="-lssl" ..
+ cd luagit2/build && PKG_CONFIG_PATH="$(shell pwd)/libgit2/build/gall-install/lib/pkgconfig:$(PKG_CONFIG_PATH)" cmake -DCMAKE_C_FLAGS="$${CMAKE_C_FLAGS} -Dluaopen_git2=luaopen_gall_ll_git2" -DCMAKE_MODULE_LINKER_FLAGS="-lssl" ..
cd luagit2/build && $(MAKE)
libgit2/build/gall-install-stamp:
@@ -41,8 +42,8 @@ libgit2/build/gall-install-stamp:
touch $@
clean:
- $(RM) luacov.report.out luacov.stats.out lib/gall/git2.so
- $(RM) -r libgit2/build luagit2/build
+ $(RM) luacov.report.out luacov.stats.out
+ $(RM) -r libgit2/build luagit2/build lib/gall/ll
distclean: clean
find . -name "*~" -delete
@@ -59,6 +60,9 @@ test: cmodule
echo -n "$${MOD}: "; \
$(LUA) test/test-$${MOD}.lua; \
test "x$$?" = "x0" || ERR=1; \
+ echo -n "$${MOD} [no git2]: "; \
+ GALL_DISABLE_GIT2=1 $(LUA) test/test-$${MOD}.lua; \
+ test "x$$?" = "x0" || ERR=1; \
done; \
$(LUA) extras/luacov/src/bin/luacov -X luacov. -X test. $(MODULES); \
exit $$ERR
diff --git a/lib/gall/ll.lua b/lib/gall/ll.lua
index 92200a4..3a24250 100644
--- a/lib/gall/ll.lua
+++ b/lib/gall/ll.lua
@@ -9,6 +9,17 @@
local sp = require "luxio.subprocess"
local util = require "gall.util"
+
+local git2
+if os.getenv "GALL_DISABLE_GIT2" then
+ git2 = nil
+else
+ ok, git2 = pcall(require, "gall.ll.git2")
+ if not ok then
+ git2 = nil
+ end
+end
+
local assert = assert
local git_exe = "git"
@@ -80,7 +91,8 @@ end
local mod_ret = {
rungit = _rungit,
get_set_git = get_set_git,
- chomp = _chomp
+ chomp = _chomp,
+ git2 = git2,
}
local simple_cmds = {
diff --git a/test/test-gall.lua b/test/test-gall.lua
index 3f0558d..5287ce9 100644
--- a/test/test-gall.lua
+++ b/test/test-gall.lua
@@ -51,6 +51,16 @@ for _, ent in ipairs {
end
end
+function suite.test_that_git2_present_if_wanted()
+ local want_git2 = not(os.getenv "GALL_DISABLE_GIT2")
+ local have_git2 = io.open("lib/gall/ll/git2.so", "r") ~= nil
+ if want_git2 and have_git2 then
+ assert(gall.ll.git2)
+ else
+ assert(not gall.ll.git2)
+ end
+end
+
local count_ok = 0
for _, testname in ipairs(testnames) do
-- print("Run: " .. testname)