为降低变化成本,在根目录增加Makefile。

This commit is contained in:
zhengchao
2018-09-24 12:02:48 +08:00
parent 7a5b6ca6fb
commit 09d8c35b26
4 changed files with 51 additions and 8 deletions

41
Makefile Normal file
View File

@@ -0,0 +1,41 @@
BUILD_DIR = $(CURDIR)/build
LOCAL_DIR = $(CURDIR)
DEBUG_FLAGS = -DCMAKE_BUILD_TYPE=Debug
REL_FLAGS = -DCMAKE_BUILD_TYPE=RelWithDebInfo
ifneq ($(INSTALL_PREFIX),)
DEBUG_FLAGS += -DCMAKE_INSTALL_PREFIX=$(INSTALL_PREFIX)
REL_FLAGS += -DCMAKE_INSTALL_PREFIX=$(INSTALL_PREFIX)
endif
all: _make_build_dir _compile_rel
PHONY: all _make_build_dir _compile_debug _compile_rel _install \
build_release build_debug install
_make_build_dir:
mkdir -p $(BUILD_DIR)
_compile_debug:
cd $(BUILD_DIR) && cmake $(LOCAL_DIR) $(DEBUG_FLAGS) && make
_compile_rel:
cd $(BUILD_DIR) && cmake $(LOCAL_DIR) $(REL_FLAGS) && make
_install:
cd $(BUILD_DIR) && make install
_package:
cd $(BUILD_DIR) && make package
_clean:
rm -rf $(BUILD_DIR)
# Release Version, No Debug Symbol and Optimized with -O2
release: _make_build_dir _compile_rel
# Debug Version, Optimized with -O0
debug: _make_build_dir _compile_debug
# Install
install: _install
# Package
package: _package
# Clean
clean: _clean

View File

@@ -8,8 +8,6 @@ set(MAAT_FRAME_VERSION ${MAAT_FRAME_MAJOR_VERSION}.${MAAT_FRAME_MINOR_VERSION}.$
message(STATUS "Maat Frame, Version: ${MAAT_FRAME_VERSION}")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wall)
add_definitions(-fPIC)
set(MAAT_SRC entry/cJSON.c entry/config_monitor.cpp entry/dynamic_array.cpp entry/gram_index_engine.c entry/interval_index.c entry/json2iris.cpp entry/Maat_api.cpp entry/Maat_command.cpp entry/Maat_rule.cpp entry/Maat_stat.cpp entry/map_str2int.cpp entry/rbtree.c entry/stream_fuzzy_hash.c entry/UniversalBoolMatch.cpp)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../inc/)
@@ -34,3 +32,5 @@ target_include_directories(maat_frame_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
target_include_directories(maat_frame_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/inc_internal/hiredis)
target_link_libraries(maat_frame_shared MESA_handle_logger MESA_htable pcre rulescan pthread m pcre MESA_field_stat2 crypto hiredis_vip)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/inc/ DESTINATION /opt/MESA/include/MESA/ FILES_MATCHING PATTERN "*.h")
install(TARGETS maat_frame_shared DESTINATION /opt/MESA/lib/)

View File

@@ -748,7 +748,7 @@ int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char*
FILE*fp=NULL;
char line[MAX_TABLE_LINE_SIZE];
int i=0,ret=0,table_cnt=0;
char table_type_str[16],not_care[1024], user_region_encoding[32];
char table_type_str[16],not_care[1024], tmp_str[32];
MESA_htable_handle string2int_map=map_create();
struct _Maat_table_info_t*p=NULL;
struct _Maat_table_info_t*conj_table=NULL;
@@ -833,17 +833,17 @@ int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char*
case TABLE_TYPE_PLUGIN:
p->cb_info=(struct _plugin_table_info*)calloc(sizeof(struct _plugin_table_info),1);
p->cb_info->cache_lines=dynamic_array_create(1024,1024);
ret=sscanf(not_care,"%d\t%d",&(p->valid_flag_column), &p->rule_tag_column);
ret=sscanf(not_care,"%d\t%d\t%[0-9,]",&(p->valid_flag_column), &p->rule_tag_column, tmp_str);
if(ret==0||ret==EOF)
{
p->valid_flag_column=-1;
}
break;
case TABLE_TYPE_COMPILE:
ret=sscanf(not_care,"%[a-z0-9]",user_region_encoding);
ret=sscanf(not_care,"%[a-z0-9]",tmp_str);
if(ret>0)
{
ret=map_str2int(string2int_map,str_tolower(user_region_encoding),(int*)&(p->user_region_encoding));
ret=map_str2int(string2int_map,str_tolower(tmp_str),(int*)&(p->user_region_encoding));
}
if(ret!=1)
{
@@ -3085,7 +3085,7 @@ void update_plugin_table(struct _Maat_table_info_t* table,const char* table_line
char* copy=NULL;
char *token=NULL,*sub_token=NULL,*saveptr;
if(table->rule_tag_column!=0&&n_tags>0)
if(table->rule_tag_column>0&&n_tags>0)
{
copy=_maat_strdup(table_line);
for (token = copy, i=0; i<table->rule_tag_column ; token= NULL, i++)

View File

@@ -11,4 +11,6 @@ file(COPY conf DESTINATION ./)
file(COPY rule DESTINATION ./)
file(COPY testdata DESTINATION ./)
file(COPY testdata_uni2ascii DESTINATION ./)
add_test(NAME MaatframeFunctionTest COMMAND test_maatframe)
include(GoogleTest)
gtest_discover_tests(test_maatframe)