From cc088ab014791450d9d5d88564f3f889ece74909 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Mon, 6 Dec 2010 19:47:42 -0800 Subject: Add guile QA code to gr-howto-write-a-block --- gr-howto-write-a-block/setup_guile_test_env.in | 140 +++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 gr-howto-write-a-block/setup_guile_test_env.in (limited to 'gr-howto-write-a-block/setup_guile_test_env.in') diff --git a/gr-howto-write-a-block/setup_guile_test_env.in b/gr-howto-write-a-block/setup_guile_test_env.in new file mode 100644 index 000000000..6a2402064 --- /dev/null +++ b/gr-howto-write-a-block/setup_guile_test_env.in @@ -0,0 +1,140 @@ +# +# Copyright 2010 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# This is sourced by run_guile_tests to establish the environment +# variables required to run the tests in the build tree. + +# add_local_paths is the only "public" function in this file + +# 1st argument is absolute path to hand coded guile source directory +# 2nd argument is absolute path to component C++ shared library build directory +# 3nd argument is absolute path to component SWIG build directory + +function add_local_paths(){ + if [ $# -ne 3 ] + then + echo "$0: requires 3 args" 1>&2 + exit 1 + fi + + # Add local dirs to the front + prepend_to_guile_load_path "$1" + prepend_to_libpath "$2/.libs" + [ "$2" != "$3" ] && prepend_to_libpath "$3/.libs" + prepend_to_guile_load_path "$3" +} + +# ------------------------------------------------------------------------ + +abs_top_srcdir=@abs_top_srcdir@ +abs_top_builddir=@abs_top_builddir@ + +# usage: prepend +function prepend(){ + if [ $# -ne 2 ] + then + echo "$0: prepend needs 2 args" 1>&2 + exit 1 + fi + local path="$1" dir="$2" contents="" + eval "contents=\$$path" + if [ "$dir" != "" ] + then + if [ "$contents" = "" ] + then + eval "$path=\"$dir\"" + else + eval "$path=\"$dir:$contents\"" + fi + fi + #echo end-of-prepend: $path=${!path} +} + +# usage: append +function append(){ + if [ $# -ne 2 ] + then + echo "$0: append needs 2 args" 1>&2 + exit 1 + fi + local path="$1" dir="$2" contents="" + eval "contents=\$$path" + if [ "$dir" != "" ] + then + if [ "$contents" = "" ] + then + eval "$path=\"$dir\"" + else + eval "$path=\"$contents:$dir\"" + fi + fi + #echo end-of-append: $path=${!path} +} + +function prepend_to_guile_load_path(){ + prepend GUILE_LOAD_PATH "$1" + export GUILE_LOAD_PATH +} + +function append_to_guile_load_path(){ + append GUILE_LOAD_PATH "$1" + export GUILE_LOAD_PATH +} + +function prepend_to_libpath(){ + prepend LTDL_LIBRARY_PATH "$1" + export LTDL_LIBRARY_PATH + case "@host_os@" in + darwin*) + prepend DYLD_LIBRARY_PATH "$1" + export DYLD_LIBRARY_PATH + ;; + cygwin*|win*|mingw*) + prepend PATH "$1" + export PATH + ;; + esac +} + +function append_to_libpath(){ + append LTDL_LIBRARY_PATH "$1" + export LTDL_LIBRARY_PATH + case "@host_os@" in + darwin*) + append DYLD_LIBRARY_PATH "$1" + export DYLD_LIBRARY_PATH + ;; + cygwin*|win*|mingw*) + append PATH "$1" + export PATH + ;; + esac +} + +# ------------------------------------------------------------------------ +# Start with gnuradio_core_LIBDIRPATH and gnuradio_core_GUILE_LOAD_PATH +# ------------------------------------------------------------------------ + +# Where to search for gnuradio-core shared libraries +prepend_to_libpath @gnuradio_core_LIBDIRPATH@ + +# Where to seach for gnuradio-core guile code +prepend_to_guile_load_path @gnuradio_core_GUILE_LOAD_PATH@ + +export GUILE_WARN_DEPRECATED=no -- cgit From c69cf50c8c553377d1ad9d353b207d57f5d3a47d Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Tue, 7 Dec 2010 13:19:06 -0800 Subject: Change shell function definitions to use POSIX syntax --- gr-howto-write-a-block/setup_guile_test_env.in | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'gr-howto-write-a-block/setup_guile_test_env.in') diff --git a/gr-howto-write-a-block/setup_guile_test_env.in b/gr-howto-write-a-block/setup_guile_test_env.in index 6a2402064..3437fab44 100644 --- a/gr-howto-write-a-block/setup_guile_test_env.in +++ b/gr-howto-write-a-block/setup_guile_test_env.in @@ -26,7 +26,7 @@ # 2nd argument is absolute path to component C++ shared library build directory # 3nd argument is absolute path to component SWIG build directory -function add_local_paths(){ +add_local_paths() { if [ $# -ne 3 ] then echo "$0: requires 3 args" 1>&2 @@ -46,7 +46,7 @@ abs_top_srcdir=@abs_top_srcdir@ abs_top_builddir=@abs_top_builddir@ # usage: prepend -function prepend(){ +prepend() { if [ $# -ne 2 ] then echo "$0: prepend needs 2 args" 1>&2 @@ -67,7 +67,7 @@ function prepend(){ } # usage: append -function append(){ +append() { if [ $# -ne 2 ] then echo "$0: append needs 2 args" 1>&2 @@ -87,17 +87,17 @@ function append(){ #echo end-of-append: $path=${!path} } -function prepend_to_guile_load_path(){ +prepend_to_guile_load_path() { prepend GUILE_LOAD_PATH "$1" export GUILE_LOAD_PATH } -function append_to_guile_load_path(){ +append_to_guile_load_path() { append GUILE_LOAD_PATH "$1" export GUILE_LOAD_PATH } -function prepend_to_libpath(){ +prepend_to_libpath() { prepend LTDL_LIBRARY_PATH "$1" export LTDL_LIBRARY_PATH case "@host_os@" in @@ -112,7 +112,7 @@ function prepend_to_libpath(){ esac } -function append_to_libpath(){ +append_to_libpath() { append LTDL_LIBRARY_PATH "$1" export LTDL_LIBRARY_PATH case "@host_os@" in -- cgit