hewei 6 年之前
父節點
當前提交
224e5e8b7f

+ 16 - 38
Makefile

@@ -1,21 +1,19 @@
 include Makefile.vars
 
 MAKEF=$(MAKE) -f Makefile.in
-TMPDIR=tmp
 
 default: all
 all: libhv examples
 examples: test timer loop tcp udp nc nmap httpd curl consul_cli
 
 clean:
-	$(MAKEF) clean SRCDIRS=". base utils event http http/client http/server protocol examples consul $(TMPDIR)"
+	$(MAKEF) clean SRCDIRS=". base utils event http http/client http/server protocol consul examples"
 
 prepare:
-	$(MKDIR) -p $(TMPDIR) lib bin
-	$(RM) base/RAII.o
+	$(MKDIR) bin
 
-libhv: prepare
-	$(RM) include
+libhv:
+	$(MKDIR) lib
 	$(MAKEF) TARGET=$@ TARGET_TYPE=SHARED SRCDIRS=". base utils event http http/client http/server protocol"
 	$(MAKEF) TARGET=$@ TARGET_TYPE=STATIC SRCDIRS=". base utils event http http/client http/server protocol"
 	$(MKDIR) include/hv
@@ -27,60 +25,40 @@ install:
 	$(CP) lib/libhv.a lib/libhv.so $(INSTALL_LIBDIR)
 
 test: prepare
-	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
-	cp main.cpp.tmpl $(TMPDIR)/main.cpp
-	$(MAKEF) TARGET=$@ SRCDIRS=". base utils $(TMPDIR)"
+	$(MAKEF) TARGET=$@ SRCDIRS=". base utils" SRCS="examples/hmain_test.cpp"
 
 timer: prepare
-	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
-	cp examples/timer.c $(TMPDIR)
-	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
+	$(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/htimer_test.c"
 
 loop: prepare
-	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
-	cp examples/loop.c $(TMPDIR)
-	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
+	$(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/hloop_test.c"
 
 tcp: prepare
-	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
-	cp examples/tcp.c $(TMPDIR)
-	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
+	$(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/tcp.c"
 
 udp: prepare
-	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
-	cp examples/udp.c $(TMPDIR)
-	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
+	$(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/udp.c"
 
 nc: prepare
-	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
-	cp examples/nc.c $(TMPDIR)
-	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
+	$(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/nc.c"
 
 nmap: prepare
-	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
-	cp examples/nmap.cpp $(TMPDIR)
 ifeq ($(OS), Windows)
 	# for nmap on Windows platform, recommand EVENT_POLL, not EVENT_IOCP
-	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)" DEFINES="$(DEFINES) PRINT_DEBUG EVENT_POLL"
+	$(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/nmap.cpp" DEFINES="$(DEFINES) PRINT_DEBUG EVENT_POLL"
 else
-	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)" DEFINES="$(DEFINES) PRINT_DEBUG"
+	$(MAKEF) TARGET=$@ SRCDIRS=". base event" SRCS="examples/nmap.cpp" DEFINES="$(DEFINES) PRINT_DEBUG"
 endif
 
 httpd: prepare
-	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
-	cp examples/httpd.cpp examples/http_api_test.h $(TMPDIR)
-	$(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/server $(TMPDIR)"
+	$(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/server examples/httpd"
 
 curl: prepare
-	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
-	cp examples/curl.cpp $(TMPDIR)
-	$(MAKEF) TARGET=$@ SRCDIRS="$(CURL_SRCDIRS)" SRCDIRS=". base utils http http/client $(TMPDIR)"
-	#$(MAKEF) TARGET=$@ SRCDIRS="$(CURL_SRCDIRS)" SRCDIRS=". base utils http http/client $(TMPDIR)" DEFINES="$(DEFINES) WITH_CURL CURL_STATICLIB"
+	$(MAKEF) TARGET=$@ SRCDIRS="$(CURL_SRCDIRS)" SRCDIRS=". base utils http http/client" SRCS="examples/curl.cpp"
+	#$(MAKEF) TARGET=$@ SRCDIRS="$(CURL_SRCDIRS)" SRCDIRS=". base utils http http/client" SRCS="examples/curl.cpp" DEFINES="$(DEFINES) WITH_CURL CURL_STATICLIB"
 
 consul_cli: prepare
-	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
-	cp examples/consul_cli.cpp $(TMPDIR)
-	$(MAKEF) TARGET=$@ SRCDIRS=". base utils http http/client consul $(TMPDIR)" DEFINES="$(DEFINES) PRINT_DEBUG"
+	$(MAKEF) TARGET=$@ SRCDIRS=". base utils http http/client consul" SRCS="examples/consul_cli.cpp" DEFINES="$(DEFINES) PRINT_DEBUG"
 
 unittest: prepare
 	$(CC)  -g -Wall -std=c99   -I. -Ibase            -o bin/hmutex_test       unittest/hmutex_test.c        -pthread

+ 0 - 1
README.md

@@ -277,7 +277,6 @@ In general, the performance of these libraries are similar, each has its own adv
 
 - hv.h:         总头文件
 - Makefile.in:   通用Makefile模板
-- main.cpp.tmpl: 通用main.cpp模板
 
 ## 学习资料
 

+ 0 - 0
examples/loop.c → examples/hloop_test.c


+ 0 - 0
main.cpp.tmpl → examples/hmain_test.cpp


+ 0 - 0
examples/timer.c → examples/htimer_test.c


+ 0 - 0
examples/http_api_test.h → examples/httpd/http_api_test.h


+ 0 - 0
examples/httpd.cpp → examples/httpd/httpd.cpp


+ 1 - 1
winbuild/libhw/libhw.sln → winbuild/libhv/libhv.sln

@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio 14
 VisualStudioVersion = 14.0.25420.1
 MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhw", "libhw.vcxproj", "{1F0DF7C6-FF67-4EFE-B4E7-41233C726D26}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libhv", "libhv.vcxproj", "{1F0DF7C6-FF67-4EFE-B4E7-41233C726D26}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution

+ 6 - 2
winbuild/libhw/libhw.vcxproj → winbuild/libhv/libhv.vcxproj

@@ -20,7 +20,7 @@
   </ItemGroup>
   <PropertyGroup Label="Globals">
     <ProjectGuid>{1F0DF7C6-FF67-4EFE-B4E7-41233C726D26}</ProjectGuid>
-    <RootNamespace>libhw</RootNamespace>
+    <RootNamespace>libhv</RootNamespace>
     <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@@ -230,7 +230,11 @@
     <ClCompile Include="..\..\event\poll.c" />
     <ClCompile Include="..\..\event\select.c" />
     <ClCompile Include="..\..\http\client\http_client.cpp" />
+    <ClCompile Include="..\..\http\Http1Session.cpp" />
+    <ClCompile Include="..\..\http\Http2Session.cpp" />
+    <ClCompile Include="..\..\http\httpdef.c" />
     <ClCompile Include="..\..\http\HttpMessage.cpp" />
+    <ClCompile Include="..\..\http\HttpSession.cpp" />
     <ClCompile Include="..\..\http\http_content.cpp" />
     <ClCompile Include="..\..\http\http_parser.c" />
     <ClCompile Include="..\..\http\multipart_parser.c" />
@@ -253,4 +257,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>