Merge pull request #2092 from atom/download-clang

Use downloaded clang binaries for building
This commit is contained in:
Cheng Zhao 2015-07-01 16:43:13 +08:00
commit e15b05603d
11 changed files with 327 additions and 51 deletions

2
.gitignore vendored
View file

@ -6,6 +6,8 @@
/vendor/brightray/vendor/download/
/vendor/python_26/
/vendor/npm/
/vendor/llvm/
/vendor/llvm-build/
/vendor/.gclient
node_modules/
*.xcodeproj

View file

@ -23,7 +23,7 @@ int32_t IDWeakMap::Add(v8::Isolate* isolate, v8::Local<v8::Object> object) {
auto global = make_linked_ptr(new v8::Global<v8::Object>(isolate, object));
global->SetWeak(this, &WeakCallback);
map_.emplace(id, global);
map_[id] = global;
return id;
}

View file

@ -20,19 +20,19 @@ class LibSpeechdLoader {
bool loaded() const { return loaded_; }
typeof(&::spd_open) spd_open;
typeof(&::spd_say) spd_say;
typeof(&::spd_stop) spd_stop;
typeof(&::spd_close) spd_close;
typeof(&::spd_pause) spd_pause;
typeof(&::spd_resume) spd_resume;
typeof(&::spd_set_notification_on) spd_set_notification_on;
typeof(&::spd_set_voice_rate) spd_set_voice_rate;
typeof(&::spd_set_voice_pitch) spd_set_voice_pitch;
typeof(&::spd_list_synthesis_voices) spd_list_synthesis_voices;
typeof(&::spd_set_synthesis_voice) spd_set_synthesis_voice;
typeof(&::spd_list_modules) spd_list_modules;
typeof(&::spd_set_output_module) spd_set_output_module;
decltype(&::spd_open) spd_open;
decltype(&::spd_say) spd_say;
decltype(&::spd_stop) spd_stop;
decltype(&::spd_close) spd_close;
decltype(&::spd_pause) spd_pause;
decltype(&::spd_resume) spd_resume;
decltype(&::spd_set_notification_on) spd_set_notification_on;
decltype(&::spd_set_voice_rate) spd_set_voice_rate;
decltype(&::spd_set_voice_pitch) spd_set_voice_pitch;
decltype(&::spd_list_synthesis_voices) spd_list_synthesis_voices;
decltype(&::spd_set_synthesis_voice) spd_set_synthesis_voice;
decltype(&::spd_list_modules) spd_list_modules;
decltype(&::spd_set_output_module) spd_set_output_module;
private:

View file

@ -34,7 +34,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_open =
reinterpret_cast<typeof(this->spd_open)>(
reinterpret_cast<decltype(this->spd_open)>(
dlsym(library_, "spd_open"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
@ -47,7 +47,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_say =
reinterpret_cast<typeof(this->spd_say)>(
reinterpret_cast<decltype(this->spd_say)>(
dlsym(library_, "spd_say"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
@ -60,7 +60,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_stop =
reinterpret_cast<typeof(this->spd_stop)>(
reinterpret_cast<decltype(this->spd_stop)>(
dlsym(library_, "spd_stop"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
@ -73,7 +73,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_close =
reinterpret_cast<typeof(this->spd_close)>(
reinterpret_cast<decltype(this->spd_close)>(
dlsym(library_, "spd_close"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
@ -86,7 +86,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_pause =
reinterpret_cast<typeof(this->spd_pause)>(
reinterpret_cast<decltype(this->spd_pause)>(
dlsym(library_, "spd_pause"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
@ -99,7 +99,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_resume =
reinterpret_cast<typeof(this->spd_resume)>(
reinterpret_cast<decltype(this->spd_resume)>(
dlsym(library_, "spd_resume"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
@ -112,7 +112,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_set_notification_on =
reinterpret_cast<typeof(this->spd_set_notification_on)>(
reinterpret_cast<decltype(this->spd_set_notification_on)>(
dlsym(library_, "spd_set_notification_on"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
@ -125,7 +125,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_set_voice_rate =
reinterpret_cast<typeof(this->spd_set_voice_rate)>(
reinterpret_cast<decltype(this->spd_set_voice_rate)>(
dlsym(library_, "spd_set_voice_rate"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
@ -138,7 +138,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_set_voice_pitch =
reinterpret_cast<typeof(this->spd_set_voice_pitch)>(
reinterpret_cast<decltype(this->spd_set_voice_pitch)>(
dlsym(library_, "spd_set_voice_pitch"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
@ -151,7 +151,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_list_synthesis_voices =
reinterpret_cast<typeof(this->spd_list_synthesis_voices)>(
reinterpret_cast<decltype(this->spd_list_synthesis_voices)>(
dlsym(library_, "spd_list_synthesis_voices"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
@ -164,7 +164,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_set_synthesis_voice =
reinterpret_cast<typeof(this->spd_set_synthesis_voice)>(
reinterpret_cast<decltype(this->spd_set_synthesis_voice)>(
dlsym(library_, "spd_set_synthesis_voice"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
@ -177,7 +177,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_list_modules =
reinterpret_cast<typeof(this->spd_list_modules)>(
reinterpret_cast<decltype(this->spd_list_modules)>(
dlsym(library_, "spd_list_modules"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)
@ -190,7 +190,7 @@ bool LibSpeechdLoader::Load(const std::string& library_name) {
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DLOPEN)
spd_set_output_module =
reinterpret_cast<typeof(this->spd_set_output_module)>(
reinterpret_cast<decltype(this->spd_set_output_module)>(
dlsym(library_, "spd_set_output_module"));
#endif
#if defined(LIBRARY_LOADER_OUT_RELEASE_GEN_LIBRARY_LOADERS_LIBSPEECHD_H_DT_NEEDED)

View file

@ -1,5 +1,6 @@
{
'includes': [
'toolchain.gypi',
'vendor/brightray/brightray.gypi',
],
'variables': {

View file

@ -29,6 +29,9 @@ def main():
update_node_modules('.')
bootstrap_brightray(args.dev, args.url, args.target_arch)
if PLATFORM != 'win32':
update_clang()
create_chrome_version_h()
touch_config_gypi()
run_update()
@ -105,6 +108,11 @@ def update_win32_python():
if not os.path.exists('python_26'):
execute_stdout(['git', 'clone', PYTHON_26_URL])
def update_clang():
execute_stdout([os.path.join(SOURCE_ROOT, 'script', 'update-clang.sh')])
def create_chrome_version_h():
version_file = os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor',
'libchromiumcontent', 'VERSION')

View file

@ -20,29 +20,18 @@ verbose_mode = False
def get_target_arch():
# Always build 64bit on OS X.
if PLATFORM == 'darwin':
return 'x64'
# Only build for host's arch on Linux.
elif PLATFORM == 'linux':
if platform.architecture()[0] == '32bit':
return 'ia32'
else:
return 'x64'
# On Windows it depends on user.
elif PLATFORM == 'win32':
try:
target_arch_path = os.path.join(__file__, '..', '..', '..', 'vendor',
'brightray', 'vendor', 'download',
'libchromiumcontent', '.target_arch')
with open(os.path.normpath(target_arch_path)) as f:
return f.read().strip()
except IOError as e:
if e.errno != errno.ENOENT:
raise
# Build 32bit by default.
try:
target_arch_path = os.path.join(__file__, '..', '..', '..', 'vendor',
'brightray', 'vendor', 'download',
'libchromiumcontent', '.target_arch')
with open(os.path.normpath(target_arch_path)) as f:
return f.read().strip()
except IOError as e:
if e.errno != errno.ENOENT:
raise
if PLATFORM == 'win32':
return 'ia32'
# Maybe we will support other platforms in future.
else:
return 'x64'

76
script/update-clang.sh Executable file
View file

@ -0,0 +1,76 @@
#!/usr/bin/env bash
# Copyright (c) 2012 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.
# This script will check out llvm and clang into third_party/llvm and build it.
# Do NOT CHANGE this if you don't know what you're doing -- see
# https://code.google.com/p/chromium/wiki/UpdatingClang
# Reverting problematic clang rolls is safe, though.
CLANG_REVISION=233105
# This is incremented when pushing a new build of Clang at the same revision.
CLANG_SUB_REVISION=1
PACKAGE_VERSION="${CLANG_REVISION}-${CLANG_SUB_REVISION}"
THIS_DIR="$(dirname "${0}")"
LLVM_DIR="${THIS_DIR}/../vendor/llvm"
LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build/Release+Asserts"
STAMP_FILE="${LLVM_DIR}/../llvm-build/cr_build_revision"
# ${A:-a} returns $A if it's set, a else.
LLVM_REPO_URL=${LLVM_URL:-https://llvm.org/svn/llvm-project}
CDS_URL=https://commondatastorage.googleapis.com/chromium-browser-clang
# Die if any command dies, error on undefined variable expansions.
set -eu
OS="$(uname -s)"
# Check if there's anything to be done, exit early if not.
if [[ -f "${STAMP_FILE}" ]]; then
PREVIOUSLY_BUILT_REVISON=$(cat "${STAMP_FILE}")
if [[ "${PREVIOUSLY_BUILT_REVISON}" = "${PACKAGE_VERSION}" ]]; then
echo "Clang already at ${PACKAGE_VERSION}"
exit 0
fi
fi
# To always force a new build if someone interrupts their build half way.
rm -f "${STAMP_FILE}"
# Check if there's a prebuilt binary and if so just fetch that. That's faster,
# and goma relies on having matching binary hashes on client and server too.
CDS_FILE="clang-${PACKAGE_VERSION}.tgz"
CDS_OUT_DIR=$(mktemp -d -t clang_download.XXXXXX)
CDS_OUTPUT="${CDS_OUT_DIR}/${CDS_FILE}"
if [ "${OS}" = "Linux" ]; then
CDS_FULL_URL="${CDS_URL}/Linux_x64/${CDS_FILE}"
elif [ "${OS}" = "Darwin" ]; then
CDS_FULL_URL="${CDS_URL}/Mac/${CDS_FILE}"
fi
echo Trying to download prebuilt clang
if which curl > /dev/null; then
curl -L --fail "${CDS_FULL_URL}" -o "${CDS_OUTPUT}" || \
rm -rf "${CDS_OUT_DIR}"
elif which wget > /dev/null; then
wget "${CDS_FULL_URL}" -O "${CDS_OUTPUT}" || rm -rf "${CDS_OUT_DIR}"
else
echo "Neither curl nor wget found. Please install one of these."
exit 1
fi
if [ -f "${CDS_OUTPUT}" ]; then
rm -rf "${LLVM_BUILD_DIR}"
mkdir -p "${LLVM_BUILD_DIR}"
tar -xzf "${CDS_OUTPUT}" -C "${LLVM_BUILD_DIR}"
echo clang "${PACKAGE_VERSION}" unpacked
echo "${PACKAGE_VERSION}" > "${STAMP_FILE}"
rm -rf "${CDS_OUT_DIR}"
exit 0
else
echo Did not find prebuilt clang "${PACKAGE_VERSION}", building
fi

View file

@ -44,7 +44,7 @@ def run_gyp(target_arch, component):
defines = [
'-Dlibchromiumcontent_component={0}'.format(component),
'-Dtarget_arch={0}'.format(target_arch),
'-Dhost_arch={0}'.format(target_arch),
'-Dhost_arch=x64',
'-Dlibrary=static_library',
]
return subprocess.call([python, gyp, '-f', 'ninja', '--depth', '.',

200
toolchain.gypi Normal file
View file

@ -0,0 +1,200 @@
{
'variables': {
# Clang stuff.
'make_clang_dir%': 'vendor/llvm-build/Release+Asserts',
# Set this to true when building with Clang.
'clang%': 1,
'variables': {
# Set ARM architecture version.
'arm_version%': 7,
# Set NEON compilation flags.
'arm_neon%': 1,
},
# Copy conditionally-set variables out one scope.
'arm_version%': '<(arm_version)',
'arm_neon%': '<(arm_neon)',
# Variables to control Link-Time Optimization (LTO).
'use_lto%': 0,
'use_lto_o2%': 0,
'conditions': [
# Do not use Clang on Windows.
['OS=="win"', {
'clang%': 0,
}], # OS=="win"
# Set default compiler flags depending on ARM version.
['arm_version==6', {
'arm_arch%': 'armv6',
'arm_tune%': '',
'arm_fpu%': 'vfp',
'arm_float_abi%': 'softfp',
'arm_thumb%': 0,
}], # arm_version==6
['arm_version==7', {
'arm_arch%': 'armv7-a',
'arm_tune%': 'generic-armv7-a',
'conditions': [
['arm_neon==1', {
'arm_fpu%': 'neon',
}, {
'arm_fpu%': 'vfpv3-d16',
}],
],
'arm_float_abi%': 'hard',
'arm_thumb%': 1,
}], # arm_version==7
],
},
'conditions': [
['clang==1', {
'make_global_settings': [
['CC', '<(make_clang_dir)/bin/clang'],
['CXX', '<(make_clang_dir)/bin/clang++'],
['CC.host', '$(CC)'],
['CXX.host', '$(CXX)'],
],
'target_defaults': {
'cflags_cc': [
'-std=c++11',
],
'xcode_settings': {
'CC': '<(make_clang_dir)/bin/clang',
'LDPLUSPLUS': '<(make_clang_dir)/bin/clang++',
'OTHER_CFLAGS': [
'-fcolor-diagnostics',
],
'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
'CLANG_CXX_LIBRARY': 'libc++', # -stdlib=libc++
'CLANG_CXX_LANGUAGE_STANDARD': 'c++11', # -std=c++11
},
'target_conditions': [
['_type in ["executable", "shared_library"]', {
'xcode_settings': {
# On some machines setting CLANG_CXX_LIBRARY doesn't work for
# linker.
'OTHER_LDFLAGS': [ '-stdlib=libc++' ],
},
}],
],
},
}], # clang==1
['OS=="linux"', {
'target_defaults': {
'target_conditions': [
['target_arch=="ia32" and _toolset=="target"', {
'asflags': [
'-32',
],
'cflags': [
'-msse2',
'-mfpmath=sse',
'-mmmx', # Allows mmintrin.h for MMX intrinsics.
'-m32',
],
'ldflags': [
'-m32',
],
}], # target_arch=="ia32" and _toolset=="target"
['target_arch=="x64" and _toolset=="target"', {
'cflags': [
'-m64',
'-march=x86-64',
],
'ldflags': [
'-m64',
],
}], # target_arch=="x64" and _toolset=="target"
['target_arch=="arm" and _toolset=="target"', {
'conditions': [
['clang==0', {
'cflags_cc': [
'-Wno-abi',
],
}],
['clang==1 and arm_arch!=""', {
'cflags': [
'-target arm-linux-gnueabihf',
],
'ldflags': [
'-target arm-linux-gnueabihf',
],
}],
['arm_arch!=""', {
'cflags': [
'-march=<(arm_arch)',
],
'conditions': [
['use_lto==1 or use_lto_o2==1', {
'ldflags': [
'-march=<(arm_arch)',
],
}],
],
}],
['clang==1', {
'cflags': [
'-no-integrated-as',
],
}],
['arm_tune!=""', {
'cflags': [
'-mtune=<(arm_tune)',
],
'conditions': [
['use_lto==1 or use_lto_o2==1', {
'ldflags': [
'-mtune=<(arm_tune)',
],
}],
],
}],
['arm_fpu!=""', {
'cflags': [
'-mfpu=<(arm_fpu)',
],
'conditions': [
['use_lto==1 or use_lto_o2==1', {
'ldflags': [
'-mfpu=<(arm_fpu)',
],
}],
],
}],
['arm_float_abi!=""', {
'cflags': [
'-mfloat-abi=<(arm_float_abi)',
],
'conditions': [
['use_lto==1 or use_lto_o2==1', {
'ldflags': [
'-mfloat-abi=<(arm_float_abi)',
],
}],
],
}],
['arm_thumb==1', {
'cflags': [
'-mthumb',
],
'conditions': [
['use_lto==1 or use_lto_o2==1', {
'ldflags': [
'-mthumb',
],
}],
],
}],
],
}], # target_arch=="arm" and _toolset=="target"
],
},
}], # OS=="linux"
],
}

2
vendor/brightray vendored

@ -1 +1 @@
Subproject commit 89f8520322a1580657febac6529b2a2ead70f327
Subproject commit 713bc650744c3ed987499f64743977c739f11186