Skip to content

Commit 2efe037

Browse files
authored
Improve documentation and add an ios build script (#549)
1 parent 86782fc commit 2efe037

File tree

3 files changed

+70
-3
lines changed

3 files changed

+70
-3
lines changed

docs/build.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
11
## Build
22

3+
### Building static libraries
4+
5+
A static library can be build using:
6+
```
7+
mkdir build #make a build dir so that you can build out of tree
8+
cd build
9+
cmake -DUSE_TLS=1 ..
10+
make -j
11+
```
12+
There are also two build scripts in the `tools` folder for creating static libraries for android and iOS/macOS respectively.<br>
13+
Arguments can be changed in the script files.
14+
15+
Android:
16+
```
17+
mkdir build
18+
cd build
19+
./../tools/build_android.sh
20+
make -j
21+
```
22+
macOS & iOS:
23+
```
24+
mkdir build
25+
cd build
26+
./../tools/build_ios.sh
27+
```
28+
329
### CMake
430

531
CMakefiles for the library and the examples are available. This library has few dependencies, so it is possible to just add the source files into your project. Otherwise the usual way will suffice.
632

733
```
8-
mkdir build # make a build dir so that you can build out of tree.
34+
mkdir build
935
cd build
1036
cmake -DUSE_TLS=1 ..
1137
make -j

tools/build_android.sh

100644100755
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
# -DANDROID_NATIVE_API_LEVEL=23
1616
# -DANDROID_TOOLCHAIN=clang
1717
# jvmArgs :
18-
#
18+
#
19+
# To use a specific version of openSSL, add the arguments:
20+
# -DOPENSSL_VERSION="[version]"
21+
# -DOPENSSL_FOUND=1
22+
# -DOPENSSL_INCLUDE_DIR=[include path]
23+
# -DOPENSSL_LIBRARIES="[lib path]/libssl.a;[lib path]/libcrypto.a"
24+
#
1925

2026
CMAKE_TOOLCHAIN_FILE=/tools/android/android-ndk-r20-darwin/build/cmake/android.toolchain.cmake
2127
ANDROID_HOME=/tools/android/android-sdk-darwin
@@ -33,4 +39,4 @@ ${CMAKE} \
3339
-G'Unix Makefiles' \
3440
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \
3541
-DCMAKE_MAKE_PROGRAM=make \
36-
-DUSE_WS=1
42+
-DUSE_TLS=1

tools/build_ios.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
#
4+
# This script creates static libraries for macOS and iOS devices
5+
#
6+
# To use a specific OpenSSL version add the arguments:
7+
# -DOPENSSL_VERSION="[version]" \
8+
# -DOPENSSL_FOUND=1 \
9+
# -DOPENSSL_INCLUDE_DIR=[include path] \
10+
# -DOPENSSL_LIBRARIES="[lib path]/libssl.a;[lib path]/libcrypto.a" \
11+
#
12+
13+
DEPLOYMENT_TARGET_IOS='12.0'
14+
DEPLOYMENT_TARGET_MAC='14.0'
15+
CMAKE_DIR=/Applications/CMake.app/Contents/bin
16+
CMAKE=${CMAKE_DIR}/cmake
17+
18+
${CMAKE} \
19+
.. \
20+
-GXcode \
21+
-DUSE_TLS=1
22+
23+
mkdir -p ios sim mac
24+
25+
xcodebuild -project 'ixwebsocket.xcodeproj' -target "ixwebsocket" -sdk iphoneos ARCHS='arm64' TARGET_BUILD_DIR='$(PWD)/ios' BUILT_PRODUCTS_DIR='$(PWD)/ios' TARGET_NAME='ixwebsocket' IPHONEOS_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET_IOS}
26+
xcodebuild -project 'ixwebsocket.xcodeproj' -target "ixwebsocket" -sdk iphonesimulator ARCHS='x86_64' TARGET_BUILD_DIR='$(PWD)/sim' BUILT_PRODUCTS_DIR='$(PWD)/sim' TARGET_NAME='ixwebsocket' IPHONEOS_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET_IOS}
27+
xcodebuild -project 'ixwebsocket.xcodeproj' -target "ixwebsocket" -destination 'platform=OS X' ARCHS='x86_64 arm64' TARGET_BUILD_DIR='$(PWD)/mac' BUILT_PRODUCTS_DIR='$(PWD)/mac' TARGET_NAME='ixwebsocket' MACOSX_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET_MAC}
28+
29+
rm -rf ./out/*.a
30+
rm -rf ./out/ios/*.a
31+
rm -rf ./out/mac/*.a
32+
mkdir -p out
33+
mkdir -p ./out/ios ./out/mac
34+
lipo -create "./ios/libixwebsocket.a" "./sim/libixwebsocket.a" -output ./out/ios/libixwebsocket.a
35+
cp "./mac/libixwebsocket.a" ./out/mac/libixwebsocket.a

0 commit comments

Comments
 (0)