-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Jack He
committed
Dec 1, 2016
1 parent
531fe1a
commit e01b05f
Showing
4 changed files
with
116 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
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" |