add gtest

This commit is contained in:
ruanshudong 2020-03-31 16:55:45 +08:00
parent 2233513426
commit 0f1a542e02
9 changed files with 259 additions and 294 deletions

View File

@ -1,17 +1,17 @@
include_directories(${util_SOURCE_DIR}/include) include_directories(${util_SOURCE_DIR}/include)
include_directories(${CMAKE_BINARY_DIR}/src/gtest/include)
link_libraries(tarsutil) link_directories(${CMAKE_BINARY_DIR}/src/gtest/lib)
FILE(GLOB_RECURSE SRC_LIST "*.cpp") FILE(GLOB_RECURSE SRC_LIST "*.cpp")
if (TARS_SSL) if (TARS_SSL)
if (WIN32) if (WIN32)
link_libraries(tarsutil ${LIB_SSL} ${LIB_CRYPTO} Crypt32) link_libraries(tarsutil gtest ${LIB_SSL} ${LIB_CRYPTO} Crypt32)
else () else ()
link_libraries(tarsutil ${LIB_SSL} ${LIB_CRYPTO}) link_libraries(tarsutil gtest ${LIB_SSL} ${LIB_CRYPTO})
endif () endif ()
else () else ()
link_libraries(tarsutil) link_libraries(tarsutil gtest)
endif () endif ()
add_executable(demo-util ${SRC_LIST}) add_executable(demo-util ${SRC_LIST})

View File

@ -1,31 +1,12 @@
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include "test_base.h" #include "gtest/gtest.h"
using namespace std; using namespace std;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
try testing::InitGoogleTest(&argc, argv);
{ return RUN_ALL_TESTS();
vector<Test_Base*> tests;
tests.push_back(new Test_TC_File());
for(auto t : tests)
{
t->test();
}
for(auto t: tests)
{
delete t;
}
tests.clear();
}
catch (exception &ex)
{
cerr << "main ex:" << ex.what() << endl;
}
} }

View File

@ -1,21 +0,0 @@
//
// Created by jarod on 2020/2/20.
//
#ifndef TARS_CPP_TEST_BASE_H
#define TARS_CPP_TEST_BASE_H
class Test_Base
{
public:
virtual void test() = 0;
virtual ~Test_Base(){}
};
class Test_TC_File : public Test_Base
{
public:
virtual void test();
};
#endif //TARS_CPP_TEST_BASE_H

View File

