cc/gcc: simplify calls to core backend
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jul 17 15:48:27 2011 +0200 (2011-07-17)
changeset 2886f1ad0445325c
parent 2885 17c162b426c6
child 2887 6ee3b25e1097
cc/gcc: simplify calls to core backend

The core backend is going to have more parameters in the upcoming
patches, so it will be a bit complex to handle.

Introduce an array-variable that is filled by the different code-paths
with the required values.

This makes the code easier to read and maintain.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
scripts/build/cc/gcc.sh
     1.1 --- a/scripts/build/cc/gcc.sh	Mon Feb 13 22:56:45 2012 +0100
     1.2 +++ b/scripts/build/cc/gcc.sh	Sun Jul 17 15:48:27 2011 +0200
     1.3 @@ -55,21 +55,39 @@
     1.4  #------------------------------------------------------------------------------
     1.5  # Core gcc pass 1
     1.6  do_cc_core_pass_1() {
     1.7 +    local -a core_opts
     1.8 +    local do_core
     1.9 +
    1.10      # If we're building for bare metal, build the static core gcc,
    1.11      # with libgcc.
    1.12      # In case we're not bare metal and building a canadian compiler, do nothing
    1.13      # In case we're not bare metal, and we're NPTL, build the static core gcc.
    1.14      # In any other case, do nothing.
    1.15      case "${CT_BARE_METAL},${CT_CANADIAN},${CT_THREADS}" in
    1.16 -        y,*,*)  do_cc_core mode=static;;
    1.17 -        ,y,*)   ;;
    1.18 -        ,,nptl) do_cc_core mode=static;;
    1.19 -        *)      ;;
    1.20 +        y,*,*)
    1.21 +            do_core=y
    1.22 +            core_opts+=( "mode=static" )
    1.23 +            ;;
    1.24 +        ,y,*)
    1.25 +            ;;
    1.26 +        ,,nptl)
    1.27 +            do_core=y
    1.28 +            core_opts+=( "mode=static" )
    1.29 +            ;;
    1.30 +        *)
    1.31 +            ;;
    1.32      esac
    1.33 +
    1.34 +    if [ "${do_core}" = "y" ]; then
    1.35 +        do_cc_core "${core_opts[@]}"
    1.36 +    fi
    1.37  }
    1.38  
    1.39  # Core gcc pass 2
    1.40  do_cc_core_pass_2() {
    1.41 +    local -a core_opts
    1.42 +    local do_core
    1.43 +
    1.44      # In case we're building for bare metal, do nothing, we already have
    1.45      # our compiler.
    1.46      # In case we're not bare metal and building a canadian compiler, do nothing
    1.47 @@ -78,31 +96,43 @@
    1.48      # also build the target libgcc.
    1.49      case "${CT_BARE_METAL},${CT_CANADIAN},${CT_THREADS}" in
    1.50          y,*,*)
    1.51 +            do_core=y
    1.52 +            core_opts+=( "mode=baremetal" )
    1.53 +            core_opts+=( "build_libgcc=yes" )
    1.54 +            core_opts+=( "build_libstdcxx=yes" )
    1.55              if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then
    1.56 -                do_cc_core mode=baremetal build_libgcc=yes build_libstdcxx=yes build_staticlinked=yes build_manuals=yes
    1.57 -            else
    1.58 -                do_cc_core mode=baremetal build_libgcc=yes build_libstdcxx=yes build_manuals=yes
    1.59 +                core_opts+=( "build_staticlinked=yes" )
    1.60              fi
    1.61 +            core_opts+=( "build_manuals=yes" )
    1.62              ;;
    1.63          ,y,*)   ;;
    1.64          ,,nptl)
    1.65 -            do_cc_core mode=shared build_libgcc=yes
    1.66 +            do_core=y
    1.67 +            core_opts+=( "mode=shared" )
    1.68 +            core_opts+=( "build_libgcc=yes" )
    1.69              ;;
    1.70          ,,win32)
    1.71 -            do_cc_core mode=static build_libgcc=yes
    1.72 +            do_core=y
    1.73 +            core_opts+=( "mode=static" )
    1.74 +            core_opts+=( "build_libgcc=yes" )
    1.75              ;;
    1.76 -        *)  if [ "${CT_CC_GCC_4_3_or_later}" = "y" ]; then
    1.77 -                do_cc_core mode=static build_libgcc=yes
    1.78 -            else
    1.79 -                do_cc_core mode=static
    1.80 +        *)
    1.81 +            do_core=y
    1.82 +            core_opts+=( "mode=static" )
    1.83 +            if [ "${CT_CC_GCC_4_3_or_later}" = "y" ]; then
    1.84 +                core_opts+=( "build_libgcc=yes" )
    1.85              fi
    1.86              ;;
    1.87      esac
    1.88 +
    1.89 +    if [ "${do_core}" = "y" ]; then
    1.90 +        do_cc_core "${core_opts[@]}"
    1.91 +    fi
    1.92  }
    1.93  
    1.94  #------------------------------------------------------------------------------
    1.95  # Build core gcc
    1.96 -# This function is used to build both the static and the shared core C conpiler,
    1.97 +# This function is used to build both the static and the shared core C compiler,
    1.98  # with or without the target libgcc. We need to know wether:
    1.99  #  - we're building static, shared or bare metal: mode=[static|shared|baremetal]
   1.100  #  - we need to build libgcc or not             : build_libgcc=[yes|no]       (default: no)