[PATCH] build: Add PROGRAM_PREFIX option

Chris Johns chrisj at rtems.org
Wed Aug 2 08:33:03 UTC 2023


On 2/8/2023 3:49 pm, Sebastian Huber wrote:
> Replace --rtems-version with a PROGRAM_PREFIX option.  This allows also
> the use of vendor tools.> ---
>  spec/build/bsps/makeinc.yml            | 16 ++++++++--------
>  spec/build/bsps/maketarget.yml         | 22 +++++++++++-----------
>  spec/build/bsps/optobjcopy.yml         |  2 +-
>  spec/build/cpukit/cpuopts.yml          |  2 ++
>  spec/build/cpukit/optgcc.yml           |  8 ++++----
>  spec/build/cpukit/optprogramprefix.yml | 18 ++++++++++++++++++
>  spec/build/testsuites/ada/optgnat.yml  |  2 +-
>  wscript                                | 24 ++----------------------
>  8 files changed, 47 insertions(+), 47 deletions(-)
>  create mode 100644 spec/build/cpukit/optprogramprefix.yml
> 
> diff --git a/spec/build/bsps/makeinc.yml b/spec/build/bsps/makeinc.yml
> index ac395f2f02..08fc75a8b9 100644
> --- a/spec/build/bsps/makeinc.yml
> +++ b/spec/build/bsps/makeinc.yml
> @@ -16,14 +16,14 @@ content: |
>    prefix = ${PREFIX}
>    exec_prefix = $${prefix}/${ARCH}-rtems${__RTEMS_MAJOR__}
>  
> -  CC_FOR_TARGET = ${ARCH}-rtems${__RTEMS_MAJOR__}-gcc
> -  CXX_FOR_TARGET = ${ARCH}-rtems${__RTEMS_MAJOR__}-g++
> -  AS_FOR_TARGET = ${ARCH}-rtems${__RTEMS_MAJOR__}-as
> -  AR_FOR_TARGET = ${ARCH}-rtems${__RTEMS_MAJOR__}-ar
> -  NM_FOR_TARGET = ${ARCH}-rtems${__RTEMS_MAJOR__}-nm
> -  LD_FOR_TARGET = ${ARCH}-rtems${__RTEMS_MAJOR__}-ld
> -  SIZE_FOR_TARGET = ${ARCH}-rtems${__RTEMS_MAJOR__}-size
> -  OBJCOPY_FOR_TARGET = ${ARCH}-rtems${__RTEMS_MAJOR__}-objcopy
> +  CC_FOR_TARGET = ${PROGRAM_PREFIX}gcc
> +  CXX_FOR_TARGET = ${PROGRAM_PREFIX}g++

Is it worth doing the same to gcc and g++ as well so these can be replaced as well?

> +  AS_FOR_TARGET = ${PROGRAM_PREFIX}as
> +  AR_FOR_TARGET = ${PROGRAM_PREFIX}ar
> +  NM_FOR_TARGET = ${PROGRAM_PREFIX}nm
> +  LD_FOR_TARGET = ${PROGRAM_PREFIX}ld
> +  SIZE_FOR_TARGET = ${PROGRAM_PREFIX}size
> +  OBJCOPY_FOR_TARGET = ${PROGRAM_PREFIX}objcopy

Where is PROGRAM_PFREFIX set?