@ -3,11 +3,33 @@
// //
#include "util/tc_file.h" #include "util/tc_file.h"
#include "test_base.h" #include "gtest/gtest.h"
using namespace tars; using namespace tars;
void Test_TC_File::test() class FileTest : public testing::Test
{
public:
//添加日志
static void SetUpTestCase()
{
cout<<"SetUpTestCase"<<endl;
}
static void TearDownTestCase()
{
cout<<"TearDownTestCase"<<endl;
}
virtual void SetUp() //TEST跑之前会执行SetUp
{
cout<<"SetUp"<<endl;
}
virtual void TearDown() //TEST跑完之后会执行TearDown
{
cout<<"TearDown"<<endl;
}
};
TEST_F(FileTest, file) //此时使用的是TEST_F宏
{ {
string file = "./test.dat"; string file = "./test.dat";
string data = "helloword"; string data = "helloword";
@ -16,27 +38,27 @@ void Test_TC_File::test()
TC_File::save2file(file, data); TC_File::save2file(file, data);
int fileSize = TC_File::getFileSize(file); int fileSize = TC_File::getFileSize(file);
cout << "file size:" << fileSize << endl; cout << "file size:" << fileSize << endl;
assert(fileSize == data.size()); ASSERT_TRUE(fileSize == data.size());
string load = TC_File::load2str(file); string load = TC_File::load2str(file);
cout << "load file size:" << load.size() << endl; cout << "load file size:" << load.size() << endl;
assert(load == data); ASSERT_TRUE(load == data);
bool fileExists = TC_File::isFileExist(file, S_IFREG); bool fileExists = TC_File::isFileExist(file, S_IFREG);
cout << "file exists:" << fileExists << endl; cout << "file exists:" << fileExists << endl;
assert(fileExists); ASSERT_TRUE(fileExists);
string dir = "test"; string dir = "test";
TC_File::makeDir(dir); TC_File::makeDir(dir);
fileExists = TC_File::isFileExist(dir, S_IFDIR); fileExists = TC_File::isFileExist(dir, S_IFDIR);
cout << "dir exists:" << fileExists << endl; cout << "dir exists:" << fileExists << endl;
assert(fileExists); ASSERT_TRUE(fileExists);
string newFile = dir + FILE_SEP + file; string newFile = dir + FILE_SEP + file;
TC_File::save2file(newFile, data); TC_File::save2file(newFile, data);
fileExists = TC_File::isFileExist(newFile, S_IFREG); fileExists = TC_File::isFileExist(newFile, S_IFREG);
cout << "newFile exists:" << fileExists << endl; cout << "newFile exists:" << fileExists << endl;
assert(fileExists); ASSERT_TRUE(fileExists);
TC_File::makeDir(dir + FILE_SEP + "test1"); TC_File::makeDir(dir + FILE_SEP + "test1");
TC_File::makeDir(dir + FILE_SEP + "test2"); TC_File::makeDir(dir + FILE_SEP + "test2");
@ -52,42 +74,53 @@ void Test_TC_File::test()
TC_File::removeFile(dir, true); TC_File::removeFile(dir, true);
fileExists = TC_File::isFileExist(file, S_IFDIR); fileExists = TC_File::isFileExist(file, S_IFDIR);
cout << "dir exists:" << fileExists << endl; cout << "dir exists:" << fileExists << endl;
assert(!fileExists); ASSERT_TRUE(!fileExists);
cout << "simplifyDirectory:" << TC_File::simplifyDirectory("/.") << endl;
cout << "simplifyDirectory:" << TC_File::simplifyDirectory("/./ab/tt//t///t//../tt/") << endl;
assert(TC_File::simplifyDirectory("/./ab/tt//t///t//../tt/") == "ab\\tt\\t\\tt");
#if TARGET_PLATFORM_WINDOWS
cout << "simplifyDirectory:" << TC_File::simplifyDirectory("c:/ab/tt//t///t//../tt/") << endl;
assert(TC_File::simplifyDirectory("c:/ab/tt//t///t//../tt/") == "c:\\ab\\tt\\t\\tt");
#endif
assert(TC_File::extractFileExt("/usr/local/app/bin.exe") == "exe");
assert(TC_File::extractFileExt("/usr/local/app/bin") == "");
assert(TC_File::extractFileExt("/usr/local/app.dir/bin.exe") == "exe");
assert(TC_File::extractFileExt("c:\\usr\\local\\app.dir\\bin.exe") == "exe");
assert(TC_File::extractFileExt("c:\\usr\\local\\app.dir\\bin") == "");
assert(TC_File::extractFileName("/usr/local/app/bin.exe") == "bin.exe");
assert(TC_File::extractFileName("/usr/local/app/bin") == "bin");
assert(TC_File::extractFileName("/usr/local/app.dir/bin.exe") == "bin.exe");
assert(TC_File::extractFileName("c:\\usr\\local\\app.dir\\bin.exe") == "bin.exe");
assert(TC_File::extractFileName("c:\\usr\\local\\app.dir\\bin") == "bin");
assert(TC_File::extractFileName("bin.exe") == "bin.exe");
assert(TC_File::extractFilePath("/usr/local/app/bin.exe") == "/usr/local/app/");
assert(TC_File::extractFilePath("/usr/local/app/bin") == "/usr/local/app/");
assert(TC_File::extractFilePath("/usr/local/app.dir/bin.exe") == "/usr/local/app.dir/");
assert(TC_File::extractFilePath("c:\\usr\\local\\app.dir\\bin.exe") == "c:\\usr\\local\\app.dir\\");
assert(TC_File::extractFilePath("c:\\usr\\local\\app.dir\\bin") == "c:\\usr\\local\\app.dir\\");
assert(TC_File::extractFilePath("temp.gif") == string(".") + FILE_SEP);
assert(TC_File::excludeFileExt("/usr/local/app/bin.exe") == "/usr/local/app/bin");
assert(TC_File::excludeFileExt("/usr/local/app/bin") == "/usr/local/app/bin");
assert(TC_File::excludeFileExt("/usr/local/app.dir/bin.exe") == "/usr/local/app.dir/bin");
assert(TC_File::excludeFileExt("c:\\usr\\local\\app.dir\\bin.exe") == "c:\\usr\\local\\app.dir\\bin");
assert(TC_File::excludeFileExt("c:\\usr\\local\\app.dir\\bin") == "c:\\usr\\local\\app.dir\\bin");
assert(TC_File::excludeFileExt("temp.gif") == "temp");
} }
TEST_F(FileTest, simplifyDirectory)
{
#if TARGET_PLATFORM_WINDOWS
cout << "simplifyDirectory:" << TC_File::simplifyDirectory("/./ab/tt//t///t//../tt/") << endl;
ASSERT_TRUE(TC_File::simplifyDirectory("/./ab/tt//t///t//../tt/") == "ab\\tt\\t\\tt");
cout << "simplifyDirectory:" << TC_File::simplifyDirectory("c:/ab/tt//t///t//../tt/") << endl;
ASSERT_TRUE(TC_File::simplifyDirectory("c:/ab/tt//t///t//../tt/") == "c:\\ab\\tt\\t\\tt");
#else
cout << "simplifyDirectory:" << TC_File::simplifyDirectory("/./ab/tt//t///t//../tt/") << endl;
ASSERT_TRUE(TC_File::simplifyDirectory("/./ab/tt//t///t//../tt/") == "/ab/tt/t/tt");
cout << "simplifyDirectory:" << TC_File::simplifyDirectory("/ab/tt//t///t//../tt/") << endl;
ASSERT_TRUE(TC_File::simplifyDirectory("/ab/tt//t///t//../tt/") == "/ab/tt/t/tt");
#endif
}
TEST_F(FileTest, nameAndPath)
{
ASSERT_TRUE(TC_File::extractFileExt("/usr/local/app/bin.exe") == "exe");
ASSERT_TRUE(TC_File::extractFileExt("/usr/local/app/bin") == "");
ASSERT_TRUE(TC_File::extractFileExt("/usr/local/app.dir/bin.exe") == "exe");
ASSERT_TRUE(TC_File::extractFileExt("c:\\usr\\local\\app.dir\\bin.exe") == "exe");
ASSERT_TRUE(TC_File::extractFileExt("c:\\usr\\local\\app.dir\\bin") == "");
ASSERT_TRUE(TC_File::extractFileName("/usr/local/app/bin.exe") == "bin.exe");
ASSERT_TRUE(TC_File::extractFileName("/usr/local/app/bin") == "bin");
ASSERT_TRUE(TC_File::extractFileName("/usr/local/app.dir/bin.exe") == "bin.exe");
ASSERT_TRUE(TC_File::extractFileName("c:\\usr\\local\\app.dir\\bin.exe") == "bin.exe");
ASSERT_TRUE(TC_File::extractFileName("c:\\usr\\local\\app.dir\\bin") == "bin");
ASSERT_TRUE(TC_File::extractFileName("bin.exe") == "bin.exe");
ASSERT_TRUE(TC_File::extractFilePath("/usr/local/app/bin.exe") == "/usr/local/app/");
ASSERT_TRUE(TC_File::extractFilePath("/usr/local/app/bin") == "/usr/local/app/");
ASSERT_TRUE(TC_File::extractFilePath("/usr/local/app.dir/bin.exe") == "/usr/local/app.dir/");
ASSERT_TRUE(TC_File::extractFilePath("c:\\usr\\local\\app.dir\\bin.exe") == "c:\\usr\\local\\app.dir\\");
ASSERT_TRUE(TC_File::extractFilePath("c:\\usr\\local\\app.dir\\bin") == "c:\\usr\\local\\app.dir\\");
ASSERT_TRUE(TC_File::extractFilePath("temp.gif") == string(".") + FILE_SEP);
ASSERT_TRUE(TC_File::excludeFileExt("/usr/local/app/bin.exe") == "/usr/local/app/bin");
ASSERT_TRUE(TC_File::excludeFileExt("/usr/local/app/bin") == "/usr/local/app/bin");
ASSERT_TRUE(TC_File::excludeFileExt("/usr/local/app.dir/bin.exe") == "/usr/local/app.dir/bin");
ASSERT_TRUE(TC_File::excludeFileExt("c:\\usr\\local\\app.dir\\bin.exe") == "c:\\usr\\local\\app.dir\\bin");
ASSERT_TRUE(TC_File::excludeFileExt("c:\\usr\\local\\app.dir\\bin") == "c:\\usr\\local\\app.dir\\bin");
ASSERT_TRUE(TC_File::excludeFileExt("temp.gif") == "temp");
}

