Ver código fonte

add make install

hewei 6 anos atrás
pai
commit
6faf413f5e
6 arquivos alterados com 121 adições e 5 exclusões
  1. 3 0
      .gitignore
  2. 62 1
      Makefile
  3. 3 1
      Makefile.in
  4. 25 1
      README.md
  5. 25 1
      html/downloads/README.md
  6. 3 1
      http/server/HttpServer.h

+ 3 - 0
.gitignore

@@ -23,11 +23,14 @@ cscope*
 *.db
 
 tmp
+include
 lib
 bin
 dist
 build
 
+hconfig.h
+
 # test
 test
 

+ 62 - 1
Makefile

@@ -80,8 +80,69 @@ unittest: prepare
 	$(CC)  -g -Wall -std=c99   -I. -Ibase -Iprotocol -o bin/ftp        unittest/ftp_test.c           protocol/ftp.c  base/hsocket.c
 	$(CC)  -g -Wall -std=c99   -I. -Ibase -Iutils -Iprotocol -o bin/sendmail  unittest/sendmail_test.c  protocol/smtp.c base/hsocket.c utils/base64.c
 
+INSTALL_HEADERS=hv.h\
+				\
+				hconfig.h\
+				base/hplatform.h\
+				\
+				base/hdef.h\
+				base/hversion.h\
+				base/hbase.h\
+				base/hsysinfo.h\
+				base/hproc.h\
+				base/hmath.h\
+				base/htime.h\
+				base/herr.h\
+				base/hlog.h\
+				base/hmutex.h\
+				base/hthread.h\
+				base/hsocket.h\
+				base/hbuf.h\
+				base/hurl.h\
+				base/hgui.h\
+				base/ssl_ctx.h\
+				\
+				base/hstring.h\
+				base/hvar.h\
+				base/hobj.h\
+				base/hfile.h\
+				base/hdir.h\
+				base/hscope.h\
+				base/hthreadpool.h\
+				base/hobjectpool.h\
+				\
+				utils/base64.h\
+				utils/md5.h\
+				utils/json.hpp\
+				utils/singleton.h\
+				utils/ifconfig.h\
+				utils/iniparser.h\
+				utils/hendian.h\
+				utils/hmain.h\
+				\
+				event/hloop.h\
+				event/nlog.h\
+				event/nmap.h\
+				\
+				http/httpdef.h\
+				http/http2def.h\
+				http/grpcdef.h\
+				http/http_content.h\
+				http/HttpMessage.h\
+				http/client/http_client.h\
+				http/server/HttpService.h\
+				http/server/HttpServer.h\
+				\
+				protocol/icmp.h\
+				protocol/dns.h\
+				protocol/ftp.h\
+				protocol/smtp.h
+install:
+	-mkdir include
+	-cp $(INSTALL_HEADERS) include/
+
 # UNIX only
 webbench: prepare
 	$(CC) -o bin/webbench unittest/webbench.c
 
-.PHONY: clean prepare libhv test timer loop tcp udp nc nmap httpd curl unittest webbench
+.PHONY: clean prepare libhv test timer loop tcp udp nc nmap httpd curl unittest webbench install

+ 3 - 1
Makefile.in

@@ -19,7 +19,7 @@
 # VARIABLES
 TARGET=test
 #BUILD_TYPE=DEBUG,RELEASE
-BUILD_TYPE=DEBUG
+BUILD_TYPE=RELEASE
 #TARGET_TYPE=EXECUTABLE,SHARED,STATIC
 TARGET_TYPE=EXECUTABLE
 
@@ -105,6 +105,8 @@ endif
 
 ifeq ($(BUILD_TYPE), DEBUG)
 	CPPFLAGS += -DDEBUG
+else
+	CPPFLAGS += -DNDEBUG
 endif
 
 CPPFLAGS += $(addprefix -D, $(DEFINES))

+ 25 - 1
README.md

@@ -10,7 +10,7 @@ but simpler apis and richer protocols.
 
 - cross-platform (Linux, Windows, Mac)
 - event-loop (IO, timer, idle)
-- http client/server (include https http1/x http2 grpc websocket)
+- http client/server (include https http1/x http2 grpc)
 - protocols
     - dns
     - ftp
@@ -30,6 +30,29 @@ but simpler apis and richer protocols.
 ## Getting Started
 
 ### http
+see examples/httpd.cpp
+```
+#include "http_server.h"
+
+int http_api_hello(HttpRequest* req, HttpResponse* res) {
+    res->body = "hello";
+    return 0;
+}
+
+int main() {
+    HttpService service;
+    service.base_url = "/v1/api";
+    service.AddApi("/hello", http_api_hello);
+
+    http_server_t server;
+    server.port = 8080;
+    server.worker_processes = 4;
+    server.service = &service;
+    http_server_run(&server);
+    return 0;
+}
+```
+
 ```shell
 git clone https://github.com/ithewei/libhv.git
 cd libhv
@@ -123,6 +146,7 @@ bin/nc -u 2222
 
 ### lib
 - make libhv
+- make install
 
 ### examples
 - make test # master-workers model

+ 25 - 1
html/downloads/README.md

@@ -10,7 +10,7 @@ but simpler apis and richer protocols.
 
 - cross-platform (Linux, Windows, Mac)
 - event-loop (IO, timer, idle)
-- http client/server (include https http1/x http2 grpc websocket)
+- http client/server (include https http1/x http2 grpc)
 - protocols
     - dns
     - ftp
@@ -30,6 +30,29 @@ but simpler apis and richer protocols.
 ## Getting Started
 
 ### http
+see examples/httpd.cpp
+```
+#include "http_server.h"
+
+int http_api_hello(HttpRequest* req, HttpResponse* res) {
+    res->body = "hello";
+    return 0;
+}
+
+int main() {
+    HttpService service;
+    service.base_url = "/v1/api";
+    service.AddApi("/hello", http_api_hello);
+
+    http_server_t server;
+    server.port = 8080;
+    server.worker_processes = 4;
+    server.service = &service;
+    http_server_run(&server);
+    return 0;
+}
+```
+
 ```shell
 git clone https://github.com/ithewei/libhv.git
 cd libhv
@@ -123,6 +146,7 @@ bin/nc -u 2222
 
 ### lib
 - make libhv
+- make install
 
 ### examples
 - make test # master-workers model

+ 3 - 1
http/server/HttpServer.h

@@ -33,12 +33,14 @@ typedef struct http_server_s {
 /*
 #include "http_server.h"
 
-void http_api_hello(HttpRequest* req, HttpResponse* res) {
+int http_api_hello(HttpRequest* req, HttpResponse* res) {
     res->body = "hello";
+    return 0;
 }
 
 int main() {
     HttpService service;
+    service.base_url = "/v1/api";
     service.AddApi("/hello", http_api_hello);
 
     http_server_t server;