>    CC= $$(CC_FOR_TARGET)
>    CXX= $$(CXX_FOR_TARGET)
> diff --git a/spec/build/bsps/maketarget.yml b/spec/build/bsps/maketarget.yml
> index 798b64fa22..7a7b0c3d35 100644
> --- a/spec/build/bsps/maketarget.yml
> +++ b/spec/build/bsps/maketarget.yml
> @@ -11,17 +11,17 @@ content: |
>    LIBS =
>  
>    RTEMS_API = ${__RTEMS_MAJOR__}
> -  CC = ${ARCH}-rtems${__RTEMS_MAJOR__}-gcc --pipe
> -  AS = ${ARCH}-rtems${__RTEMS_MAJOR__}-as
> -  AR = ${ARCH}-rtems${__RTEMS_MAJOR__}-ar
> -  NM = ${ARCH}-rtems${__RTEMS_MAJOR__}-nm
> -  LD = ${ARCH}-rtems${__RTEMS_MAJOR__}-ld
> -  SIZE = ${ARCH}-rtems${__RTEMS_MAJOR__}-size
> -  STRIP = ${ARCH}-rtems${__RTEMS_MAJOR__}-strip
> -  OBJCOPY = ${ARCH}-rtems${__RTEMS_MAJOR__}-objcopy
> -  RANLIB = ${ARCH}-rtems${__RTEMS_MAJOR__}-ranlib
> -
> -  CXX = ${ARCH}-rtems${__RTEMS_MAJOR__}-g++
> +  CC = ${PROGRAM_PREFIX}gcc --pipe
> +  AS = ${PROGRAM_PREFIX}as
> +  AR = ${PROGRAM_PREFIX}ar
> +  NM = ${PROGRAM_PREFIX}nm
> +  LD = ${PROGRAM_PREFIX}ld
> +  SIZE = ${PROGRAM_PREFIX}size
> +  STRIP = ${PROGRAM_PREFIX}strip
> +  OBJCOPY = ${PROGRAM_PREFIX}objcopy
> +  RANLIB = ${PROGRAM_PREFIX}ranlib
> +
> +  CXX = ${PROGRAM_PREFIX}g++

Same here with setting PROGRAM_PREFIX?

Chris

