summaryrefslogtreecommitdiffstats
path: root/packaging/macos/jhb/etc/jhb.conf/ccache.sh
blob: 82a2208648e184f82754eeb84e01947e23baf772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# SPDX-FileCopyrightText: 2022 René de Hesselle <dehesselle@web.de>
#
# SPDX-License-Identifier: GPL-2.0-or-later

### description ################################################################

# Settings and functions to setup ccache.

### shellcheck #################################################################

# shellcheck shell=bash # no shebang as this file is intended to be sourced

### variables ##################################################################

export CCACHE_DIR=${CCACHE_DIR:-$WRK_DIR/ccache}

# https://ccache.dev
# https://github.com/ccache/ccache
# https://gitlab.com/dehesselle/ccache_macos
CCACHE_VER=4.6.3r1
CCACHE_URL=https://gitlab.com/api/v4/projects/29039216/packages/generic/\
ccache_macos/$CCACHE_VER/ccache_$(uname -m).tar.xz

### functions ##################################################################

function ccache_configure
{
    mkdir -p "$CCACHE_DIR"

  cat <<EOF > "$CCACHE_DIR/ccache.conf"
base_dir = $WRK_DIR
hash_dir = false
max_size = 3.0G
temporary_dir = $CCACHE_DIR/tmp
EOF
}

function ccache_install
{
  curl -L "$CCACHE_URL" | tar -C "$USR_DIR"/bin --exclude="ccache.sha256" -xJ

  for compiler in clang clang++ gcc g++; do
    ln -sf ccache "$USR_DIR"/bin/$compiler
  done
}

### main #######################################################################

# Nothing here.