mirror of
https://gitee.com/TarsCloud/TarsCpp.git
synced 2024-12-22 22:16:38 +08:00
add gtest
This commit is contained in:
parent
2233513426
commit
0f1a542e02
@ -1,17 +1,17 @@
|
||||
include_directories(${util_SOURCE_DIR}/include)
|
||||
|
||||
link_libraries(tarsutil)
|
||||
include_directories(${CMAKE_BINARY_DIR}/src/gtest/include)
|
||||
link_directories(${CMAKE_BINARY_DIR}/src/gtest/lib)
|
||||
|
||||
FILE(GLOB_RECURSE SRC_LIST "*.cpp")
|
||||
|
||||
if (TARS_SSL)
|
||||
if (WIN32)
|
||||
link_libraries(tarsutil ${LIB_SSL} ${LIB_CRYPTO} Crypt32)
|
||||
link_libraries(tarsutil gtest ${LIB_SSL} ${LIB_CRYPTO} Crypt32)
|
||||
else ()
|
||||
link_libraries(tarsutil ${LIB_SSL} ${LIB_CRYPTO})
|
||||
link_libraries(tarsutil gtest ${LIB_SSL} ${LIB_CRYPTO})
|
||||
endif ()
|
||||
else ()
|
||||
link_libraries(tarsutil)
|
||||
link_libraries(tarsutil gtest)
|
||||
endif ()
|
||||
|
||||
add_executable(demo-util ${SRC_LIST})
|
||||
|
@ -1,31 +1,12 @@
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include "test_base.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
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;
|
||||
}
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
@ -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
|
@ -3,11 +3,33 @@
|
||||
//
|
||||
|
||||
#include "util/tc_file.h"
|
||||
#include "test_base.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
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 data = "helloword";
|
||||
@ -16,27 +38,27 @@ void Test_TC_File::test()
|
||||
TC_File::save2file(file, data);
|
||||
int fileSize = TC_File::getFileSize(file);
|
||||
cout << "file size:" << fileSize << endl;
|
||||
assert(fileSize == data.size());
|
||||
ASSERT_TRUE(fileSize == data.size());
|
||||
|
||||
string load = TC_File::load2str(file);
|
||||
cout << "load file size:" << load.size() << endl;
|
||||
assert(load == data);
|
||||
ASSERT_TRUE(load == data);
|
||||
|
||||
bool fileExists = TC_File::isFileExist(file, S_IFREG);
|
||||
cout << "file exists:" << fileExists << endl;
|
||||
assert(fileExists);
|
||||
ASSERT_TRUE(fileExists);
|
||||
|
||||
string dir = "test";
|
||||
TC_File::makeDir(dir);
|
||||
fileExists = TC_File::isFileExist(dir, S_IFDIR);
|
||||
cout << "dir exists:" << fileExists << endl;
|
||||
assert(fileExists);
|
||||
ASSERT_TRUE(fileExists);
|
||||
|
||||
string newFile = dir + FILE_SEP + file;
|
||||
TC_File::save2file(newFile, data);
|
||||
fileExists = TC_File::isFileExist(newFile, S_IFREG);
|
||||
cout << "newFile exists:" << fileExists << endl;
|
||||
assert(fileExists);
|
||||
ASSERT_TRUE(fileExists);
|
||||
|
||||
TC_File::makeDir(dir + FILE_SEP + "test1");
|
||||
TC_File::makeDir(dir + FILE_SEP + "test2");
|
||||
@ -52,42 +74,53 @@ void Test_TC_File::test()
|
||||
TC_File::removeFile(dir, true);
|
||||
fileExists = TC_File::isFileExist(file, S_IFDIR);
|
||||
cout << "dir exists:" << fileExists << endl;
|
||||
assert(!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");
|
||||
|
||||
ASSERT_TRUE(!fileExists);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
@ -157,13 +157,13 @@ macro(gen_server APP TARGET)
|
||||
|
||||
#make tar #########################################################################
|
||||
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)
|
||||
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()
|
||||
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()
|
||||
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
|
||||
@ -173,7 +173,7 @@ macro(gen_server APP 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 #########################################################################
|
||||
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}
|
||||
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 #########################################################################
|
||||
SET(RUN_RELEASE_COMMAND_FILE "${PROJECT_BINARY_DIR}/run-release-${TARGET}.cmake")
|
||||
@ -210,15 +210,15 @@ macro(gen_server APP TARGET)
|
||||
if(WIN32)
|
||||
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 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)
|
||||
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 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)
|
||||
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 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()
|
||||
endforeach(TARS_FILE ${TARS_INPUT})
|
||||
|
||||
@ -228,7 +228,7 @@ macro(gen_server APP TARGET)
|
||||
COMMAND cmake -P ${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 ()
|
||||
endmacro()
|
||||
|
||||
|
@ -4,8 +4,6 @@ macro(complice_lex OUT_DEPENDS_LEX_LIST)
|
||||
|
||||
FILE(GLOB SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/*.l")
|
||||
|
||||
# set(CLEAN_LIST)
|
||||
|
||||
foreach (FILE ${SRC_LIST})
|
||||
|
||||
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})
|
||||
|
||||
get_filename_component(PATH ${FILE} PATH)
|
||||
# list(APPEND CLEAN_LIST ${PATH}/${LEX_CPP})
|
||||
|
||||
endforeach (FILE)
|
||||
|
||||
set(OUT_DEPENDS_LEX_LIST ${DEPENDS_LIST})
|
||||
|
||||
# set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEAN_LIST}")
|
||||
|
||||
endmacro()
|
||||
|
||||
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")
|
||||
|
||||
# set(CLEAN_LIST)
|
||||
|
||||
foreach (FILE ${SRC_LIST})
|
||||
|
||||
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)
|
||||
|
||||
# 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)
|
||||
|
||||
# set(OUT_DEPENDS_YACC_LIST ${DEPENDS_LIST})
|
||||
|
||||
# set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEAN_LIST}")
|
||||
|
||||
endmacro()
|
||||
|
||||
##########################################################################################
|
||||
@ -101,9 +84,6 @@ foreach (FILE ${SRC_LEX_LIST})
|
||||
#设置依赖
|
||||
list(APPEND OUT_DEPENDS_LEX_LIST ${CP_SOURCE_CPP_DIR}/${LEX_CPP})
|
||||
|
||||
#设置需要清除的.h文件
|
||||
# list(APPEND CLEAN_LIST ${CP_SOURCE_CPP_DIR}/${LEX_CPP})
|
||||
|
||||
endforeach ()
|
||||
|
||||
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})
|
||||
|
||||
#设置需要清除的.h文件
|
||||
# list(APPEND CLEAN_LIST ${CP_SOURCE_H_DIR}/${YACC_H})
|
||||
# list(APPEND CLEAN_LIST ${CP_SOURCE_H_DIR}/${YACC_CPP})
|
||||
|
||||
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} ${CP_SOURCE_CPP_DIR}/${LEX_CPP} ${OUT_DEPENDS_YACC_LIST} ${CP_SOURCE_H_DIR}/${YACC_H})
|
||||
|
@ -8,27 +8,27 @@ aux_source_directory(. DIR_SRCS)
|
||||
set(DEPENDS_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.tab.hpp")
|
||||
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(
|
||||
OUTPUT ${CURRENT_SRC_DIR}/${LEC_YACC_SRC}
|
||||
WORKING_DIRECTORY ${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}")
|
||||
# add_custom_command(
|
||||
# OUTPUT ${CURRENT_SRC_DIR}/${LEC_YACC_SRC}
|
||||
# WORKING_DIRECTORY ${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}")
|
||||
|
||||
endforeach()
|
||||
# endforeach()
|
||||
|
||||
add_library(${TARGETNAME} ${DIR_SRCS} ${DEPENDS_SRC_LIST})
|
||||
|
||||
|
@ -513,7 +513,7 @@ int yy_flex_debug = 0;
|
||||
#define YY_MORE_ADJ 0
|
||||
#define YY_RESTORE_YY_MORE_OFFSET
|
||||
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.
|
||||
*
|
||||
@ -529,7 +529,7 @@ char *yytext;
|
||||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* 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 <string>
|
||||
#include <sstream>
|
||||
@ -742,7 +742,7 @@ YY_DECL
|
||||
register char *yy_cp, *yy_bp;
|
||||
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"
|
||||
@ -840,12 +840,12 @@ do_action: /* This label is used only to access EOF actions. */
|
||||
|
||||
case 1:
|
||||
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); }
|
||||
YY_BREAK
|
||||
case 2:
|
||||
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 )
|
||||
{
|
||||
@ -878,7 +878,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
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;
|
||||
if ( include_file_stack_ptr < 0 )
|
||||
@ -897,14 +897,14 @@ case YY_STATE_EOF(INCL):
|
||||
YY_BREAK
|
||||
case 3:
|
||||
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;
|
||||
}
|
||||
YY_BREAK
|
||||
case 4:
|
||||
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
|
||||
bool e = false;
|
||||
@ -925,7 +925,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 5:
|
||||
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
|
||||
bool e = false;
|
||||
@ -976,7 +976,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 6:
|
||||
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;
|
||||
ident->v = yytext;
|
||||
@ -987,7 +987,7 @@ YY_RULE_SETUP
|
||||
case 7:
|
||||
/* rule 7 can match eol */
|
||||
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;
|
||||
ident->v = yytext;
|
||||
@ -1000,7 +1000,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 8:
|
||||
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;
|
||||
bool e = false;
|
||||
@ -1115,7 +1115,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 9:
|
||||
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;
|
||||
IntergerGrammarPtr ptr = new IntergerGrammar;
|
||||
@ -1140,7 +1140,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 10:
|
||||
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;
|
||||
FloatGrammarPtr ptr = new FloatGrammar;
|
||||
@ -1175,7 +1175,7 @@ YY_RULE_SETUP
|
||||
case 11:
|
||||
/* rule 11 can match eol */
|
||||
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')
|
||||
{
|
||||
@ -1185,7 +1185,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 12:
|
||||
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)
|
||||
{
|
||||
@ -1204,7 +1204,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 13:
|
||||
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;
|
||||
YY_BREAK
|
||||
#line 1211 "tars.lex.cpp"
|
||||
@ -2214,7 +2214,7 @@ void yyfree (void * ptr )
|
||||
|
||||
#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
Loading…
Reference in New Issue
Block a user