ithewei 5 yıl önce
ebeveyn
işleme
acc25f2fa1

+ 21 - 15
.travis.yml

@@ -2,22 +2,28 @@ language: cpp
 
 compiler: gcc
 
-os:
-    - linux
-    - osx
+jobs:
+  include:
+    - os: linux
+      dist: xenial
+      env: COVERALLS=no
+    - os: osx
+      env: COVERALLS=no
 
-#before_install:
-  #- pip install --user cpp-coveralls
+before_script:
+  - if [ "$COVERALLS" = "yes" ]; then
+      pip install --user cpp-coveralls;
+      export CC="$CC --coverage" CXX="$CXX --coverage";
+    fi
 
 script:
-    - ./configure
-    - make unittest
-    - make all
+  - ./configure
+  - make libhv
+  - make unittest
+  - make examples
 
-#after_success:
-    #- coveralls
-        #--exclude cert
-        #--exclude crc
-        #--exclude etc
-        #--exclude html
-        #--gcov-options '\-lp';
+after_success:
+  - if [ "$COVERALLS" = "yes" ]; then
+      scripts/test-coverage.sh;
+      coveralls --gcov-options '\-lp' --include base --include event --include http;
+    fi

+ 2 - 1
CMakeLists.txt

@@ -1,6 +1,6 @@
 cmake_minimum_required(VERSION 3.0)
 
-project(hv VERSION 1.20)
+project(hv VERSION 1.20.8)
 
 option(BUILD_SHARED "build shared library" ON)
 option(BUILD_STATIC "build static library" ON)
@@ -169,6 +169,7 @@ if(BUILD_STATIC)
     add_custom_target(libhv_static DEPENDS hv_static)
 endif()
 
+file(INSTALL ${LIBHV_HEADERS} DESTINATION include/hv)
 install(FILES ${LIBHV_HEADERS} DESTINATION include/hv)
 
 add_subdirectory(unittest)

+ 2 - 4
README.md

@@ -187,8 +187,6 @@ bin/nc 127.0.0.1 10514
 - make unittest
 
 ### compile options
-#### compile with print debug info
-- make DEFINES=PRINT_DEBUG
 
 #### compile WITH_OPENSSL
 libhv combines OpenSSL perfectly, something almost all asynchronous IO network libraries don't do.<br>
@@ -203,7 +201,7 @@ int hio_enable_ssl(hio_t* io);
 
 https is the best example.
 ```
-sudo apt-get install openssl libssl-dev # ubuntu
+sudo apt install openssl libssl-dev # ubuntu
 make clean
 make libhv httpd curl WITH_OPENSSL=yes
 # editor etc/httpd.conf => ssl = on
@@ -217,7 +215,7 @@ curl -v https://localhost:8080 --insecure
 
 #### compile WITH_NGHTTP2
 ```
-sudo apt-get install libnghttp2-dev # ubuntu
+sudo apt install libnghttp2-dev # ubuntu
 make clean
 make libhv httpd curl WITH_NGHTTP2=yes
 bin/httpd -d

+ 1 - 3
base/hatomic.h

@@ -14,7 +14,7 @@ using std::atomic_long;
 
 #else
 
-#include "hconfig.h"    // for HAVE_STDATOMIC_H
+#include "hplatform.h"  // for HAVE_STDATOMIC_H
 #if HAVE_STDATOMIC_H
 
 // c11
@@ -29,8 +29,6 @@ using std::atomic_long;
 
 #else
 
-#include "hplatform.h"  // for bool, size_t
-
 typedef volatile bool               atomic_bool;
 typedef volatile char               atomic_char;
 typedef volatile unsigned char      atomic_uchar;

+ 1 - 1
base/hversion.h

@@ -8,7 +8,7 @@ BEGIN_EXTERN_C
 
 #define HV_VERSION_MAJOR    1
 #define HV_VERSION_MINOR    20
-#define HV_VERSION_PATCH    7
+#define HV_VERSION_PATCH    8
 
 #define HV_VERSION_STRING   STRINGIFY(HV_VERSION_MAJOR) "." \
                             STRINGIFY(HV_VERSION_MINOR) "." \

+ 1 - 1
hconfig.h

@@ -10,7 +10,7 @@
 #endif
 
 #ifndef HAVE_STDATOMIC_H
-#define HAVE_STDATOMIC_H 0
+#define HAVE_STDATOMIC_H 1
 #endif
 
 #ifndef HAVE_SYS_TYPES_H

+ 2 - 4
readme_cn.md

@@ -186,8 +186,6 @@ bin/nc 127.0.0.1 10514
 - make unittest
 
 ### 编译选项
-#### 打印调试信息
-- make DEFINES=PRINT_DEBUG
 
 #### 编译WITH_OPENSSL
 libhv完美结合了OpenSSL库,这是几乎所有的异步IO库没有做的一点。
@@ -202,7 +200,7 @@ int hio_enable_ssl(hio_t* io);
 
 https就是做好的例子:
 ```
-sudo apt-get install openssl libssl-dev # ubuntu
+sudo apt install openssl libssl-dev # ubuntu
 make clean
 make libhv httpd curl WITH_OPENSSL=yes
 # editor etc/httpd.conf => ssl = on
@@ -216,7 +214,7 @@ curl -v https://localhost:8080 --insecure
 
 #### 编译WITH_NGHTTP2
 ```
-sudo apt-get install libnghttp2-dev # ubuntu
+sudo apt install libnghttp2-dev # ubuntu
 make clean
 make libhv httpd curl WITH_NGHTTP2=yes
 bin/httpd -d

+ 0 - 1
scripts/cmake.sh