View File

@ -157,13 +157,13 @@ macro(gen_server APP TARGET)
#make tar ######################################################################### #make tar #########################################################################
SET(RUN_TAR_COMMAND_FILE "${CMAKE_BINARY_DIR}/run-tar-${TARGET}.cmake") SET(RUN_TAR_COMMAND_FILE "${CMAKE_BINARY_DIR}/run-tar-${TARGET}.cmake")
FILE(WRITE ${RUN_TAR_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/${TARGET})\n") FILE(WRITE ${RUN_TAR_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND make_directory ${CMAKE_BINARY_DIR}/${TARGET})\n")
IF(WIN32) IF(WIN32)
FILE(APPEND ${RUN_TAR_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND cmake -E copy ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/${TARGET}.exe ${CMAKE_BINARY_DIR}/${TARGET}/)\n") FILE(APPEND ${RUN_TAR_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND copy ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/${TARGET}.exe ${CMAKE_BINARY_DIR}/${TARGET}/)\n")
ELSE() ELSE()
FILE(APPEND ${RUN_TAR_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND cmake -E copy ${CMAKE_BINARY_DIR}/bin/${TARGET} ${CMAKE_BINARY_DIR}/${TARGET}/)\n") FILE(APPEND ${RUN_TAR_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND copy ${CMAKE_BINARY_DIR}/bin/${TARGET} ${CMAKE_BINARY_DIR}/${TARGET}/)\n")
ENDIF() ENDIF()
FILE(APPEND ${RUN_TAR_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND cmake -E tar czfv ${CMAKE_BINARY_DIR}/${TARGET}.tgz ${CMAKE_BINARY_DIR}/${TARGET})\n") FILE(APPEND ${RUN_TAR_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND tar czfv ${CMAKE_BINARY_DIR}/${TARGET}.tgz ${CMAKE_BINARY_DIR}/${TARGET})\n")
# #
add_custom_command(OUTPUT ${TARGET}.tgz add_custom_command(OUTPUT ${TARGET}.tgz
@ -173,7 +173,7 @@ macro(gen_server APP TARGET)
add_custom_target(${TARGET}-tar DEPENDS ${TARGET}.tgz ${TARGET}) add_custom_target(${TARGET}-tar DEPENDS ${TARGET}.tgz ${TARGET})
FILE(APPEND ${TARS_TAR} "EXECUTE_PROCESS(COMMAND cmake -P ${RUN_TAR_COMMAND_FILE})\n") FILE(APPEND ${TARS_TAR} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -P ${RUN_TAR_COMMAND_FILE})\n")
#make upload ######################################################################### #make upload #########################################################################
SET(RUN_UPLOAD_COMMAND_FILE "${PROJECT_BINARY_DIR}/run-upload-${TARGET}.cmake") SET(RUN_UPLOAD_COMMAND_FILE "${PROJECT_BINARY_DIR}/run-upload-${TARGET}.cmake")
@ -195,7 +195,7 @@ macro(gen_server APP TARGET)
COMMAND cmake -P ${RUN_UPLOAD_COMMAND_FILE} COMMAND cmake -P ${RUN_UPLOAD_COMMAND_FILE}
COMMENT "upload ${APP}.${TARGET}.tgz and publish...") COMMENT "upload ${APP}.${TARGET}.tgz and publish...")
FILE(APPEND ${TARS_UPLOAD} "EXECUTE_PROCESS(COMMAND cmake -P ${RUN_UPLOAD_COMMAND_FILE})\n") FILE(APPEND ${TARS_UPLOAD} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -P ${RUN_UPLOAD_COMMAND_FILE})\n")
#make release ######################################################################### #make release #########################################################################
SET(RUN_RELEASE_COMMAND_FILE "${PROJECT_BINARY_DIR}/run-release-${TARGET}.cmake") SET(RUN_RELEASE_COMMAND_FILE "${PROJECT_BINARY_DIR}/run-release-${TARGET}.cmake")
@ -210,15 +210,15 @@ macro(gen_server APP TARGET)
if(WIN32) if(WIN32)
FILE(WRITE ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND make_directory c:\\tarsproto\\protocol\\${APP}\\${TARGET})\n") FILE(WRITE ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND make_directory c:\\tarsproto\\protocol\\${APP}\\${TARGET})\n")
FILE(APPEND ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND echo cp -rf ${CUR_TARS_GEN} c:\\tarsproto\\protocol\\${APP}\\${TARGET})\n") FILE(APPEND ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND echo cp -rf ${CUR_TARS_GEN} c:\\tarsproto\\protocol\\${APP}\\${TARGET})\n")
FILE(APPEND ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND cmake -E copy ${CUR_TARS_GEN} c:\\tarsproto\\protocol\\${APP}\\${TARGET})\n") FILE(APPEND ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND copy ${CUR_TARS_GEN} c:\\tarsproto\\protocol\\${APP}\\${TARGET})\n")
elseif(APPLE) elseif(APPLE)
FILE(WRITE ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND make_directory $ENV{HOME}/tarsproto/protocol/${APP}/${TARGET})\n") FILE(WRITE ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND make_directory $ENV{HOME}/tarsproto/protocol/${APP}/${TARGET})\n")
FILE(APPEND ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND echo cp -rf ${CUR_TARS_GEN} $ENV{HOME}/tarsproto/protocol/${APP}/${TARGET})\n") FILE(APPEND ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND echo cp -rf ${CUR_TARS_GEN} $ENV{HOME}/tarsproto/protocol/${APP}/${TARGET})\n")
FILE(APPEND ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND cmake -E copy ${CUR_TARS_GEN} $ENV{HOME}/tarsproto/protocol/${APP}/${TARGET})\n") FILE(APPEND ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND copy ${CUR_TARS_GEN} $ENV{HOME}/tarsproto/protocol/${APP}/${TARGET})\n")
elseif(UNIX) elseif(UNIX)
FILE(WRITE ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND make_directory /home/tarsproto/${APP}/${TARGET})\n") FILE(WRITE ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND make_directory /home/tarsproto/${APP}/${TARGET})\n")
FILE(APPEND ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND echo cp -rf ${CUR_TARS_GEN} /home/tarsproto/${APP}/${TARGET})\n") FILE(APPEND ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND echo cp -rf ${CUR_TARS_GEN} /home/tarsproto/${APP}/${TARGET})\n")
FILE(APPEND ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND cmake -E copy ${CUR_TARS_GEN} /home/tarsproto/${APP}/${TARGET})\n") FILE(APPEND ${RUN_RELEASE_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND copy ${CUR_TARS_GEN} /home/tarsproto/${APP}/${TARGET})\n")
endif() endif()
endforeach(TARS_FILE ${TARS_INPUT}) endforeach(TARS_FILE ${TARS_INPUT})
@ -228,7 +228,7 @@ macro(gen_server APP TARGET)
COMMAND cmake -P ${RUN_RELEASE_COMMAND_FILE} COMMAND cmake -P ${RUN_RELEASE_COMMAND_FILE}
COMMENT "call ${RUN_RELEASE_COMMAND_FILE}") COMMENT "call ${RUN_RELEASE_COMMAND_FILE}")
FILE(APPEND ${TARS_RELEASE} "EXECUTE_PROCESS(COMMAND cmake -P ${RUN_RELEASE_COMMAND_FILE})\n") FILE(APPEND ${TARS_RELEASE} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -P ${RUN_RELEASE_COMMAND_FILE})\n")
endif () endif ()
endmacro() endmacro()

