Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/instrumented_libraries/download_build_install.sh

Issue 60733027: Rewrited build script for instrumented libraries from bash to python (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/bin/bash
2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 # Downloads, builds (with instrumentation) and installs shared libraries.
7
8 # Go to this shell script directory
9 cd $(dirname "$0")
10
11 # Colored print.
12
13 RED_COLOR='\e[0;31m'
14 GREEN_COLOR='\e[0;32m'
15 NO_COLOR='\e[0m'
16
17 function echo_red {
18 echo -e "${RED_COLOR}$1${NO_COLOR}"
19 }
20
21 function echo_green {
22 echo -e "${GREEN_COLOR}$1${NO_COLOR}"
23 }
24
25 # Default values.
26
27 product_dir=$(pwd)
28 intermediate_dir=$(pwd)
29
30 # Should be without spaces to pass it to dpkg-buildpackage.
31 makejobs="-j14"
32
33 # Parsing args.
34
35 while getopts ":i:l:m:hp:s:j:" opt; do
36 case ${opt} in
37 p)
38 echo_green "Only installing dependencies (requires root access)"
39 echo_green "Installing dependencies for: ${OPTARG}"
40 sudo apt-get -y --no-remove build-dep ${OPTARG}
41 exit
42 ;;
43 h)
44 echo "Possible flags:
45 -p - install dependencies for packages,
46 -h - this help,
47 -l - which library to build,
48 -i - sets relative product_dir,
49 -s - sanitizer (only asan is supported now)."
50 echo "Environment variabless, which affect this script: CC and CXX"
51 exit
52 ;;
53 i)
54 product_dir="$(pwd)/${OPTARG}"
55 ;;
56 l)
57 library="${OPTARG}"
58 ;;
59 m)
60 intermediate_dir="${OPTARG}"
61 ;;
62 j)
63 makejobs="-j${OPTARG}"
64 ;;
65 s)
66 sanitizer_type="${OPTARG}"
67 if [[ "${OPTARG}" == "asan" ]]; then
68 sanitizer_flag_string="address"
69 else
70 echo_red "Invalid sanitizer: ${OPTARG}" >&2
71 exit 1
72 fi
73 ;;
74 *)
75 echo_red "Invalid option: -${OPTARG}" >&2
76 exit 1
77 ;;
78 esac
79 done
80
81 if [[ -z "${library}" ]]; then
82 echo_red "No library specified to build" >&2
83 exit 1
84 fi
85
86 if [[ -z "${sanitizer_type}" ]]; then
87 echo_red "No sanitizer specified" >&2
88 exit
89 fi
90
91 export CFLAGS="-fsanitize=${sanitizer_flag_string} -g -fPIC -w"
92 export CXXFLAGS="-fsanitize=${sanitizer_flag_string} -g -fPIC -w"
93
94 # We use XORIGIN as RPATH and after building library replace it to $ORIGIN
95 # The reason: this flag goes through configure script and makefiles
96 # differently for different libraries. So the dollar sign "$" should be
97 # differently escaped. Instead of having problems with that it just
98 # uses XORIGIN to build library and after that replaces it to $ORIGIN
99 # directly in .so file.
100 export LDFLAGS="-Wl,-z,origin -Wl,-R,XORIGIN/."
101
102 mkdir -p ${product_dir}/instrumented_libraries/${sanitizer_type}
103
104 needed_dependencies=$(apt-get -s build-dep ${library} | grep Inst \
105 | cut -d " " -f 2)
106
107 if [[ -n "${needed_dependencies}" ]]; then
108 echo_red "Library ${library} needs dependencies: ${needed_dependencies}" >&2
109 echo_red "Please, install dependencies using:
110 third_party/instrumented_libraries/download_build_install -p ${library}" >&2
111 exit 1
112 fi
113
114 (
115 # Downloading library
116 mkdir -p ${intermediate_dir}/${library}
117 cd ${intermediate_dir}/${library}
118 apt-get source ${library} 2>&1
119
120 # cd into the only directory in the current folder
121 # where our package has been unpacked.
122 cd $(ls -F |grep \/$)
123
124 # Build library
125 ./configure --prefix="${product_dir}/instrumented_libraries/${sanitizer_type}"
126 make ${makejobs}
127
128 # Install library
129 make ${makejobs} install 2>&1
130 ) > /dev/null
131
132 # Mark that library is installed.
133 # This file is used by GYP as 'output' to mark that it's already build
134 # while making incremental build.
135 touch ${product_dir}/instrumented_libraries/${sanitizer_type}/${library}.txt
136
137 # Clean up.
138 rm -rf ${intermediate_dir}/${library}
OLDNEW
« no previous file with comments | « third_party/instrumented_libraries/download_build_install.py ('k') | third_party/instrumented_libraries/fix_rpaths.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698