[MacPorts] howto/ccache modified

MacPorts Wiki noreply at macports.org
Fri Apr 26 08:00:11 UTC 2019


Page "howto/ccache" was changed by ra1nb0w
Diff URL: <https://trac.macports.org/wiki/howto/ccache?action=diff&version=8>
Revision 8
Changes:
-------8<------8<------8<------8<------8<------8<------8<------8<--------
Index: howto/ccache
=========================================================================
--- howto/ccache (version: 7)
+++ howto/ccache (version: 8)
@@ -52,7 +52,44 @@
 
 === '''Use ccache outside MacPorts''' ===
 
-To use ccache also outside MacPorts you have to edit your PATH which is set in your `.profile` or `.bash_profile`.
+MacPorts doesn't create symlinks to local compiler therefore you need to create it manually.
+
+One way could be to use the following script that find the available compilers and create symlinks on {{{/opt/local/libexec/ccache}}}.
+
+{{{
+#!/bin/sh
+
+##
+## run with sudo or adjust prefix/dest_links
+##
+
+# adjust if needed
+prefix="/opt/local"
+dest_links="${prefix}/libexec/ccache"
+bin_paths="/usr/bin /opt/local/bin /usr/local/bin"
+ccache_bin=$(which ccache)
+
+# set umask to avoid strict starting shell
+umask 022
+
+if [ ! -d ${dest_links} ]; then
+  install -d ${dest_links}
+fi
+
+find $bin_paths \( -name "gcc*" -or -name "cc*" \
+  -or -name "g++*" -or -name "c++*" \
+  -or -name "clang++-mp*" -or -name "clang-mp*" \) | \
+  egrep -v "cmake*|ccache*|ccomps*|c\+\+filt*" | \
+while read file; do
+  base=$(basename $file)
+  ln -s ${ccache_bin} ${dest_links}/${base}
+done
+
+echo ">> add $dest_links in front of your \$PATH"
+}}}
+
+
+Now to use ccache also outside MacPorts you have to edit your PATH which is set in your `.profile` or `.bash_profile`.
 
 First, locate the file you are using. If there is a `.bash_profile` edit this file, if there is only `.profile` you want to edit this.
     
@@ -68,6 +105,6 @@
 
 '''Important:''' Reopen your Terminal afterwards.
 
-If you now use commands like ''gcc'' they automatically go through ccache.
+If you now use commands like ''gcc'' or "clang" they automatically go through ccache.
 
 [wiki:howto <- Back to the HOWTO section]
-------8<------8<------8<------8<------8<------8<------8<------8<--------

--
Page URL: <https://trac.macports.org/wiki/howto/ccache>
MacPorts <https://www.macports.org/>
Ports system for macOS

This is an automated message. Someone added your email address to be
notified of changes on 'howto/ccache' page.
If it was not you, please report to admin at macports.org.


More information about the macports-changes mailing list