build tests with library

This commit is contained in:
Pedro 2015-12-23 16:14:39 +01:00
parent 5046c6477f
commit 8f26c45c01
7 changed files with 25 additions and 3 deletions

View File

@ -18,6 +18,7 @@ PARSERFILES = $(SRCPARSER)/bison_parser.cpp $(SRCPARSER)/flex_lexer.cpp
LIBCPP = $(shell find $(SRC)/ -name '*.cpp' -not -path "$(SRCPARSER)/*") $(SRCPARSER)/bison_parser.cpp $(SRCPARSER)/flex_lexer.cpp
LIBOBJ = $(LIBCPP:%.cpp=%.o)
LIBHEADERS = $(shell find $(SRCSQL)/ -name '*.h') $(SRC)/SQLParser.h
TESTCPP = $(shell find test/lib/ -name '*.cpp')
# compile & link flages
CC = g++
@ -25,11 +26,13 @@ CFLAGS = -std=c++11 -Wall -fPIC
LIBFLAGS = -shared
TARGET = libsqlparser.so
CTESTFLAGS = -Wall -Isrc/ -Itest/ -L./ -std=c++11
all: library
library: $(TARGET)
library: $(LIBOBJ)
$(TARGET): $(LIBOBJ)
$(CC) $(LIBFLAGS) -o $(TARGET) $(LIBOBJ)
@ -43,9 +46,28 @@ parser:
make -C $(SRCPARSER)/
clean:
rm -f $(TARGET)
rm -rf $(BIN)
find $(SRC) -type f -name '*.o' -delete
cleanparser:
make -C $(SRCPARSER)/ clean
############
### Test ###
############
test: $(BIN)/sql_tests $(BIN)/sql_grammar_test
LD_LIBRARY_PATH=./ $(BIN)/sql_grammar_test -f "test/lib/valid_queries.sql"
LD_LIBRARY_PATH=./ $(BIN)/sql_tests
$(BIN)/sql_tests: library
@mkdir -p $(BIN)/
$(CC) $(CTESTFLAGS) $(TESTCPP) test/sql_tests.cpp -o $(BIN)/sql_tests -lsqlparser
$(BIN)/sql_grammar_test: library
@mkdir -p $(BIN)/
$(CC) $(CTESTFLAGS) test/sql_grammar_test.cpp -o $(BIN)/sql_grammar_test -lsqlparser
FORCE:

View File

@ -2,8 +2,8 @@
* sql_tests.cpp
*/
#include "tests/test.h"
#include "tests/helper.h"
#include "lib/test.h"
#include "lib/helper.h"
#include "SQLParser.h"
#include "sqlhelper.h"