hewei.it преди 4 години
родител
ревизия
727872b8c4
променени са 3 файла, в които са добавени 108 реда и са изтрити 117 реда
  1. 51 3
      BUILD.md
  2. 29 58
      README.md
  3. 28 56
      readme_cn.md

+ 51 - 3
BUILD.md

@@ -1,4 +1,4 @@
-## Required
+## Prequired
 
 - c99
 - c++11
@@ -6,7 +6,7 @@
 gcc4.8+, msvc2015 or later
 
 ## Makefile
-options modify config.mk
+options modify [config.mk](config.mk)
 ```
 ./configure
 make
@@ -14,7 +14,7 @@ sudo make install
 ```
 
 ## cmake
-options modify CMakeLists.txt
+options modify [CMakeLists.txt](CMakeLists.txt)
 ```
 mkdir build
 cd build
@@ -76,3 +76,51 @@ export CROSS_COMPILE=aarch64-linux-android-
 make clean
 make libhv
 ```
+
+## targets
+
+### lib
+- make libhv
+
+### examples
+- make examples
+
+### unittest
+- make unittest
+
+## options
+
+### compile WITH_OPENSSL
+Enable SSL in libhv is so easy, just only two apis:
+```
+// init ssl_ctx, see base/hssl.h
+hssl_ctx_t hssl_ctx_init(hssl_ctx_init_param_t* param);
+
+// enable ssl, see event/hloop.h
+int hio_enable_ssl(hio_t* io);
+```
+
+https is the best example.
+```
+sudo apt install openssl libssl-dev # ubuntu
+make clean
+make WITH_OPENSSL=yes
+# editor etc/httpd.conf => ssl = on
+bin/httpd -s restart -d
+bin/curl -v https://localhost:8080
+curl -v https://localhost:8080 --insecure
+```
+
+### compile WITH_CURL
+```
+make WITH_CURL=yes DEFINES="CURL_STATICLIB"
+```
+
+### compile WITH_NGHTTP2
+```
+sudo apt install libnghttp2-dev # ubuntu
+make clean
+make WITH_NGHTTP2=yes
+bin/httpd -d
+bin/curl -v localhost:8080 --http2
+```

+ 29 - 58
README.md

@@ -22,6 +22,7 @@ but simpler api and richer protocols.
 ## Getting Started
 
 run `./getting_started.sh`:
+
 ```shell
 git clone https://github.com/ithewei/libhv.git
 cd libhv
@@ -131,8 +132,32 @@ wrk -c 100 -t 4 -d 10s http://127.0.0.1:8080/
 **libhv(port:8080) vs nginx(port:80)**
 ![libhv-vs-nginx.png](html/downloads/libhv-vs-nginx.png)
 
-### More examples
-#### c version
+## BUILD
+
+see [BUILD.md](BUILD.md)
+
+Makefile:
+```shell
+./configure
+make
+sudo make install
+```
+
+or cmake:
+```shell
+mkdir build
+cd build
+cmake ..
+cmake --build .
+```
+
+or vcpkg:
+```shell
+vcpkg install libhv
+```
+
+## Examples
+### c version
 - [examples/hloop_test.c](examples/hloop_test.c)
 - [examples/tcp_echo_server.c](examples/tcp_echo_server.c)
 - [examples/tcp_chat_server.c](examples/tcp_chat_server.c)
@@ -140,7 +165,7 @@ wrk -c 100 -t 4 -d 10s http://127.0.0.1:8080/
 - [examples/udp_echo_server.c](examples/udp_echo_server.c)
 - [examples/nc.c](examples/nc.c)
 
-#### c++ version
+### c++ version
 - [evpp/EventLoop_test.cpp](evpp/EventLoop_test.cpp)
 - [evpp/EventLoopThread_test.cpp](evpp/EventLoopThread_test.cpp)
 - [evpp/EventLoopThreadPool_test.cpp](evpp/EventLoopThreadPool_test.cpp)
@@ -153,60 +178,7 @@ wrk -c 100 -t 4 -d 10s http://127.0.0.1:8080/
 - [examples/websocket_server_test.cpp](examples/websocket_server_test.cpp)
 - [examples/websocket_client_test.cpp](examples/websocket_client_test.cpp)
 
-## BUILD
-see [BUILD.md](BUILD.md)
-
-### lib
-- make libhv
-- sudo make install
-
-### examples
-- make examples
-
-### unittest
-- make unittest
-
-### compile options
-
-#### compile WITH_OPENSSL
-Enable SSL in libhv is so easy, just only two apis:
-```
-// init ssl_ctx, see base/hssl.h
-hssl_ctx_t hssl_ctx_init(hssl_ctx_init_param_t* param);
-
-// enable ssl, see event/hloop.h
-int hio_enable_ssl(hio_t* io);
-```
-
-https is the best example.
-```
-sudo apt install openssl libssl-dev # ubuntu
-make clean
-make WITH_OPENSSL=yes
-# editor etc/httpd.conf => ssl = on
-bin/httpd -s restart -d
-bin/curl -v https://localhost:8080
-curl -v https://localhost:8080 --insecure
-```
-
-#### compile WITH_CURL
-```
-make WITH_CURL=yes DEFINES="CURL_STATICLIB"
-```
-
-#### compile WITH_NGHTTP2
-```
-sudo apt install libnghttp2-dev # ubuntu
-make clean
-make WITH_NGHTTP2=yes
-bin/httpd -d
-bin/curl -v localhost:8080 --http2
-```
-
-#### other options
-see [config.mk](config.mk)
-
-### echo-servers
+## echo-servers
 ```shell
 cd echo-servers
 ./build.sh
