Browse Source

make evpp

hewei.it 4 years ago
parent
commit
a12be753c2
4 changed files with 38 additions and 43 deletions
  1. 2 2
      .travis.yml
  2. 31 22
      Makefile
  3. 1 1
      evpp/EventLoop_test.cpp
  4. 4 18
      evpp/build_test.sh

+ 2 - 2
.travis.yml

@@ -9,7 +9,7 @@ jobs:
       script:
         - ./configure
         - make clean
-        - make libhv examples unittest
+        - make libhv examples unittest evpp
 
     - os: osx
       compiler: clang
@@ -17,7 +17,7 @@ jobs:
       scrit:
         - ./configure
         - make clean
-        - make libhv examples unittest
+        - make libhv examples unittest evpp
 
     - os: windows
       compiler: msvc

+ 31 - 22
Makefile

@@ -57,7 +57,7 @@ libhv:
 install:
 	$(MKDIR) $(INSTALL_INCDIR)
 	$(CP) include/hv/* $(INSTALL_INCDIR)
-	$(CP) lib/libhv.a lib/libhv.so $(INSTALL_LIBDIR)
+	$(CP) lib/libhv.*  $(INSTALL_LIBDIR)
 
 hmain_test: prepare
 	$(MAKEF) TARGET=$@ SRCDIRS=". base utils" SRCS="examples/hmain_test.cpp"
@@ -109,26 +109,35 @@ consul_cli: prepare
 	$(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/client consul" SRCS="examples/consul_cli.cpp" DEFINES="PRINT_DEBUG"
 
 unittest: prepare
-	$(CC)  -g -Wall -std=c99   -I. -Ibase            -o bin/mkdir_p           unittest/mkdir_test.c         base/hbase.c
-	$(CC)  -g -Wall -std=c99   -I. -Ibase            -o bin/rmdir_p           unittest/rmdir_test.c         base/hbase.c
-	$(CC)  -g -Wall -std=c99   -I. -Ibase            -o bin/date              unittest/date_test.c          base/htime.c
-	$(CC)  -g -Wall -std=c99   -I. -Ibase            -o bin/hatomic_test      unittest/hatomic_test.c       -pthread
-	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/hatomic_cpp_test  unittest/hatomic_test.cpp     -pthread
-	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/hthread_test      unittest/hthread_test.cpp     -pthread
-	$(CC)  -g -Wall -std=c99   -I. -Ibase            -o bin/hmutex_test       unittest/hmutex_test.c        base/htime.c   -pthread
-	$(CC)  -g -Wall -std=c99   -I. -Ibase            -o bin/connect_test      unittest/connect_test.c       base/hsocket.c base/htime.c
-	$(CC)  -g -Wall -std=c99   -I. -Ibase            -o bin/socketpair_test   unittest/socketpair_test.c    base/hsocket.c
-	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/defer_test        unittest/defer_test.cpp
-	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/synchronized_test unittest/synchronized_test.cpp -pthread
-	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/hstring_test      unittest/hstring_test.cpp     base/hstring.cpp
-	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/threadpool_test   unittest/threadpool_test.cpp  -pthread
-	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/objectpool_test   unittest/objectpool_test.cpp  -pthread
-	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/ls                unittest/listdir_test.cpp     base/hdir.cpp
-	$(CXX) -g -Wall -std=c++11 -I. -Ibase            -o bin/ifconfig          unittest/ifconfig_test.cpp    base/ifconfig.cpp
-	$(CC)  -g -Wall -std=c99   -I. -Ibase -Iprotocol -o bin/nslookup          unittest/nslookup_test.c      protocol/dns.c
-	$(CC)  -g -Wall -std=c99   -I. -Ibase -Iprotocol -o bin/ping              unittest/ping_test.c          protocol/icmp.c base/hsocket.c base/htime.c -DPRINT_DEBUG
-	$(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
+	$(CC)  -g -Wall -O0 -std=c99   -I. -Ibase            -o bin/mkdir_p           unittest/mkdir_test.c         base/hbase.c
+	$(CC)  -g -Wall -O0 -std=c99   -I. -Ibase            -o bin/rmdir_p           unittest/rmdir_test.c         base/hbase.c
+	$(CC)  -g -Wall -O0 -std=c99   -I. -Ibase            -o bin/date              unittest/date_test.c          base/htime.c
+	$(CC)  -g -Wall -O0 -std=c99   -I. -Ibase            -o bin/hatomic_test      unittest/hatomic_test.c       -pthread
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase            -o bin/hatomic_cpp_test  unittest/hatomic_test.cpp     -pthread
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase            -o bin/hthread_test      unittest/hthread_test.cpp     -pthread
+	$(CC)  -g -Wall -O0 -std=c99   -I. -Ibase            -o bin/hmutex_test       unittest/hmutex_test.c        base/htime.c   -pthread
+	$(CC)  -g -Wall -O0 -std=c99   -I. -Ibase            -o bin/connect_test      unittest/connect_test.c       base/hsocket.c base/htime.c
+	$(CC)  -g -Wall -O0 -std=c99   -I. -Ibase            -o bin/socketpair_test   unittest/socketpair_test.c    base/hsocket.c
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase            -o bin/defer_test        unittest/defer_test.cpp
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase            -o bin/synchronized_test unittest/synchronized_test.cpp -pthread
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase            -o bin/hstring_test      unittest/hstring_test.cpp     base/hstring.cpp
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase            -o bin/threadpool_test   unittest/threadpool_test.cpp  -pthread
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase            -o bin/objectpool_test   unittest/objectpool_test.cpp  -pthread
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase            -o bin/ls                unittest/listdir_test.cpp     base/hdir.cpp
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase            -o bin/ifconfig          unittest/ifconfig_test.cpp    base/ifconfig.cpp
+	$(CC)  -g -Wall -O0 -std=c99   -I. -Ibase -Iprotocol -o bin/nslookup          unittest/nslookup_test.c      protocol/dns.c
+	$(CC)  -g -Wall -O0 -std=c99   -I. -Ibase -Iprotocol -o bin/ping              unittest/ping_test.c          protocol/icmp.c base/hsocket.c base/htime.c -DPRINT_DEBUG
+	$(CC)  -g -Wall -O0 -std=c99   -I. -Ibase -Iprotocol -o bin/ftp               unittest/ftp_test.c           protocol/ftp.c  base/hsocket.c
+	$(CC)  -g -Wall -O0 -std=c99   -I. -Ibase -Iutils -Iprotocol -o bin/sendmail  unittest/sendmail_test.c      protocol/smtp.c base/hsocket.c utils/base64.c
+
+evpp: prepare libhv
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Ievpp -o bin/EventLoop_test           evpp/EventLoop_test.cpp           -Llib -lhv -lpthread
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Ievpp -o bin/EventLoopThread_test     evpp/EventLoopThread_test.cpp     -Llib -lhv -lpthread
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Ievpp -o bin/EventLoopThreadPool_test evpp/EventLoopThreadPool_test.cpp -Llib -lhv -lpthread
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Ievpp -o bin/TcpServer_test           evpp/TcpServer_test.cpp           -Llib -lhv -lpthread
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Ievpp -o bin/TcpClient_test           evpp/TcpClient_test.cpp           -Llib -lhv -lpthread
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Ievpp -o bin/UdpServer_test           evpp/UdpServer_test.cpp           -Llib -lhv -lpthread
+	$(CXX) -g -Wall -O0 -std=c++11 -I. -Ibase -Ievent -Ievpp -o bin/UdpClient_test           evpp/UdpClient_test.cpp           -Llib -lhv -lpthread
 
 # UNIX only
 webbench: prepare
@@ -143,4 +152,4 @@ echo-servers:
 	$(CXX) -g -Wall -std=c++11 -o bin/poco_echo     echo-servers/poco_echo.cpp   -lPocoNet -lPocoUtil -lPocoFoundation
 	$(CXX) -g -Wall -std=c++11 -o bin/muduo_echo    echo-servers/muduo_echo.cpp  -lmuduo_net -lmuduo_base -lpthread
 
-.PHONY: clean prepare libhv install examples nc nmap httpd curl consul_cli unittest webbench echo-servers
+.PHONY: clean prepare libhv install examples nc nmap httpd curl consul_cli unittest evpp webbench echo-servers

+ 1 - 1
evpp/EventLoop_test.cpp

@@ -3,7 +3,7 @@
  *
  * @build
  * make libhv && sudo make install
- * g++ -std=c++11 EventLoop_test.cpp -o EventLoop_test -I/usr/local/include/hv -lhv
+ * g++ -std=c++11 EventLoop_test.cpp -o EventLoop_test -I/usr/local/include/hv -lhv -lpthread
  *
  */
 

