Chromium Code Reviews| Index: third_party/instrumented_libraries/download_build_install |
| =================================================================== |
| --- third_party/instrumented_libraries/download_build_install (revision 0) |
| +++ third_party/instrumented_libraries/download_build_install (revision 0) |
| @@ -0,0 +1,128 @@ |
| +#!/bin/bash |
| +# Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +# Downloads, builds (with instrumentation) and installs shared libraries. |
| + |
| +# Colored print. |
| + |
| +RED_COLOR='\e[0;31m' |
| +GREEN_COLOR='\e[0;32m' |
| +NO_COLOR='\e[0m' |
| + |
| +function echo_red { |
| + echo -e "${RED_COLOR}$1${NO_COLOR}" |
| +} |
| + |
| +function echo_green { |
| + echo -e "${GREEN_COLOR}$1${NO_COLOR}" |
| +} |
| + |
| +# Default values. |
| + |
| +product_dir=$(pwd) |
|
Nico
2013/10/30 14:47:02
Scripts shouldn't depend on the pwd
alextaran1
2013/10/30 16:08:54
The library should be installed into <(product_dir
Alexander Potapenko
2013/10/31 12:18:16
As Nico suggested below, $(dirname "${0}") is bett
alextaran1
2013/11/01 11:17:00
Added cd $(dirname "${0}") in the beginning. After
|
| +intermediate_dir=$(pwd) |
| + |
| +# Should be without spaces to pass it to dpkg-buildpackage. |
| +makejobs="-j14" |
| + |
| +# Parsing args. |
| + |
| +while getopts ":i:l:m:hp:s:j:" opt; do |
| + case ${opt} in |
| + p) |
| + echo_green "Only installing dependencies (requires root access)" |
| + echo_green "Installing dependencies for: ${OPTARG}" |
| + sudo apt-get -y --no-remove build-dep ${OPTARG} |
| + exit |
| + ;; |
| + h) |
| + echo "Possible flags: |
| + -p - install dependencies for packages, |
| + -h - this help, |
| + -l - which library to build, |
| + -i - sets relative product_dir, |
| + -s - sanitizer (only asan is supported now)." |
| + echo "Environment variabless, which affect this script: CC and CXX" |
| + exit |
| + ;; |
| + i) |
| + product_dir="$(pwd)/${OPTARG}" |
|
Nico
2013/10/30 14:47:02
Does this need to be configurable? Can you just ha
alextaran1
2013/10/30 16:08:54
product_dir should be a path to chrome binary (or
|
| + ;; |
| + l) |
| + library="${OPTARG}" |
| + ;; |
| + m) |
| + intermediate_dir="${OPTARG}" |
| + ;; |
| + j) |
| + makejobs="-j${OPTARG}" |
| + ;; |
| + s) |
| + sanitizer_type="${OPTARG}" |
| + if [[ "${OPTARG}" == "asan" ]]; then |
| + sanitizer_flag_string="address" |
| + else |
| + echo_red "Invalid sanitizer: ${OPTARG}" >&2 |
| + exit 1 |
| + fi |
| + ;; |
| + *) |
| + echo_red "Invalid option: -${OPTARG}" >&2 |
| + exit 1 |
| + ;; |
| + esac |
| +done |
| + |
| +if [[ -z "${library}" ]]; then |
| + echo_red "No library specified to build" >&2 |
| + exit 1 |
| +fi |
| + |
| +if [[ -z "${sanitizer_type}" ]]; then |
|
Nico
2013/10/30 14:47:02
Can this be python instead?
alextaran1
2013/10/30 16:08:54
Not sure what do you mean here..
Nico
2013/11/02 00:05:02
Could this whole script be a python script instead
Alexander Potapenko
2013/11/05 14:07:23
I support this, but maybe we can rewrite the scrip
|
| + echo_red "No sanitizer specified" >&2 |
| + exit |
| +fi |
| + |
| +export CFLAGS="-fsanitize=${sanitizer_flag_string} -g -fPIC -w" |
| +export CXXFLAGS="-fsanitize=${sanitizer_flag_string} -g -fPIC -w" |
| +export LDFLAGS="-Wl,-z,origin -Wl,-R,XORIGIN/." |
| + |
| +mkdir -p ${product_dir}/instrumented_libraries/${sanitizer_type} |
| + |
| +needed_dependencies=$(apt-get -s build-dep ${library} | grep Inst \ |
| + | cut -d " " -f 2) |
| + |
| +if [[ -n "${needed_dependencies}" ]]; then |
| + echo_red "Library ${library} needs dependencies: ${needed_dependencies}" >&2 |
| + echo_red "Please, install dependencies using: |
| + third_party/instrumented_libraries/download_build_install -p ${library}" >&2 |
| + exit 1 |
| +fi |
| + |
| +( |
| + # Downloading library |
| + mkdir -p ${intermediate_dir}/${library} |
| + cd ${intermediate_dir}/${library} |
| + apt-get source ${library} 2>&1 |
|
Nico
2013/10/30 14:47:02
How does this work on non-apt systems?
alextaran1
2013/10/30 16:08:54
This will not work. Does anybody want to build chr
Alexander Potapenko
2013/10/31 12:18:16
Apt systems (namely Ubuntu) are first-class citize
|
| + |
| + # cd into the only directory in the current folder |
| + # where our package has been unpacked. |
| + cd $(ls -F |grep \/$) |
| + |
| + # Build library |
| + ./configure --prefix="${product_dir}/instrumented_libraries/${sanitizer_type}" |
| + make ${makejobs} |
| + |
| + # Install library |
| + make ${makejobs} install 2>&1 |
| +) > /dev/null |
| + |
| +# Mark that library is installed. |
| +# This file is used by GYP as 'output' to mark that it's already build |
| +# while making incremental build. |
| +touch ${product_dir}/instrumented_libraries/${sanitizer_type}/${library}.txt |
| + |
| +# Clean up. |
| +rm -rf ${intermediate_dir}/${library} |
| Property changes on: third_party/instrumented_libraries/download_build_install |
| ___________________________________________________________________ |
| Added: svn:executable |
| + * |