From b2ca1d68c12c9a09e33c734037d76bd9663ed28f Mon Sep 17 00:00:00 2001 From: ruanshudong Date: Tue, 10 Mar 2020 20:38:16 +0800 Subject: [PATCH] change http-demo to cmake --- servant/script/create_http_server.sh | 30 ++++++++++++------- servant/script/http_demo/CMakeLists.txt | 11 +++---- servant/script/http_demo/src/CMakeLists.txt | 5 ++++ .../http_demo/{ => src}/DemoServantImp.cpp | 0 .../http_demo/{ => src}/DemoServantImp.h | 0 .../script/http_demo/{ => src}/DemoServer.cpp | 0 .../script/http_demo/{ => src}/DemoServer.h | 0 7 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 servant/script/http_demo/src/CMakeLists.txt rename servant/script/http_demo/{ => src}/DemoServantImp.cpp (100%) rename servant/script/http_demo/{ => src}/DemoServantImp.h (100%) rename servant/script/http_demo/{ => src}/DemoServer.cpp (100%) rename servant/script/http_demo/{ => src}/DemoServer.h (100%) diff --git a/servant/script/create_http_server.sh b/servant/script/create_http_server.sh index 230b0ca..dc86f19 100755 --- a/servant/script/create_http_server.sh +++ b/servant/script/create_http_server.sh @@ -10,27 +10,31 @@ APP=$1 SERVER=$2 SERVANT=$3 +echo "APP:$APP, SERVER:$SERVER, SERVANT:$SERVANT" + if [ "$SERVER" == "$SERVANT" ] then echo "Error!(ServerName == ServantName)" exit -1 fi -if [ ! -d $APP/$SERVER ] +if [ ! -d $SERVER ] then - echo "[mkdir: $APP/$SERVER]" - mkdir -p $APP/$SERVER + echo "[mkdir: $SERVER]" + mkdir -p $SERVER fi echo "[create server: $APP.$SERVER ...]" DEMO_PATH=/usr/local/tars/cpp/script/http_demo -cp $DEMO_PATH/* $APP/$SERVER/ +#make cleanall -C $DEMO_PATH -cd $APP/$SERVER/ +cp -rf $DEMO_PATH/* $SERVER/ -SRC_FILE="DemoServer.h DemoServer.cpp DemoServantImp.h DemoServantImp.cpp makefile" +cd $SERVER/src + +SRC_FILE="DemoServer.h DemoServer.cpp DemoServantImp.h DemoServantImp.cpp CMakeLists.txt" for FILE in $SRC_FILE do @@ -39,14 +43,20 @@ do cat $FILE | sed "s/DemoApp/$APP/g" > $FILE.tmp mv $FILE.tmp $FILE - + cat $FILE | sed "s/DemoServant/$SERVANT/g" > $FILE.tmp mv $FILE.tmp $FILE done -rename "DemoServer" "$SERVER" $SRC_FILE -rename "DemoServant" "$SERVANT" $SRC_FILE +mv DemoServer.h ${SERVER}.h +mv DemoServer.cpp ${SERVER}.cpp +mv DemoServantImp.h ${SERVANT}Imp.h +mv DemoServantImp.cpp ${SERVANT}Imp.cpp -cd ../../ +cd .. +mkdir build; cd build +cmake ..; make + +#cd ../../ echo "[done.]" diff --git a/servant/script/http_demo/CMakeLists.txt b/servant/script/http_demo/CMakeLists.txt index 89798e4..43f4342 100644 --- a/servant/script/http_demo/CMakeLists.txt +++ b/servant/script/http_demo/CMakeLists.txt @@ -12,12 +12,13 @@ else() include (/usr/local/tars/cpp/makefile/tars-tools.cmake) endif() -set(TARS_WEB_SERVER "upchina@taf.test.whup.com") -set(TARS_WEB_HOST "taf.test.whup.com:8080") +set(TARS_WEB_HOST "http://tars.test.com") -include_directories(/usr/local/taf/cpp/thirdparty/include) -link_directories(/usr/local/taf/cpp/thirdparty/lib) +include_directories(/usr/local/tars/cpp/thirdparty/include) +link_directories(/usr/local/tars/cpp/thirdparty/lib) #include_directories(/home/tarsprotol/App/OtherServer) -gen_server(Demo DemoServer) +add_subdirectory(src) + +#target_link_libraries(mysqlclient ssl crypto nghttp2-static) diff --git a/servant/script/http_demo/src/CMakeLists.txt b/servant/script/http_demo/src/CMakeLists.txt new file mode 100644 index 0000000..61d91e5 --- /dev/null +++ b/servant/script/http_demo/src/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8) + +project(DemoApp-DemoServer) + +gen_server(DemoApp DemoServer) diff --git a/servant/script/http_demo/DemoServantImp.cpp b/servant/script/http_demo/src/DemoServantImp.cpp similarity index 100% rename from servant/script/http_demo/DemoServantImp.cpp rename to servant/script/http_demo/src/DemoServantImp.cpp diff --git a/servant/script/http_demo/DemoServantImp.h b/servant/script/http_demo/src/DemoServantImp.h similarity index 100% rename from servant/script/http_demo/DemoServantImp.h rename to servant/script/http_demo/src/DemoServantImp.h diff --git a/servant/script/http_demo/DemoServer.cpp b/servant/script/http_demo/src/DemoServer.cpp similarity index 100% rename from servant/script/http_demo/DemoServer.cpp rename to servant/script/http_demo/src/DemoServer.cpp diff --git a/servant/script/http_demo/DemoServer.h b/servant/script/http_demo/src/DemoServer.h similarity index 100% rename from servant/script/http_demo/DemoServer.h rename to servant/script/http_demo/src/DemoServer.h