-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-webrtc.sh
More file actions
executable file
·129 lines (108 loc) · 3.03 KB
/
build-webrtc.sh
File metadata and controls
executable file
·129 lines (108 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
revision=`cat revision`
fail() {
echo "*** webrtc build failed"
exit 1
}
set_environment() {
export JAVA_HOME='/usr/lib/jvm/java-7-openjdk-amd64'
export GYP_DEFINES="build_with_libjingle=1 build_with_chromium=0 libjingle_objc=0 OS=android"
export GYP_GENERATORS="ninja"
export GYP_CROSSCOMPILE=1
export MACH=`uname -m`
export RELEASE_VERSION=`grep -Po '(?<==)[^\"]+' release-version`
}
set_environment_for_arm() {
set_environment
export GYP_GENERATOR_FLAGS="$GYP_GENERATOR_FLAGS output_dir=out_arm"
export STRIP="$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-$MACH/arm-linux-androideabi/bin/strip"
}
set_environment_for_x86() {
set_environment
export GYP_DEFINES="$GYP_DEFINES target_arch=ia32"
export GYP_GENERATOR_FLAGS="$GYP_GENERATOR_FLAGS output_dir=out_x86"
export STRIP="$ANDROID_NDK/toolchains/x86-4.8/prebuilt/linux-$MACH/bin/i686-linux-android-strip"
}
prerequisites() {
git pull || fail
if [ -d "depot_tools" ]; then
echo "depot exists"
else
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git || fail
fi
export PATH=`pwd`/depot_tools:"$PATH"
if [ -d "src" ]; then
gclient sync || fail
echo "src exists. Fetch updates"
pushd src || fail
git stash save || fail
rm -r out_arm
rm -r out_x86
echo "patches stashed"
git fetch || fail
echo "updates fetched"
popd
else
echo "src not found. Fetch all sources"
fetch webrtc_android || fail
fi
pushd src || fail
git checkout $1
git stash pop || fail
echo "patches unstashed"
. build/android/envsetup.sh
python webrtc/build/gyp_webrtc
popd
}
build() {
echo "-- building webrtc/$1"
set_environment_for_$1
pushd src || fail
python webrtc/build/gyp_webrtc
ninja -C out_$1/Debug libjingle_peerconnection_so libjingle_peerconnection_java || fail
ninja -C out_$1/Release libjingle_peerconnection_so libjingle_peerconnection_java || fail
$STRIP -s out_$1/Release/lib/libjingle_peerconnection_so.so || fail
pushd out_$1/Release || fail
popd
popd
echo "-- webrtc/$1 has been successfully built"
}
init_mvn_repo() {
if [ -d "repo" ]; then
echo "repo exists"
else
mkdir repo || fail
fi
}
cleanDiff() {
if [ -f "patches/$1.diff" ]; then
echo "previous diff for revision $1 found"
rm -f patches/$1.diff
else
echo "no diff for revision $1 found."
fi
}
checkForPatch() {
if [ -f "patches/$1.diff" ]; then
echo "diff for revision $1 found"
else
echo "no diff for revision $1 found. Have you applied patches?"
fail
fi
}
build_aar() {
pushd aar-project || fail
echo "arr build for rev: $1"
./gradlew -Prevision=$1 build
popd
}
echo "Building revision: $revision"
prerequisites $revision
build arm
build x86
init_mvn_repo
cleanDiff $revision
make -B repo
checkForPatch $revision
build_aar $revision
make -B aar