diff --git a/.gitignore b/.gitignore index 1a07bf75bf..506da5383c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ *.manifest *.dmp *.swp -.tags +.tags +test/builds/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..fa1f3e5143 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +language: c +sudo: false + +addons: + apt: + sources: + - llvm-toolchain-trusty-5.0 + packages: + - clang-5.0 +env: + - MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0" + +before_install: + - eval "${MATRIX_EVAL}" + +before_script: + - ./test/setup.sh + +script: + - make -C test -f test.make normal.test + - make -C test -f test.make gc64.test + - make -C test -f test.make dualnum.test + - make -C test -f test.make nojit.test + diff --git a/test/setup.sh b/test/setup.sh new file mode 100755 index 0000000000..3a6d32275b --- /dev/null +++ b/test/setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +cd ${DIR} + +if [ ! -d "testsuite" ]; then + git clone -b lib_apichanges https://github.com/softdevteam/LuaJIT-test-cleanup testsuite +fi diff --git a/test/test.make b/test/test.make new file mode 100644 index 0000000000..f628bccaf5 --- /dev/null +++ b/test/test.make @@ -0,0 +1,64 @@ +.SECONDEXPANSION: +all:: +SRC=../src + +BUILDS= normal gc64 dualnum nojit +normal : XCFLAGS= +gc64 : XCFLAGS=-DLUAJIT_ENABLE_GC64 +dualnum : XCFLAGS=-DLUAJIT_NUMMODE=2 +nojit : XCFLAGS=-DLUAJIT_DISABLE_JIT + +SRC_LUA= $(wildcard $(SRC)/jit/*.lua) +#Skip the dynamically generated VM info file that is generated at compile time +SRC_LUA:= $(filter-out vmdef.lua,$(SRC_LUA)) +LUA_NAMES= $(notdir $(SRC_LUA)) + +define make_buildtarget + $1_BUILD_OUTPUTS= builds/$1/libluajit.so builds/$1/luajit builds/$1/jit/vmdef.lua + $1_LUAFILES= $(addprefix builds/$1/jit/,$(LUA_NAMES)) + $$($1_LUAFILES): $1.copylua + $$($1_BUILD_OUTPUTS): $1.build + $1: $$($1_BUILD_OUTPUTS) $$($1_LUAFILES) + $1: BUILD_TARGET=$1 + BUILD_TARGETS += $1.build + LUA_TARGETS += $1.copylua + TEST_TARGETS += $1.test + CLEAN_TARGETS += $1.clean +endef + +$(foreach build, $(BUILDS), $(eval $(call make_buildtarget,$(build)))) + +.INTERMEDIATE: $(BUILD_TARGETS) $(LUA_TARGETS) + +%.copylua: $(SRC_LUA) + mkdir -p builds/$*/jit/ + $(foreach luafile, $(SRC_LUA), $(eval $(shell cp $(luafile) builds/$*/jit/))) + +%.build: $(SRC)/*.h $(SRC)/*.c + @echo "==== Building LuaJIT target = ${BUILD_TARGET} ====" + $(MAKE) -C $(SRC) -j XCFLAGS="-DLUAJIT_ENABLE_LUA52COMPAT ${XCFLAGS}" + mkdir -p builds/${BUILD_TARGET}/ + cp $(SRC)/luajit builds/${BUILD_TARGET}/ + cp $(SRC)/libluajit.so builds/${BUILD_TARGET}/ + mkdir -p builds/${BUILD_TARGET}/jit/ + cp $(SRC)/jit/vmdef.lua builds/${BUILD_TARGET}/jit/ + $(MAKE) -C $(SRC) clean + @echo "==== Successfully built LuaJIT ====" + +build : $(BUILDS) + +all test:: $(TEST_TARGETS) + +#Builds the binaries if they don't exist first +%.test: $$* + ./builds/$*/luajit testsuite/test/test.lua + +%.clean: + rm -f ./builds/$*/luajit + rm -f ./builds/$*/libluajit.so + rm -f ./builds/$*/jit/*.lua + +clean: $(CLEAN_TARGETS) + $(MAKE) -C $(SRC) clean + +.PHONY: all build test clean $(BUILDS)