Add tools/sethost.sh. This is a script that you can use to quickly change the host platform from Linux to Windows/Cygwin. Might save you a lot of headaches.

This commit is contained in:
Gregory Nutt 2016-08-03 16:31:35 -06:00
parent 610afe9cd9
commit 6be282af96
4 changed files with 306 additions and 2 deletions

View File

@ -15,6 +15,7 @@ README
- NuttX Configuration Tool
- Finding Selections in the Configuration Menus
- Reveal Hidden Configuration Options
- Make Sure that You on on the Right Platform
- Comparing Two Configurations
- Incompatibilities with Older Configurations
- NuttX Configuration Tool under DOS
@ -576,6 +577,38 @@ Reveal Hidden Configuration Options
cannot be selected and has no value). About all you do is to select
the <Help> option to see what the dependencies are.
Make Sure that You on on the Right Platform
-------------------------------------------
Saved configurations may run on Linux, Cygwin (32- or 64-bit), or other
platforms. The platform characteristics can be changed use 'make
menuconfig'. Sometimes this can be confusing due to the differences
between the platforms. Enter sethost.sh
sethost.sh is a simple script that changes a configuration to your
host platform. This can greatly simplify life if you use many different
configurations. For example, if you are running on Linux and you
configure like this:
$ cd tools
$ ./configure.sh board/configuration
$ cd ..
The you can use the following command to both (1) make sure that the
configuration is up to date, AND (2) the configuration is set up
correctly for Linux:
$ tools/sethost.sh -l
Or, if you are on a Windows/Cygwin 64-bit platform:
$ tools/sethost.sh -w
Other options are available from the help option built into the
script. You can see all options with:
$ tools/sethost.sh -h
Comparing Two Configurations
----------------------------

View File

@ -585,6 +585,47 @@ indent.sh
-h
Show this help message and exit
sethost.sh
----------
Saved configurations may run on Linux, Cygwin (32- or 64-bit), or other
platforms. The platform characteristics can be changed use 'make
menuconfig'. Sometimes this can be confusing due to the differences
between the platforms. Enter sethost.sh
sethost.sh is a simple script that changes a configuration to your
host platform. This can greatly simplify life if you use many different
configurations. For example, if you are running on Linux and you
configure like this:
$ cd tools
$ ./configure.sh board/configuration
$ cd ..
The you can use the following command to both (1) make sure that the
configuration is up to date, AND (2) the configuration is set up
correctly for Linux:
$ tools/sethost.sh -l
Or, if you are on a Windows/Cygwin 64-bit platform:
$ tools/sethost.sh -w
Other options are available:
$ tools/sethost.sh -h
USAGE: tools/sethost.sh [-w|l] [-c|n] [-32|64] [<config>]
tools/sethost.sh -h
Where:
-w|l selects Windows (w) or Linux (l). Default: Linux
-c|n selects Windows native (n) or Cygwin (c). Default Cygwin
-32|64 selects 32- or 64-bit host (Only for Cygwin). Default 64
-h will show this help test and terminate
refresh.sh
----------

232
tools/sethost.sh Normal file
View File

@ -0,0 +1,232 @@
#!/bin/bash
# tools/sethost.sh
#
# Copyright (C) 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# 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.
#
WD=$PWD
progname=$0
host=linux
wenv=cygwin
hsize=64
unset configfile
function showusage {
echo ""
echo "USAGE: $progname [-w|l] [-c|n] [-32|64] [<config>]"
echo " $progname -h"
echo ""
echo "Where:"
echo " -w|l selects Windows (w) or Linux (l). Default: Linux"
echo " -c|n selects Windows native (n) or Cygwin (c). Default Cygwin"
echo " -32|64 selects 32- or 64-bit host (Only for Cygwin). Default 64"
echo " -h will show this help test and terminate"
echo " <config> selects configuration file. Default: .config"
exit 1
}
# Parse command line
while [ ! -z "$1" ]; do
case $1 in
-w )
host=windows
;;
-l )
host=linux
;;
-c )
wenv=cygwin
;;
-n )
wenv=native
;;
-32 )
hsize=32
;;
-64 )
hsize=32
;;
-h )
showusage
;;
* )
configfile="$1"
shift
break;
;;
esac
shift
done
if [ ! -z "$1" ]; then
echo "ERROR: Garbage at the end of line"
showusage
fi
if [ -x sethost.sh ]; then
nuttx=$PWD/..
else
if [ -x tools/sethost.sh ]; then
nuttx=$PWD
else
echo "This script must be execute in nuttx/ or nutts/tools directories"
exit 1
fi
fi
rm -f $nuttx/SAVEconfig
rm -f $nuttx/SAVEMake.defs
unset dotconfig
if [ -z "$configfile" ]; then
dotconfig=y
else
if [ "X$configfile" = "X.config"]; then
dotconfig=y
else
if [ "X$configfile" = "X$nuttx/.config"]; then
dotconfig=y
fi
fi
fi
if [ "X$dotconfig" = "Xy" ]; then
unset configfile
if [ -r $nuttx/.config ]; then
configfile=$nuttx/.config
else
echo "There is no .config at $nuttx"
exit 1
fi
if [ ! -r $nuttx/Make.defs ]; then
echo "ERROR: No readable Make.defs file exists at $nuttx"
exit 1
fi
else
if [ ! -r "$configfile" ]; then
echo "ERROR: No readable configuration file exists at $configfile"
exit 1
fi
configdir=`dirname $configfile`
makedefs=$configdir/Make.defs
if [ ! -r $makedefs]; then
echo "ERROR: No readable Make.defs file exists at $configdir"
exit 1
fi
if [ -f $nuttx/.config]; then
mv $nuttx/.config $nuttx/SAVEconfig
fi
cp $configfile $nuttx/.config || \
{ echo "ERROR: cp to $nuttx/.config failed"; exit 1; }
if [ -f $nuttx/Make.defs]; then
mv $nuttx/Make.defs $nuttx/SAVEMake.defs
fi
cp $makedefs $nuttx/Make.defs || \
{ echo "ERROR: cp to $nuttx/Make.defs failed"; exit 1; }
fi
# Modify the configuration
if [ "X$host" == "Xlinux" ]; then
echo " Select CONFIG_HOST_LINUX=y"
kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_LINUX
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_WINDOWS
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_NATIVE
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_CYGWIN
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_MSYS
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_OTHER
kconfig-tweak --file $nuttx/.config --enable CONFIG_SIM_X8664_SYSTEMV
kconfig-tweak --file $nuttx/.config --disable CONFIG_SIM_X8664_MICROSOFT
kconfig-tweak --file $nuttx/.config --disable CONFIG_SIM_M32
else
echo " Select CONFIG_HOST_WINDOWS=y"
kconfig-tweak --file $nuttx/.config --enable CONFIG_HOST_WINDOWS
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_LINUX
if [ "X$wenv" == "Xcygwin" ]; then
echo " Select CONFIG_WINDOWS_CYGWIN=y"
kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_CYGWIN
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_NATIVE
else
echo " Select CONFIG_WINDOWS_NATIVE=y"
kconfig-tweak --file $nuttx/.config --enable CONFIG_WINDOWS_NATIVE
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_CYGWIN
fi
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_MSYS
kconfig-tweak --file $nuttx/.config --disable CONFIG_WINDOWS_OTHER
kconfig-tweak --file $nuttx/.config --enable CONFIG_SIM_X8664_MICROSOFT
kconfig-tweak --file $nuttx/.config --disable CONFIG_SIM_X8664_SYSTEMV
if [ "X$hsize" == "X32" ]; then
kconfig-tweak --file $nuttx/.config --enable CONFIG_SIM_M32
else
kconfig-tweak --file $nuttx/.config --disable CONFIG_SIM_M32
fi
fi
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_OSX
kconfig-tweak --file $nuttx/.config --disable CONFIG_HOST_OTHER
echo " Refreshing..."
cd $nuttx || { echo "ERROR: failed to cd to $nuttx"; exit 1; }
make clean_context 1>/dev/null 2>&1
make olddefconfig 1>/dev/null 2>&1
# Restore any previous .config and Make.defs files
if [ "X$dotconfig" != "Xy" ]; then
sed -i -e "s/^CONFIG_APPS_DIR/# CONFIG_APPS_DIR/g" .config
mv .config $configfile || \
{ echo "ERROR: Failed to move .conig to $configfile"; exit 1; }
if [ -e SAVEconfig ]; then
mv SAVEconfig .config || \
{ echo "ERROR: Failed to move SAVEconfig to .config"; exit 1; }
fi
if [ -e SAVEMake.defs ]; then
mv SAVEMake.defs Make.defs || \
{ echo "ERROR: Failed to move SAVEMake.defs to Make.defs"; exit 1; }
fi
fi

View File

@ -116,13 +116,11 @@ fi
if [ ! -r "$testfile" ]; then
echo "ERROR: No readable file exists at $testfile"
echo $USAGE
showusage
fi
if [ ! -d "$nuttx" ]; then
echo "ERROR: Expected to find nuttx/ at $nuttx"
echo $USAGE
showusage
fi