forked from rstudio/rstudio
-
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.
Merge pull request rstudio#12526 from rstudio/feature/sccache-support
Add sccache support
- Loading branch information
Showing
10 changed files
with
130 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -481,3 +481,7 @@ if(APPLE) | |
|
||
endif() | ||
|
||
# If enabled, use caching for the build | ||
if(SCCACHE_ENABLED) | ||
include(sccache) | ||
endif() |
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,28 @@ | ||
find_program(CCACHE_PROGRAM sccache) | ||
message(STATUS "Looking for SCCACHE...") | ||
|
||
if(CCACHE_PROGRAM) | ||
message(STATUS "Found SCCACHE: ${CCACHE_PROGRAM}") | ||
# Support Unix Makefiles and Ninja. See https://stackoverflow.com/a/24305849/1170370 | ||
# set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") | ||
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) | ||
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) | ||
endif() | ||
|
||
# ccache compatibility with XCode | ||
# see https://stackoverflow.com/a/36515503/1170370 | ||
get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE) | ||
if(RULE_LAUNCH_COMPILE AND CMAKE_GENERATOR STREQUAL "Xcode") | ||
# Set up wrapper scripts | ||
configure_file(launch-c.in launch-c) | ||
configure_file(launch-cxx.in launch-cxx) | ||
execute_process(COMMAND chmod a+rx | ||
"${CMAKE_BINARY_DIR}/launch-c" | ||
"${CMAKE_BINARY_DIR}/launch-cxx") | ||
|
||
# Set Xcode project attributes to route compilation through our scripts | ||
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c") | ||
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx") | ||
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c") | ||
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx") | ||
endif() |
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
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 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# install-sccache | ||
# | ||
# Copyright (C) 2023 by Posit Software, PBC | ||
# | ||
# Unless you have received this program directly from RStudio pursuant | ||
# to the terms of a commercial license agreement with RStudio, then | ||
# this program is licensed to you under the terms of version 3 of the | ||
# GNU Affero General Public License. This program is distributed WITHOUT | ||
# ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT, | ||
# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the | ||
# AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details. | ||
# | ||
# | ||
|
||
set -e | ||
|
||
source "$(dirname "${BASH_SOURCE[0]}")/../tools/rstudio-tools.sh" | ||
section "Installing sccache" | ||
|
||
# install dir | ||
export INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}" | ||
if ! [ -w "$INSTALL_DIR" ]; then | ||
export INSTALL_DIR="$HOME/opt/bin" | ||
fi | ||
|
||
VERSION=0.3.1 | ||
|
||
# default architecture to amd64/x86_64 | ||
ARCH=x86_64 | ||
SCCACHE_PACKAGE_HASH="94ea33aac8dcb358753f8240cc87345963cf83cda7c6af0395dff31ffdc88df4" | ||
|
||
# override to aarch64 if running on arm | ||
if [ "$(arch)" = "aarch64" ] ; then | ||
ARCH=aarch64 | ||
SCCACHE_PACKAGE_HASH="1bf58385dc27b66324bb9ee82084e65c4d2e60baa19e3d16d2ab4da6c1ae66b2" | ||
fi | ||
|
||
URL=https://github.com/mozilla/sccache/releases/download/v${VERSION}/sccache-v${VERSION}-${ARCH}-unknown-linux-musl.tar.gz | ||
|
||
wget --progress=bar:force:noscroll ${URL} -O sccache.tar.gz \ | ||
&& echo "${SCCACHE_PACKAGE_HASH} sccache.tar.gz" | sha256sum -c - | ||
|
||
tar -zxvpf sccache.tar.gz | ||
mkdir -p ${INSTALL_DIR} | ||
if [ ! -f ${INSTALL_DIR}/sccache ]; then | ||
mv sccache-v${VERSION}-*/sccache ${INSTALL_DIR}/sccache | ||
|
||
chmod +x ${INSTALL_DIR}/sccache | ||
# this is so that boost/bjam will find and use sccache | ||
ln -sf ${INSTALL_DIR}/sccache ${INSTALL_DIR}/ccache | ||
|
||
fi | ||
|
||
rm -rf sccache* |
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
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