mirror of
https://gitee.com/TarsCloud/TarsCpp.git
synced 2024-12-22 22:16:38 +08:00
install in windows
This commit is contained in:
parent
79bc349737
commit
0aa338b06b
@ -67,6 +67,42 @@ include(ExternalProject)
|
||||
|
||||
set(LIB_GTEST "libgtest")
|
||||
|
||||
if(WIN32)
|
||||
ExternalProject_Add(ADD_CURL
|
||||
URL http://cdn.tarsyun.com/src/curl-7.69.1.tar.gz
|
||||
DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
|
||||
PREFIX ${CMAKE_BINARY_DIR}
|
||||
INSTALL_DIR ${CMAKE_SOURCE_DIR}
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/curl
|
||||
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/curl-lib
|
||||
BUILD_IN_SOURCE 1
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install
|
||||
URL_MD5 b9bb5e11d579425154a9f97ed44be9b8
|
||||
)
|
||||
|
||||
add_dependencies(thirdparty ADD_CURL)
|
||||
|
||||
INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/src/curl/ DESTINATION thirdparty)
|
||||
|
||||
# ExternalProject_Add(ADD_BUSYBOX
|
||||
# URL http://cdn.tarsyun.com/src/busybox-1.31.1.tar.bz2
|
||||
# DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/download
|
||||
# PREFIX ${CMAKE_BINARY_DIR}
|
||||
# INSTALL_DIR ${CMAKE_SOURCE_DIR}
|
||||
# CONFIGURE_COMMAND ${CMAKE_COMMAND} . -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/src/busybox
|
||||
# SOURCE_DIR ${CMAKE_BINARY_DIR}/src/busybox-lib
|
||||
# BUILD_IN_SOURCE 1
|
||||
# BUILD_COMMAND ${CMAKE_COMMAND} --build . --config release
|
||||
# INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config release --target install
|
||||
# URL_MD5 70913edaf2263a157393af07565c17f0
|
||||
# )
|
||||
|
||||
# add_dependencies(thirdparty ADD_BUSYBOX)
|
||||
|
||||
# INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/src/busybox/ DESTINATION thirdparty)
|
||||
endif(WIN32)
|
||||
|
||||
if (WIN32)
|
||||
|
||||
ExternalProject_Add(ADD_${LIB_GTEST}
|
||||
|
@ -4,8 +4,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
if(WIN32)
|
||||
set(TARS2CPP "c:\\tars\\cpp\\tools\\tars2cpp")
|
||||
set(TARS_PATH "c:\\tars\\cpp")
|
||||
set(TARS2CPP "c:/tars/cpp/tools/tars2cpp.exe")
|
||||
set(TARS_PATH "c:/tars/cpp")
|
||||
else()
|
||||
set(TARS2CPP "/usr/local/tars/cpp/tools/tars2cpp")
|
||||
set(TARS_PATH "/usr/local/tars/cpp")
|
||||
@ -178,9 +178,9 @@ macro(gen_server APP TARGET)
|
||||
#make upload #########################################################################
|
||||
SET(RUN_UPLOAD_COMMAND_FILE "${PROJECT_BINARY_DIR}/run-upload-${TARGET}.cmake")
|
||||
IF(WIN32)
|
||||
FILE(WRITE ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND cmake -E copy ${TARGET}.tgz ${APP}.${TARGET}.tgz)\n")
|
||||
FILE(APPEND ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${TARS_PATH}\\cpp\\\\script\\\\WinSCP.exe sftp://${TARS_WEB_SERVER}/usr/local/app/patchs/tars.upload/ /upload ${APP}.${TARGET}.tgz)\n")
|
||||
FILE(APPEND ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${TARS_PATH}\\cpp\\\\script\\\\busybox.exe wget -O ${APP}.${TARGET}.wget.out http://${TARS_WEB_HOST}/doUpload.jsp?SERVER=${APP}.${TARGET}&TGZ=/usr/local/app/patchs/tars.upload/${APP}.${TARGET}.tgz)\n")
|
||||
FILE(WRITE ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND echo ${TARS_WEB_HOST}/api/upload_and_publish -Fsuse=@${TARGET}.tgz -Fapplication=${APP} -Fmodule_name=${TARGET} -Fcomment=developer-auto-upload)\n")
|
||||
FILE(APPEND ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND ${TARS_PATH}/thirdparty/bin/curl.exe ${TARS_WEB_HOST}/api/upload_and_publish?ticket=${TARS_TOKEN} -Fsuse=@${TARGET}.tgz -Fapplication=${APP} -Fmodule_name=${TARGET} -Fcomment=developer-auto-upload)\n")
|
||||
FILE(APPEND ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND echo \n---------------------------------------------------------------------------)\n")
|
||||
ELSE()
|
||||
FILE(WRITE ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND echo ${TARS_WEB_HOST}/api/upload_and_publish -Fsuse=@${TARGET}.tgz -Fapplication=${APP} -Fmodule_name=${TARGET} -Fcomment=developer-auto-upload)\n")
|
||||
FILE(APPEND ${RUN_UPLOAD_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND curl ${TARS_WEB_HOST}/api/upload_and_publish?ticket=${TARS_TOKEN} -Fsuse=@${TARGET}.tgz -Fapplication=${APP} -Fmodule_name=${TARGET} -Fcomment=developer-auto-upload)\n")
|
||||
|
@ -26,7 +26,13 @@ fi
|
||||
|
||||
echo "[create server: $APP.$SERVER ...]"
|
||||
|
||||
DEMO_PATH=/usr/local/tars/cpp/script/cmake_http_demo
|
||||
TARSPATH=$4
|
||||
|
||||
if [ "$TARSPATH" == "" ]; then
|
||||
TARSPATH=/usr/local/tars
|
||||
fi
|
||||
|
||||
DEMO_PATH=${TARSPATH}/cpp/script/cmake_http_demo
|
||||
|
||||
#make cleanall -C $DEMO_PATH
|
||||
|
||||
@ -55,7 +61,8 @@ mv DemoServantImp.cpp ${SERVANT}Imp.cpp
|
||||
|
||||
cd ..
|
||||
mkdir build; cd build
|
||||
cmake ..; make
|
||||
cmake ..
|
||||
cmake --build . --config Release
|
||||
|
||||
#cd ../../
|
||||
|
||||
|
@ -12,6 +12,12 @@ SERVANT=$3
|
||||
|
||||
echo "APP:$APP, SERVER:$SERVER, SERVANT:$SERVANT"
|
||||
|
||||
TARSPATH=$4
|
||||
|
||||
if [ "$TARSPATH" == "" ]; then
|
||||
TARSPATH=/usr/local/tars/
|
||||
fi
|
||||
|
||||
if [ "$SERVER" == "$SERVANT" ]
|
||||
then
|
||||
echo "Error!(ServerName == ServantName)"
|
||||
@ -26,7 +32,7 @@ fi
|
||||
|
||||
echo "[create server: $APP.$SERVER ...]"
|
||||
|
||||
DEMO_PATH=/usr/local/tars/cpp/script/cmake_demo
|
||||
DEMO_PATH=${TARSPATH}/cpp/script/cmake_demo
|
||||
|
||||
#make cleanall -C $DEMO_PATH
|
||||
|
||||
@ -56,7 +62,9 @@ mv DemoServant.tars ${SERVANT}.tars
|
||||
|
||||
cd ..
|
||||
mkdir build; cd build
|
||||
cmake ..; make
|
||||
cmake ..
|
||||
cmake --build . --config Release
|
||||
|
||||
|
||||
#cd ../../
|
||||
|
||||
|
@ -9,6 +9,11 @@ fi
|
||||
APP=$1
|
||||
SERVER=$2
|
||||
SERVANT=$3
|
||||
TARSPATH=$4
|
||||
|
||||
if [ "$TARSPATH" == "" ]; then
|
||||
TARSPATH=/usr/local/tars/
|
||||
fi
|
||||
|
||||
if [ "$SERVER" == "$SERVANT" ]
|
||||
then
|
||||
@ -24,13 +29,13 @@ fi
|
||||
|
||||
echo "[create server: $APP.$SERVER ...]"
|
||||
|
||||
DEMO_PATH=/usr/local/tars/cpp/script/demo
|
||||
DEMO_PATH=${TARSPATH}/cpp/script/http_demo
|
||||
|
||||
cp $DEMO_PATH/* $APP/$SERVER/
|
||||
|
||||
cd $APP/$SERVER/
|
||||
|
||||
SRC_FILE="DemoServer.h DemoServer.cpp DemoServantImp.h DemoServantImp.cpp DemoServant.tars makefile"
|
||||
SRC_FILE="DemoServer.h DemoServer.cpp DemoServantImp.h DemoServantImp.cpp makefile"
|
||||
|
||||
for FILE in $SRC_FILE
|
||||
do
|
||||
|
@ -1 +0,0 @@
|
||||
c:\\tars\\cpp\\script\\busybox.exe bash c:\\tars\\cpp\\script\\win_create.bat %1 %2 %3
|
@ -1,58 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ $# -lt 3 ]
|
||||
then
|
||||
echo "<Usage: $0 App Server Servant>"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
APP=$1
|
||||
SERVER=$2
|
||||
SERVANT=$3
|
||||
|
||||
if [ "$SERVER" == "$SERVANT" ]
|
||||
then
|
||||
echo "Error!(ServerName == ServantName)"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ ! -d $APP/$SERVER/src ]
|
||||
then
|
||||
echo "[mkdir: $APP/$SERVER/src]"
|
||||
mkdir -p $APP/$SERVER/src
|
||||
echo "[mkdir: $APP/$SERVER/build]"
|
||||
mkdir -p $APP/$SERVER/build
|
||||
fi
|
||||
|
||||
echo "[create server: $APP.$SERVER ...]"
|
||||
|
||||
DEMO_PATH=c:/tars/cpp/script/cmake_demo
|
||||
|
||||
cp -rf $DEMO_PATH/* $APP/$SERVER
|
||||
|
||||
SRC_FILE="DemoServer.h DemoServer.cpp DemoServantImp.h DemoServantImp.cpp DemoServant.tars CMakeLists.txt ../CMakeLists.txt"
|
||||
|
||||
cd $APP/$SERVER/src
|
||||
|
||||
for FILE in $SRC_FILE
|
||||
do
|
||||
cat $FILE | sed "s/DemoServer/$SERVER/g" > $FILE.tmp
|
||||
mv $FILE.tmp $FILE
|
||||
|
||||
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
|
||||
|
||||
mv DemoServer.h ${SERVER}.h
|
||||
mv DemoServer.cpp ${SERVER}.cpp
|
||||
mv DemoServantImp.h ${SERVANT}Imp.h
|
||||
mv DemoServantImp.cpp ${SERVANT}Imp.cpp
|
||||
mv DemoServant.tars ${SERVANT}.tars
|
||||
|
||||
cd ..\\build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
echo "[done.]"
|
@ -380,20 +380,52 @@ string TC_File::simplifyDirectory(const string& path)
|
||||
|
||||
string TC_File::load2str(const string &sFullFileName)
|
||||
{
|
||||
ifstream ifs(sFullFileName.c_str());
|
||||
FILE *fd = TC_Port::fopen(sFullFileName.data(), "r");
|
||||
if (fd == NULL)
|
||||
return "";
|
||||
|
||||
return string(istreambuf_iterator<char>(ifs), istreambuf_iterator<char>());
|
||||
string s;
|
||||
int nread = -1;
|
||||
do {
|
||||
char buf[8096] = {'\0'};
|
||||
nread = fread(buf, 1, sizeof(buf), fd);
|
||||
if (nread > 0)
|
||||
{
|
||||
s.append(buf, nread);
|
||||
}
|
||||
} while (nread > 0);
|
||||
fclose(fd);
|
||||
return s;
|
||||
|
||||
// ifstream ifs(sFullFileName.c_str());
|
||||
|
||||
// return string(istreambuf_iterator<char>(ifs), istreambuf_iterator<char>());
|
||||
}
|
||||
|
||||
bool TC_File::load2str(const string &sFullFileName, vector<char> &data)
|
||||
{
|
||||
ifstream ifs(sFullFileName.c_str());
|
||||
if(ifs.is_open())
|
||||
{
|
||||
data.assign(istreambuf_iterator<char>(ifs), istreambuf_iterator<char>());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
FILE *fd = TC_Port::fopen(sFullFileName.data(), "r");
|
||||
if (fd == NULL)
|
||||
return false;
|
||||
|
||||
int nread = -1;
|
||||
do {
|
||||
char buf[8096] = {'\0'};
|
||||
nread = fread(buf, 1, sizeof(buf), fd);
|
||||
if (nread > 0)
|
||||
{
|
||||
data.insert(data.end(), buf, buf+nread);
|
||||
}
|
||||
} while (nread > 0);
|
||||
fclose(fd);
|
||||
return true;
|
||||
// ifstream ifs(sFullFileName.c_str());
|
||||
// if(ifs.is_open())
|
||||
// {
|
||||
// data.assign(istreambuf_iterator<char>(ifs), istreambuf_iterator<char>());
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
}
|
||||
|
||||
void TC_File::save2file(const string &sFullFileName, const string &sFileData)
|
||||
|
Loading…
Reference in New Issue
Block a user