@@ -1 +0,0 @@
-cmake .. -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_SYSTEM_NAME=$H_TARGET_OS -DCMAKE_SYSTEM_PROCESSOR=$H_TARGET_ARCH

+ 25 - 0
scripts/cmake_cross_compile.sh

@@ -0,0 +1,25 @@
+#!/bin/bash
+
+SCRIPT_DIR=$(cd `dirname $0`; pwd)
+ROOT_DIR=${SCRIPT_DIR}/..
+
+if [ $# -gt 0 ]; then
+CROSS_COMPILE=$1
+else
+sudo apt install g++-arm-linux-gnueabi
+CROSS_COMPILE=arm-linux-gnueabi-
+fi
+echo CROSS_COMPILE=${CROSS_COMPILE}
+
+cd ${ROOT_DIR}
+. scripts/toolchain.sh export ${CROSS_COMPILE}
+BUILD_DIR=build/${HV_TARGET_OS}/${HV_TARGET_ARCH}
+echo BUILD_DIR=${BUILD_DIR}
+mkdir -p ${BUILD_DIR}
+cd ${BUILD_DIR}
+cmake ../../.. -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_SYSTEM_NAME=$HV_TARGET_OS -DCMAKE_SYSTEM_PROCESSOR=$HV_TARGET_ARCH
+make libhv libhv_static
+cd ${ROOT_DIR}
+. scripts/toolchain.sh unset ${CROSS_COMPILE}
+
+echo 'Completed => ${BUILD_DIR}'

+ 5 - 3
scripts/libhv.cmake

@@ -1,7 +1,9 @@
 set(CMAKE_C_COMPILER $CC)
 set(CMAKE_CXX_COMPILER $CXX)
 
-set(CMAKE_SYSTEM_NAME $H_TARGET_OS)
-set(CMAKE_SYSTEM_PROCESSOR $H_TARGET_ARCH)
+set(CMAKE_SYSTEM_NAME $HV_TARGET_OS)
+set(CMAKE_SYSTEM_PROCESSOR $HV_TARGET_ARCH)
 
-add_definitions(-D_WIN32_WINNT=0x600)
+if(WIN32)
+    add_definitions(-D_WIN32_WINNT=0x600)
+endif()

+ 39 - 0
scripts/test-coverage.sh

@@ -0,0 +1,39 @@
+#!/bin/bash
+
+SCRIPT_DIR=$(cd `dirname $0`; pwd)
+ROOT_DIR=${SCRIPT_DIR}/..
+cd ${ROOT_DIR}
+
+bin/httpd -c etc/httpd.conf -s restart -d
+
+bin/ls
+bin/date
+bin/ifconfig
+bin/mkdir_p 123/456
+bin/rmdir_p 123/456
+
+bin/defer_test
+bin/hstring_test
+bin/hatomic_test
+bin/hatomic_cpp_test
+bin/hmutex_test
+bin/socketpair_test
+bin/threadpool_test
+bin/objectpool_test
+
+bin/curl -v localhost:8080
+bin/curl -v localhost:8080/ping
+bin/curl -v localhost:8080/echo -d "hello,world!"
+bin/curl -v localhost:8080/query?page_no=1\&page_size=10
+bin/curl -v localhost:8080/kv   -H "Content-Type:application/x-www-form-urlencoded" -d 'user=admin&pswd=123456'
+bin/curl -v localhost:8080/json -H "Content-Type:application/json" -d '{"user":"admin","pswd":"123456"}'
+bin/curl -v localhost:8080/form -F "user=admin pswd=123456"
+bin/curl -v localhost:8080/upload -F "file=@LICENSE"
+bin/curl -v localhost:8080/test -H "Content-Type:application/x-www-form-urlencoded" -d 'bool=1&int=123&float=3.14&string=hello'
+bin/curl -v localhost:8080/test -H "Content-Type:application/json" -d '{"bool":true,"int":123,"float":3.14,"string":"hello"}'
+bin/curl -v localhost:8080/test -F 'bool=1 int=123 float=3.14 string=hello'
+bin/curl -v -X DELETE localhost:8080/group/test/user/123
+
+bin/httpd -s stop
+
+bin/htimer_test

+ 8 - 8
scripts/toolchain.sh

@@ -54,10 +54,10 @@ main() {
             *) TARGET_OS=Linux ;;
         esac
         # TARGET_OS,TARGET_ARCH used by make
-        export H_HOST_OS=$HOST_OS
-        export H_HOST_ARCH=$HOST_ARCH
-        export H_TARGET_OS=$TARGET_OS
-        export H_TARGET_ARCH=$TARGET_ARCH
+        export HV_HOST_OS=$HOST_OS
+        export HV_HOST_ARCH=$HOST_ARCH
+        export HV_TARGET_OS=$TARGET_OS
+        export HV_TARGET_ARCH=$TARGET_ARCH
         export HOST=$TARGET_PLATFORM
     elif [ $COMMAND = "unset" ]; then
         unset  CROSS_COMPILE
@@ -95,7 +95,7 @@ echo "STRIP  =   $STRIP"
 echo "RANLIB =   $RANLIB"
 echo "NM     =   $NM"
 
-echo "H_HOST_OS     = $HOST_OS"
-echo "H_HOST_ARCH   = $HOST_ARCH"
-echo "H_TARGET_OS   = $TARGET_OS"
-echo "H_TARGET_ARCH = $TARGET_ARCH"
+echo "HV_HOST_OS     = $HOST_OS"
+echo "HV_HOST_ARCH   = $HOST_ARCH"
+echo "HV_TARGET_OS   = $TARGET_OS"
+echo "HV_TARGET_ARCH = $TARGET_ARCH"