tools/sethost.sh: Correct error in setting a different host.

In an older PR, the standard kconfig-tweak calls were replaced with sed edit.  This is an incorrect change and results in invalid configurations.  This change restores the use of kconfig-tweak and always generates correct configurations.

This change resolves issue #386

sed edits do not handle all of the dependencies correct and generates invalid configurations.  Most defconfig files specify Linux by default, so you will only see the effect of the corruped configuration when sethost changes changes to a different configuration.  Then, when 'make olddefconfig' is subsequentyly run, the corruption in the defconfig file is reflected by warnings such as:

   $ tools/configure.sh -c stm32f4discovery:nsh
      Copy files
      Select CONFIG_HOST_WINDOWS=y
      Select CONFIG_WINDOWS_CYGWIN=y
      Refreshing...
    .config:62:warning: override: reassigning to symbol HOST_WINDOWS
    .config:62:warning: override: HOST_WINDOWS changes choice state

Those warnings are eliminated by this changed.

Tested by repeatedly doing:

  tools/configure.sh -c stm32f4discovery:nsh
This commit is contained in:
Gregory Nutt
2020-04-27 11:22:40 -06:00
committed by Abdelatif Guettouche
parent e11c1e7cb3
commit 100bd740cd
+31 -63
View File
@@ -1,35 +1,20 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# tools/sethost.sh # tools/sethost.sh
# #
# Copyright (C) 2016-2017 Gregory Nutt. All rights reserved. # Licensed to the Apache Software Foundation (ASF) under one or more
# Author: Gregory Nutt <gnutt@nuttx.org> # contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
# #
# Redistribution and use in source and binary forms, with or without # http://www.apache.org/licenses/LICENSE-2.0
# modification, are permitted provided that the following conditions
# are met:
# #
# 1. Redistributions of source code must retain the above copyright # Unless required by applicable law or agreed to in writing, software
# notice, this list of conditions and the following disclaimer. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# 2. Redistributions in binary form must reproduce the above copyright # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# notice, this list of conditions and the following disclaimer in # License for the specific language governing permissions and limitations
# the documentation and/or other materials provided with the # under the License.
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# #
progname=$0 progname=$0
@@ -142,76 +127,59 @@ fi
if [ "X$host" == "Xlinux" -o "X$host" == "Xmacos" ]; then if [ "X$host" == "Xlinux" -o "X$host" == "Xmacos" ]; then
# Disable Windows (to suppress warnings from Window Environment selections)
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_WINDOWS
# Enable Linux or macOS # Enable Linux or macOS
if [ "X$host" == "Xlinux" ]; then if [ "X$host" == "Xlinux" ]; then
echo " Select CONFIG_HOST_LINUX=y" echo " Select CONFIG_HOST_LINUX=y"
echo "CONFIG_HOST_LINUX=y" >> $nuttx/.config kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_MACOS
sed -i -e "/CONFIG_HOST_MACOS/d" $nuttx/.config kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_LINUX
else else
echo " Select CONFIG_HOST_MACOS=y" echo " Select CONFIG_HOST_MACOS=y"
sed -i -e "/CONFIG_HOST_LINUX/d" $nuttx/.config kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_LINUX
echo "CONFIG_HOST_MACOS=y" >> $nuttx/.config kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_MACOS
fi fi
# Disable all Windows options # Enable the System V ABI
sed -i -e "/CONFIG_HOST_WINDOWS/d" $nuttx/.config kconfig-tweak --file $nuttx/.config --enable CONFIG_SIM_X8664_SYSTEMV
sed -i -e "/CONFIG_SIM_X8664_MICROSOFT/d" $nuttx/.config
echo "CONFIG_SIM_X8664_SYSTEMV=y" >> $nuttx/.config
sed -i -e "/CONFIG_WINDOWS_NATIVE/d" $nuttx/.config
sed -i -e "/CONFIG_WINDOWS_CYGWIN/d" $nuttx/.config
sed -i -e "/CONFIG_WINDOWS_UBUNTU/d" $nuttx/.config
sed -i -e "/CONFIG_WINDOWS_MSYS/d" $nuttx/.config
sed -i -e "/CONFIG_WINDOWS_OTHER/d" $nuttx/.config
else else
echo " Select CONFIG_HOST_WINDOWS=y" echo " Select CONFIG_HOST_WINDOWS=y"
# Enable Windows kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_LINUX
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_MACOS
echo "CONFIG_HOST_WINDOWS=y" >> $nuttx/.config # Enable Windows and the Microsoft ABI
sed -i -e "/CONFIG_HOST_LINUX/d" $nuttx/.config
sed -i -e "/CONFIG_HOST_MACOS/d" $nuttx/.config
echo "CONFIG_SIM_X8664_MICROSOFT=y" >> $nuttx/.config kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_WINDOWS
sed -i -e "/CONFIG_SIM_X8664_SYSTEMV/d" $nuttx/.config kconfig-tweak --file $nuttx/.config --enable CONFIG_SIM_X8664_MICROSOFT
# Enable Windows environment # Enable Windows environment
sed -i -e "/CONFIG_WINDOWS_OTHER/d" $nuttx/.config
if [ "X$wenv" == "Xcygwin" ]; then if [ "X$wenv" == "Xcygwin" ]; then
echo " Select CONFIG_WINDOWS_CYGWIN=y" echo " Select CONFIG_WINDOWS_CYGWIN=y"
echo "CONFIG_WINDOWS_CYGWIN=y" >> $nuttx/.config kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_CYGWIN
sed -i -e "/CONFIG_WINDOWS_MSYS/d" $nuttx/.config
sed -i -e "/CONFIG_WINDOWS_UBUNTU/d" $nuttx/.config
sed -i -e "/CONFIG_WINDOWS_NATIVE/d" $nuttx/.config
else else
sed -i -e "/CONFIG_WINDOWS_CYGWIN/d" $nuttx/.config
if [ "X$wenv" == "Xmsys" ]; then if [ "X$wenv" == "Xmsys" ]; then
echo " Select CONFIG_WINDOWS_MSYS=y" echo " Select CONFIG_WINDOWS_MSYS=y"
echo "CONFIG_WINDOWS_MSYS=y" >> $nuttx/.config kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_MSYS
sed -i -e "/CONFIG_WINDOWS_UBUNTU/d" $nuttx/.config
sed -i -e "/CONFIG_WINDOWS_NATIVE/d" $nuttx/.config
else else
sed -i -e "/CONFIG_WINDOWS_MSYS/d" $nuttx/.config
if [ "X$wenv" == "Xubuntu" ]; then if [ "X$wenv" == "Xubuntu" ]; then
echo " Select CONFIG_WINDOWS_UBUNTU=y" echo " Select CONFIG_WINDOWS_UBUNTU=y"
echo "CONFIG_WINDOWS_UBUNTU=y" >> $nuttx/.config kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_UBUNTU
sed -i -e "/CONFIG_WINDOWS_NATIVE/d" $nuttx/.config
else else
echo " Select CONFIG_WINDOWS_NATIVE=y" echo " Select CONFIG_WINDOWS_NATIVE=y"
sed -i -e "/CONFIG_WINDOWS_UBUNTU/d" $nuttx/.config kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_NATIVE
echo "CONFIG_WINDOWS_NATIVE=y" $nuttx/.config
fi fi
fi fi
fi fi
fi fi
sed -i -e "/CONFIG_HOST_OTHER/d" $nuttx/.config
echo " Refreshing..." echo " Refreshing..."
if grep -q "V=1" <<< "$*" ; then if grep -q "V=1" <<< "$*" ; then