@@ -215,4 +187,3 @@ cd echo-servers
 
 **echo-servers/benchmark**<br>
 ![echo-servers](html/downloads/echo-servers.png)
-

+ 28 - 56
readme_cn.md

@@ -130,7 +130,33 @@ wrk -c 100 -t 4 -d 10s http://127.0.0.1:8080/
 **libhv(port:8080) vs nginx(port:80)**
 ![libhv-vs-nginx.png](html/downloads/libhv-vs-nginx.png)
 
-### 更多入门示例
+## 构建
+
+见[BUILD.md](BUILD.md)
+
+libhv提供了三种构建方式:
+
+1、通过Makefile:
+```shell
+./configure
+make
+sudo make install
+```
+
+2、通过cmake:
+```shell
+mkdir build
+cd build
+cmake ..
+cmake --build .
+```
+
+3、通过vcpkg:
+```shell
+vcpkg install libhv
+```
+
+## 示例
 
 #### c版本
 - 事件循环: [examples/hloop_test.c](examples/hloop_test.c)
@@ -153,61 +179,7 @@ wrk -c 100 -t 4 -d 10s http://127.0.0.1:8080/
 - WebSocket服务端: [examples/websocket_server_test.cpp](examples/websocket_server_test.cpp)
 - WebSocket客户端: [examples/websocket_client_test.cpp](examples/websocket_client_test.cpp)
 
-## 构建
-
-见[BUILD.md](BUILD.md)
-
-### 库
-- make libhv
-- sudo make install
-
-### 示例
-- make examples
-
-### 单元测试
-- make unittest
-
-### 编译选项
-
-#### 编译WITH_OPENSSL
-在libhv中开启SSL非常简单,仅需要两个API接口:
-```
-// init ssl_ctx, see base/hssl.h
-hssl_ctx_t hssl_ctx_init(hssl_ctx_init_param_t* param);
-
-// enable ssl, see event/hloop.h
-int hio_enable_ssl(hio_t* io);
-```
-
-https就是做好的例子:
-```
-sudo apt install openssl libssl-dev # ubuntu
-make clean
-make WITH_OPENSSL=yes
-# editor etc/httpd.conf => ssl = on
-bin/httpd -s restart -d
-bin/curl -v https://localhost:8080
-curl -v https://localhost:8080 --insecure
-```
-
-#### 编译WITH_CURL
-```
-make WITH_CURL=yes DEFINES="CURL_STATICLIB"
-```
-
-#### 编译WITH_NGHTTP2
-```
-sudo apt install libnghttp2-dev # ubuntu
-make clean
-make WITH_NGHTTP2=yes
-bin/httpd -d
-bin/curl -v localhost:8080 --http2
-```
-
-#### 更多选项
-见[config.mk](config.mk)
-
-### echo-servers
+## 网络库比对
 ```shell
 cd echo-servers
 ./build.sh