View File

@ -4,8 +4,6 @@ macro(complice_lex OUT_DEPENDS_LEX_LIST)
FILE(GLOB SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/*.l") FILE(GLOB SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/*.l")
# set(CLEAN_LIST)
foreach (FILE ${SRC_LIST}) foreach (FILE ${SRC_LIST})
get_filename_component(NAME_WE ${FILE} NAME_WE) get_filename_component(NAME_WE ${FILE} NAME_WE)
@ -23,14 +21,11 @@ macro(complice_lex OUT_DEPENDS_LEX_LIST)
list(APPEND DEPENDS_LIST ${CMAKE_CURRENT_SOURCE_DIR}/${LEX_CPP}) list(APPEND DEPENDS_LIST ${CMAKE_CURRENT_SOURCE_DIR}/${LEX_CPP})
get_filename_component(PATH ${FILE} PATH) get_filename_component(PATH ${FILE} PATH)
# list(APPEND CLEAN_LIST ${PATH}/${LEX_CPP})
endforeach (FILE) endforeach (FILE)
set(OUT_DEPENDS_LEX_LIST ${DEPENDS_LIST}) set(OUT_DEPENDS_LEX_LIST ${DEPENDS_LIST})
# set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEAN_LIST}")
endmacro() endmacro()
macro(complice_yacc OUT_DEPENDS_YACC_LIST) macro(complice_yacc OUT_DEPENDS_YACC_LIST)
@ -38,8 +33,6 @@ macro(complice_yacc OUT_DEPENDS_YACC_LIST)
FILE(GLOB SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/*.y") FILE(GLOB SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/*.y")
# set(CLEAN_LIST)
foreach (FILE ${SRC_LIST}) foreach (FILE ${SRC_LIST})
get_filename_component(NAME_WE ${FILE} NAME_WE) get_filename_component(NAME_WE ${FILE} NAME_WE)
@ -59,18 +52,8 @@ macro(complice_yacc OUT_DEPENDS_YACC_LIST)
get_filename_component(PATH ${FILE} PATH) get_filename_component(PATH ${FILE} PATH)
# list(APPEND CLEAN_LIST ${PATH}/${YACC_H})
# list(APPEND CLEAN_LIST ${PATH}/${YACC_CPP})
#if (EXISTS ${PATH}/${NAME_WE}.tab.cpp)
# list(APPEND CLEAN_LIST ${PATH}/${NAME_WE}.tab.cpp)
#endif (EXISTS ${PATH}/${NAME_WE}.tab.cpp)
endforeach (FILE) endforeach (FILE)
# set(OUT_DEPENDS_YACC_LIST ${DEPENDS_LIST})
# set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEAN_LIST}")
endmacro() endmacro()
########################################################################################## ##########################################################################################
@ -101,9 +84,6 @@ foreach (FILE ${SRC_LEX_LIST})
# #
list(APPEND OUT_DEPENDS_LEX_LIST ${CP_SOURCE_CPP_DIR}/${LEX_CPP}) list(APPEND OUT_DEPENDS_LEX_LIST ${CP_SOURCE_CPP_DIR}/${LEX_CPP})
#.h
# list(APPEND CLEAN_LIST ${CP_SOURCE_CPP_DIR}/${LEX_CPP})
endforeach () endforeach ()
set(OUT_DEPENDS_YACC_LIST) set(OUT_DEPENDS_YACC_LIST)
@ -130,15 +110,7 @@ foreach (FILE ${SRC_YACC_LIST})
# #
list(APPEND OUT_DEPENDS_YACC_LIST ${CP_SOURCE_H_DIR}/${YACC_H}) list(APPEND OUT_DEPENDS_YACC_LIST ${CP_SOURCE_H_DIR}/${YACC_H})
#.h
# list(APPEND CLEAN_LIST ${CP_SOURCE_H_DIR}/${YACC_H})
# list(APPEND CLEAN_LIST ${CP_SOURCE_H_DIR}/${YACC_CPP})
endforeach () endforeach ()
#
#set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEAN_LIST}")
add_custom_target(COPY-LEX-YACC ALL DEPENDS ${OUT_DEPENDS_LEX_LIST} ${OUT_DEPENDS_YACC_LIST}) add_custom_target(COPY-LEX-YACC ALL DEPENDS ${OUT_DEPENDS_LEX_LIST} ${OUT_DEPENDS_YACC_LIST})
#add_custom_target(COPY-LEX-YACC ALL DEPENDS ${OUT_DEPENDS_LEX_LIST} ${CP_SOURCE_CPP_DIR}/${LEX_CPP} ${OUT_DEPENDS_YACC_LIST} ${CP_SOURCE_H_DIR}/${YACC_H})

View File

@ -8,27 +8,27 @@ aux_source_directory(. DIR_SRCS)
set(DEPENDS_SRC_LIST) set(DEPENDS_SRC_LIST)
set(DEPENDS_LEC_YACC_SRC_LIST) set(DEPENDS_LEC_YACC_SRC_LIST)
#if(WIN32) # #if(WIN32)
list(APPEND DEPENDS_LEC_YACC_SRC_LIST "tars.lex.cpp") list(APPEND DEPENDS_LEC_YACC_SRC_LIST "tars.lex.cpp")
list(APPEND DEPENDS_LEC_YACC_SRC_LIST "tars.tab.hpp") list(APPEND DEPENDS_LEC_YACC_SRC_LIST "tars.tab.hpp")
list(APPEND DEPENDS_LEC_YACC_SRC_LIST "tars.tab.cpp") list(APPEND DEPENDS_LEC_YACC_SRC_LIST "tars.tab.cpp")
#endif() # #endif()
set(DEPENDS_LEC_YACC_SRC_DIR "${PROJECT_SOURCE_DIR}/tarsGrammar/") # set(DEPENDS_LEC_YACC_SRC_DIR "${PROJECT_SOURCE_DIR}/tarsGrammar/")
set(CURRENT_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}") # set(CURRENT_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
foreach(LEC_YACC_SRC ${DEPENDS_LEC_YACC_SRC_LIST}) # foreach(LEC_YACC_SRC ${DEPENDS_LEC_YACC_SRC_LIST})
list(APPEND DEPENDS_SRC_LIST ${CURRENT_SRC_DIR}/${LEC_YACC_SRC}) # list(APPEND DEPENDS_SRC_LIST ${CURRENT_SRC_DIR}/${LEC_YACC_SRC})
add_custom_command( # add_custom_command(
OUTPUT ${CURRENT_SRC_DIR}/${LEC_YACC_SRC} # OUTPUT ${CURRENT_SRC_DIR}/${LEC_YACC_SRC}
WORKING_DIRECTORY ${CURRENT_SRC_DIR}) # WORKING_DIRECTORY ${CURRENT_SRC_DIR})
# COMMAND cp ${DEPENDS_LEC_YACC_SRC_DIR}/${LEC_YACC_SRC} ${CURRENT_SRC_DIR} # # COMMAND cp ${DEPENDS_LEC_YACC_SRC_DIR}/${LEC_YACC_SRC} ${CURRENT_SRC_DIR}
# COMMENT "cp ${DEPENDS_LEC_YACC_SRC_DIR}/${LEC_YACC_SRC} ${CURRENT_SRC_DIR}") # # COMMENT "cp ${DEPENDS_LEC_YACC_SRC_DIR}/${LEC_YACC_SRC} ${CURRENT_SRC_DIR}")
endforeach() # endforeach()
add_library(${TARGETNAME} ${DIR_SRCS} ${DEPENDS_SRC_LIST}) add_library(${TARGETNAME} ${DIR_SRCS} ${DEPENDS_SRC_LIST})

View File

@ -513,7 +513,7 @@ int yy_flex_debug = 0;
#define YY_MORE_ADJ 0 #define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET #define YY_RESTORE_YY_MORE_OFFSET
char *yytext; char *yytext;
#line 1 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 1 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
/** /**
* Tencent is pleased to support the open source community by making Tars available. * Tencent is pleased to support the open source community by making Tars available.
* *
@ -529,7 +529,7 @@ char *yytext;
* CONDITIONS OF ANY KIND, either express or implied. See the License for the * CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License. * specific language governing permissions and limitations under the License.
*/ */
#line 20 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 20 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
#include <map> #include <map>
#include <string> #include <string>
#include <sstream> #include <sstream>
@ -742,7 +742,7 @@ YY_DECL
register char *yy_cp, *yy_bp; register char *yy_cp, *yy_bp;
register int yy_act; register int yy_act;
#line 67 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 67 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
#line 749 "tars.lex.cpp" #line 749 "tars.lex.cpp"
@ -840,12 +840,12 @@ do_action: /* This label is used only to access EOF actions. */
case 1: case 1:
YY_RULE_SETUP YY_RULE_SETUP
#line 69 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 69 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ BEGIN(INCL); } { BEGIN(INCL); }
YY_BREAK YY_BREAK
case 2: case 2:
YY_RULE_SETUP YY_RULE_SETUP
#line 71 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 71 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
if ( include_file_stack_ptr >= MAX_INCLUDE_DEPTH ) if ( include_file_stack_ptr >= MAX_INCLUDE_DEPTH )
{ {
@ -878,7 +878,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(INCL): case YY_STATE_EOF(INCL):
#line 101 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 101 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
--include_file_stack_ptr; --include_file_stack_ptr;
if ( include_file_stack_ptr < 0 ) if ( include_file_stack_ptr < 0 )
@ -897,14 +897,14 @@ case YY_STATE_EOF(INCL):
YY_BREAK YY_BREAK
case 3: case 3:
YY_RULE_SETUP YY_RULE_SETUP
#line 117 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 117 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
return TARS_SCOPE_DELIMITER; return TARS_SCOPE_DELIMITER;
} }
YY_BREAK YY_BREAK
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 121 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 121 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
// C++ comment // C++ comment
bool e = false; bool e = false;
@ -925,7 +925,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
#line 139 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 139 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
// C comment // C comment
bool e = false; bool e = false;
@ -976,7 +976,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 6: case 6:
YY_RULE_SETUP YY_RULE_SETUP
#line 187 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 187 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
StringGrammarPtr ident = new StringGrammar; StringGrammarPtr ident = new StringGrammar;
ident->v = yytext; ident->v = yytext;
@ -987,7 +987,7 @@ YY_RULE_SETUP
case 7: case 7:
/* rule 7 can match eol */ /* rule 7 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 194 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 194 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
StringGrammarPtr ident = new StringGrammar; StringGrammarPtr ident = new StringGrammar;
ident->v = yytext; ident->v = yytext;
@ -1000,7 +1000,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 8: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 204 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 204 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
StringGrammarPtr str = new StringGrammar; StringGrammarPtr str = new StringGrammar;
bool e = false; bool e = false;
@ -1115,7 +1115,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 316 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 316 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
errno = 0; errno = 0;
IntergerGrammarPtr ptr = new IntergerGrammar; IntergerGrammarPtr ptr = new IntergerGrammar;
@ -1140,7 +1140,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 338 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 338 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
errno = 0; errno = 0;
FloatGrammarPtr ptr = new FloatGrammar; FloatGrammarPtr ptr = new FloatGrammar;
@ -1175,7 +1175,7 @@ YY_RULE_SETUP
case 11: case 11:
/* rule 11 can match eol */ /* rule 11 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 369 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 369 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
if(yytext[0] == '\n') if(yytext[0] == '\n')
{ {
@ -1185,7 +1185,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 376 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 376 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
{ {
if(yytext[0] < 32 || yytext[0] > 126) if(yytext[0] < 32 || yytext[0] > 126)
{ {
@ -1204,7 +1204,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 392 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 392 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 1211 "tars.lex.cpp" #line 1211 "tars.lex.cpp"
@ -2214,7 +2214,7 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables" #define YYTABLES_NAME "yytables"
#line 392 "/Volumes/MyData/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l" #line 392 "/Users/jarod/centos/TarsCloud/framework/tarscpp/tools/tarsgrammar/tars.l"

File diff suppressed because it is too large Load Diff