kou commented on code in PR #13556:
URL: https://github.com/apache/arrow/pull/13556#discussion_r971414553


##########
ci/docker/centos-7-cpp.dockerfile:
##########
@@ -20,6 +20,7 @@ FROM centos:centos7
 RUN yum install -y \
         diffutils \
         gcc-c++ \
+        curl \

Review Comment:
   Could you keep this list in alphabetical order?



##########
cpp/CMakeLists.txt:
##########
@@ -191,18 +191,47 @@ else()
   set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
 endif()
 
-if(ARROW_USE_CCACHE
+if((ARROW_USE_SCCACHE)
    AND NOT CMAKE_C_COMPILER_LAUNCHER
    AND NOT CMAKE_CXX_COMPILER_LAUNCHER)
+
+  find_program(SCCACHE_FOUND sccache)
+  
+  if(NOT SCCACHE_FOUND AND DEFINED ENV{SCCACHE_PATH})
+    # cmake has problems finding sccache from within mingw
+    message(STATUS "Did not find sccache, using envvar fallback.")
+    set(SCCACHE_FOUND $ENV{SCCACHE_PATH})
+  endif()
+
+  # Only use sccache if a storage backend is configured
+  if(SCCACHE_FOUND AND (
+    DEFINED ENV{SCCACHE_AZURE_BLOB_CONTAINER}
+    OR DEFINED ENV{SCCACHE_BUCKET}
+    OR DEFINED ENV{SCCACHE_DIR}
+    OR DEFINED ENV{SCCACHE_GCS_BUCKET}
+    OR DEFINED ENV{SCCACHE_MEMCACHED}
+    OR DEFINED ENV{SCCACHE_REDIS}
+  ))
+    message(STATUS "Using sccache: ${SCCACHE_FOUND}")
+    set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE_FOUND})
+    set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE_FOUND})
+  endif()
+endif()
+
+if((ARROW_USE_CCACHE)

Review Comment:
   ```suggestion
   if(ARROW_USE_CCACHE
   ```



##########
dev/tasks/docker-tests/github.linux.yml:
##########
@@ -31,6 +31,8 @@ jobs:
 
       - name: Execute Docker Build
         shell: bash
+        env:
+        {{ macros.github_set_sccache_envvars()|indent(8) }}

Review Comment:
   Do we need one more indent here?
   
   ```suggestion
             {{ macros.github_set_sccache_envvars()|indent(10) }}
   ```



##########
docker-compose.yml:
##########
@@ -411,14 +416,16 @@ services:
       - apparmor:unconfined
     ulimits: *ulimits
     environment:
-      <<: *ccache
+      <<: [*ccache, *sccache]
       ARROW_HOME: /arrow
       ARROW_DEPENDENCY_SOURCE: BUNDLED
       LIBARROW_MINIMAL: "false"
       ARROW_MIMALLOC: "ON"
     volumes: *ubuntu-volumes
-    command: /bin/bash -c "
-        cd /arrow && r/inst/build_arrow_static.sh"
+    command: &arrow-static-cmd

Review Comment:
   Could you use the same naming convention others use? 
   
   ```suggestion
       command: &cpp-static-command
   ```



##########
cpp/CMakeLists.txt:
##########
@@ -191,18 +191,47 @@ else()
   set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
 endif()
 
-if(ARROW_USE_CCACHE
+if((ARROW_USE_SCCACHE)

Review Comment:
   ```suggestion
   if(ARROW_USE_SCCACHE
   ```



##########
ci/scripts/install_sccache.sh:
##########
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+
+if [  "$#" -lt 1 -o "$#" -gt 3 ]; then
+    echo "Usage: $0 <build> <prefix> <arch> <version>"
+    echo "Will default to arch=x86_64 and version=0.3.0 "
+    exit 1
+fi
+
+BUILD=$1
+PREFIX=$2
+ARCH=${3:-x86_64}
+VERSION=${4:-0.3.0}
+
+SCCACHE_URL="https://github.com/mozilla/sccache/releases/download/v0.3.0/sccache-v$VERSION-$ARCH-$BUILD.tar.gz";
+SCCACHE_ARCHIVE=sccache.tar.gz
+
+# Download archive and checksum
+curl -L $SCCACHE_URL --output $SCCACHE_ARCHIVE
+curl -L $SCCACHE_URL.sha256 --output $SCCACHE_ARCHIVE.sha256
+
+echo "$(cat $SCCACHE_ARCHIVE.sha256) $SCCACHE_ARCHIVE" | sha256sum --check 
--status
+
+if [ ! -d $PREFIX ]; then
+    mkdir -p $PREFIX
+fi
+
+tar -xzvf $SCCACHE_ARCHIVE --strip-component=1 --directory $PREFIX --wildcards 
sccache*/sccache* 
+chmod u+x $PREFIX/sccache
+
+if [ "$GITHUB_ACTIONS" ]; then

Review Comment:
   ```suggestion
   if [ -n "$GITHUB_ACTIONS" ]; then
   ```
   
   How about using `$GITHUB_PATH` or `$GITHUB_ENV` instead because 
`$GITHUB_ACTION` is for the action name not whether the current environment is 
GitHub Actions or not:
   
   
https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
   
   > GITHUB_ACTION | The name of the action currently running, or the id of a 
step. For example, for an action, __repo-owner_name-of-action-repo.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to