+ 4 - 18
evpp/build_test.sh

@@ -1,21 +1,7 @@
 #!/bin/bash
 
-CC=gcc
-CXX=g++
-CFLAGS="-g -O0 -Wall"
-CXXFLAGS="-std=c++11"
-INCFLAGS="-I/usr/local/include/hv"
-LDFLAGS="-lhv -lpthread"
+SCRIPT_DIR=$(cd `dirname $0`; pwd)
+ROOT_DIR=${SCRIPT_DIR}/..
 
-# EventLoop
-$CXX $CFLAGS $CXXFLAGS EventLoop_test.cpp -o EventLoop_test $INCFLAGS $LDFLAGS
-$CXX $CFLAGS $CXXFLAGS EventLoopThread_test.cpp -o EventLoopThread_test $INCFLAGS $LDFLAGS
-$CXX $CFLAGS $CXXFLAGS EventLoopThreadPool_test.cpp -o EventLoopThreadPool_test $INCFLAGS $LDFLAGS
-
-# TCP
-$CXX $CFLAGS $CXXFLAGS TcpServer_test.cpp -o TcpServer_test $INCFLAGS $LDFLAGS
-$CXX $CFLAGS $CXXFLAGS TcpClient_test.cpp -o TcpClient_test $INCFLAGS $LDFLAGS
-
-# UDP
-$CXX $CFLAGS $CXXFLAGS UdpServer_test.cpp -o UdpServer_test $INCFLAGS $LDFLAGS
-$CXX $CFLAGS $CXXFLAGS UdpClient_test.cpp -o UdpClient_test $INCFLAGS $LDFLAGS
+cd ${ROOT_DIR}
+make evpp