mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-29 10:27:39 +08:00
modify acl Makefiles to renaming lib names.
This commit is contained in:
parent
d2128e6f70
commit
57f8afc403
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_minimum_required(VERSION 2.8.0)
|
||||
project(acl)
|
||||
message(${CMAKE_SYSTEM_NAME})
|
||||
#message(${CMAKE_SYSTEM_NAME})
|
||||
|
||||
#set(CMAKE_BUILD_TYPE Release)
|
||||
#set(CMAKE_BUILD_TYPE Release CACHE STRING "set build type to release")
|
||||
@ -9,12 +9,18 @@ if (${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
|
||||
message(FATAL_ERROR "Please into another dir to build!")
|
||||
endif()
|
||||
|
||||
add_subdirectory(lib_acl lib_acl)
|
||||
add_subdirectory(lib_protocol lib_protocol)
|
||||
add_subdirectory(lib_acl_cpp lib_acl_cpp)
|
||||
#The below line was built error on Android Studio
|
||||
#string(TOUPPER ${CMAKE_SYSTEM_NAME} OS_NAME)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set(CMAKE_MACOSX_RPATH build)
|
||||
endif()
|
||||
|
||||
add_subdirectory(lib_acl acl)
|
||||
add_subdirectory(lib_protocol protocol)
|
||||
add_subdirectory(lib_acl_cpp acl_cpp)
|
||||
|
||||
#if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
add_subdirectory(lib_fiber/c lib_fiber)
|
||||
add_subdirectory(lib_fiber/cpp lib_fiber_cpp)
|
||||
add_subdirectory(lib_fiber/c fiber)
|
||||
add_subdirectory(lib_fiber/cpp fiber_cpp)
|
||||
endif()
|
||||
|
26
Makefile
26
Makefile
@ -114,7 +114,7 @@ clean:
|
||||
@(cd unit_test; make clean)
|
||||
@(cd lib_acl/samples; make clean)
|
||||
@(cd lib_protocol/samples; make clean)
|
||||
@(rm -f lib_acl.a lib_acl.so)
|
||||
@(rm -f libacl.a libacl.so)
|
||||
# @(cd lib_dict; make clean)
|
||||
# @(cd lib_tls; make clean)
|
||||
|
||||
@ -122,11 +122,11 @@ install:
|
||||
@(echo "")
|
||||
@(echo "begin copy file...")
|
||||
cp -f lib_acl/master/acl_master ./dist/master/libexec/$(RPATH)/
|
||||
cp -f lib_acl/lib/lib_acl.a $(ACL_LIB)/$(RPATH)/
|
||||
cp -f lib_acl/lib/libacl.a $(ACL_LIB)/$(RPATH)/
|
||||
cp -Rf lib_acl/include/* $(ACL_INC)/
|
||||
cp -f lib_protocol/lib/lib_protocol.a $(PROTO_LIB)/$(RPATH)/
|
||||
cp -Rf lib_protocol/include/* $(PROTO_INC)/
|
||||
cp -f lib_acl_cpp/lib/lib_acl_cpp.a $(ACL_LIB)/$(RPATH)/
|
||||
cp -f lib_acl_cpp/lib/libacl_cpp.a $(ACL_LIB)/$(RPATH)/
|
||||
cp -Rf lib_acl_cpp/include/acl_cpp/* $(INC_PATH)/acl_cpp/
|
||||
# cp -f lib_dict/lib/lib_dict.a $(DICT_LIB)/$(RPATH)/
|
||||
# cp -Rf lib_dict/include/* $(DICT_INC)/
|
||||
@ -136,11 +136,11 @@ uninstall:
|
||||
@(echo "")
|
||||
@(echo "begin remove file...")
|
||||
rm -f ./dist/master/libexec/$(RPATH)/*
|
||||
rm -f $(ACL_LIB)/$(RPATH)/lib_acl.a
|
||||
rm -f $(ACL_LIB)/$(RPATH)/libacl.a
|
||||
rm -Rf $(ACL_INC)/*
|
||||
rm -f $(PROTO_LIB)/$(RPATH)/lib_protocol.a
|
||||
rm -Rf $(PROTO_INC)/*
|
||||
rm -f $(ACL_LIB)/$(RPATH)/lib_acl_cpp.a
|
||||
rm -f $(ACL_LIB)/$(RPATH)/libacl_cpp.a
|
||||
rm -Rf $(INC_PATH)/acl_cpp/*
|
||||
rm -f $(DICT_LIB)/$(RPATH)/lib_dict.a
|
||||
rm -Rf $(DICT_INC)/*
|
||||
@ -258,21 +258,21 @@ build_one: all_lib
|
||||
@(mkdir -p $(RELEASE_PATH); mkdir -p $(RELEASE_PATH)/acl; \
|
||||
mkdir -p $(RELEASE_PATH)/protocol; \
|
||||
mkdir -p $(RELEASE_PATH)/acl_cpp)
|
||||
@(cp lib_acl/lib/lib_acl.a $(RELEASE_PATH)/acl/)
|
||||
@(cp lib_acl/lib/libacl.a $(RELEASE_PATH)/acl/)
|
||||
@(cp lib_protocol/lib/lib_protocol.a $(RELEASE_PATH)/protocol/)
|
||||
@(cp lib_acl_cpp/lib/lib_acl_cpp.a $(RELEASE_PATH)/acl_cpp/)
|
||||
@(cd $(RELEASE_PATH)/acl; ar -x lib_acl.a)
|
||||
@(cp lib_acl_cpp/lib/libacl_cpp.a $(RELEASE_PATH)/acl_cpp/)
|
||||
@(cd $(RELEASE_PATH)/acl; ar -x libacl.a)
|
||||
@(cd $(RELEASE_PATH)/protocol; ar -x lib_protocol.a)
|
||||
@(cd $(RELEASE_PATH)/acl_cpp; ar -x lib_acl_cpp.a)
|
||||
$(AR) $(ARFL) ./lib_acl.a $(RELEASE_PATH)/acl/*.o \
|
||||
@(cd $(RELEASE_PATH)/acl_cpp; ar -x libacl_cpp.a)
|
||||
$(AR) $(ARFL) ./libacl.a $(RELEASE_PATH)/acl/*.o \
|
||||
$(RELEASE_PATH)/protocol/*.o $(RELEASE_PATH)/acl_cpp/*.o
|
||||
$(RANLIB) ./lib_acl.a
|
||||
$(CC) $(LDFLAGS) -o ./lib_acl.so $(RELEASE_PATH)/acl_cpp/*.o \
|
||||
$(RANLIB) ./libacl.a
|
||||
$(CC) $(LDFLAGS) -o ./libacl.so $(RELEASE_PATH)/acl_cpp/*.o \
|
||||
$(RELEASE_PATH)/protocol/*.o $(RELEASE_PATH)/acl/*.o \
|
||||
$(SYSLIB)
|
||||
@(rm -rf $(RELEASE_PATH))
|
||||
@echo ""
|
||||
@echo "Over, lib_acl.a and lib_acl.so were built ok!"
|
||||
@echo "Over, libacl.a and libacl.so were built ok!"
|
||||
@echo ""
|
||||
|
||||
check:
|
||||
|
@ -87,7 +87,7 @@ endif
|
||||
|
||||
CFLAGS += -I../../lib_acl/include -I../../lib_protocol/include -I../../lib_acl_cpp/include
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L../../lib_acl_cpp/lib -l_acl_cpp -L../../lib_protocol/lib -l_protocol -L../../lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L../../lib_acl_cpp/lib -lacl_cpp -L../../lib_protocol/lib -lprotocol -L../../lib_acl/lib -lacl \
|
||||
$(EXTLIBS) $(SYSLIB)
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
@ -87,7 +87,7 @@ endif
|
||||
|
||||
CFLAGS += -I./include -I../../lib_acl/include -I../../lib_protocol/include -I../../lib_acl_cpp/include
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L../../lib_acl_cpp/lib -l_acl_cpp -L../../lib_protocol/lib -l_protocol -L../../lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L../../lib_acl_cpp/lib -lacl_cpp -L../../lib_protocol/lib -lprotocol -L../../lib_acl/lib -lacl \
|
||||
$(EXTLIBS) $(SYSLIB)
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
@ -83,7 +83,7 @@ endif
|
||||
|
||||
CFLAGS += -I../../../lib_acl/include -I../../../lib_protocol/include -I../../../lib_acl_cpp/include
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L../../../lib_acl_cpp/lib -l_acl_cpp -L../../../lib_protocol/lib -l_protocol -L../../../lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L../../../lib_acl_cpp/lib -lacl_cpp -L../../../lib_protocol/lib -lprotocol -L../../../lib_acl/lib -lacl \
|
||||
$(EXTLIBS) $(SYSLIB)
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#include ".\struct.h"
|
||||
#include "struct.h"
|
||||
#include "gson.h"
|
||||
#include "acl_cpp/serialize/gson_helper.ipp"
|
||||
namespace acl
|
||||
|
@ -1,4 +1,11 @@
|
||||
|
||||
all:
|
||||
@(cd benchmark; make)
|
||||
@(cd test; make)
|
||||
@(cd test0; make)
|
||||
@(cd test1; make)
|
||||
@(cd test2; make)
|
||||
@(cd test3; make)
|
||||
clean:
|
||||
@(cd benchmark; make clean)
|
||||
@(cd test; make clean)
|
||||
|
@ -99,9 +99,9 @@ CFLAGS += -I../../../../lib_acl/include \
|
||||
-I../../../../lib_protocol/include \
|
||||
-I../../../../lib_acl_cpp/include
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L../../../../lib_acl_cpp/lib -l_acl_cpp \
|
||||
-L../../../../lib_protocol/lib -l_protocol \
|
||||
-L../../../../lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L../../../../lib_acl_cpp/lib -lacl_cpp \
|
||||
-L../../../../lib_protocol/lib -lprotocol \
|
||||
-L../../../../lib_acl/lib -lacl \
|
||||
$(EXTLIBS) $(SYSLIB)
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
@ -89,9 +89,9 @@ endif
|
||||
CFLAGS += -I../../../lib_acl/include -I../../../lib_protocol/include \
|
||||
-I../../../lib_acl_cpp/include -I.
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L../../../lib_acl_cpp/lib -l_acl_cpp \
|
||||
-L../../../lib_protocol/lib -l_protocol \
|
||||
-L../../../lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L../../../lib_acl_cpp/lib -lacl_cpp \
|
||||
-L../../../lib_protocol/lib -lprotocol \
|
||||
-L../../../lib_acl/lib -lacl \
|
||||
$(EXTLIBS) $(SYSLIB) -rdynamic
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
@ -86,7 +86,7 @@ endif
|
||||
|
||||
CFLAGS += -I. -I../../../lib_acl/include -I../../../lib_protocol/include -I../../../lib_acl_cpp/include
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L../../../lib_acl_cpp/lib -l_acl_cpp -L../../../lib_protocol/lib -l_protocol -L../../../lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L../../../lib_acl_cpp/lib -lacl_cpp -L../../../lib_protocol/lib -lprotocol -L../../../lib_acl/lib -lacl \
|
||||
$(EXTLIBS) $(SYSLIB) -rdynamic
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
@ -86,7 +86,7 @@ endif
|
||||
|
||||
CFLAGS += -I../../../../lib_acl/include -I../../../../lib_protocol/include -I../../../../lib_acl_cpp/include
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L../../../../lib_acl_cpp/lib -l_acl_cpp -L../../../../lib_protocol/lib -l_protocol -L../../../../lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L../../../../lib_acl_cpp/lib -lacl_cpp -L../../../../lib_protocol/lib -lprotocol -L../../../../lib_acl/lib -lacl \
|
||||
$(EXTLIBS) $(SYSLIB)
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
@ -88,10 +88,10 @@ CFLAGS += -I../../../lib_acl/include \
|
||||
-I../../../lib_fiber/c/include \
|
||||
-I../../../lib_fiber/cpp/include
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L../../../lib_fiber/lib -l_fiber_cpp -l_fiber \
|
||||
-L../../../lib_acl_cpp/lib -l_acl_cpp \
|
||||
-L../../../lib_protocol/lib -l_protocol \
|
||||
-L../../../lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L../../../lib_fiber/lib -lfiber_cpp -lfiber \
|
||||
-L../../../lib_acl_cpp/lib -lacl_cpp \
|
||||
-L../../../lib_protocol/lib -lprotocol \
|
||||
-L../../../lib_acl/lib -lacl \
|
||||
$(EXTLIBS) $(SYSLIB)
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
@ -22,7 +22,7 @@ int main(int argc, char *argv[])
|
||||
addr = argv[3];
|
||||
printf("listen: %s\r\n", addr);
|
||||
|
||||
ms.run_alone(addr, argc >= 3 ? argv[2] : NULL, 0);
|
||||
ms.run_alone(addr, argc >= 3 ? argv[2] : NULL);
|
||||
}
|
||||
else
|
||||
ms.run_daemon(argc, argv);
|
||||
|
@ -108,9 +108,9 @@ endif
|
||||
CFLAGS += -I../../../lib_acl/include -I../../../lib_protocol/include \
|
||||
-I../../../lib_acl_cpp/include -I.
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L../../../lib_acl_cpp/lib -l_acl_cpp \
|
||||
-L../../../lib_protocol/lib -l_protocol \
|
||||
-L../../../lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L../../../lib_acl_cpp/lib -lacl_cpp \
|
||||
-L../../../lib_protocol/lib -lprotocol \
|
||||
-L../../../lib_acl/lib -lacl \
|
||||
$(EXTLIBS) $(SYSLIB) -rdynamic
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
@ -101,9 +101,9 @@ CFLAGS += -I$(ACL_PATH)/lib_acl/include \
|
||||
-I$(ACL_PATH)/lib_protocol/include \
|
||||
-I$(ACL_PATH)/lib_acl_cpp/include
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L$(ACL_PATH)/lib_acl_cpp/lib -l_acl_cpp \
|
||||
-L$(ACL_PATH)/lib_protocol/lib -l_protocol \
|
||||
-L$(ACL_PATH)/lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L$(ACL_PATH)/lib_acl_cpp/lib -lacl_cpp \
|
||||
-L$(ACL_PATH)/lib_protocol/lib -lprotocol \
|
||||
-L$(ACL_PATH)/lib_acl/lib -lacl \
|
||||
$(EXTLIBS) $(SYSLIB)
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
@ -103,10 +103,10 @@ CFLAGS += -I$(ACL_PATH)/lib_acl/include \
|
||||
-I$(ACL_PATH)/lib_fiber/c/include \
|
||||
-I$(ACL_PATH)/lib_fiber/cpp/include
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L$(ACL_PATH)/lib_fiber/lib -l_fiber_cpp -l_fiber \
|
||||
-L$(ACL_PATH)/lib_acl_cpp/lib -l_acl_cpp \
|
||||
-L$(ACL_PATH)/lib_protocol/lib -l_protocol \
|
||||
-L$(ACL_PATH)/lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L$(ACL_PATH)/lib_fiber/lib -lfiber_cpp -lfiber \
|
||||
-L$(ACL_PATH)/lib_acl_cpp/lib -lacl_cpp \
|
||||
-L$(ACL_PATH)/lib_protocol/lib -lprotocol \
|
||||
-L$(ACL_PATH)/lib_acl/lib -lacl \
|
||||
$(EXTLIBS) $(SYSLIB)
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
189
build4ios/build-ios.sh
Normal file
189
build4ios/build-ios.sh
Normal file
@ -0,0 +1,189 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
CURRENT_DIR=${PWD}
|
||||
|
||||
cd $CURRENT_DIR
|
||||
|
||||
if [ ! -d "$CURRENT_DIR/dist" ]; then
|
||||
mkdir -p $CURRENT_DIR/dist
|
||||
mkdir -p $CURRENT_DIR/dist/include
|
||||
mkdir -p $CURRENT_DIR/dist/lib
|
||||
else
|
||||
rm -rf $CURRENT_DIR/dist
|
||||
mkdir -p $CURRENT_DIR/dist
|
||||
mkdir -p $CURRENT_DIR/dist/include
|
||||
mkdir -p $CURRENT_DIR/dist/lib
|
||||
fi
|
||||
|
||||
TARGET_FILE_PATH=$CURRENT_DIR/dist
|
||||
|
||||
XCODEPROJ_FILE_PATH=$CURRENT_DIR/xcodeproj-path
|
||||
|
||||
while read ProjectSub
|
||||
do
|
||||
echo "${ProjectSub} build ..."
|
||||
|
||||
#TargetPath lib_${ProjectSub}/${ProjectSub}
|
||||
|
||||
echo "Target xcodeproj path is lib_${ProjectSub}"
|
||||
|
||||
cd $CURRENT_DIR/../lib_${ProjectSub}
|
||||
|
||||
if [ -d "build" ]; then
|
||||
rm -rf build
|
||||
fi
|
||||
|
||||
echo "***************************************************"
|
||||
echo "***************iPhoneOS.platform*******************"
|
||||
|
||||
#iPhoneOS.platform
|
||||
|
||||
DEVPATH="";
|
||||
# Set the main iPhone developer directory, if not set
|
||||
if test "x${DEVPATH}" = "x"; then
|
||||
DEVPATH=/Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
|
||||
if test ! -d $DEVPATH; then
|
||||
DEVPATH=/Developer/Platforms/iPhoneOS.platform/Developer
|
||||
fi
|
||||
echo "$F: DEVPATH is not specified, using ${DEVPATH}"
|
||||
fi
|
||||
|
||||
# Make sure $DEVPATH directory exist
|
||||
if test ! -d $DEVPATH; then
|
||||
echo "$F error: directory $DEVPATH does not exist. Please install iPhone development kit"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Choose SDK version to use
|
||||
if test "" = ""; then
|
||||
#if test "$IPHONESDK" = ""; then
|
||||
# If IPHONESDK is not set, use the latest one
|
||||
for f in `ls $DEVPATH/SDKs/`;
|
||||
do echo $f | sed 's/\(.sdk\)//';
|
||||
done | sort | tail -1 > tmpsdkname
|
||||
IPHONESDK=`cat tmpsdkname`.sdk
|
||||
rm -f tmpsdkname
|
||||
SDKPATH=${DEVPATH}/SDKs/${IPHONESDK}
|
||||
echo "$F: IPHONESDK is not specified, choosing ${IPHONESDK}"
|
||||
elif test -d ${IPHONESDK}; then
|
||||
# .. else if IPHONESDK is set and it points to a valid path, just use it
|
||||
SDKPATH=${IPHONESDK}
|
||||
else
|
||||
# .. else assume the SDK name is used.
|
||||
SDKPATH=${DEVPATH}/SDKs/${IPHONESDK}
|
||||
fi
|
||||
|
||||
echo ${IPHONESDK%.sdk} | awk '{print tolower($0);}' > tempFile
|
||||
IPHONESDK=`cat tempFile`
|
||||
rm tempFile
|
||||
|
||||
xcodebuild -sdk $IPHONESDK -configuration Release
|
||||
#cp build/Release-iphoneos/*.a $TARGET_FILE_PATH/lib
|
||||
#rm -rf build
|
||||
|
||||
echo "***************************************************"
|
||||
echo "************iPhoneSimulator.platform***************"
|
||||
|
||||
#iPhoneSimulator.platform
|
||||
|
||||
DEVPATH="";
|
||||
# Set the main iPhone developer directory, if not set
|
||||
if test "x${DEVPATH}" = "x"; then
|
||||
DEVPATH=/Applications/XCode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer
|
||||
if test ! -d $DEVPATH; then
|
||||
DEVPATH=/Developer/Platforms/iPhoneSimulator.platform/Developer
|
||||
fi
|
||||
echo "$F: DEVPATH is not specified, using ${DEVPATH}"
|
||||
fi
|
||||
|
||||
# Make sure $DEVPATH directory exist
|
||||
if test ! -d $DEVPATH; then
|
||||
echo "$F error: directory $DEVPATH does not exist. Please install iPhone development kit"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Choose SDK version to use
|
||||
if test "" = ""; then
|
||||
#if test "$IPHONESDK" = ""; then
|
||||
# If IPHONESDK is not set, use the latest one
|
||||
for f in `ls $DEVPATH/SDKs/`;
|
||||
do echo $f | sed 's/\(.sdk\)//';
|
||||
done | sort | tail -1 > tmpsdkname
|
||||
IPHONESDK=`cat tmpsdkname`.sdk
|
||||
rm -f tmpsdkname
|
||||
SDKPATH=${DEVPATH}/SDKs/${IPHONESDK}
|
||||
echo "$F: IPHONESDK is not specified, choosing ${IPHONESDK}"
|
||||
elif test -d ${IPHONESDK}; then
|
||||
# .. else if IPHONESDK is set and it points to a valid path, just use it
|
||||
SDKPATH=${IPHONESDK}
|
||||
else
|
||||
# .. else assume the SDK name is used.
|
||||
SDKPATH=${DEVPATH}/SDKs/${IPHONESDK}
|
||||
fi
|
||||
|
||||
echo ${IPHONESDK%.sdk} | awk '{print tolower($0);}' > tempFile
|
||||
IPHONESDK=`cat tempFile`
|
||||
rm tempFile
|
||||
|
||||
xcodebuild -sdk $IPHONESDK -configuration Release
|
||||
#cp build/Release-iphonesimulator/*.a $TARGET_FILE_PATH/lib
|
||||
#rm -rf build
|
||||
|
||||
lipo -create \
|
||||
build/Release-iphoneos/lib${ProjectSub}.a \
|
||||
build/Release-iphonesimulator/lib${ProjectSub}.a \
|
||||
-output $TARGET_FILE_PATH/lib/lib${ProjectSub}.a
|
||||
|
||||
echo "***************************************************"
|
||||
#echo "${ProjectSub} build success"
|
||||
|
||||
#remove all build file
|
||||
rm -rf build
|
||||
|
||||
# if [ -d "$CURRENT_DIR/../lib_${ProjectSub}" ]; then
|
||||
#
|
||||
# cd $CURRENT_DIR/../lib_${ProjectSub}
|
||||
# if [ -d "include" ]; then
|
||||
# mkdir -p $TARGET_FILE_PATH/include
|
||||
# cp -r include/* $TARGET_FILE_PATH/include
|
||||
# fi
|
||||
|
||||
# elif test "$ProjectSub" = "acl"; then
|
||||
if test "$ProjectSub" = "acl"; then
|
||||
|
||||
#subPath acl path is lib_acl
|
||||
if [ -d "$CURRENT_DIR/../lib_acl" ]; then
|
||||
cd $CURRENT_DIR/../lib_acl
|
||||
if [ -d "include" ]; then
|
||||
mkdir -p $TARGET_FILE_PATH/include/acl
|
||||
cp -r include/* $TARGET_FILE_PATH/include/acl
|
||||
fi
|
||||
fi
|
||||
|
||||
elif test "$ProjectSub" = "acl_cpp"; then
|
||||
|
||||
#subPath acl_cpp path is lib_acl_cpp
|
||||
if [ -d "$CURRENT_DIR/../lib_acl_cpp" ]; then
|
||||
cd $CURRENT_DIR/../lib_acl_cpp
|
||||
if [ -d "include" ]; then
|
||||
mkdir -p $TARGET_FILE_PATH/include
|
||||
cp -r include/* $TARGET_FILE_PATH/include
|
||||
fi
|
||||
fi
|
||||
|
||||
elif test "$ProjectSub" = "protocol"; then
|
||||
|
||||
#subPath protocol path is lib_protocol
|
||||
if [ -d "$CURRENT_DIR/../lib_protocol" ]; then
|
||||
cd $CURRENT_DIR/../lib_protocol
|
||||
if [ -d "include" ]; then
|
||||
mkdir -p $TARGET_FILE_PATH/include/protocol
|
||||
cp -r include/* $TARGET_FILE_PATH/include/protocol
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
done < $XCODEPROJ_FILE_PATH #read xcodeproj
|
||||
|
3
build4ios/xcodeproj-path
Normal file
3
build4ios/xcodeproj-path
Normal file
@ -0,0 +1,3 @@
|
||||
acl
|
||||
acl_cpp
|
||||
protocol
|
@ -1,5 +1,13 @@
|
||||
修改历史列表:
|
||||
------------------------------------------------------------------------
|
||||
104) 2017.3.25
|
||||
104.1) 库名重命名:
|
||||
lib_acl.a --> libacl.a
|
||||
lib_protocol.a --> libprotocol.a
|
||||
lib_acl_cpp.a --> libacl_cpp.a
|
||||
lib_fiber.a --> libfiber.a
|
||||
lib_fiber_cpp.a --> libfiber_acpp.a
|
||||
|
||||
103) 2017.3.10
|
||||
103.1) compile: 在macosx 上编译时不必再添加预编译选项,会根据编译器的默认
|
||||
的预定义宏自动进行识别编译平台
|
||||
|
@ -11,6 +11,7 @@ endif()
|
||||
|
||||
add_definitions(
|
||||
"-W"
|
||||
"-fPIC"
|
||||
"-Wall"
|
||||
"-Werror"
|
||||
"-Wshadow"
|
||||
@ -25,7 +26,6 @@ add_definitions(
|
||||
"-D_POSIX_PTHREAD_SEMANTICS"
|
||||
"-DACL_PREPARE_COMPILE"
|
||||
"-Wno-invalid-source-encoding"
|
||||
"-fPIC"
|
||||
"-Wstrict-prototypes"
|
||||
)
|
||||
|
||||
@ -41,10 +41,11 @@ else()
|
||||
add_definitions("-g")
|
||||
endif()
|
||||
|
||||
string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "ANDROID")
|
||||
#string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
add_definitions("-DANDROID")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "LINUX")
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
else()
|
||||
message(FATAL_ERROR "unknown CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
@ -99,16 +100,18 @@ foreach(iter ${sources})
|
||||
aux_source_directory(${iter} lib_src)
|
||||
endforeach()
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME MATCHES "ANDROID")
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-shared")
|
||||
else()
|
||||
set(lib_output_path ${PROJECT_BINARY_DIR}/lib)
|
||||
|
||||
set(LIBRARY_OUTPUT_PATH ${lib_output_path})
|
||||
add_library(_acl_static STATIC ${lib_src})
|
||||
SET_TARGET_PROPERTIES(_acl_static PROPERTIES OUTPUT_NAME "_acl")
|
||||
add_library(acl_static STATIC ${lib_src})
|
||||
SET_TARGET_PROPERTIES(acl_static PROPERTIES OUTPUT_NAME "acl")
|
||||
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
|
||||
endif()
|
||||
|
||||
add_library(_acl SHARED ${lib_src})
|
||||
add_library(acl SHARED ${lib_src})
|
||||
|
||||
##############################################################################
|
||||
|
@ -10,14 +10,16 @@ RANLIB = ${ENV_RANLIB}
|
||||
FLAGS = ${ENV_FLAGS}
|
||||
|
||||
# default lib name
|
||||
LIB_NAME = lib_acl.a
|
||||
LIB_NAME = libacl.a
|
||||
|
||||
#-fno-strict-aliasing \
|
||||
#CFLAGS = -c -g -W -Wall -Wcast-qual -Wcast-align
|
||||
|
||||
CFLAGS = -c -g -W \
|
||||
-O3 \
|
||||
-fPIC \
|
||||
-Wall \
|
||||
-Werror \
|
||||
-Wshadow \
|
||||
-Wpointer-arith \
|
||||
-Waggregate-return \
|
||||
@ -29,7 +31,7 @@ CFLAGS = -c -g -W \
|
||||
-Wuninitialized \
|
||||
-D_POSIX_PTHREAD_SEMANTICS \
|
||||
-DACL_PREPARE_COMPILE \
|
||||
-Winvalid-pch
|
||||
-Winvalid-pch \
|
||||
#-DDEBUG_MEM
|
||||
#-DUSE_EPOLL \
|
||||
#-Wno-tautological-compare \
|
||||
@ -79,25 +81,20 @@ endif
|
||||
|
||||
# For FreeBSD
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
# CFLAGS += -DFREEBSD -fPIC -Werror
|
||||
CFLAGS += -fPIC -Werror
|
||||
UNIXTYPE = FREEBSD
|
||||
RPATH = freebsd
|
||||
endif
|
||||
|
||||
# For Darwin
|
||||
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
||||
# CFLAGS += -DMACOSX -Wno-invalid-source-encoding
|
||||
CFLAGS += -Wno-invalid-source-encoding \
|
||||
-Wno-extended-offsetof -fPIC -Werror
|
||||
-Wno-extended-offsetof
|
||||
UNIXTYPE = MACOSX
|
||||
RPATH = macos
|
||||
endif
|
||||
|
||||
# For Linux
|
||||
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
|
||||
# CFLAGS += -DLINUX2 -fPIC -Werror
|
||||
CFLAGS += -fPIC -Werror
|
||||
UNIXTYPE = LINUX
|
||||
ifeq ($(findstring i686, $(OSTYPE)), i686)
|
||||
CFLAGS += -march=i686
|
||||
@ -282,8 +279,10 @@ OBJS_DEF = $(INIT_DEF) $(PRIV_DEF) $(STDLIB_DEF) \
|
||||
###########################################################
|
||||
.PHONY = all static shared acl_master clean clean_lib clean_master rebuild
|
||||
|
||||
STATIC_LIBNAME = lib_acl.a
|
||||
SHARED_LIBNAME = lib_acl.so
|
||||
STATIC_OLD_LIBNAME = lib_acl.a
|
||||
SHARED_OLD_LIBNAME = lib_acl.so
|
||||
STATIC_LIBNAME = libacl.a
|
||||
SHARED_LIBNAME = libacl.so
|
||||
|
||||
all: static shared acl_master
|
||||
|
||||
@ -310,6 +309,8 @@ static: depends $(OBJS_DST)
|
||||
@echo 'creating $(LIB_PATH_DST)/$(STATIC_LIBNAME)'
|
||||
@$(AR) $(ARFL) $(LIB_PATH_DST)/$(STATIC_LIBNAME) $(OBJS_DST)
|
||||
@$(RANLIB) $(LIB_PATH_DST)/$(STATIC_LIBNAME)
|
||||
@(cd $(LIB_PATH_DST); rm -f $(STATIC_OLD_LIBNAME); \
|
||||
ln -s $(STATIC_LIBNAME) $(STATIC_OLD_LIBNAME))
|
||||
@echo 'build $(LIB_PATH_DST)/$(STATIC_LIBNAME) ok!'
|
||||
|
||||
#shared_ldflags = -lmysqlclient -lrt -lpthread -ldl
|
||||
@ -530,8 +531,9 @@ $(DEF_PATH_DST)/%.inc: $(SRC_PATH_SRC)/unit_test/%.c
|
||||
# $(CREATE_DEF)
|
||||
|
||||
clean_lib:
|
||||
rm -f $(LIB_PATH_DST)/$(LIB_NAME)
|
||||
rm -f $(LIB_PATH_DST)/lib_acl.so
|
||||
rm -f $(LIB_PATH_DST)/$(STATIC_LIBNAME)
|
||||
rm -f $(LIB_PATH_DST)/$(STATIC_OLD_LIBNAME)
|
||||
rm -f $(LIB_PATH_DST)/libacl.so
|
||||
rm -f $(OBJS_DST)
|
||||
rm -f $(OBJS_DEF)
|
||||
rm -f $(PCH)
|
||||
|
@ -122,7 +122,7 @@ ACL_LIB = $(ACL_PATH)/lib
|
||||
|
||||
EXTLIBS =
|
||||
CFLAGS += -I$(ACL_INC)
|
||||
LDFLAGS = -L$(ACL_LIB) -l_acl $(EXTLIBS) $(SYSLIB)
|
||||
LDFLAGS = -L$(ACL_LIB) -lacl $(EXTLIBS) $(SYSLIB)
|
||||
|
||||
###########################################################
|
||||
|
||||
|
@ -118,9 +118,9 @@ ACL_LIB = $(ACL_PATH)/lib
|
||||
|
||||
EXTLIBS =
|
||||
#CFLAGS += -I$(ACL_INC) -I$(PROTO_INC)
|
||||
#LDFLAGS = -L$(ACL_LIB) -L$(PROTO_LIB) -l_protocol -l_acl $(EXTLIBS) $(SYSLIB)
|
||||
#LDFLAGS = -L$(ACL_LIB) -L$(PROTO_LIB) -l_protocol -lacl $(EXTLIBS) $(SYSLIB)
|
||||
CFLAGS += -I$(ACL_INC)
|
||||
LDFLAGS = -L$(ACL_LIB) -l_acl $(EXTLIBS) $(SYSLIB)
|
||||
LDFLAGS = -L$(ACL_LIB) -lacl $(EXTLIBS) $(SYSLIB)
|
||||
|
||||
|
||||
###########################################################
|
||||
|
@ -94,9 +94,9 @@ ACL_LIB = $(ACL_PATH)/lib
|
||||
|
||||
EXTLIBS =
|
||||
#CFLAGS += -I$(ACL_INC) -I$(PROTO_INC)
|
||||
#LDFLAGS = -L$(ACL_LIB) -L$(PROTO_LIB) -l_protocol -l_acl $(EXTLIBS) $(SYSLIB)
|
||||
#LDFLAGS = -L$(ACL_LIB) -L$(PROTO_LIB) -l_protocol -lacl $(EXTLIBS) $(SYSLIB)
|
||||
CFLAGS += -I$(ACL_INC)
|
||||
LDFLAGS = -L$(ACL_LIB) -l_acl $(EXTLIBS) $(SYSLIB)
|
||||
LDFLAGS = -L$(ACL_LIB) -lacl $(EXTLIBS) $(SYSLIB)
|
||||
|
||||
###########################################################
|
||||
|
||||
|
@ -85,7 +85,7 @@ CFLAGS += -I. -I$(ACL_INC)
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L$(ACL_LIB) -l_acl $(EXTLIBS) $(SYSLIB)
|
||||
LDFLAGS = -L$(ACL_LIB) -lacl $(EXTLIBS) $(SYSLIB)
|
||||
LINKS = $(CC) -o $(PROG) $(OBJS) $(LDFLAGS)
|
||||
|
||||
OUT_PATH = ./
|
||||
|
@ -94,9 +94,9 @@ ACL_LIB = $(ACL_PATH)/lib
|
||||
|
||||
EXTLIBS =
|
||||
#CFLAGS += -I$(ACL_INC) -I$(PROTO_INC)
|
||||
#LDFLAGS = -L$(ACL_LIB) -L$(PROTO_LIB) -l_protocol -l_acl $(EXTLIBS) $(SYSLIB)
|
||||
#LDFLAGS = -L$(ACL_LIB) -L$(PROTO_LIB) -l_protocol -lacl $(EXTLIBS) $(SYSLIB)
|
||||
CFLAGS += -I$(ACL_INC)
|
||||
LDFLAGS = -L$(ACL_LIB) -l_acl $(EXTLIBS) $(SYSLIB)
|
||||
LDFLAGS = -L$(ACL_LIB) -lacl $(EXTLIBS) $(SYSLIB)
|
||||
|
||||
###########################################################
|
||||
|
||||
|
@ -82,7 +82,7 @@ LIB_BASE_PATH = ../../../lib_acl
|
||||
LIB_NAME_PATH = -L$(LIB_BASE_PATH)/lib
|
||||
LIB_INCL_PATH = $(LIB_BASE_PATH)/include
|
||||
|
||||
ALL_LIBS = -l_acl $(SYSLIB)
|
||||
ALL_LIBS = -lacl $(SYSLIB)
|
||||
|
||||
BASE_PATH = .
|
||||
INCLUDEDIR = $(BASE_PATH)
|
||||
|
@ -34,7 +34,9 @@ int acl_write_wait(ACL_SOCKET fd, int timeout)
|
||||
fds.events = POLLOUT | POLLHUP | POLLERR;
|
||||
fds.fd = fd;
|
||||
|
||||
#if 0
|
||||
acl_set_error(0);
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
switch (poll(&fds, 1, delay)) {
|
||||
@ -105,7 +107,9 @@ int acl_write_wait(ACL_SOCKET fd, int timeout)
|
||||
} else
|
||||
tp = 0;
|
||||
|
||||
#if 0
|
||||
acl_set_error(0);
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
#ifdef ACL_WINDOWS
|
||||
|
@ -8,6 +8,7 @@ endif()
|
||||
|
||||
add_definitions(
|
||||
"-W"
|
||||
"-fPIC"
|
||||
"-Wall"
|
||||
"-Werror"
|
||||
"-Wshadow"
|
||||
@ -20,7 +21,6 @@ add_definitions(
|
||||
"-D_POSIX_PTHREAD_SEMANTICS"
|
||||
"-DHAS_MYSQL_DLL"
|
||||
"-DHAS_SQLITE_DLL"
|
||||
"-DHAS_ZLIB_DLL"
|
||||
"-Wno-invalid-source-encoding"
|
||||
"-Wno-unused-private-field"
|
||||
"-Wno-unused-parameter"
|
||||
@ -40,10 +40,11 @@ else()
|
||||
add_definitions("-g")
|
||||
endif()
|
||||
|
||||
string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "ANDROID")
|
||||
#string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
add_definitions("-DANDROID")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "LINUX")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
else()
|
||||
message(FATAL_ERROR "unknown CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
@ -95,21 +96,30 @@ foreach(iter ${sources})
|
||||
aux_source_directory(${iter} lib_src)
|
||||
endforeach()
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME MATCHES "ANDROID")
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-shared")
|
||||
else()
|
||||
set(lib_output_path ${PROJECT_BINARY_DIR}/lib)
|
||||
|
||||
set(LIBRARY_OUTPUT_PATH ${lib_output_path})
|
||||
add_library(_acl_cpp_static STATIC ${lib_src})
|
||||
SET_TARGET_PROPERTIES(_acl_cpp_static PROPERTIES OUTPUT_NAME "_acl_cpp")
|
||||
SET_TARGET_PROPERTIES(_acl_cpp_static PROPERTIES OUTPUT_NAME "acl_cpp")
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS
|
||||
"-shared -Wl,-rpath,. -L${lib_output_path} -lprotocol -lacl -liconv -lz -lpthread")
|
||||
else()
|
||||
set(CMAKE_SHARED_LINKER_FLAGS
|
||||
"-shared -Wl,-rpath,. -L${lib_output_path} -lprotocol -lacl -lz -lpthread")
|
||||
endif()
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-rpath,. -L${lib_output_path} -l_protocol -l_acl")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
|
||||
link_directories(${lib_output_path})
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
add_library(_acl_cpp SHARED ${lib_src})
|
||||
target_link_libraries(_acl_cpp _protocol _acl)
|
||||
add_library(acl_cpp SHARED ${lib_src})
|
||||
target_link_libraries(acl_cpp protocol acl)
|
||||
endif()
|
||||
|
||||
##############################################################################
|
||||
|
@ -10,7 +10,9 @@ FLAGS = ${ENV_FLAGS}
|
||||
|
||||
CFLAGS = -c -g -W \
|
||||
-O3 \
|
||||
-fPIC \
|
||||
-Wall \
|
||||
-Werror \
|
||||
-Wpointer-arith \
|
||||
-Wshadow \
|
||||
-D_REENTRANT \
|
||||
@ -67,17 +69,14 @@ endif
|
||||
|
||||
# For FreeBSD
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
# CFLAGS += -DFREEBSD -fPIC -Werror
|
||||
CFLAGS += -fPIC -Werror
|
||||
UNIXTYPE = FREEBSD
|
||||
shared_ldflags = -l_protocol -l_acl -L/usr/local/lib -liconv -lz -lpthread
|
||||
endif
|
||||
|
||||
# For Darwin
|
||||
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
||||
# CFLAGS += -DMACOSX -Wno-invalid-source-encoding
|
||||
CFLAGS += -Wno-invalid-source-encoding \
|
||||
-Wno-extended-offsetof -fPIC -Werror \
|
||||
-Wno-extended-offsetof \
|
||||
-Wno-unused-private-field
|
||||
UNIXTYPE = MACOSX
|
||||
shared_ldflags = -l_protocol -l_acl -L/usr/lib -liconv -lz -lpthread
|
||||
@ -85,8 +84,6 @@ endif
|
||||
|
||||
# For Linux
|
||||
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
|
||||
# CFLAGS += -DLINUX2 -fPIC -Werror
|
||||
CFLAGS += -fPIC -Werror
|
||||
UNIXTYPE = LINUX
|
||||
shared_ldflags = -l_protocol -l_acl -lrt -lpthread -lz -ldl
|
||||
endif
|
||||
@ -111,13 +108,13 @@ ifeq ($(findstring SunOS, $(UNIXNAME)), SunOS)
|
||||
ifeq ($(findstring sun4u, $(UNIXNAME)), sun4u)
|
||||
SYSLIB = -lsocket -lnsl -lrt
|
||||
endif
|
||||
CFLAGS += -DSUNOS5 -fPIC -Werror
|
||||
CFLAGS += -DSUNOS5
|
||||
UNIXTYPE = SUNOS5
|
||||
endif
|
||||
|
||||
# For HP-UX
|
||||
ifeq ($(findstring HP-UX, $(UNIXNAME)), HP-UX)
|
||||
CFLAGS += -DHP_UX -DHPUX11 -fPIC -Werror
|
||||
CFLAGS += -DHP_UX -DHPUX11
|
||||
UNIXTYPE = HPUX
|
||||
endif
|
||||
|
||||
@ -182,8 +179,8 @@ OBJS_DEF = $(patsubst %.cpp, $(DEF_PATH_DST)/%.inc, $(notdir $(wildcard src/*.cp
|
||||
VERSION = 1.1.1.2
|
||||
DATE_NOW = 20`date +%y`.`date +%m`.`date +%d`
|
||||
|
||||
STATIC_LIBNAME = lib_acl_cpp.a
|
||||
SHARED_LIBNAME = lib_acl_cpp.so
|
||||
STATIC_LIBNAME = libacl_cpp.a
|
||||
SHARED_LIBNAME = libacl_cpp.so
|
||||
PCH = src/acl_stdafx.hpp.gch
|
||||
|
||||
lib: static
|
||||
@ -210,6 +207,8 @@ static: depends $(OBJS_DST)
|
||||
@echo 'creating $(LIB_PATH_DST)/$(STATIC_LIBNAME)'
|
||||
@$(AR) $(ARFL) $(LIB_PATH_DST)/$(STATIC_LIBNAME) $(OBJS_DST)
|
||||
@$(RANLIB) $(LIB_PATH_DST)/$(STATIC_LIBNAME)
|
||||
@(cd $(LIB_PATH_DST); rm -f lib_acl_cpp.a; \
|
||||
ln -s $(STATIC_LIBNAME) lib_acl_cpp.a)
|
||||
@echo 'create $(LIB_PATH_DST)/$(STATIC_LIBNAME) ok!'
|
||||
|
||||
shared: depends pch $(OBJS_DST)
|
||||
@ -338,7 +337,9 @@ $(DEF_PATH_DST)/%.inc: ./src/serialize/%.cpp
|
||||
$(CREATE_DEF)
|
||||
|
||||
clean:
|
||||
rm -f $(LIB_PATH_DST)/libacl_cpp.a
|
||||
rm -f $(LIB_PATH_DST)/lib_acl_cpp.a
|
||||
rm -f $(LIB_PATH_DST)/libacl_cpp.so
|
||||
rm -f $(LIB_PATH_DST)/lib_acl_cpp.so
|
||||
rm -f $(OBJS_DST)
|
||||
rm -f $(OBJS_DEF)
|
||||
|
@ -7,8 +7,8 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
07A458351E6FCCB4002C9B3C /* acl_cpp.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 07A458341E6FCCB4002C9B3C /* acl_cpp.h */; };
|
||||
07A458371E6FCCB4002C9B3C /* acl_cpp.m in Sources */ = {isa = PBXBuildFile; fileRef = 07A458361E6FCCB4002C9B3C /* acl_cpp.m */; };
|
||||
07A458351E6FCCB4002C9B3C /* acl_cpp.h in Copy Files */ = {isa = PBXBuildFile; fileRef = 07A458341E6FCCB4002C9B3C /* acl_cpp.h */; };
|
||||
07A458371E6FCCB4002C9B3C /* acl_cpp.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07A458361E6FCCB4002C9B3C /* acl_cpp.mm */; };
|
||||
07A467C01E6FCCF1002C9B3C /* acl_cpp_init.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A466DA1E6FCCF1002C9B3C /* acl_cpp_init.cpp */; };
|
||||
07A467C11E6FCCF1002C9B3C /* acl_cpp_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A466DB1E6FCCF1002C9B3C /* acl_cpp_test.cpp */; };
|
||||
07A467C21E6FCCF1002C9B3C /* acl_stdafx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A466DC1E6FCCF1002C9B3C /* acl_stdafx.cpp */; };
|
||||
@ -193,14 +193,15 @@
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
07A4582F1E6FCCB4002C9B3C /* CopyFiles */ = {
|
||||
07A4582F1E6FCCB4002C9B3C /* Copy Files */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "include/$(PRODUCT_NAME)";
|
||||
dstSubfolderSpec = 16;
|
||||
files = (
|
||||
07A458351E6FCCB4002C9B3C /* acl_cpp.h in CopyFiles */,
|
||||
07A458351E6FCCB4002C9B3C /* acl_cpp.h in Copy Files */,
|
||||
);
|
||||
name = "Copy Files";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
@ -208,7 +209,7 @@
|
||||
/* Begin PBXFileReference section */
|
||||
07A458311E6FCCB4002C9B3C /* libacl_cpp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libacl_cpp.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
07A458341E6FCCB4002C9B3C /* acl_cpp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = acl_cpp.h; sourceTree = "<group>"; };
|
||||
07A458361E6FCCB4002C9B3C /* acl_cpp.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = acl_cpp.m; sourceTree = "<group>"; };
|
||||
07A458361E6FCCB4002C9B3C /* acl_cpp.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = acl_cpp.mm; sourceTree = "<group>"; };
|
||||
07A466DA1E6FCCF1002C9B3C /* acl_cpp_init.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = acl_cpp_init.cpp; sourceTree = "<group>"; };
|
||||
07A466DB1E6FCCF1002C9B3C /* acl_cpp_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = acl_cpp_test.cpp; sourceTree = "<group>"; };
|
||||
07A466DC1E6FCCF1002C9B3C /* acl_stdafx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = acl_stdafx.cpp; sourceTree = "<group>"; };
|
||||
@ -627,7 +628,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
07A458341E6FCCB4002C9B3C /* acl_cpp.h */,
|
||||
07A458361E6FCCB4002C9B3C /* acl_cpp.m */,
|
||||
07A458361E6FCCB4002C9B3C /* acl_cpp.mm */,
|
||||
);
|
||||
path = acl_cpp;
|
||||
sourceTree = "<group>";
|
||||
@ -1408,7 +1409,7 @@
|
||||
buildPhases = (
|
||||
07A4582D1E6FCCB4002C9B3C /* Sources */,
|
||||
07A4582E1E6FCCB4002C9B3C /* Frameworks */,
|
||||
07A4582F1E6FCCB4002C9B3C /* CopyFiles */,
|
||||
07A4582F1E6FCCB4002C9B3C /* Copy Files */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@ -1600,7 +1601,7 @@
|
||||
07A468381E6FCCF1002C9B3C /* redis_result.cpp in Sources */,
|
||||
07A467F51E6FCCF1002C9B3C /* http_request_pool.cpp in Sources */,
|
||||
07A468691E6FCCF1002C9B3C /* aio_timer_delay_free.cpp in Sources */,
|
||||
07A458371E6FCCB4002C9B3C /* acl_cpp.m in Sources */,
|
||||
07A458371E6FCCB4002C9B3C /* acl_cpp.mm in Sources */,
|
||||
07A468271E6FCCF1002C9B3C /* queue_file.cpp in Sources */,
|
||||
07A4686F1E6FCCF1002C9B3C /* polarssl_conf.cpp in Sources */,
|
||||
07A468461E6FCCF1002C9B3C /* mail_message.cpp in Sources */,
|
||||
@ -1728,7 +1729,11 @@
|
||||
07A4583B1E6FCCB4002C9B3C /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited) ";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
HAS_MYSQL,
|
||||
HAS_SQLITE,
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
../lib_acl/include,
|
||||
../lib_protocol/include,
|
||||
@ -1747,6 +1752,11 @@
|
||||
07A4583C1E6FCCB4002C9B3C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
HAS_MYSQL,
|
||||
HAS_SQLITE,
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
../lib_acl/include,
|
||||
../lib_protocol/include,
|
||||
|
13
lib_acl_cpp/acl_cpp/acl_cpp.mm
Normal file
13
lib_acl_cpp/acl_cpp/acl_cpp.mm
Normal file
@ -0,0 +1,13 @@
|
||||
//
|
||||
// acl_cpp.m
|
||||
// acl_cpp
|
||||
//
|
||||
// Created by zsx on 17/3/8.
|
||||
// Copyright © 2017年 zsx. All rights reserved.
|
||||
//
|
||||
|
||||
#import "acl_cpp.h"
|
||||
|
||||
@implementation acl_cpp
|
||||
|
||||
@end
|
@ -1,6 +1,16 @@
|
||||
修改历史列表:
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
468) 2017.3.25
|
||||
468.1) connect_pool 连接池模块取消自动将连接池置为不可用操作
|
||||
|
||||
467) 2017.3.24
|
||||
467.1) bugfix: db_mysql/db_sqlite 模块当采用静态方式使用时,编译出错
|
||||
|
||||
466) 2017.3.21
|
||||
466.1) feature: db 模块中 db_handle/db_mysql/db_sqlite 在查询时,允许将结果集
|
||||
存储于用户输入的对象中,从而实现结果集与 db 句柄分离的目的
|
||||
|
||||
465) 2017.3.9
|
||||
465.1) bugfix: db_mysql.cpp 当进程退出前会自动卸载 mysql 动态库,但 mysql 的
|
||||
句柄有可能会在该操作后发生,从而造成程序崩溃,增加判断条件以防止此问题发生
|
||||
|
@ -202,7 +202,7 @@ public:
|
||||
*/
|
||||
size_t length() const;
|
||||
|
||||
protected:
|
||||
public:
|
||||
// 数据表字段名
|
||||
std::vector<const char*> names_;
|
||||
|
||||
@ -212,6 +212,12 @@ protected:
|
||||
|
||||
// 临时结果行集合
|
||||
std::vector<const db_row*> rows_tmp_;
|
||||
|
||||
// 存储临时结果集对象
|
||||
void* result_tmp_;
|
||||
|
||||
// 用来释放临时结果集对象
|
||||
void (*result_free)(void* result);
|
||||
};
|
||||
|
||||
class db_pool;
|
||||
@ -289,9 +295,11 @@ public:
|
||||
* 纯虚接口,子类必须实现此接口用于执行 SELECT SQL 语句
|
||||
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注意该
|
||||
* SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @param result {db_rows*} 如果非空,则将查询结果填充进该结果对象中,
|
||||
* 否则,会引用 db_handle 内部的一个临时存储对象
|
||||
* @return {bool} 执行是否成功
|
||||
*/
|
||||
virtual bool sql_select(const char* sql) = 0;
|
||||
virtual bool sql_select(const char* sql, db_rows* result = NULL) = 0;
|
||||
|
||||
/**
|
||||
* 纯虚接口,子类必须实现此接口用于执行 INSERT/UPDATE/DELETE SQL 语句
|
||||
@ -318,9 +326,11 @@ public:
|
||||
* 对象 query 构建的 sql 语句是安全的,可以防止 sql 注入,该方法
|
||||
* 执行 SELECT SQL 语句
|
||||
* @param query {query&}
|
||||
* @param result {db_rows*} 如果非空,则将查询结果填充进该结果对象中,
|
||||
* 否则,会引用 db_handle 内部的一个临时存储对象
|
||||
* @return {bool} 执行是否成功
|
||||
*/
|
||||
bool exec_select(query& query);
|
||||
bool exec_select(query& query, db_rows* result = NULL);
|
||||
|
||||
/**
|
||||
* 更安全易用的更新过程,调用此函数功能等同于 sql_update,只是查询
|
||||
|
@ -112,9 +112,11 @@ public:
|
||||
* 基类 db_handle 的纯虚接口
|
||||
* @param sql {const char*} 标准的 SELECT SQL 语句,非空,并且一定
|
||||
* 得要注意该 SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @param result {db_rows*} 如果非空,则将查询结果填充进该结果对象中,
|
||||
* 否则,会引用 db_handle 内部的一个临时存储对象
|
||||
* @return {bool} 执行是否成功
|
||||
*/
|
||||
bool sql_select(const char* sql);
|
||||
bool sql_select(const char* sql, db_rows* result = NULL);
|
||||
|
||||
/**
|
||||
* 基类 db_handle 的纯虚接口
|
||||
|
@ -119,9 +119,11 @@ public:
|
||||
* 基类 db_handle 的纯虚接口
|
||||
* @param sql {const char*} 标准的 SELECT SQL 语句,并且一定得要
|
||||
* 注意该 SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @param result {db_rows*} 如果非空,则将查询结果填充进该结果对象中,
|
||||
* 否则,会引用 db_handle 内部的一个临时存储对象
|
||||
* @return {bool} 执行是否成功
|
||||
*/
|
||||
bool sql_select(const char* sql);
|
||||
bool sql_select(const char* sql, db_rows* result = NULL);
|
||||
|
||||
/**
|
||||
* 基类 db_handle 的纯虚接口
|
||||
@ -151,7 +153,7 @@ private:
|
||||
string charset_;
|
||||
|
||||
// 真正执行SQL查询的函数
|
||||
bool exec_sql(const char* sql);
|
||||
bool exec_sql(const char* sql, db_rows* result = NULL);
|
||||
};
|
||||
|
||||
} // namespace acl
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "acl_cpp/acl_cpp_define.hpp"
|
||||
#include "acl_cpp/stdlib/string.hpp"
|
||||
#include "acl_cpp/stdlib/noncopyable.hpp"
|
||||
#include <map>
|
||||
|
||||
namespace acl
|
||||
@ -10,7 +11,7 @@ namespace acl
|
||||
* SQL 查询语句查询器,该类会自动对 sql 中的一些特殊字符进行转义,使用方式类似于
|
||||
* java hibernate 的 SQL 语句构建方式
|
||||
*/
|
||||
class ACL_CPP_API query
|
||||
class ACL_CPP_API query : public noncopyable
|
||||
{
|
||||
public:
|
||||
query();
|
||||
|
@ -127,7 +127,7 @@ endif
|
||||
#endif
|
||||
|
||||
CFLAGS += -I. -I$(BASE_PATH)/include -I$(BASE_PATH)/../lib_acl/include -I$(BASE_PATH)/../lib_protocol/include
|
||||
LDFLAGS = -L$(BASE_PATH)/lib -l_acl_cpp -L$(BASE_PATH)/../lib_protocol/lib -l_protocol -L$(BASE_PATH)/../lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L$(BASE_PATH)/lib -lacl_cpp -L$(BASE_PATH)/../lib_protocol/lib -lprotocol -L$(BASE_PATH)/../lib_acl/lib -lacl \
|
||||
-L$(BASE_PATH)/../lib/$(RPATH) $(EXTLIBS) $(SYSLIB)
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
@ -133,8 +133,10 @@ connect_client* connect_pool::peek()
|
||||
if (conn->open() == false)
|
||||
{
|
||||
delete conn;
|
||||
#ifdef AUTO_SET_ALIVE
|
||||
alive_ = false;
|
||||
(void) time(&last_dead_);
|
||||
#endif
|
||||
lock_.unlock();
|
||||
return NULL;
|
||||
}
|
||||
@ -204,11 +206,11 @@ void connect_pool::set_delay_destroy()
|
||||
lock_.unlock();
|
||||
}
|
||||
|
||||
void connect_pool::set_alive(bool ok /* true | false */)
|
||||
void connect_pool::set_alive(bool yes /* true | false */)
|
||||
{
|
||||
lock_.lock();
|
||||
alive_ = ok;
|
||||
if (ok == false)
|
||||
alive_ = yes;
|
||||
if (yes == false)
|
||||
time(&last_dead_);
|
||||
lock_.unlock();
|
||||
}
|
||||
|
@ -164,6 +164,8 @@ size_t db_row::length() const
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
db_rows::db_rows()
|
||||
: result_tmp_(NULL)
|
||||
, result_free(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
@ -173,6 +175,9 @@ db_rows::~db_rows()
|
||||
std::vector<db_row*>::iterator it = rows_.begin();
|
||||
for (; it != rows_.end(); ++it)
|
||||
delete (*it);
|
||||
|
||||
if (result_free && result_tmp_)
|
||||
result_free(result_tmp_);
|
||||
}
|
||||
|
||||
const std::vector<const db_row*>& db_rows::get_rows(
|
||||
@ -260,9 +265,9 @@ bool db_handle::open()
|
||||
return dbopen();
|
||||
}
|
||||
|
||||
bool db_handle::exec_select(query& query)
|
||||
bool db_handle::exec_select(query& query, db_rows* result /* = NULL */)
|
||||
{
|
||||
return sql_select(query.to_string().c_str());
|
||||
return sql_select(query.to_string().c_str(), result);
|
||||
}
|
||||
|
||||
bool db_handle::exec_update(query& query)
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#if defined(HAS_MYSQL) || defined(HAS_MYSQL_DLL)
|
||||
|
||||
# if defined(ACL_CPP_DLL) || defined(HAS_MYSQL_DLL)
|
||||
# ifdef HAS_MYSQL_DLL
|
||||
|
||||
# ifndef STDCALL
|
||||
# ifdef ACL_WINDOWS
|
||||
@ -308,42 +308,41 @@ namespace acl
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// mysql 的记录行类型定义
|
||||
|
||||
class db_mysql_rows : public db_rows
|
||||
static void mysql_rows_free(void* ctx)
|
||||
{
|
||||
public:
|
||||
db_mysql_rows(MYSQL_RES *my_res)
|
||||
{
|
||||
int ncolumn = __mysql_num_fields(my_res);
|
||||
MYSQL_FIELD *fields = __mysql_fetch_fields(my_res);
|
||||
MYSQL_RES* my_res = (MYSQL_RES*) ctx;
|
||||
#ifdef HAS_MYSQL_DLL
|
||||
if (my_res && __mysql_dll)
|
||||
#else
|
||||
if (my_res)
|
||||
#endif
|
||||
__mysql_free_result(my_res);
|
||||
}
|
||||
|
||||
// 取出变量名
|
||||
static void mysql_rows_save(MYSQL_RES* my_res, db_rows& result)
|
||||
{
|
||||
int ncolumn = __mysql_num_fields(my_res);
|
||||
MYSQL_FIELD *fields = __mysql_fetch_fields(my_res);
|
||||
|
||||
// 取出变量名
|
||||
for (int j = 0; j < ncolumn; j++)
|
||||
result.names_.push_back(fields[j].name);
|
||||
|
||||
// 开始取出所有行数据结果,加入动态数组中
|
||||
while (true)
|
||||
{
|
||||
MYSQL_ROW my_row = __mysql_fetch_row(my_res);
|
||||
if (my_row == NULL)
|
||||
break;
|
||||
db_row* row = NEW db_row(result.names_);
|
||||
for (int j = 0; j < ncolumn; j++)
|
||||
names_.push_back(fields[j].name);
|
||||
|
||||
// 开始取出所有行数据结果,加入动态数组中
|
||||
while (true)
|
||||
{
|
||||
MYSQL_ROW my_row = __mysql_fetch_row(my_res);
|
||||
if (my_row == NULL)
|
||||
break;
|
||||
db_row* row = NEW db_row(names_);
|
||||
for (int j = 0; j < ncolumn; j++)
|
||||
row->push_back(my_row[j]);
|
||||
rows_.push_back(row);
|
||||
}
|
||||
|
||||
my_res_ = my_res;
|
||||
row->push_back(my_row[j]);
|
||||
result.rows_.push_back(row);
|
||||
}
|
||||
|
||||
~db_mysql_rows()
|
||||
{
|
||||
if (__mysql_dll)
|
||||
__mysql_free_result(my_res_);
|
||||
}
|
||||
|
||||
private:
|
||||
MYSQL_RES *my_res_;
|
||||
};
|
||||
result.result_free = mysql_rows_free;
|
||||
result.result_tmp_ = my_res;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -386,7 +385,7 @@ void db_mysql::sane_mysql_init(const char* dbaddr, const char* dbname,
|
||||
conn_timeout_ = conn_timeout;
|
||||
rw_timeout_ = rw_timeout;
|
||||
|
||||
#if defined(ACL_CPP_DLL) || defined(HAS_MYSQL_DLL)
|
||||
#ifdef HAS_MYSQL_DLL
|
||||
acl_pthread_once(&__mysql_once, __mysql_dll_load);
|
||||
#endif
|
||||
conn_ = NULL;
|
||||
@ -418,7 +417,11 @@ db_mysql::~db_mysql()
|
||||
acl_myfree(dbuser_);
|
||||
if (dbpass_)
|
||||
acl_myfree(dbpass_);
|
||||
#ifdef HAS_MYSQL_DLL
|
||||
if (conn_ && __mysql_dll)
|
||||
#else
|
||||
if (conn_)
|
||||
#endif
|
||||
__mysql_close(conn_);
|
||||
}
|
||||
|
||||
@ -461,7 +464,7 @@ static void thread_free_dummy(void* ctx)
|
||||
if ((unsigned long) acl_pthread_self() != acl_main_thread_self())
|
||||
acl_myfree(ctx);
|
||||
|
||||
#if defined(ACL_CPP_DLL) || defined(HAS_MYSQL_DLL)
|
||||
#ifdef HAS_MYSQL_DLL
|
||||
if (__mysql_thread_end)
|
||||
__mysql_thread_end();
|
||||
#endif
|
||||
@ -476,7 +479,7 @@ static void main_free_dummy(void)
|
||||
__main_dummy = NULL;
|
||||
}
|
||||
|
||||
#if defined(ACL_CPP_DLL) || defined(HAS_MYSQL_DLL)
|
||||
#ifdef HAS_MYSQL_DLL
|
||||
if (__mysql_thread_end)
|
||||
__mysql_thread_end();
|
||||
#endif
|
||||
@ -650,7 +653,11 @@ bool db_mysql::is_opened() const
|
||||
|
||||
bool db_mysql::close()
|
||||
{
|
||||
#ifdef HAS_MYSQL_DLL
|
||||
if (conn_ && __mysql_dll)
|
||||
#else
|
||||
if (conn_)
|
||||
#endif
|
||||
{
|
||||
__mysql_close(conn_);
|
||||
conn_ = NULL;
|
||||
@ -724,7 +731,7 @@ bool db_mysql::tbl_exists(const char* tbl_name)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool db_mysql::sql_select(const char* sql)
|
||||
bool db_mysql::sql_select(const char* sql, db_rows* result /* = NULL */)
|
||||
{
|
||||
// 优先调用基类方法释放上次的查询结果
|
||||
free_result();
|
||||
@ -751,7 +758,14 @@ bool db_mysql::sql_select(const char* sql)
|
||||
return true;
|
||||
}
|
||||
|
||||
result_ = NEW db_mysql_rows(my_res);
|
||||
if (result != NULL)
|
||||
mysql_rows_save(my_res, *result);
|
||||
else
|
||||
{
|
||||
result_ = NEW db_rows();
|
||||
mysql_rows_save(my_res, *result_);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -854,7 +868,7 @@ bool db_mysql::tbl_exists(const char*)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool db_mysql::sql_select(const char*)
|
||||
bool db_mysql::sql_select(const char*, db_rows*)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -901,4 +915,4 @@ const char* db_mysql::get_error() const
|
||||
|
||||
} // namespace acl
|
||||
|
||||
#endif // HAS_MYSQL
|
||||
#endif // !HAS_MYSQL && !HAS_MYSQL_DLL
|
||||
|
@ -11,16 +11,11 @@
|
||||
|
||||
#if defined(HAS_SQLITE) || defined(HAS_SQLITE_DLL)
|
||||
|
||||
#if defined(ACL_WINDOWS) || defined(HAS_SQLITE_DLL)
|
||||
# ifdef HAS_SQLITE_DLL
|
||||
|
||||
#ifndef STDCALL
|
||||
# ifdef ACL_WINDOWS
|
||||
//# define STDCALL __stdcall
|
||||
# define STDCALL
|
||||
# else
|
||||
# define STDCALL
|
||||
# endif // ACL_WINDOWS
|
||||
#endif // STDCALL
|
||||
# ifndef STDCALL
|
||||
# define STDCALL
|
||||
# endif // STDCALL
|
||||
|
||||
typedef char* (STDCALL *sqlite3_libversion_fn)(void);
|
||||
typedef int (STDCALL *sqlite3_open_fn)(const char*, sqlite3**);
|
||||
@ -151,18 +146,18 @@
|
||||
logger("%s loaded", path);
|
||||
atexit(__sqlite_dll_unload);
|
||||
}
|
||||
#else
|
||||
# define __sqlite3_libversion sqlite3_libversion
|
||||
# define __sqlite3_open sqlite3_open
|
||||
# define __sqlite3_close sqlite3_close
|
||||
# define __sqlite3_get_table sqlite3_get_table
|
||||
# define __sqlite3_free_table sqlite3_free_table
|
||||
# define __sqlite3_busy_handler sqlite3_busy_handler
|
||||
# define __sqlite3_errmsg sqlite3_errmsg
|
||||
# define __sqlite3_errcode sqlite3_errcode
|
||||
# define __sqlite3_changes sqlite3_changes
|
||||
# define __sqlite3_total_changes sqlite3_total_changes
|
||||
#endif
|
||||
# else
|
||||
# define __sqlite3_libversion sqlite3_libversion
|
||||
# define __sqlite3_open sqlite3_open
|
||||
# define __sqlite3_close sqlite3_close
|
||||
# define __sqlite3_get_table sqlite3_get_table
|
||||
# define __sqlite3_free_table sqlite3_free_table
|
||||
# define __sqlite3_busy_handler sqlite3_busy_handler
|
||||
# define __sqlite3_errmsg sqlite3_errmsg
|
||||
# define __sqlite3_errcode sqlite3_errcode
|
||||
# define __sqlite3_changes sqlite3_changes
|
||||
# define __sqlite3_total_changes sqlite3_total_changes
|
||||
# endif // HAS_SQLITE && !HAS_SQLITE_DLL
|
||||
|
||||
namespace acl
|
||||
{
|
||||
@ -170,44 +165,44 @@ namespace acl
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// sqlite 的记录行类型定义
|
||||
|
||||
class db_sqlite_rows : public db_rows
|
||||
static void sqlite_rows_free(void* ctx)
|
||||
{
|
||||
public:
|
||||
db_sqlite_rows(char** results, int nrow, int ncolumn)
|
||||
char** results = (char**) ctx;
|
||||
#ifdef HAS_SQLITE_DLL
|
||||
if (__sqlite_dll && results)
|
||||
#else
|
||||
if (results)
|
||||
#endif
|
||||
__sqlite3_free_table(results);
|
||||
}
|
||||
|
||||
|
||||
static void sqlite_rows_save(char** results, int nrow,
|
||||
int ncolumn, db_rows& result)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
// 取出变量名
|
||||
for (int j = 0; j < ncolumn; j++)
|
||||
{
|
||||
results_ = results;
|
||||
result.names_.push_back(results[j]);
|
||||
n++;
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
|
||||
// 取出变量名
|
||||
// 开始取出所有行数据结果,加入动态数组中
|
||||
for (int i = 0; i < nrow; i++)
|
||||
{
|
||||
db_row* row = NEW db_row(result.names_);
|
||||
for (int j = 0; j < ncolumn; j++)
|
||||
{
|
||||
names_.push_back(results[j]);
|
||||
row->push_back(results[n]);
|
||||
n++;
|
||||
}
|
||||
|
||||
// 开始取出所有行数据结果,加入动态数组中
|
||||
for (int i = 0; i < nrow; i++)
|
||||
{
|
||||
db_row* row = NEW db_row(names_);
|
||||
for (int j = 0; j < ncolumn; j++)
|
||||
{
|
||||
row->push_back(results[n]);
|
||||
n++;
|
||||
}
|
||||
rows_.push_back(row);
|
||||
}
|
||||
result.rows_.push_back(row);
|
||||
}
|
||||
|
||||
~db_sqlite_rows()
|
||||
{
|
||||
if (results_)
|
||||
__sqlite3_free_table(results_);
|
||||
}
|
||||
|
||||
private:
|
||||
char** results_;
|
||||
};
|
||||
result.result_tmp_ = results;
|
||||
result.result_free = sqlite_rows_free;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -224,7 +219,7 @@ db_sqlite::db_sqlite(const char* dbfile, const char* charset /* ="utf-8" */)
|
||||
conv_ = NULL;
|
||||
|
||||
acl_assert(dbfile && *dbfile);
|
||||
#if defined(ACL_CPP_DLL) || defined(HAS_SQLITE_DLL)
|
||||
#ifdef HAS_SQLITE_DLL
|
||||
acl_pthread_once(&__sqlite_once, __sqlite_dll_load);
|
||||
#endif
|
||||
}
|
||||
@ -479,9 +474,9 @@ bool db_sqlite::tbl_exists(const char* tbl_name)
|
||||
}
|
||||
}
|
||||
|
||||
bool db_sqlite::sql_select(const char* sql)
|
||||
bool db_sqlite::sql_select(const char* sql, db_rows* result /* = NULL */)
|
||||
{
|
||||
return exec_sql(sql);
|
||||
return exec_sql(sql, result);
|
||||
}
|
||||
|
||||
bool db_sqlite::sql_update(const char* sql)
|
||||
@ -489,7 +484,7 @@ bool db_sqlite::sql_update(const char* sql)
|
||||
return exec_sql(sql);
|
||||
}
|
||||
|
||||
bool db_sqlite::exec_sql(const char* sql)
|
||||
bool db_sqlite::exec_sql(const char* sql, db_rows* result /* = NULL */)
|
||||
{
|
||||
// 必须将上次的查询结果删除
|
||||
free_result();
|
||||
@ -506,7 +501,7 @@ bool db_sqlite::exec_sql(const char* sql)
|
||||
}
|
||||
|
||||
char** results = NULL, *err;
|
||||
int nrow, ncolumn;
|
||||
int nrow, ncolumn;
|
||||
|
||||
// 执行 sqlite 的查询过程
|
||||
int ret = __sqlite3_get_table(db_, sql, &results,
|
||||
@ -520,12 +515,21 @@ bool db_sqlite::exec_sql(const char* sql)
|
||||
}
|
||||
|
||||
if (nrow > 0)
|
||||
result_ = NEW db_sqlite_rows(results, nrow, ncolumn);
|
||||
{
|
||||
if (result != NULL)
|
||||
sqlite_rows_save(results, nrow, ncolumn, *result);
|
||||
else
|
||||
{
|
||||
result_ = NEW db_rows();
|
||||
sqlite_rows_save(results, nrow, ncolumn, *result_);
|
||||
}
|
||||
}
|
||||
else if (results)
|
||||
{
|
||||
result_ = NULL;
|
||||
__sqlite3_free_table(results);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -564,7 +568,7 @@ bool db_sqlite::dbopen(const char*) { return false; }
|
||||
bool db_sqlite::is_opened() const { return false; }
|
||||
bool db_sqlite::close(void) { return false; }
|
||||
bool db_sqlite::tbl_exists(const char*) { return false; }
|
||||
bool db_sqlite::sql_select(const char*) { return false; }
|
||||
bool db_sqlite::sql_select(const char*, db_rows*) { return false; }
|
||||
bool db_sqlite::sql_update(const char*) { return false; }
|
||||
int db_sqlite::affect_count() const { return 0; }
|
||||
int db_sqlite::get_errno() const { return -1; }
|
||||
@ -572,4 +576,4 @@ const char* db_sqlite::get_error() const { return "unknown"; }
|
||||
|
||||
} // namespace acl
|
||||
|
||||
#endif // HAS_SQLITE
|
||||
#endif // !HAS_SQLITE && !HAS_SQLITE_DLL
|
||||
|
@ -342,7 +342,9 @@ redis_client* redis_command::redirect(redis_client_cluster* cluster,
|
||||
if (conn != NULL)
|
||||
return conn;
|
||||
|
||||
#ifdef AUTO_SET_ALIVE
|
||||
conns->set_alive(false);
|
||||
#endif
|
||||
conns = (redis_client_pool*) cluster->peek();
|
||||
if (conns == NULL)
|
||||
{
|
||||
@ -385,8 +387,10 @@ redis_client* redis_command::peek_conn(redis_client_cluster* cluster, int slot)
|
||||
// 取消哈希槽的地址映射关系
|
||||
cluster->clear_slot(slot);
|
||||
|
||||
#ifdef AUTO_SET_ALIVE
|
||||
// 将连接池对象置为不可用状态
|
||||
conns->set_alive(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
logger_warn("too many retry: %d, slot: %d", i, slot);
|
||||
@ -439,8 +443,10 @@ const redis_result* redis_command::run(redis_client_cluster* cluster,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef AUTO_SET_ALIVE
|
||||
// 将连接池对象置为不可用状态
|
||||
pool->set_alive(false);
|
||||
#endif
|
||||
|
||||
// 从连接池集群中顺序取得一个连接对象
|
||||
conn = peek_conn(cluster, slot_);
|
||||
|
@ -113,7 +113,8 @@ bool json_node::is_string(void) const
|
||||
bool json_node::is_number(void) const
|
||||
{
|
||||
return (node_me_->type & ACL_JSON_T_A_NUMBER)
|
||||
|| (node_me_->type & ACL_JSON_T_NUMBER);
|
||||
|| (node_me_->type & ACL_JSON_T_NUMBER)
|
||||
|| is_double();
|
||||
}
|
||||
|
||||
bool json_node::is_double(void) const
|
||||
@ -163,6 +164,8 @@ const char* json_node::get_type(void) const
|
||||
{
|
||||
if (is_string())
|
||||
return "string";
|
||||
else if (is_double())
|
||||
return "double";
|
||||
else if (is_number())
|
||||
return "number";
|
||||
else if (is_bool())
|
||||
|
@ -10,6 +10,7 @@ endif()
|
||||
|
||||
add_definitions(
|
||||
"-W"
|
||||
"-fPIC"
|
||||
"-Wall"
|
||||
"-Werror"
|
||||
"-Wshadow"
|
||||
@ -24,7 +25,6 @@ add_definitions(
|
||||
"-D_POSIX_PTHREAD_SEMANTICS"
|
||||
"-DACL_PREPARE_COMPILE"
|
||||
"-Wno-invalid-source-encoding"
|
||||
"-fPIC"
|
||||
"-Wstrict-prototypes"
|
||||
)
|
||||
|
||||
@ -40,17 +40,16 @@ else()
|
||||
add_definitions("-g")
|
||||
endif()
|
||||
|
||||
string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "ANDROID")
|
||||
#string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
add_definitions("-DANDROID")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "LINUX")
|
||||
add_definitions("-Wno-incompatible-pointer-types-discards-qualifiers")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
else()
|
||||
message(FATAL_ERROR "unknown CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "ANDROID")
|
||||
add_definitions("-Wno-incompatible-pointer-types-discards-qualifiers")
|
||||
endif()
|
||||
##############################################################################
|
||||
|
||||
set(src ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
@ -77,18 +76,18 @@ if(NOT CMAKE_SYSTEM_NAME MATCHES "ANDROID")
|
||||
set(lib_output_path ${PROJECT_BINARY_DIR}/lib)
|
||||
|
||||
set(LIBRARY_OUTPUT_PATH ${lib_output_path})
|
||||
add_library(_fiber_static STATIC ${lib_src})
|
||||
SET_TARGET_PROPERTIES(_fiber_static PROPERTIES OUTPUT_NAME "_fiber")
|
||||
add_library(fiber_static STATIC ${lib_src})
|
||||
SET_TARGET_PROPERTIES(fiber_static PROPERTIES OUTPUT_NAME "fiber")
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS
|
||||
-Wl,-rpath,. -L${lib_output_path} -l_acl)
|
||||
-Wl,-rpath,. -L${lib_output_path} -lacl)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
|
||||
link_directories(${lib_output_path})
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
add_library(_fiber SHARED ${lib_src})
|
||||
target_link_libraries(_fiber _acl)
|
||||
add_library(fiber SHARED ${lib_src})
|
||||
target_link_libraries(fiber acl)
|
||||
endif()
|
||||
|
||||
##############################################################################
|
||||
|
@ -8,7 +8,9 @@ ARFL = rv
|
||||
RANLIB = ${ENV_RANLIB}
|
||||
|
||||
CFLAGS = -c -g -W \
|
||||
-fPIC \
|
||||
-Wall \
|
||||
-Werror \
|
||||
-Wcast-qual \
|
||||
-Waggregate-return \
|
||||
-Wmissing-prototypes \
|
||||
@ -66,21 +68,18 @@ endif
|
||||
|
||||
# For FreeBSD
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
CFLAGS += -DFREEBSD -fPIC -Werror
|
||||
UNIXTYPE = FREEBSD
|
||||
endif
|
||||
|
||||
# For Darwin
|
||||
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
||||
CFLAGS += -DMACOSX -Wno-invalid-source-encoding \
|
||||
-Wno-extended-offsetof -fPIC -Werror
|
||||
-Wno-extended-offsetof
|
||||
UNIXTYPE = MACOSX
|
||||
endif
|
||||
|
||||
# For Linux
|
||||
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
|
||||
# CFLAGS += -DLINUX2 -fPIC -Werror
|
||||
CFLAGS += -fPIC -Werror
|
||||
UNIXTYPE = LINUX
|
||||
endif
|
||||
|
||||
@ -104,13 +103,13 @@ ifeq ($(findstring SunOS, $(UNIXNAME)), SunOS)
|
||||
ifeq ($(findstring sun4u, $(UNIXNAME)), sun4u)
|
||||
SYSLIB = -lsocket -lnsl -lrt
|
||||
endif
|
||||
CFLAGS += -DSUNOS5 -fPIC -Werror
|
||||
CFLAGS += -DSUNOS5
|
||||
UNIXTYPE = SUNOS5
|
||||
endif
|
||||
|
||||
# For HP-UX
|
||||
ifeq ($(findstring HP-UX, $(UNIXNAME)), HP-UX)
|
||||
CFLAGS += -DHP_UX -DHPUX11 -fPIC -Werror
|
||||
CFLAGS += -DHP_UX -DHPUX11
|
||||
UNIXTYPE = HPUX
|
||||
endif
|
||||
|
||||
@ -139,8 +138,8 @@ OBJ = $(patsubst %.c, $(OBJ_PATH_DST)/%.o, $(notdir $(SRC)))
|
||||
LIB_ACL_PATH = ../../lib_acl
|
||||
CFLAGS += -I $(LIB_ACL_PATH)/include -I$(LIB_ACL_PATH)/src/master
|
||||
|
||||
STATIC_LIBNAME = lib_fiber.a
|
||||
SHARED_LIBNAME = lib_fiber.so
|
||||
STATIC_LIBNAME = libfiber.a
|
||||
SHARED_LIBNAME = libfiber.so
|
||||
|
||||
###########################################################
|
||||
|
||||
|
@ -419,8 +419,11 @@ void acl_fiber_signal(ACL_FIBER *fiber, int signum)
|
||||
return;
|
||||
}
|
||||
|
||||
if (signum == SIGKILL || signum == SIGTERM || signum == SIGQUIT)
|
||||
if (signum == SIGKILL || signum == SIGTERM || signum == SIGQUIT) {
|
||||
fiber->errnum = ECANCELED;
|
||||
fiber->flag |= FIBER_F_KILLED;
|
||||
}
|
||||
|
||||
fiber->signum = signum;
|
||||
|
||||
if (fiber == curr) // just return if kill myself
|
||||
|
@ -321,8 +321,9 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
|
||||
fiber_wait_write(sockfd);
|
||||
|
||||
if (acl_fiber_killed(me)) {
|
||||
acl_msg_info("%s(%d), %s: fiber-%u was killed",
|
||||
__FILE__, __LINE__, __FUNCTION__, acl_fiber_id(me));
|
||||
acl_msg_info("%s(%d), %s: fiber-%u was killed, %s",
|
||||
__FILE__, __LINE__, __FUNCTION__,
|
||||
acl_fiber_id(me), acl_last_serror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -434,11 +435,12 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
||||
|
||||
fiber_io_check();
|
||||
|
||||
ev = fiber_io_event();
|
||||
pe.fds = fds;
|
||||
pe.nfds = nfds;
|
||||
pe.fiber = acl_fiber_running();
|
||||
pe.proc = poll_callback;
|
||||
ev = fiber_io_event();
|
||||
pe.fds = fds;
|
||||
pe.nfds = nfds;
|
||||
pe.fiber = acl_fiber_running();
|
||||
pe.proc = poll_callback;
|
||||
pe.nready = 0;
|
||||
|
||||
SET_TIME(begin);
|
||||
|
||||
@ -449,9 +451,10 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
||||
|
||||
if (acl_fiber_killed(pe.fiber)) {
|
||||
acl_ring_detach(&pe.me);
|
||||
acl_msg_info("%s(%d), %s: fiber-%u was killed",
|
||||
acl_msg_info("%s(%d), %s: fiber-%u was killed, %s",
|
||||
__FILE__, __LINE__, __FUNCTION__,
|
||||
acl_fiber_id(pe.fiber));
|
||||
acl_fiber_id(pe.fiber), acl_last_serror());
|
||||
pe.nready = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,8 @@
|
||||
|
||||
43) 2017.3.23
|
||||
43.1) feature: fiber.c 中 acl_fiber_signal/acl_fiber_kill 中,需要设置 errno
|
||||
为 ECANCELED
|
||||
|
||||
42) 2017.3.9
|
||||
42.1) compile: 当打开 valgrind 编译选项时,有一处编译警告
|
||||
42.2) workaround: master_fiber 类中的方法 run_alone 去掉最后一个参数,其原来用
|
||||
|
@ -8,6 +8,7 @@ endif()
|
||||
|
||||
add_definitions(
|
||||
"-W"
|
||||
"-fPIC"
|
||||
"-Wall"
|
||||
"-Werror"
|
||||
"-Wshadow"
|
||||
@ -40,10 +41,11 @@ else()
|
||||
add_definitions("-g")
|
||||
endif()
|
||||
|
||||
string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "ANDROID")
|
||||
#string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
add_definitions("-DANDROID")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "LINUX")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
else()
|
||||
message(FATAL_ERROR "unknown CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
@ -72,23 +74,23 @@ foreach(iter ${sources})
|
||||
aux_source_directory(${iter} lib_src)
|
||||
endforeach()
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME MATCHES "ANDROID")
|
||||
if(NOT CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
set(lib_output_path ${PROJECT_BINARY_DIR}/lib)
|
||||
|
||||
set(LIBRARY_OUTPUT_PATH ${lib_output_path})
|
||||
add_library(_fiber_cpp_static STATIC ${lib_src})
|
||||
SET_TARGET_PROPERTIES(_fiber_cpp_static PROPERTIES OUTPUT_NAME "_fiber_cpp")
|
||||
add_library(fiber_cpp_static STATIC ${lib_src})
|
||||
SET_TARGET_PROPERTIES(fiber_cpp_static PROPERTIES OUTPUT_NAME "fiber_cpp")
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS
|
||||
-Wl,-rpath,. -L${lib_output_path}
|
||||
-l_acl_cpp -l_protocol -l_fiber -l_acl)
|
||||
-lacl_cpp -lprotocol -lfiber -lacl)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
|
||||
link_directories(${lib_output_path})
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
add_library(_fiber_cpp SHARED ${lib_src})
|
||||
target_link_libraries(_fiber_cpp _acl_cpp _protocol _fiber _acl)
|
||||
add_library(fiber_cpp SHARED ${lib_src})
|
||||
target_link_libraries(fiber_cpp acl_cpp protocol fiber acl)
|
||||
endif()
|
||||
|
||||
##############################################################################
|
||||
|
@ -10,7 +10,9 @@ FLAGS = ${ENV_FLAGS}
|
||||
|
||||
CFLAGS = -c -g -W \
|
||||
-O3 \
|
||||
-fPIC \
|
||||
-Wall \
|
||||
-Werror \
|
||||
-Wpointer-arith \
|
||||
-Wshadow \
|
||||
-D_REENTRANT \
|
||||
@ -55,7 +57,6 @@ endif
|
||||
|
||||
# For FreeBSD
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
CFLAGS += -DFREEBSD -fPIC -Werror
|
||||
UNIXTYPE = FREEBSD
|
||||
shared_ldflags = -l_acl_cpp -l_protocol -l_acl -L/usr/local/lib -liconv -lz -lpthread
|
||||
endif
|
||||
@ -63,7 +64,7 @@ endif
|
||||
# For Darwin
|
||||
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
||||
CFLAGS += -DMACOSX -Wno-invalid-source-encoding \
|
||||
-Wno-extended-offsetof -fPIC -Werror \
|
||||
-Wno-extended-offsetof \
|
||||
-Wno-unused-private-field
|
||||
UNIXTYPE = MACOSX
|
||||
shared_ldflags = -l_acl_cpp -l_protocol -l_acl -L/usr/lib -liconv -lz -lpthread
|
||||
@ -71,8 +72,6 @@ endif
|
||||
|
||||
# For Linux
|
||||
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
|
||||
# CFLAGS += -DLINUX2 -fPIC -Werror
|
||||
CFLAGS += -fPIC -Werror
|
||||
UNIXTYPE = LINUX
|
||||
shared_ldflags = -l_acl_cpp -l_protocol -l_acl -lrt -lpthread -lz -ldl
|
||||
endif
|
||||
@ -91,13 +90,13 @@ ifeq ($(findstring SunOS, $(UNIXNAME)), SunOS)
|
||||
ifeq ($(findstring sun4u, $(UNIXNAME)), sun4u)
|
||||
SYSLIB = -lsocket -lnsl -lrt
|
||||
endif
|
||||
CFLAGS += -DSUNOS5 -fPIC -Werror
|
||||
CFLAGS += -DSUNOS5
|
||||
UNIXTYPE = SUNOS5
|
||||
endif
|
||||
|
||||
# For HP-UX
|
||||
ifeq ($(findstring HP-UX, $(UNIXNAME)), HP-UX)
|
||||
CFLAGS += -DHP_UX -DHPUX11 -fPIC -Werror
|
||||
CFLAGS += -DHP_UX -DHPUX11
|
||||
UNIXTYPE = HPUX
|
||||
endif
|
||||
|
||||
@ -123,8 +122,8 @@ OBJS_DEF = $(patsubst %.cpp, $(DEF_PATH_DST)/%.inc, $(notdir $(wildcard src/*.cp
|
||||
VERSION = 0.9
|
||||
DATE_NOW = 20`date +%y`.`date +%m`.`date +%d`
|
||||
|
||||
STATIC_LIBNAME = lib_fiber_cpp.a
|
||||
SHARED_LIBNAME = lib_fiber_cpp.so
|
||||
STATIC_LIBNAME = libfiber_cpp.a
|
||||
SHARED_LIBNAME = libfiber_cpp.so
|
||||
PCH = ./acl_stdafx.hpp.gch
|
||||
|
||||
lib: static
|
||||
@ -195,8 +194,8 @@ $(DEF_PATH_DST)/%.inc: ./src/%.cpp
|
||||
$(CREATE_DEF)
|
||||
|
||||
clean:
|
||||
rm -f $(LIB_PATH_DST)/lib_fiber_cpp.a
|
||||
rm -f $(LIB_PATH_DST)/lib_fiber_cpp.so
|
||||
rm -f $(LIB_PATH_DST)/libfiber_cpp.a
|
||||
rm -f $(LIB_PATH_DST)/libfiber_cpp.so
|
||||
rm -f $(OBJS_DST)
|
||||
rm -f $(OBJS_DEF)
|
||||
rm -f $(PCH)
|
||||
|
@ -110,8 +110,8 @@ FIBER_LIB = $(FIBER_PATH)/lib
|
||||
|
||||
EXTLIBS =
|
||||
CFLAGS += -I.. -I$(PRO_INC) -I$(ACL_INC) -I$(FIBER_INC)
|
||||
LDFLAGS = -L$(PRO_LIB) -l_protocol -L$(FIBER_LIB) -l_fiber \
|
||||
-L$(ACL_LIB) -l_acl $(EXTLIBS) $(SYSLIB)
|
||||
LDFLAGS = -L$(PRO_LIB) -lprotocol -L$(FIBER_LIB) -lfiber \
|
||||
-L$(ACL_LIB) -lacl $(EXTLIBS) $(SYSLIB)
|
||||
|
||||
###########################################################
|
||||
|
||||
|
@ -86,10 +86,10 @@ endif
|
||||
CFLAGS += -I.. -I../../../lib_acl/include -I../../../lib_protocol/include -I../../../lib_acl_cpp/include \
|
||||
-I../../../lib_fiber/c/include -I../../../lib_fiber/cpp/include
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L../../../lib_fiber/lib -l_fiber_cpp -l_fiber \
|
||||
-L../../../lib_acl_cpp/lib -l_acl_cpp \
|
||||
-L../../../lib_protocol/lib -l_protocol \
|
||||
-L../../../lib_acl/lib -l_acl \
|
||||
LDFLAGS = -L../../../lib_fiber/lib -lfiber_cpp -lfiber \
|
||||
-L../../../lib_acl_cpp/lib -lacl_cpp \
|
||||
-L../../../lib_protocol/lib -lprotocol \
|
||||
-L../../../lib_acl/lib -lacl \
|
||||
$(EXTLIBS) $(SYSLIB)
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
@ -8,6 +8,7 @@ endif()
|
||||
|
||||
add_definitions(
|
||||
"-W"
|
||||
"-fPIC"
|
||||
"-Wall"
|
||||
"-Werror"
|
||||
"-Wshadow"
|
||||
@ -22,7 +23,6 @@ add_definitions(
|
||||
"-D_POSIX_PTHREAD_SEMANTICS"
|
||||
"-DACL_PREPARE_COMPILE"
|
||||
"-Wno-invalid-source-encoding"
|
||||
"-fPIC"
|
||||
"-Wstrict-prototypes"
|
||||
)
|
||||
|
||||
@ -38,10 +38,11 @@ else()
|
||||
add_definitions("-g")
|
||||
endif()
|
||||
|
||||
string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "ANDROID")
|
||||
#string(TOUPPER ${CMAKE_SYSTEM_NAME} CMAKE_SYSTEM_NAME)
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
add_definitions("-DANDROID")
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "LINUX")
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
else()
|
||||
message(FATAL_ERROR "unknown CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
@ -65,25 +66,27 @@ set(sources
|
||||
${src}/icmp
|
||||
)
|
||||
|
||||
foreach(iter ${sources})
|
||||
foreach (iter ${sources})
|
||||
aux_source_directory(${iter} lib_src)
|
||||
endforeach()
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME MATCHES "ANDROID")
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-shared")
|
||||
else()
|
||||
set(lib_output_path ${PROJECT_BINARY_DIR}/lib)
|
||||
|
||||
set(LIBRARY_OUTPUT_PATH ${lib_output_path})
|
||||
add_library(_protocol_static STATIC ${lib_src})
|
||||
SET_TARGET_PROPERTIES(_protocol_static PROPERTIES OUTPUT_NAME "_protocol")
|
||||
add_library(protocol_static STATIC ${lib_src})
|
||||
SET_TARGET_PROPERTIES(protocol_static PROPERTIES OUTPUT_NAME "protocol")
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-rpath,. -L${lib_output_path} -l_acl")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-shared -Wl,-rpath,. -L${lib_output_path} -lacl")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${lib_output_path})
|
||||
link_directories(${lib_output_path})
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
add_library(_protocol SHARED ${lib_src})
|
||||
target_link_libraries(_protocol _acl)
|
||||
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
add_library(protocol SHARED ${lib_src})
|
||||
target_link_libraries(protocol acl)
|
||||
endif()
|
||||
|
||||
##############################################################################
|
||||
|
@ -9,7 +9,9 @@ RANLIB = ${ENV_RANLIB}
|
||||
|
||||
CFLAGS = -c -g -W \
|
||||
-O3 \
|
||||
-fPIC \
|
||||
-Wall \
|
||||
-Werror \
|
||||
-Wcast-qual \
|
||||
-Waggregate-return \
|
||||
-Wmissing-prototypes \
|
||||
@ -63,23 +65,18 @@ endif
|
||||
|
||||
# For FreeBSD
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
# CFLAGS += -DFREEBSD -fPIC -Werror
|
||||
CFLAGS += -fPIC -Werror
|
||||
UNIXTYPE = FREEBSD
|
||||
endif
|
||||
|
||||
# For Darwin
|
||||
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
||||
# CFLAGS += -DMACOSX -Wno-invalid-source-encoding
|
||||
CFLAGS += -Wno-invalid-source-encoding \
|
||||
-Wno-extended-offsetof -fPIC -Werror
|
||||
-Wno-extended-offsetof
|
||||
UNIXTYPE = MACOSX
|
||||
endif
|
||||
|
||||
# For Linux
|
||||
ifeq ($(findstring Linux, $(UNIXNAME)), Linux)
|
||||
# CFLAGS += -DLINUX2 -fPIC -Werror
|
||||
CFLAGS += -fPIC -Werror
|
||||
UNIXTYPE = LINUX
|
||||
endif
|
||||
|
||||
@ -103,13 +100,13 @@ ifeq ($(findstring SunOS, $(UNIXNAME)), SunOS)
|
||||
ifeq ($(findstring sun4u, $(UNIXNAME)), sun4u)
|
||||
SYSLIB = -lsocket -lnsl -lrt
|
||||
endif
|
||||
CFLAGS += -DSUNOS5 -fPIC -Werror
|
||||
CFLAGS += -DSUNOS5
|
||||
UNIXTYPE = SUNOS5
|
||||
endif
|
||||
|
||||
# For HP-UX
|
||||
ifeq ($(findstring HP-UX, $(UNIXNAME)), HP-UX)
|
||||
CFLAGS += -DHP_UX -DHPUX11 -fPIC -Werror
|
||||
CFLAGS += -DHP_UX -DHPUX11
|
||||
UNIXTYPE = HPUX
|
||||
endif
|
||||
|
||||
@ -147,8 +144,8 @@ OBJS_DST = $(BASE_OBJ) $(HTTP_OBJ) $(ICMP_OBJ) $(SMTP_OBJ)
|
||||
LIB_ACL_PATH = ../lib_acl
|
||||
CFLAGS += -I $(LIB_ACL_PATH)/include
|
||||
|
||||
STATIC_LIBNAME = lib_protocol.a
|
||||
SHARED_LIBNAME = lib_protocol.so
|
||||
STATIC_LIBNAME = libprotocol.a
|
||||
SHARED_LIBNAME = libprotocol.so
|
||||
|
||||
###########################################################
|
||||
|
||||
@ -163,6 +160,8 @@ static: $(OBJS_DST)
|
||||
@echo 'creating $(LIB_PATH_DST)/$(STATIC_LIBNAME)'
|
||||
$(AR) $(ARFL) $(LIB_PATH_DST)/$(STATIC_LIBNAME) $(OBJS_DST)
|
||||
$(RANLIB) $(LIB_PATH_DST)/$(STATIC_LIBNAME)
|
||||
@(cd $(LIB_PATH_DST); rm -f lib_protocol.a; \
|
||||
ln -s $(STATIC_LIBNAME) lib_protocol.a)
|
||||
@echo 'build $(LIB_PATH_DST)/$(STATIC_LIBNAME) ok!'
|
||||
|
||||
shared_ldflags = -l_acl -lrt -lpthread
|
||||
@ -209,12 +208,13 @@ $(OBJ_PATH_DST)/%.o: $(SRC_PATH_SRC)/smtp/%.c
|
||||
$(COMPILE) $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(LIB_PATH_DST)/libprotocol.a
|
||||
rm -f $(LIB_PATH_DST)/lib_protocol.a
|
||||
rm -f $(LIB_PATH_DST)/lib_protocol.so
|
||||
rm -f $(LIB_PATH_DST)/libprotocol.so
|
||||
rm -f $(OBJS_DST)
|
||||
|
||||
all_lib: $(OBJS_DST)
|
||||
@(cd debug; ar x ../../lib_acl/lib/lib_acl.a)
|
||||
$(AR) $(ARFL) $(LIB_PATH_DST)/lib_protocol.a debug/*.o
|
||||
$(RANLIB) $(LIB_PATH_DST)/lib_protocol.a
|
||||
$(AR) $(ARFL) $(LIB_PATH_DST)/libprotocol.a debug/*.o
|
||||
$(RANLIB) $(LIB_PATH_DST)/libprotocol.a
|
||||
@(cd debug; rm -f `ar -t ../../lib_acl/lib/lib_acl.a`)
|
||||
|
@ -113,7 +113,7 @@ PROTO_LIB = $(PROTO_PATH)/lib
|
||||
|
||||
EXTLIBS =
|
||||
CFLAGS += -I$(ACL_INC) -I$(PROTO_INC)
|
||||
LDFLAGS = -L$(ACL_LIB) -L$(PROTO_LIB) -l_protocol -l_acl $(EXTLIBS) $(SYSLIB)
|
||||
LDFLAGS = -L$(ACL_LIB) -L$(PROTO_LIB) -lprotocol -lacl $(EXTLIBS) $(SYSLIB)
|
||||
|
||||
###########################################################
|
||||
|
||||
|
@ -110,7 +110,7 @@ PROTO_LIB = $(PROTO_PATH)/lib
|
||||
|
||||
EXTLIBS =
|
||||
CFLAGS += -I$(ACL_INC) -I$(PROTO_INC)
|
||||
LDFLAGS = -L$(ACL_LIB) -L$(PROTO_LIB) -l_protocol -l_acl $(EXTLIBS) $(SYSLIB)
|
||||
LDFLAGS = -L$(ACL_LIB) -L$(PROTO_LIB) -lprotocol -lacl $(EXTLIBS) $(SYSLIB)
|
||||
|
||||
###########################################################
|
||||
|
||||
|
@ -85,7 +85,7 @@ CFLAGS += -I. -I$(ACL_INC) -I$(PRO_INC)
|
||||
COMPILE = $(CC) $(CFLAGS)
|
||||
|
||||
EXTLIBS =
|
||||
LDFLAGS = -L$(PRO_LIB) -l_protocol -L$(ACL_LIB) -l_acl $(EXTLIBS) $(SYSLIB)
|
||||
LDFLAGS = -L$(PRO_LIB) -lprotocol -L$(ACL_LIB) -lacl $(EXTLIBS) $(SYSLIB)
|
||||
LINKS = $(CC) -o $(PROG) $(OBJS) $(LDFLAGS)
|
||||
|
||||
OUT_PATH = ./
|
||||
|
@ -16,7 +16,7 @@ CFLAGS = -c -g -W \
|
||||
# -Wcast-align
|
||||
#-Waggregate-return
|
||||
|
||||
LDFLAGS = -Wl,-rpath,$(BASE_PATH) -L$(BASE_PATH) -l_acl \
|
||||
LDFLAGS = -Wl,-rpath,$(BASE_PATH) -L$(BASE_PATH) -lacl \
|
||||
$(EXTLIBS) $(SYSLIB)
|
||||
|
||||
###########################################################
|
||||
|
@ -85,7 +85,7 @@ ACL_LIB_PATH = $(ACL_HOME)/lib
|
||||
|
||||
CFLAGS += -I$(ACL_INC_PATH)
|
||||
|
||||
LINK_LIBS = -L$(ACL_LIB_PATH) -l_acl $(SYSLIB)
|
||||
LINK_LIBS = -L$(ACL_LIB_PATH) -lacl $(SYSLIB)
|
||||
|
||||
###########################################################
|
||||
OUT_PATH = .
|
||||
|
@ -75,7 +75,7 @@ ACL_LIB_PATH = $(ACL_HOME)/lib
|
||||
|
||||
CFLAGS += -I$(ACL_INC_PATH)
|
||||
|
||||
LINK_LIBS = -L$(ACL_LIB_PATH) -l_acl -L/opt/messenger/lib/glib/linux/lib -lglib-2.0 $(SYSLIB)
|
||||
LINK_LIBS = -L$(ACL_LIB_PATH) -lacl -L/opt/messenger/lib/glib/linux/lib -lglib-2.0 $(SYSLIB)
|
||||
|
||||
###########################################################
|
||||
OUT_PATH = .
|
||||
|
Loading…
Reference in New Issue
Block a user