>  
>    export CC
>    export AS
> diff --git a/spec/build/bsps/optobjcopy.yml b/spec/build/bsps/optobjcopy.yml
> index 3387e23794..63fab08ac6 100644
> --- a/spec/build/bsps/optobjcopy.yml
> +++ b/spec/build/bsps/optobjcopy.yml
> @@ -1,6 +1,6 @@
>  SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
>  actions:
> -- set-value: ${ARCH}-rtems${__RTEMS_MAJOR__}-objcopy
> +- set-value: ${PROGRAM_PREFIX}objcopy
>  - substitute: null
>  - find-program: null
>  - env-assign: OBJCOPY
> diff --git a/spec/build/cpukit/cpuopts.yml b/spec/build/cpukit/cpuopts.yml
> index f1b30eec55..1d28ace552 100644
> --- a/spec/build/cpukit/cpuopts.yml
> +++ b/spec/build/cpukit/cpuopts.yml
> @@ -7,6 +7,8 @@ guard: _RTEMS_SCORE_CPUOPTS_H
>  include-headers: []
>  install-path: ${BSP_INCLUDEDIR}/rtems/score
>  links:
> +- role: build-dependency
> +  uid: optprogramprefix
>  - role: build-dependency
>    uid: optgcc
>  - role: build-dependency
> diff --git a/spec/build/cpukit/optgcc.yml b/spec/build/cpukit/optgcc.yml
> index 3afb909444..94af494af4 100644
> --- a/spec/build/cpukit/optgcc.yml
> +++ b/spec/build/cpukit/optgcc.yml
> @@ -1,21 +1,21 @@
>  SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
>  actions:
> -- set-value: ${ARCH}-rtems${__RTEMS_MAJOR__}-gcc
> +- set-value: ${PROGRAM_PREFIX}gcc
>  - substitute: null
>  - find-program: null
>  - env-assign: AS
>  - env-assign: CC
>  - env-assign: LINK_CC
> -- set-value: ${ARCH}-rtems${__RTEMS_MAJOR__}-g++
> +- set-value: ${PROGRAM_PREFIX}g++
>  - substitute: null
>  - find-program: null
>  - env-assign: CXX
>  - env-assign: LINK_CXX
> -- set-value: ${ARCH}-rtems${__RTEMS_MAJOR__}-ar
> +- set-value: ${PROGRAM_PREFIX}ar
>  - substitute: null
>  - find-program: null
>  - env-assign: AR
> -- set-value: ${ARCH}-rtems${__RTEMS_MAJOR__}-ld
> +- set-value: ${PROGRAM_PREFIX}ld
>  - substitute: null
>  - find-program: null
>  - env-assign: LD
> diff --git a/spec/build/cpukit/optprogramprefix.yml b/spec/build/cpukit/optprogramprefix.yml
> new file mode 100644
> index 0000000000..73deef79d1
> --- /dev/null
> +++ b/spec/build/cpukit/optprogramprefix.yml
> @@ -0,0 +1,18 @@
> +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
> +actions:
> +- get-string: null
> +- substitute: null
> +- env-assign: null
> +build-type: option
> +copyrights:
> +- Copyright (C) 2023 embedded brains GmbH & Co. KG
> +default:
> +- enabled-by: true
> +  value: ${ARCH}-rtems${__RTEMS_MAJOR__}-
> +description: |
> +  Defines the program prefix of tools (compiler, assembler, linker).
> +enabled-by: true
> +format: '{}'
> +links: []
> +name: PROGRAM_PREFIX
> +type: build
> diff --git a/spec/build/testsuites/ada/optgnat.yml b/spec/build/testsuites/ada/optgnat.yml
> index 6d84f64845..449859bde0 100644
> --- a/spec/build/testsuites/ada/optgnat.yml
> +++ b/spec/build/testsuites/ada/optgnat.yml
> @@ -1,6 +1,6 @@
>  SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
>  actions:
> -- set-value: ${ARCH}-rtems${__RTEMS_MAJOR__}-gnatmake
> +- set-value: ${PROGRAM_PREFIX}gnatmake
>  - substitute: null
>  - find-program: null
>  - env-assign: GNATMAKE
> diff --git a/wscript b/wscript
> index 85600b9e05..a8fca88dcb 100755
> --- a/wscript
> +++ b/wscript
> @@ -1306,12 +1306,6 @@ def options(ctx):
>          help=
>          "the UID of the top-level group [default: '/grp']; it may be used in the bspdefaults and configure commands",
>      )
> -    rg.add_option(
> -        "--rtems-version",
> -        metavar="VALUE",
> -        help=
> -        "sets the RTEMS major version number; it is intended for RTEMS maintainers and may be used in the bspdefaults and configure commands",
> -    )
>  
>  
>  def check_environment(conf):
> @@ -1351,12 +1345,6 @@ def configure_version(conf):
>                  version[key] = no_unicode(value)
>              except configparser.NoOptionError:
>                  pass
> -    major = conf.options.rtems_version
> -    if major is not None:
> -        conf.msg("Set __RTEMS_MAJOR__ via command line to:",
> -                 major,
> -                 color="YELLOW")
> -        version["__RTEMS_MAJOR__"] = major
>  
>  
>  def load_config_files(ctx):
> @@ -1566,14 +1554,7 @@ def build(bld):
>      if not bld.variant:
>          check_forbidden_options(
>              bld,
> -            [
> -                "compiler",
> -                "config",
> -                "specs",
> -                "tools",
> -                "top_group",
> -                "version",
> -            ],
> +            ["compiler", "config", "specs", "tools", "top_group"],
>          )
>          load_items(bld, bld.env.SPECS)
>          append_variant_builds(bld)
> @@ -1662,8 +1643,7 @@ COMPILER = {}""".format(variant, compiler))
>  
>  def bsplist(ctx):
>      """lists base BSP variants"""
> -    check_forbidden_options(
> -        ctx, ["compiler", "config", "tools", "top_group", "version"])
> +    check_forbidden_options(ctx, ["compiler", "config", "tools", "top_group"])
>      add_log_filter(ctx.cmd)
>      load_items_from_options(ctx)
>      white_list = get_white_list(ctx)


More information about the devel mailing list