build 3.34 KB
Newer Older
boklm's avatar
boklm committed
1
2
#!/bin/bash
[% c("var/set_default_env") -%]
boklm's avatar
boklm committed
3
[% c("var/setarch") -%]
boklm's avatar
boklm committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
distdir=/var/tmp/dist/[% project %]
[% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

mkdir -p /var/tmp/dist

[% IF c("var/linux") %]
  tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
  export PATH="/var/tmp/dist/binutils/bin:$PATH"
[% END -%]

# Setting up depot_tools
# https://dev.chromium.org/developers/how-tos/install-depot-tools
tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/depot_tools') %]
export PATH="$PATH:/var/tmp/dist/depot_tools"
# Disable automatic updating.
export DEPOT_TOOLS_UPDATE=0

mkdir -p /var/tmp/build
tar -C /var/tmp/build -xf webrtc-sources-[% c('version') %].tar.gz

builddir=/var/tmp/build/[% project %]/src
cd $builddir
boklm's avatar
boklm committed
26
27
28
29
30
31
32
33
34
35
36

patch -p1 < $rootdir/webrtc-linux.patch

# First, build a copy of GN, rather than use the prebuilt copy in buildtools/linux64.
cd tools/gn
# __STDC_FORMAT_MACROS is needed for a definition of PRIxPTR from inttypes.h.
CXXFLAGS=-D__STDC_FORMAT_MACROS=1 LDFLAGS=-latomic ./bootstrap/bootstrap.py --no-rebuild --no-clean
cd ../..
# This is where bootstrap.py stashes the built gn.
GN="$PWD/out_bootstrap/gn"

boklm's avatar
boklm committed
37
38
39
40
41
42
43
44
45
46
47
48
[% IF c("var/linux") -%]
  export CC=gcc
  export CXX=g++
[% END -%]
[% IF c("var/linux-i686") -%]
  GYP_DEFINES+=" target_arch=ia32"
  export CC='gcc -m32'
  export CXX='g++ -m32'
  export CFLAGS=-m32
  export CXXFLAGS=-m32
  export LDFLAGS=-m32
[% END -%]
boklm's avatar
boklm committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

export GN_ARGS=""
# For a list of all possible GN args, do "gn gen out/Release; gn args --list out/Release".
# https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/cross_compiles.md
GN_ARGS+=" target_os=\"linux\" target_cpu=\"[% IF c("var/linux-i686") %]x86[% ELSE %]x64[% END %]\""
# Not debug.
GN_ARGS+=" is_debug=false"
# There are warnings from unused returns.
GN_ARGS+=" treat_warnings_as_errors=false"
# Build static libraries.
GN_ARGS+=" is_component_build=false"
# Do not use bundled utilities.
GN_ARGS+=" is_clang=false use_sysroot=false"
GN_ARGS+=" gold_path=\"$INSTDIR/binutils/bin\""
# Make extra sure we don't use bundled binutils.
rm -rf third_party/binutils/Linux_*
# Avoid some dependencies.
GN_ARGS+=" use_ozone=true use_gconf=false"
GN_ARGS+=" rtc_include_opus=false rtc_include_ilbc=false rtc_include_internal_audio_device=false rtc_include_pulse_audio=false"
# Included for "field_trial" below.  Maybe "fieldtrial_testing_like_official_build" could help here?
#GN_ARGS+=" rtc_include_tests=false"
rm -rf out/Release
"$GN" gen out/Release --args="$GN_ARGS"
ninja -C out/Release webrtc field_trial metrics_default pc_test_utils
73
74
75
76
77
78
# .o files under out/Release/obj/ are the build outputs. Don't include .o
# files from elsewhere under out/ because they are build helpers and things
# like that, not necessarily of the target architecture, and anyway are not
# needed.
# https://bugs.torproject.org/22832
ar crs libwebrtc-magic.a $(find out/Release/obj -name '*.o' | sort)
boklm's avatar
boklm committed
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96

mkdir -p $distdir
cd $distdir
mkdir -p include lib
cp -f $builddir/libwebrtc-magic.a [% c("var/webrtc/lib_path") %]
INCLUDE_DIR="$PWD/include"
cd $builddir
for h in $(find talk/ webrtc/ -type f -name '*.h');
do
  mkdir -p "$INCLUDE_DIR/$(dirname $h)"
  cp -f "$h" "$INCLUDE_DIR/$h"
done

cd /var/tmp/dist
[% c('tar', {
        tar_src => [ project ],
        tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
        }) %]