build_libwebrtc_linux.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash -eu
  2. if [ ! -e "$(pwd)/depot_tools" ]
  3. then
  4. git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
  5. fi
  6. export COMMAND_DIR=$(cd $(dirname $0); pwd)
  7. export PATH="$(pwd)/depot_tools:$PATH"
  8. export WEBRTC_VERSION=4515
  9. export OUTPUT_DIR="$(pwd)/out"
  10. export ARTIFACTS_DIR="$(pwd)/artifacts"
  11. if [ ! -e "$(pwd)/src" ]
  12. then
  13. fetch --nohooks webrtc
  14. cd src
  15. sudo sh -c 'echo 127.0.1.1 $(hostname) >> /etc/hosts'
  16. sudo git config --system core.longpaths true
  17. git checkout "refs/remotes/branch-heads/$WEBRTC_VERSION"
  18. cd ..
  19. gclient sync -f
  20. fi
  21. # add jsoncpp
  22. patch -N "src/BUILD.gn" < "$COMMAND_DIR/patches/add_jsoncpp.patch"
  23. mkdir -p "$ARTIFACTS_DIR/lib"
  24. for target_cpu in "x64"
  25. do
  26. mkdir -p "$ARTIFACTS_DIR/lib/${target_cpu}"
  27. for is_debug in "true" "false"
  28. do
  29. args="is_debug=${is_debug} target_os=\"linux\" target_cpu=\"${target_cpu}\" rtc_include_tests=false rtc_build_examples=false rtc_use_h264=false symbol_level=0 enable_iterator_debugging=false is_component_build=false use_rtti=true rtc_use_x11=false libcxx_abi_unstable=false";
  30. if [ $is_debug = "true" ]; then
  31. args="${args} is_asan=true is_lsan=true";
  32. fi
  33. # generate ninja files
  34. gn gen "$OUTPUT_DIR" --root="src" --args="${args}"
  35. # build static library
  36. ninja -C "$OUTPUT_DIR" webrtc
  37. filename="libwebrtc.a"
  38. if [ $is_debug = "true" ]; then
  39. filename="libwebrtcd.a"
  40. fi
  41. # cppy static library
  42. cp "$OUTPUT_DIR/obj/libwebrtc.a" "$ARTIFACTS_DIR/lib/${target_cpu}/${filename}"
  43. done
  44. done
  45. # fix error when generate license
  46. patch -N "./src/tools_webrtc/libs/generate_licenses.py" < \
  47. "$COMMAND_DIR/patches/generate_licenses.patch"
  48. vpython "./src/tools_webrtc/libs/generate_licenses.py" \
  49. --target //:default "$OUTPUT_DIR" "$OUTPUT_DIR"
  50. cd src
  51. find . -name "*.h" -print | cpio -pd "$ARTIFACTS_DIR/include"
  52. cp "$OUTPUT_DIR/LICENSE.md" "$ARTIFACTS_DIR"
  53. # create zip
  54. cd "$ARTIFACTS_DIR"
  55. zip -r webrtc-linux.zip lib include LICENSE.md