├── README.md └── build_webrtc_android_static_lib.sh /README.md: -------------------------------------------------------------------------------- 1 | A Script for Building WebRTC Android Static Library. (Linux Only) 2 | ======================== 3 | 4 | ### Getting the Code 5 | 6 | [Refer to This Page](https://webrtc.googlesource.com/src/+/refs/heads/master/docs/native-code/index.md) 7 | 8 | ### Build the Static Library 9 | 10 | Go to the source code root directory, and run this script. For example, build the APM: 11 | ``` 12 | sh build_webrtc_android_static_lib.sh audio_processing 13 | ``` 14 | 15 | ### Use the libs 16 | It will generate the libs and the header files under the 'out' directory. -------------------------------------------------------------------------------- /build_webrtc_android_static_lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script is used to build the webrtc static library. 4 | # You need to put it into the webrtc source code root directory. 5 | 6 | rm -rf out 7 | 8 | # check the params 9 | if [ $# != 1 ]; then 10 | echo "Usage:" 11 | echo " sh build_webrtc_static_lib.sh STATIC_MODULE_NAME" 12 | echo "For example:" 13 | echo " sh build_webrtc_static_lib.sh audio_processing" 14 | exit 1 15 | fi 16 | 17 | lib_name=$1 18 | 19 | # build the 32bit static library 20 | gn gen out/intermediate/arm --args='target_os="android" target_cpu="arm" use_custom_libcxx=false' 21 | 22 | ninja -C out/intermediate/arm ${lib_name} 23 | 24 | rm -rf out/intermediate/arm/tmp 25 | mkdir -p out/intermediate/arm/tmp 26 | 27 | # copy all .o files to a temp directory 28 | find out/intermediate/arm/obj -name *.o | xargs -n1 -I {} cp {} ./out/intermediate/arm/tmp 29 | 30 | cd out/intermediate/arm/tmp 31 | 32 | # use the .o files to generate static library 33 | ar rc lib${lib_name}.a *.o 34 | 35 | cd ../../../.. 36 | 37 | mkdir -p out/lib/armeabi-v7a 38 | 39 | cp out/intermediate/arm/tmp/lib${lib_name}.a out/lib/armeabi-v7a 40 | 41 | 42 | # build the 64bit static library 43 | gn gen out/intermediate/arm64 --args='target_os="android" target_cpu="arm64" use_custom_libcxx=false' 44 | 45 | ninja -C out/intermediate/arm64 ${lib_name} 46 | 47 | rm -rf out/intermediate/arm64/tmp 48 | mkdir -p out/intermediate/arm64/tmp 49 | 50 | # copy all .o files to a temp directory 51 | find out/intermediate/arm64/obj -name *.o | xargs -n1 -I {} cp {} ./out/intermediate/arm64/tmp 52 | 53 | cd out/intermediate/arm64/tmp 54 | 55 | # use the .o files to generate static library 56 | ar rc lib${lib_name}.a *.o 57 | 58 | cd ../../../.. 59 | 60 | mkdir -p out/lib/arm64-v8a 61 | 62 | cp out/intermediate/arm64/tmp/lib${lib_name}.a out/lib/arm64-v8a 63 | 64 | rm -rf out/intermediate 65 | 66 | # copy the header files 67 | mkdir -p out/include 68 | headers=`find . -name '*.h'` 69 | for header in $headers 70 | do 71 | echo "copy header path: ${header}" 72 | cp --parents ${header} out/include 73 | done --------------------------------------------------------------------------------