rtems/kernel: Update the confg file support

- Check for config file tests and install if enabled

- Support buildset BSP options defines if building a single BSP

- Remove bootstrap and autotools fragments
This commit is contained in:
Chris Johns 2022-09-07 18:22:04 +10:00
parent e1f87e5d72
commit c12cbadfa9

View File

@ -20,41 +20,110 @@
%endif %endif
%if %{defined with_rtems_bsp_config} %if %{defined with_rtems_bsp_config}
%define _target %(%{_sbdir}/sb/rtems-kernel-config-check -v %{rtems_version} -t %{with_rtems_bsp_config}) #
%define rtems_bsp %(%{_sbdir}/sb/rtems-kernel-config-check -b %{with_rtems_bsp_config}) # A config file can build any BSP from any architecture. No options are
%endif # accepted.
#
# %if %{defined with_rtems_target} || %{defined with_rtems_bsp} || \
# The target. It could be set in rtems_target. %{defined with_rtems_bspopts} || %{defined enable_cxx} || \
# %{defined with_rtems_tests} || %{defined with_rtems_smp}
%if %{defined rtems_target} && !%{defined with_rtems_bsp_config} %error Options --with-rtems-* are not valid with --with-rtems-bsp-config
%define _target %{rtems_target} %endif
%endif %if %{defined rtems_posix} || %{defined rtems_tests} || %{defined rtems_bspopts}
%if %{_target} == %{nil} && %{rtems_kernel_error} %error Options rtems_* macros are not valid with --with-rtems-bsp-config
%error No RTEMS target specified: --target=<arch>-rtems<ver>. %endif
%endif %define config_file %(realpath %{with_rtems_bsp_config})
%if %(test -f %{config_file}; echo $?) == 1
# %error Configuration INI file not found: %{config_file}
# The BSP. %endif
# %define rtems_bsp %(%{_sbdir}/sb/rtems-kernel-config-check -c %{with_rtems_bsp_config})
%if !%{defined with_rtems_bsp} && %{rtems_kernel_error} && !%{defined with_rtems_bsp_config} %define rtems_bsp_count %(echo %{rtems_bsp} | tr ' ' '\n' | wc -l)
%error No RTEMS BSP specified: --with-rtems-bsp=bsp %define rtems_tests %(%{_sbdir}/sb/rtems-kernel-config-check -t %{with_rtems_bsp_config})
%endif
%if !%{defined with_rtems_bsp_config}
%define rtems_bsp %{with_rtems_bsp}
# If a list the path gets too long # If a list the path gets too long
%define rtems_bsp_pkgname %(basename %{with_rtems_bsp_config} | sed -e 's/\..*//g')
%else
#
# Backwards compatible command line or deployed build set
# options.
#
%define config_file config.ini
%if !%{defined with_rtems_bsp} && %{rtems_kernel_error}
%error No RTEMS BSP specified: --with-rtems-bsp=bsp
%endif
%if %{defined with_rtems_bspopts}
%define bspopts %{with_rtems_bspopts}
%endif
%define rtems_bsp_pkgname bsps %define rtems_bsp_pkgname bsps
#
# Check the various --with/--without options we support. These are
# turned into the internal settings.
#
# --with-rtems-bsp : The BSP or list of BSPs
# --without-rtems-bsp : Not supported
# --with-rtems-tests : Supported, samples/yes/no
# --without-rtems-tests : Supported, forced to no
# --with-rtems-smp : Supported
# --without-rtems-smp : Don't care
# --with-rtems-legacy-network : Unsupported
# --without-rtems-legacy-network : Don't care
%if !%{defined with_rtems_bsp}
%error Option --without-rtems-bsp is not found.
%endif
%if %{defined without_rtems_bsp}
%error Option --without-rtems-bsp is not supported.
%endif
%define rtems_bsp %{with_rtems_bsp}
%define rtems_bsp_count %(echo %{rtems_bsp} | tr ' ' '\n' | wc -l)
%if %{defined with_rtems_legacy_network}
echo "RTEMS legacy network has been removed."
echo "Please review and update your configuration."
exit 1
%endif
%if %{defined enable_cxx}
echo "CXX has been removed."
echo "Please review and update your configuration."
exit 1
%endif
%if %{defined without_rtems_tests}
%define rtems_tests False
%define rtems_sample_tests False
%endif
%if %{defined with_rtems_tests}
%if %{with_rtems_tests} == 1
%define rtems_tests True
%define rtems_sample_tests True
%endif
%if %{with_rtems_tests} == samples
%define rtems_tests False
%define rtems_sample_tests True
%endif
%endif
%if %{defined with_rtems_smp}
%define rtems_smp 1
%endif
%if %{defined with_rtems_bspopts}
%if %{rtems_bsp_count} > 1
%error BSP options not supported with more than one BSP builds
%endif
%define rtems_bspopts %{with_rtems_bspopts}
%endif
#
# Default set up. Override these in a BSP if you want a
# specific setup.
#
%ifn %{defined rtems_posix}
%define rtems_posix 1
%endif
%ifn %{defined rtems_tests}
%define rtems_tests False
%define rtems_sample_tests True
%endif
%ifn %{defined rtems_bspopts}
%define rtems_bspopts %{nil}
%endif
%endif %endif
# %define _target not-used
# Configuration file used with waf
#
%if !%{defined with_rtems_bsp_config}
%define config_file config.ini
%else
%define config_file %{with_rtems_bsp_config}
%define rtems_bsp_pkgname %(basename %{with_rtems_bsp_config})
%endif
# #
# If no tools are provided use the prefix. # If no tools are provided use the prefix.
@ -71,13 +140,13 @@
# #
# Define the package. # Define the package.
# #
package: rtems-%{rtems_version}-%{_target}-%{rtems_bsp_pkgname}-%{_host}-%{release} package: rtems-%{rtems_version}-%{rtems_bsp_pkgname}-%{_host}-%{release}
# #
# Package details. # Package details.
# #
Name: %{_target}-kernel-%{rtems_bsp_pkgname}-%{release} Name: rtems-kernel-%{rtems_bsp_pkgname}-%{release}
Summary: RTEMS v%{rtems_kernel_version} for target %{_target} BSP %{rtems_bsp} Summary: RTEMS v%{rtems_kernel_version} for BSP(s) %{rtems_bsp}
Version: %{rtems_kernel_version} Version: %{rtems_kernel_version}
Release: %{release} Release: %{release}
URL: https://www.rtems.org/ URL: https://www.rtems.org/
@ -100,23 +169,13 @@ URL: https://www.rtems.org/
%define rtems_posix 0 %define rtems_posix 0
%endif %endif
%if %{defined with_rtems_bspopts}
%define bspopts %{with_rtems_bspopts}
%endif
# #
# Source # Source
# #
%if %{rsb_released} %if %{rsb_released}
%define rtems_kernel_file rtems-%{rtems_kernel_version}.tar.xz %define rtems_kernel_file rtems-%{rtems_kernel_version}.tar.xz
%define rtems_bootstrap 0
%else %else
%define rtems_kernel_file rtems-kernel-%{rtems_kernel_version}.tar.bz2 %define rtems_kernel_file rtems-kernel-%{rtems_kernel_version}.tar.bz2
#
# The code in git needs to be bootstrapped. Do each build because we have
# no way to change what changes may have happened in the code.
#
%define rtems_bootstrap 1
%endif %endif
%if ! %{defined rtems_kernel_version} %if ! %{defined rtems_kernel_version}
@ -126,70 +185,6 @@ URL: https://www.rtems.org/
%source set rtems_kernel --rsb-file=%{rtems_kernel_file} \ %source set rtems_kernel --rsb-file=%{rtems_kernel_file} \
https://git.rtems.org/rtems/snapshot/rtems-%{rtems_kernel_version}.tar.bz2 https://git.rtems.org/rtems/snapshot/rtems-%{rtems_kernel_version}.tar.bz2
#
# Check the various --with/--without options we support. These are
# turned into the internal settings.
#
# --target : The architecture
# --with-rtems-bsp : The BSP
# --without-rtems-bsp : Not supported
# --with-rtems-tests : Supported, samples/yes/no
# --without-rtems-tests : Supported, forced to no
# --with-rtems-smp : Supported
# --without-rtems-smp : Don't care
# --with-rtems-legacy-network : Unsupported
# --without-rtems-legacy-network : Don't care
%if %{defined without_rtemsbsp}
%error Option --without-rtemsbsp is not supported.
%endif
%if %{defined with_rtems_legacy_network}
echo "RTEMS legacy network has been removed."
echo "Please review and update your configuration."
exit 1
%endif
%if %{defined enable_cxx}
echo "CXX has been removed."
echo "Please review and update your configuration."
exit 1
%endif
%if %{defined without_rtems_tests}
%define rtems_tests False
%define rtems_sample_tests False
%endif
%if %{defined with_rtems_tests}
%if %{with_rtems_tests} == 1
%define rtems_tests True
%define rtems_sample_tests True
%endif
%if %{with_rtems_tests} == samples
%define rtems_tests False
%define rtems_sample_tests True
%endif
%endif
%if %{defined with_rtems_smp}
%define rtems_smp 1
%endif
%if %{defined with_rtems_bspopts}
%define rtems_bspopts %{with_rtems_bspopts}
%endif
#
# Default set up. Override these in a BSP if you want a
# specific setup.
#
%ifn %{defined rtems_posix}
%define rtems_posix 1
%endif
%ifn %{defined rtems_tests}
%define rtems_tests False
%define rtems_sample_tests True
%endif
%ifn %{defined rtems_bspopts}
%define rtems_bspopts %{nil}
%endif
# #
# Prepare the source code. # Prepare the source code.
# #
@ -198,11 +193,6 @@ URL: https://www.rtems.org/
%source setup rtems_kernel -q -c -n %{name}-%{version} %source setup rtems_kernel -q -c -n %{name}-%{version}
cd ${source_dir_rtems} cd ${source_dir_rtems}
%patch setup rtems_kernel -p1 %patch setup rtems_kernel -p1
%if %{rtems_bootstrap}
%if %{defined _internal_autotools_path}
export PATH="%{_internal_autotools_path}/bin:${PATH}"
%endif
%endif
cd .. cd ..
%build %build
@ -215,7 +205,10 @@ URL: https://www.rtems.org/
cd ${source_dir_rtems} cd ${source_dir_rtems}
%ifn %{defined with_rtems_bsp_config} #
# If no user supplied configuration file create one
#
%if !%{defined with_rtems_bsp_config}
echo "[DEFAULT]" > %{config_file} echo "[DEFAULT]" > %{config_file}
echo "RTEMS_POSIX_API = %{?rtems_posix:True}%{!?rtems_posix:False}" >> %{config_file} echo "RTEMS_POSIX_API = %{?rtems_posix:True}%{!?rtems_posix:False}" >> %{config_file}
echo "RTEMS_SMP = %{?rtems_smp:True}%{!?rtems_smp:False}" >> %{config_file} echo "RTEMS_SMP = %{?rtems_smp:True}%{!?rtems_smp:False}" >> %{config_file}
@ -224,7 +217,13 @@ URL: https://www.rtems.org/
echo "" >> %{config_file} echo "" >> %{config_file}
for bsp in %{rtems_bsp} for bsp in %{rtems_bsp}
do do
echo "[$bsp]" >> %{config_file}; echo "[$bsp]" >> %{config_file}
%if %{rtems_bsp_count} == 1 && %{defined rtems_bspopts}
for opt in $(echo %{rtems_bspopts} | tr ' ' '\n')
do
echo "$opt" >> %{config_file}
done
%endif
echo "" >> %{config_file} echo "" >> %{config_file}
done done
%endif %endif
@ -248,10 +247,13 @@ URL: https://www.rtems.org/
echo "rtems_tests: %{rtems_tests}" echo "rtems_tests: %{rtems_tests}"
%if %{rtems_tests} != False %if %{rtems_tests} != False
%define rtems_test_install %{_target}/%{rtems_bsp}/tests for bsp in %{rtems_bsp}
mkdir -p $SB_BUILD_ROOT/%{_prefix}/%{rtems_test_install} do
find . -name \*.exe -and -not -name \*.norun.exe \ export bsp
-exec cp -v \{\} $SB_BUILD_ROOT/%{_prefix}/%{rtems_test_install}/ \; mkdir -p $SB_BUILD_ROOT/%{_prefix}/${bsp}-rtems%{rtems_kernel_version}/tests
find build/$bsp -name \*.exe -and -not -name \*.norun.exe \
-exec sh -c 'cp -v {} $SB_BUILD_ROOT/%{_prefix}/${bsp}-rtems%{rtems_kernel_version}/tests/$(basename {})' \;
done
%endif %endif
cd - cd -