Skip to content

Commit

Permalink
Add clang (pantsbuild#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Mar 30, 2018
1 parent 1598e82 commit e1f7c95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
21 changes: 5 additions & 16 deletions build-clang-5.0.1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ mkdir -p "$LLVM_RELEASE_BUILD_DIRNAME"

function extract-required-files-from-unpacked-llvm {
local -r unpacked_llvm_dir_abs="$1"
local -r c_stdlib_header_dir_abs="$2"
local -r cpp_stdlib_header_dir_abs="$3"
local -r pants_output_archive_name="$4"
local -r pants_output_archive_name="$2"

mkdir -p bin/ include/

Expand All @@ -42,9 +40,6 @@ function extract-required-files-from-unpacked-llvm {

popd

cp -r "$c_stdlib_header_dir_abs" include/c
cp -r "$cpp_stdlib_header_dir_abs" include/c++

tar czf "$pants_output_archive_name" bin/ include/
}

Expand All @@ -67,19 +62,11 @@ curl -L -O "https://releases.llvm.org/${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}
tar xf "clang+llvm-${LLVM_VERSION}-x86_64-apple-darwin.tar.xz"
llvm_macos_bin_release_dir_abs="$(pwd)/clang+llvm-${LLVM_VERSION}-final-x86_64-apple-darwin"

# Get C and C++ standard library headers from the MacOS binary release (they're
# not available in the Linux source release). These files are not
# platform-specific.
c_header_dir_abs="${llvm_macos_bin_release_dir_abs}/lib/clang/${LLVM_VERSION}/include"
cpp_header_dir_abs="${llvm_macos_bin_release_dir_abs}/include/c++/v1"

mkdir -p "$LLVM_TMP_MACOS_PKG_DIR"
pushd "$LLVM_TMP_MACOS_PKG_DIR"

extract-required-files-from-unpacked-llvm \
"$llvm_macos_bin_release_dir_abs" \
"$c_header_dir_abs" \
"$cpp_header_dir_abs" \
"$LLVM_PANTS_ARCHIVE_NAME"

llvm_macos_packaged_abs="$(pwd)/${LLVM_PANTS_ARCHIVE_NAME}"
Expand Down Expand Up @@ -123,6 +110,10 @@ tar xf "cfe-${LLVM_VERSION}.src.tar.xz"
mkdir -p "$LLVM_BUILD_TMP_DIR"
pushd "$LLVM_BUILD_TMP_DIR"

# This didn't immediately compile right off the bat -- I'd recommend to anyone
# watching that Homebrew formulas are good places to learn about how to provide
# high-quality toolchains on OSX. I found https://llvm.org/docs/CMake.html
# "helpful" for this line as well.
"$cmake_linux_bin_abs" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_EXTERNAL_CLANG_SOURCE_DIR="../cfe-${LLVM_VERSION}.src" \
Expand All @@ -142,8 +133,6 @@ pushd "$LLVM_TMP_LINUX_PKG_DIR"

extract-required-files-from-unpacked-llvm \
"$llvm_linux_source_release_dir_abs" \
"$c_header_dir_abs" \
"$cpp_header_dir_abs" \
"$LLVM_PANTS_ARCHIVE_NAME"

llvm_linux_packaged_abs="$(pwd)/${LLVM_PANTS_ARCHIVE_NAME}"
Expand Down
4 changes: 4 additions & 0 deletions build-clang-6.0.0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ tar xf "cfe-${LLVM_VERSION}.src.tar.xz"
mkdir -p "$LLVM_BUILD_TMP_DIR"
pushd "$LLVM_BUILD_TMP_DIR"

# This didn't immediately compile right off the bat -- I'd recommend to anyone
# watching that Homebrew formulas are good places to learn about how to provide
# high-quality toolchains on OSX. I found https://llvm.org/docs/CMake.html
# "helpful" for this line as well.
"$cmake_linux_bin_abs" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_EXTERNAL_CLANG_SOURCE_DIR="../cfe-${LLVM_VERSION}.src" \
Expand Down

0 comments on commit e1f7c95

Please sign in to comment.