浏览代码

update for CROSS_COMPILE

ithewei 5 年之前
父节点
当前提交
3fc5d78916
共有 6 个文件被更改,包括 67 次插入34 次删除
  1. 1 0
      .gitignore
  2. 50 18
      BUILD.md
  3. 7 7
      README.md
  4. 1 1
      config.mk
  5. 1 1
      http/server/http_page.cpp
  6. 7 7
      readme_cn.md

+ 1 - 0
.gitignore

@@ -52,6 +52,7 @@ tmp
 dist
 test
 build
+hconfig.h
 html/uploads
 
 # msvc

+ 50 - 18
BUILD.md

@@ -3,44 +3,76 @@
 - c99
 - c++11
 
-gcc4.8+, msvc2015+
+gcc4.8+, msvc2015 or later
 
-## Dependencies
-modify config.mk
-
-## Unix
+## Makefile
+options modify config.mk
 ```
 ./configure
 make
 sudo make install
 ```
 
+## cmake
+options modify CMakeLists.txt
+```
+mkdir build
+cd build
+cmake ..
+cmake --build .
+```
+
+## Unix
+use Makefile or cmake
+
+## Windows
+use cmake
+```
+mkdir win64
+cd win64
+cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release
+cmake --build .
+```
+
 ## CROSS_COMPILE
+use Makefile
 ```
-export CROSS_COMPILE=arm-linux-androideabi-
+sudo apt install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi # ubuntu
+export CROSS_COMPILE=arm-linux-gnueabi-
 ./configure
-make
+make clean
+make libhv
+```
+or use cmake
+```
+mkdir build
+cd build
+cmake .. -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++
+cmake --build . --target libhv libhv_static
 ```
 
 ### mingw
 see CROSS_COMPILE
-
-For example:
 ```
-sudo apt-get install mingw-w64 # ubuntu
+sudo apt install mingw-w64 # ubuntu
 #export CROSS_COMPILE=i686-w64-mingw32-
 export CROSS_COMPILE=x86_64-w64-mingw32-
 ./configure
-make
+make clean
+make libhv
 ```
 
-## cmake
+### android
+see CROSS_COMPILE
 ```
-mkdir build
-cd build
-cmake ..
+#https://developer.android.com/ndk/downloads
+#export NDK_ROOT=~/Downloads/android-ndk-r21b
+#sudo $NDK_ROOT/build/tools/make-standalone-toolchain.sh --arch=arm   --platform=android-21 --install-dir=/opt/ndk/arm
+#sudo $NDK_ROOT/build/tools/make-standalone-toolchain.sh --arch=arm64 --platform=android-21 --install-dir=/opt/ndk/arm64
+#export PATH=/opt/ndk/arm/bin:/opt/ndk/arm64/bin:$PATH
+#export CROSS_COMPILE=arm-linux-androideabi-
+export CROSS_COMPILE=aarch64-linux-android-
+./configure
+make clean
 make libhv
-make libhv_static
-make unittest
-make examples
 ```

+ 7 - 7
README.md

@@ -168,6 +168,7 @@ bin/nc 127.0.0.1 10514
 ```
 
 ## BUILD
+see BUILD.md
 
 ### lib
 - make libhv
@@ -201,21 +202,23 @@ https is the best example.
 ```
 sudo apt install openssl libssl-dev # ubuntu
 make clean
-make libhv httpd curl WITH_OPENSSL=yes
+make WITH_OPENSSL=yes
 # editor etc/httpd.conf => ssl = on
-bin/httpd -d
+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"
+```
+make WITH_CURL=yes DEFINES="CURL_STATICLIB"
+```
 
 #### compile WITH_NGHTTP2
 ```
 sudo apt install libnghttp2-dev # ubuntu
 make clean
-make libhv httpd curl WITH_NGHTTP2=yes
+make WITH_NGHTTP2=yes
 bin/httpd -d
 bin/curl -v localhost:8080 --http2
 ```
@@ -225,9 +228,6 @@ see config.mk
 
 ### echo-servers
 ```shell
-# ubuntu16.04
-sudo apt install libevent-dev libev-dev libuv1-dev libboost-dev libboost-system-dev libasio-dev libpoco-dev
-# muduo install => https://github.com/chenshuo/muduo.git
 cd echo-servers
 ./build.sh
 ./benchmark.sh

+ 1 - 1
config.mk

@@ -16,7 +16,7 @@ ENABLE_IPV6=no
 ENABLE_UDS=no
 # base/RAII.cpp: Windows MiniDumpWriteDump
 ENABLE_WINDUMP=no
-# http/http_content.h: QueryParams,MultiPart
+# http/http_content.h: KeyValue,QueryParams,MultiPart
 USE_MULTIMAP=no
 
 # dependencies

+ 1 - 1
http/server/http_page.cpp

@@ -62,7 +62,7 @@ void make_index_of_page(const char* dir, std::string& page, const char* url) {
             else {
                 float hsize;
                 if (item.size < 1024) {
-                    snprintf(c_str, sizeof(c_str), "%lu", item.size);
+                    snprintf(c_str, sizeof(c_str), "%lu", (unsigned long)item.size);
                 }
                 else if ((hsize = item.size/1024.0f) < 1024.0f) {
                     snprintf(c_str, sizeof(c_str), "%.1fK", hsize);

+ 7 - 7
readme_cn.md

@@ -166,6 +166,7 @@ bin/nc 127.0.0.1 10514
 ```
 
 ## 构建
+见BUILD.md
 
 ### 库
 - make libhv
@@ -199,21 +200,23 @@ https就是做好的例子:
 ```
 sudo apt install openssl libssl-dev # ubuntu
 make clean
-make libhv httpd curl WITH_OPENSSL=yes
+make WITH_OPENSSL=yes
 # editor etc/httpd.conf => ssl = on
-bin/httpd -d
+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"
+```
+make WITH_CURL=yes DEFINES="CURL_STATICLIB"
+```
 
 #### 编译WITH_NGHTTP2
 ```
 sudo apt install libnghttp2-dev # ubuntu
 make clean
-make libhv httpd curl WITH_NGHTTP2=yes
+make WITH_NGHTTP2=yes
 bin/httpd -d
 bin/curl -v localhost:8080 --http2
 ```
@@ -223,9 +226,6 @@ bin/curl -v localhost:8080 --http2
 
 ### echo-servers
 ```shell
-# ubuntu16.04
-sudo apt install libevent-dev libev-dev libuv1-dev libboost-dev libboost-system-dev libasio-dev libpoco-dev
-# muduo install => https://github.com/chenshuo/muduo.git
 cd echo-servers
 ./build.sh
 ./benchmark.sh