Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SCRIPT] dmake -- distcc make
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools)
View previous topic :: View next topic  
Author Message
drizztbsd
Retired Dev
Retired Dev


Joined: 21 Nov 2004
Posts: 278
Location: Cesano Maderno

PostPosted: Fri Jan 26, 2007 2:51 pm    Post subject: [SCRIPT] dmake -- distcc make Reply with quote

Oggi mi sono fatto uno script per gestire comodamente la compilazione con distcc
Le features sono le seguenti:
  • Utilizza di ccache e/o distcc automaticamente se rilevati
  • Supporto cross-distcc
  • Supporto porte diverse da quelle standard e numero jobs

L'unico problema per ora è che devi usare la sintassi col numero jobs (host/num o host:port/num)

Code:
#!/bin/bash
# Copyright 2007 Timothy Redaelli <drizzt@gentoo.org>
# Distributed under the terms of the GNU General Public License v2

einfo() {
   echo -e " \e[32;01m*\e[0m $*"
}

ewarn() {
   echo -e " \e[33;01m*\e[0m $*" >&2
}

CHOST=$(gcc -v 2>&1 | awk '/^Target: /{print $2}')
export AS="/usr/${CHOST}/bin/as"
export LD="/usr/${CHOST}/bin/ld"

if type ccache &>/dev/null; then
   einfo ccache detected
   export PATH="/usr/lib/ccache/bin/:$PATH"
   export CC="/usr/lib/ccache/bin/${CHOST}-gcc"
   export CXX="/usr/lib/ccache/bin/${CHOST}-g++"
fi

if type distcc &>/dev/null; then
   einfo distcc detected
   if [[ -z "$DISTCC_HOSTS" ]]; then
      for i in $(</etc/distcc/hosts); do
         ip=${i%/*}
         port=${ip#*:}
         [[ "${port}" = "${ip}" ]] && port=3632 || ip=${ip%:*}
         if ( > "/dev/tcp/${ip}/${port}" ) 2>/dev/null || [[ ${ip} = localhost ]]; then
            DISTCC_HOSTS="${DISTCC_HOSTS} ${i}"
         else
            ewarn "${ip}:${port} is not available."
         fi
      done
   fi
    if [[ "${DISTCC_HOSTS}" ]]; then
        export DISTCC_HOSTS=${DISTCC_HOSTS}
        MAKEOPTS="-j$(($(for i in ${DISTCC_HOSTS}; do echo -n ${i#*/}+; done ; echo 0)))"
   if type ccache &>/dev/null; then
      export CCACHE_PREFIX="distcc"
   else
      export PATH="/usr/lib/distcc/bin/:$PATH"
      export CC="/usr/lib/distcc/bin/${CHOST}-gcc"
      export CXX="/usr/lib/distcc/bin/${CHOST}-g++"
   fi
        einfo "I'm using distcc with \"${DISTCC_HOSTS}\""
    fi
fi

make -e ${MAKEOPTS} $*


Per gli host usare distcc-config
_________________
Gentoo/Alt lead
Gentoo/*BSD and Gentoo/FreeBSD deputy lead
Paludis contributor
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum