Skip to content
Snippets Groups Projects
Commit 1399ab99 authored by Jack He's avatar Jack He
Browse files

Add dependency installation files for x86_64

* The installation script installs the necessary dependencies based on
  host OS version on Ubuntu OS
* clang toolchain BUILD.gn will only use clang-3.5 or above
* Update documentation

Test: gn gen out/Default; ninja -C out/Default
Change-Id: Ibc732ebc68009af25e9a911a724a888e008d45ac
parent a2356a4b
No related branches found
No related tags found
No related merge requests found
......@@ -8,47 +8,6 @@ Just build AOSP - Fluoride is there by default.
Instructions for Ubuntu, tested on 14.04 with Clang 3.5.0 and 16.10 with Clang
3.8.0
### Install required libraries
```sh
sudo apt-get install libevent-dev libc++-dev libc++abi-dev
```
### Install build tools
- Install [ninja](https://ninja-build.org/) build system
```sh
sudo apt-get install ninja-build
```
or download binary from https://github.com/ninja-build/ninja/releases
- Install [gn](https://chromium.googlesource.com/chromium/src/tools/gn/) -
meta-build system that generates NinjaBuild files.
Get sha1 of current version from [here](
https://chromium.googlesource.com/chromium/buildtools/+/master/linux64/gn.sha1)
and then download corresponding executable:
```sh
wget -O gn http://storage.googleapis.com/chromium-gn/<gn.sha1>
```
i.e. if sha1 is "3491f6687bd9f19946035700eb84ce3eed18c5fa" (value from 24 Feb
2016) do
```sh
wget -O gn http://storage.googleapis.com/chromium-gn/3491f6687bd9f19946035700eb84ce3eed18c5fa
```
Then make binary executable and put it on your PATH, i.e.:
```sh
chmod a+x ./gn
sudo mv ./gn /usr/bin
```
### Download source
```sh
......@@ -57,6 +16,13 @@ cd ~/fluoride
git clone https://android.googlesource.com/platform/packages/modules/Bluetooth/system
```
Install dependencies (require sudo access):
```sh
cd ~/fluoride/bt
build/install_deps.sh
```
Then fetch third party dependencies:
```sh
......
#!/bin/bash
CLANG_PACKAGE=clang
GNSHA1_URL="https://chromium.googlesource.com/chromium/buildtools/\
+/master/linux64/gn.sha1?format=TEXT"
# Check if clang is already installed on current system
clang_path=`which clang`
if [ -f "$clang_path" ]; then
# if clang binary is avalable, check its version
clang_version=$($clang_path --version | grep clang | sed "s/.*version\s*\([0-9]*\.[0-9]*\).*/\1/")
IFS="." read -ra clang_version_array <<< "$clang_version"
clang_version_major=${clang_version_array[0]}
clang_version_minor=${clang_version_array[1]}
# if the version is greater than 3.5 then do not install clang here
if [ $clang_version_major -ge 3 ] && [ $clang_version_minor -ge 5 ]; then
echo "Detected clang $clang_version"
CLANG_PACKAGE=""
fi
fi
if [ ! -z "$CLANG_PACKAGE" ]; then
# Try to find clang from a known list
for clang_version in 3.9 3.8 3.7 3.6 3.5
do
clang_path=`which clang-$clang_version`
if [ -f "$clang_path" ]; then
echo "Detected clang-$clang_version"
CLANG_PACKAGE=""
break
fi
done
fi
if [ ! -z "$CLANG_PACKAGE" ]; then
echo "clang not found on current system, installing"
if [ -f /etc/lsb-release ]; then
# Ubuntu
ubuntu_version=$(lsb_release --release --short)
IFS="." read -ra ubuntu_version_array <<< "$ubuntu_version"
ubuntu_version_major=${ubuntu_version_array[0]}
ubuntu_version_minor=${ubuntu_version_array[1]}
if [ $ubuntu_version_major -lt 15 ]; then
echo "Choose clang-3.8 for Ubuntu 14 and below"
CLANG_PACKAGE=clang-3.8
fi
fi
fi
sudo apt-get -y install $CLANG_PACKAGE libevent-dev libc++-dev libc++abi-dev \
ninja-build
gn_path=`which gn`
if [ -z $gn_path ]; then
gnsha1=$(curl $GNSHA1_URL | base64 -d)
wget -O gn http://storage.googleapis.com/chromium-gn/$gnsha1
chmod a+x ./gn
sudo mv ./gn /usr/bin/
fi
......@@ -13,8 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
clang = "clang"
clangxx = "clang++"
clang_suffix = exec_script("get_clang_suffix.py", [], "list lines")
clang_suffix = clang_suffix[0]
assert(clang_suffix != "None",
"Cannot find clang, please install clang 3.5 or above")
if (clang_suffix != "") {
clang_suffix = "-" + clang_suffix
}
clang = "clang$clang_suffix"
clangxx = "clang++$clang_suffix"
config("clang_config") {
include_dirs = [
......
import os
import subprocess
import re
import sys
def which(cmd):
for p in os.environ["PATH"].split(os.pathsep):
clang_path = os.path.join(p, cmd)
if os.path.exists(clang_path):
return clang_path
return None
CLANG_VERSION_REGEX=".*version\s*([0-9]*\.[0-9]*)\.*"
clang_path = which("clang++")
clang_version_major = 0
clang_version_minor = 0
if clang_path:
clang_version_out = subprocess.Popen([clang_path, "--version"],
stdout=subprocess.PIPE).communicate()[0]
clang_version_match = re.search(CLANG_VERSION_REGEX, clang_version_out)
clang_version_str = clang_version_match.group(1)
clang_version_array = clang_version_str.split('.')
clang_version_major = int(clang_version_array[0])
clang_version_minor = int(clang_version_array[1])
if clang_version_major >= 3 and clang_version_minor >= 5:
print ""
else:
# Loop in support clang version only
clang_version_major = 3
clang_version_minor = 9
while clang_version_major >= 3 and clang_version_minor >= 5:
clang_version_str = "%d.%d" % (clang_version_major, clang_version_minor)
clang_path = which("clang++-" + clang_version_str)
if clang_path:
print clang_version_str
sys.exit(0)
clang_version_minor -= 1
if clang_version_minor < 0:
clang_version_minor = 9
clang_version_major -= 1
print "None"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment