Openwrt shell. This patch enables possibility to ease some development steps when we want to manualy compile some part of package. It does not work like emulator of target environment but try to setup shell environment and functions to ease target compilation. Even more, it adds support for get environment variables into external shell functions. Next to this, it add hints on compilation.
It can be invoked by: ./scripts/shell.sh It enters interactive shell with some basic builtin functions. It can be easily extended: buildpkg pkg - build package with name pkg. Same as make package/pkg/compile rebuildpkg pkg - rebuild package with name pkg. Same as make package/pkg/clean package/pkg/compile buildpkg2 pkg - quicker way, but pkg needs to be directory name. Does not solve dependencies rebuildpkg2 pkg - quicker way, --//-- tmake - Target MAKE tgcc - Target GCC tconfigure - Target configure ./scripts/getvar.sh var1 [var2] [var3] ... will show variables from OpenWrt internal Makefiles. example: ./scripts/getvar.sh LINUX_DIR VARIABLES="LINUX_DIR" export LINUX_DIR=./build_dir/linux-x86_net5501/linux-3.2.2 Signed-off-by: Lukas Macura <mac...@opf.slu.cz> Index: scripts/shell.sh =================================================================== --- scripts/shell.sh (revision 0) +++ scripts/shell.sh (revision 0) @@ -0,0 +1,43 @@ +#!/bin/sh + +export SDIR=$(dirname $(readlink -f $0)) +export TOPDIR=$(readlink -f $SDIR/..) +export INCFILE="/tmp/owrtshell.$$.inc" +export FUNCTIONS=$SDIR/shell-functions.sh + +$SDIR/getvar.sh STAGING_DIR BUILD_DIR TOOLCHAIN_DIR STAGING_DIR_HOST LINUX_DIR \ + HOSTCC TARGET_CC TARGET_CFLAGS STRIP \ + GNU_TARGET_NAME GNU_HOST_NAME \ + CONFIGURE_CMD CONFIGURE_VARS CONFIGURE_ARGS TARGET_CONFIGURE_OPTS \ + MAKE MAKE_FLAGS \ + >$INCFILE +cat <<EOF >>$INCFILE +export PATH="\$STAGING_DIR_HOST/bin:\$TOOLCHAIN_DIR/usr/bin:\$TOOLCHAIN_DIR/bin:\$TOOLCHAIN_DIR/sbin:\$PATH" +export CC="\$TARGET_CC" +export CFLAGS="\$TARGET_CFLAGS" +export PS1="(oWRT):" +EOF + +. $INCFILE + +if [ "$1" = "env" ]; then + if [ -n "$2" ]; then + while [ -n "$2" ]; do + eval echo "\$$2" + shift + done + else + cat $INCFILE + fi +else + if [ -n "$1" ]; then + $SHELL --rcfile $INCFILE $* + else + echo "Entering interactive shell. To get more info, type 'ohelp' . Use 'exit' for end. Good luck!" + cat $FUNCTIONS >>$INCFILE + $SHELL --rcfile $INCFILE + fi +fi + +rm -f $INCFILE + Property changes on: scripts/shell.sh ___________________________________________________________________ Added: svn:executable + * Index: scripts/shell-functions.sh =================================================================== --- scripts/shell-functions.sh (revision 0) +++ scripts/shell-functions.sh (revision 0) @@ -0,0 +1,67 @@ + +ohelp() { + cat <<EOF +This is OpenWRT shell help system. Welcome! +TOPDIR=$TOPDIR +SDIR=$SDIR +INCFILE=$INCFILE + +Available commands: + +buildpkg pkg - build package with name pkg. Same as make package/pkg/compile +rebuildpkg pkg - rebuild package with name pkg. Same as make package/pkg/clean package/pkg/compile +buildpkg2 pkg - quicker way, but pkg needs to be directory name. Does not solve dependencies +rebuildpkg2 pkg - quicker way, --//-- +tmake - Target MAKE +tgcc - Target GCC +tconfigure - Target configure + +EOF +} + +ohint() { + echo "HINT: $*" +} + +ohintcmd() { + echo "HINT: You can use '$*' to do same thing" + sh -c "$*" +} + +buildpkg() { + ohint "You can use faster package build buildpkg2 for testing compilation." + ohintcmd cd $TOPDIR\; make package/$1/compile V=99 +} +rebuildpkg() { + ohint "You can use faster package build rebuildpkg2 for testing compilation." + ohintcmd cd $TOPDIR\; make package/$1/clean package/$1/compile V=99 +} + +buildpkg2() { + local dir=$(find $TOPDIR/feeds $TOPDIR/package -name $1) || echo "Package $1 not found." + ohintcmd make -C $dir TOPDIR=$TOPDIR +} +rebuildpkg2() { + local dir=$(find $TOPDIR/feeds $TOPDIR/package -name $1) || echo "Package $1 not found." + ohintcmd make -C $dir TOPDIR=$TOPDIR clean all +} + +alias tconfigure="$CONFIGURE_VARS $CONFIGURE_CMD $CONFIGURE_ARGS $TARGET_CONFIGURE_OPTS" +alias tmake="$MAKE $MAKE_FLAGS" +alias tgcc="$TARGET_CC $TARGET_CFLAGS" +alias tscons="scons target=$GNU_TARGET_NAME host=$GNU_TARGET_NAME build=$GNU_HOST_NAME \ + CC=\"$TARGET_CC -I$STAGING_DIR/usr/include $TARGET_CFLAGS\" CXX=\"$TARGET_CXX -I$STAGING_DIR/usr/include $TARGET_CXXFLAGS\" \ + CPPPATH=$STAGING_DIR/usr/include \ + LINKFLAGS=\"-L$STAGING_DIR/usr/lib -Wl,-rpath-link,$STAGING_DIR/usr/lib\" \ + prefix=/usr/ \ + strip=yes shared=yes STRIP=$STRIP" + + + + + + + + + + Index: scripts/getvar.sh =================================================================== --- scripts/getvar.sh (revision 0) +++ scripts/getvar.sh (revision 0) @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ -z "$*" ]; then + echo "Usage: $0 var1 var2 var3 ..." + exit 1 +fi + +make -f $(dirname $0)/../include/getvar.mk VARIABLES="$*" TOPDIR=$(dirname $0)/.. MAKELEVEL=0 + Property changes on: scripts/getvar.sh ___________________________________________________________________ Added: svn:executable + * Index: include/getvar.mk =================================================================== --- include/getvar.mk (revision 0) +++ include/getvar.mk (revision 0) @@ -0,0 +1,9 @@ + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk + +all: + @echo VARIABLES=\"$(VARIABLES)\" + @$(foreach var,$(VARIABLES),printf "%q %q\n" export $(var)='$($(var))';) + _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel