[pacman-dev] [PATCH v3 2/2] ccache and distcc as buildenv_ext scripts
quequotion at gmail.com
quequotion at gmail.com
Sat Apr 2 00:32:29 UTC 2016
From: Que Quotion <quequotion at gmail.com>
I really only mean these as an example, but it does allow for a little more simplification to makepkg.
I like the idea that the only built-in build_options would be 'buildflags' and 'makeflags'.
---
scripts/libmakepkg/buildenv_ext/ccache.sh.in | 46 ++++++++++++++++++++++++++++
scripts/libmakepkg/buildenv_ext/distcc.sh.in | 45 ++++++++++++++++++++++++++++
scripts/makepkg.sh.in | 36 +---------------------
3 files changed, 92 insertions(+), 35 deletions(-)
create mode 100644 scripts/libmakepkg/buildenv_ext/ccache.sh.in
create mode 100644 scripts/libmakepkg/buildenv_ext/distcc.sh.in
diff --git a/scripts/libmakepkg/buildenv_ext/ccache.sh.in b/scripts/libmakepkg/buildenv_ext/ccache.sh.in
new file mode 100644
index 0000000..8d9e0b5
--- /dev/null
+++ b/scripts/libmakepkg/buildenv_ext/ccache.sh.in
@@ -0,0 +1,46 @@
+#!/usr/bin/bash
+#
+# ccache.sh - Cache compiliations and recycle them to save time on repititions
+#
+# Copyright (c) 2008-2016 Pacman Development Team <pacman-dev at archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_CCACHE_SH" ]] && return
+LIBMAKEPKG_CCACHE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+extra_buildopts+=('ccache')
+
+local ccache=0
+
+ccache() {
+
+ # use ccache if it is requested (check buildenv and PKGBUILD opts)
+ if check_buildoption "ccache" "y"; then
+ if ! type -p ccache >/dev/null; then
+ error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache"
+ return 1
+ fi
+ if [ -d /usr/lib/ccache/bin ]; then
+ export PATH="/usr/lib/ccache/bin:$PATH"
+ ccache=1
+ fi
+ fi
+}
diff --git a/scripts/libmakepkg/buildenv_ext/distcc.sh.in b/scripts/libmakepkg/buildenv_ext/distcc.sh.in
new file mode 100644
index 0000000..248445a
--- /dev/null
+++ b/scripts/libmakepkg/buildenv_ext/distcc.sh.in
@@ -0,0 +1,45 @@
+#!/usr/bin/bash
+#
+# distcc.sh - Distribute compliation to reduce compilation time
+#
+# Copyright (c) 2008-2016 Pacman Development Team <pacman-dev at archlinux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+[[ -n "$LIBMAKEPKG_CCACHE_SH" ]] && return
+LIBMAKEPKG_CCACHE_SH=1
+
+LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
+
+source "$LIBRARY/util/message.sh"
+source "$LIBRARY/util/option.sh"
+
+extra_buildopts+=('distcc')
+
+distcc() {
+ if check_buildoption "distcc" "y"; then
+ if ! type -p distcc >/dev/null; then
+ error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc"
+ return 1
+ fi
+ if (( ccache )); then
+ export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc"
+ export CCACHE_BASEDIR="$srcdir"
+ elif [[ -d /usr/lib/distcc/bin ]]; then
+ export PATH="/usr/lib/distcc/bin:$PATH"
+ fi
+ export DISTCC_HOSTS
+ fi
+}
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index aafec5d..e5f2028 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -48,7 +48,7 @@ declare -r startdir="$PWD"
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
-build_options=('ccache' 'distcc' 'buildflags' 'makeflags')
+build_options=('buildflags' 'makeflags')
splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends'
'optdepends' 'provides' 'conflicts' 'replaces' 'backup'
'options' 'install' 'changelog')
@@ -847,24 +847,6 @@ run_prepare() {
}
run_build() {
- local ccache=0
-
- # use ccache if it is requested (check buildenv and PKGBUILD opts)
- if check_buildoption "ccache" "y" && [[ -d /usr/lib/ccache/bin ]]; then
- export PATH="/usr/lib/ccache/bin:$PATH"
- ccache=1
- fi
-
- # use distcc if it is requested (check buildenv and PKGBUILD opts)
- if check_buildoption "distcc" "y"; then
- if (( ccache )); then
- export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc"
- export CCACHE_BASEDIR="$srcdir"
- elif [[ -d /usr/lib/distcc/bin ]]; then
- export PATH="/usr/lib/distcc/bin:$PATH"
- fi
- export DISTCC_HOSTS
- fi
# Check for BUILDENV extensions, use any that are requested (check buildenv and PKGBUILD opts)
buildenv_ext
@@ -1559,22 +1541,6 @@ check_software() {
fi
fi
- # distcc - compilation with distcc
- if check_buildoption "distcc" "y"; then
- if ! type -p distcc >/dev/null; then
- error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc"
- ret=1
- fi
- fi
-
- # ccache - compilation with ccache
- if check_buildoption "ccache" "y"; then
- if ! type -p ccache >/dev/null; then
- error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache"
- ret=1
- fi
- fi
-
# strip - strip symbols from binaries/libraries
if check_option "strip" "y"; then
if ! type -p strip >/dev/null; then
--
2.7.4
More information about the pacman-dev
mailing list