[llvm-commits] [llvm-top] r40377 - in /llvm-top/trunk: README.txt build clean get info install library.sh options update
Reid Spencer
rspencer at reidspencer.com
Sat Jul 21 14:08:24 PDT 2007
Author: reid
Date: Sat Jul 21 16:08:24 2007
New Revision: 40377
URL: http://llvm.org/viewvc/llvm-project?rev=40377&view=rev
Log:
Several improvements:
1. Have the scripts find llvm-top either by the LLVM_TOP environment variable,
if its set, looking for library.sh in . or looking for library.sh in ..
This allows the scripts to be put in a path or invoked from a module dir.
2. Fix the scripts to not rely on $cwd because build scripts in the modules
could change it. Instead, always use $LLVM_TOP/$module to get to a module.
3. Don't support the MODULE= variable, it has no utility except for really
breaking things.
4. Make the set of options supported by library.sh and options scripts both
consistent and alphabetized.
Modified:
llvm-top/trunk/README.txt
llvm-top/trunk/build
llvm-top/trunk/clean
llvm-top/trunk/get
llvm-top/trunk/info
llvm-top/trunk/install
llvm-top/trunk/library.sh
llvm-top/trunk/options
llvm-top/trunk/update
Modified: llvm-top/trunk/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/README.txt?rev=40377&r1=40376&r2=40377&view=diff
==============================================================================
--- llvm-top/trunk/README.txt (original)
+++ llvm-top/trunk/README.txt Sat Jul 21 16:08:24 2007
@@ -79,9 +79,6 @@
you don't actually want it installed there! So, specify DESTDIR=/tmp and
it would actually get installed in /tmp/usr/bin.
- MODULE={module_name}
- This allows you to override the name of the module (not recommended).
-
LLVM_TOP=/path/to/llvm-top
This allows you to override the location of the llvm-top directory.
Modified: llvm-top/trunk/build
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/build?rev=40377&r1=40376&r2=40377&view=diff
==============================================================================
--- llvm-top/trunk/build (original)
+++ llvm-top/trunk/build Sat Jul 21 16:08:24 2007
@@ -12,7 +12,21 @@
# specified list. You can also specify build options. See the README.txt file.
# Get the library.
-. ./library.sh
+if test ! -z "$LLVM_TOP" ; then
+ if test -f "$LLVM_TOP/library.sh" ; then
+ . "$LLVM_TOP/library.sh"
+ else
+ echo "Your LLVM_TOP variable is not set to an llvm-top directory"
+ exit 1
+ fi
+elif test -f ./library.sh ; then
+ . ./library.sh
+elif test -f ../library.sh ; then
+ . ../library.sh
+else
+ echo Please run $0 from the llvm-top directory or a module directory.
+ exit 1
+fi
# Process the arguments so that anything starting with - is passed down to the
# configure scripts while anything else is a module name. Collect the arguments
Modified: llvm-top/trunk/clean
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/clean?rev=40377&r1=40376&r2=40377&view=diff
==============================================================================
--- llvm-top/trunk/clean (original)
+++ llvm-top/trunk/clean Sat Jul 21 16:08:24 2007
@@ -10,7 +10,22 @@
# of the modules on the command line and they and their dependencies will be
# cleaned. See the README.txt file.
-. ./library.sh
+# Get the shell function library
+if test ! -z "$LLVM_TOP" ; then
+ if test -f "$LLVM_TOP/library.sh" ; then
+ . "$LLVM_TOP/library.sh"
+ else
+ echo "Your LLVM_TOP variable is not set to an llvm-top directory"
+ exit 1
+ fi
+elif test -f ./library.sh ; then
+ . ./library.sh
+elif test -f ../library.sh ; then
+ . ../library.sh
+else
+ echo Please run $0 from the llvm-top directory or a module directory.
+ exit 1
+fi
# Get the list of modules.
process_arguments "$@"
@@ -22,7 +37,7 @@
get_module_info $mod CleanCmd
if test ! -z "$MODULE_INFO_VALUE" ; then
msg 1 Cleaning module $mod
- cd $mod
+ cd $LLVM_TOP/$mod
$MODULE_INFO_VALUE || die $? "Clean of module $mod failed."
else
msg 2 Module $mod has no CleanCmd in the ModuleInfo.txt
Modified: llvm-top/trunk/get
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/get?rev=40377&r1=40376&r2=40377&view=diff
==============================================================================
--- llvm-top/trunk/get (original)
+++ llvm-top/trunk/get Sat Jul 21 16:08:24 2007
@@ -9,8 +9,22 @@
# This script allows easier checkout of LLVM modules. Just specify the names
# of the modules on the command line. See the README.txt file.
-# Get the library.
-. ./library.sh
+# Get the shell function library.
+if test ! -z "$LLVM_TOP" ; then
+ if test -f "$LLVM_TOP/library.sh" ; then
+ . "$LLVM_TOP/library.sh"
+ else
+ echo "Your LLVM_TOP variable is not set to an llvm-top directory"
+ exit 1
+ fi
+elif test -f ./library.sh ; then
+ . ./library.sh
+elif test -f ../library.sh ; then
+ . ../library.sh
+else
+ echo Please run $0 from the llvm-top directory or a module directory.
+ exit 1
+fi
# Get the list of modules
process_arguments "$@"
Modified: llvm-top/trunk/info
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/info?rev=40377&r1=40376&r2=40377&view=diff
==============================================================================
--- llvm-top/trunk/info (original)
+++ llvm-top/trunk/info Sat Jul 21 16:08:24 2007
@@ -11,7 +11,21 @@
# information about the currently checked out modules. See the README.txt file.
# Get the library.
-. ./library.sh
+if test ! -z "$LLVM_TOP" ; then
+ if test -f "$LLVM_TOP/library.sh" ; then
+ . "$LLVM_TOP/library.sh"
+ else
+ echo "Your LLVM_TOP variable is not set to an llvm-top directory"
+ exit 1
+ fi
+elif test -f ./library.sh ; then
+ . ./library.sh
+elif test -f ../library.sh ; then
+ . ../library.sh
+else
+ echo Please run $0 from the llvm-top directory or a module directory.
+ exit 1
+fi
# Get the list of modules
process_arguments "$@"
Modified: llvm-top/trunk/install
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/install?rev=40377&r1=40376&r2=40377&view=diff
==============================================================================
--- llvm-top/trunk/install (original)
+++ llvm-top/trunk/install Sat Jul 21 16:08:24 2007
@@ -11,7 +11,22 @@
# checked out, built and installed. Use PREFIX= to specify where the modules
# should be installed. See the README.txt file.
-. ./library.sh
+# Get the shell function library.
+if test ! -z "$LLVM_TOP" ; then
+ if test -f "$LLVM_TOP/library.sh" ; then
+ . "$LLVM_TOP/library.sh"
+ else
+ echo "Your LLVM_TOP variable is not set to an llvm-top directory"
+ exit 1
+ fi
+elif test -f ./library.sh ; then
+ . ./library.sh
+elif test -f ../library.sh ; then
+ . ../library.sh
+else
+ echo Please run $0 from the llvm-top directory or a module directory.
+ exit 1
+fi
# Get the list of modules to install.
process_arguments "$@"
@@ -25,9 +40,8 @@
get_module_info $mod InstallCmd
if test ! -z "$MODULE_INFO_VALUE" ; then
msg 1 Installing module $mod
- cd $mod
+ cd $LLVM_TOP/$mod
$MODULE_INFO_VALUE || die $? "Install of module $mod failed."
- cd $LLVM_TOP
else
msg 2 Module $mod has no InstallCmd in the ModuleInfo.txt
fi
Modified: llvm-top/trunk/library.sh
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/library.sh?rev=40377&r1=40376&r2=40377&view=diff
==============================================================================
--- llvm-top/trunk/library.sh (original)
+++ llvm-top/trunk/library.sh Sat Jul 21 16:08:24 2007
@@ -9,28 +9,39 @@
# This script provides the script fragments and functions that are common to
# the scripts in the llvm-top module.
-# The arguments to all scripts are
+# Figure out where the llvm-top directory is located. This could be executed
+# in a module or in llvm-top, so we have to figure out where the llvm-top
+# directory is located by examining contents.
+if test -z "$LLVM_TOP" ; then
+ if test -x ./build -a -x ./get -a -f ./library.sh -a -x ./info ; then
+ LLVM_TOP=`pwd`
+ elif test -x ../build -a -x ../get -a -f ../library.sh -a -x ../info ; then
+ LLVM_TOP=`cd .. ; pwd`
+ else
+ echo "Cannot determine where your llvm-top directory is"
+ exit 1
+ fi
+fi
# Get the options. If there is no options file, default the values.
-options="./.options"
+options="$LLVM_TOP/.options"
if test -r "$options" -a -f "$options" ; then
. "$options"
else
- LLVM_TOP=`pwd`
- PREFIX="$LLVM_TOP/installed"
- DESTDIR=
- VERBOSE=0
- TOOL_VERBOSE=0
- SHAREDLIBS=0
- ARCHIVELIBS=1
- OPTIMIZED=0
+ ARCHIVE_LIBS=1
+ ASSERTS=1
DEBUG=1
- ASSERT=1
+ DESTDIR=""
EXPENSIVE=0
+ OPTIMIZED=0
+ OPT_FOR_SIZE=0
+ PREFIX="$LLVM_TOP/installed"
PROFILING=0
- USEOBJDIR=0
+ SHARED_LIBS=0
STRIP=0
- OPTFORSIZE=0
+ TOOL_VERBOSE=0
+ USE_OBJ_DIR=0
+ VERBOSE=0
fi
# Define where subversion is. We assume by default its in the path.
@@ -65,7 +76,6 @@
LLVM_TOP=*) LLVM_TOP=`echo "$arg" | sed -e 's/LLVM_TOP=//'` ;;
PREFIX=*) PREFIX=`echo "$arg" | sed -e 's/PREFIX=//'` ;;
DESTDIR=*) DESTDIR=`echo "$arg" | sed -e 's/DESTDIR=//'` ;;
- MODULE=*) MODULE=`echo "$arg" | sed -e 's/MODULE=//'` ;;
VERBOSE=*) VERBOSE=`echo "$arg" | sed -e 's/VERBOSE=//'` ;;
--*) OPTIONS_DASH_DASH="$OPTIONS_DASH_DASH $arg" ;;
-*) OPTIONS_DASH="$OPTIONS_DASH $arg" ;;
@@ -154,6 +164,11 @@
MODULE_DEPENDENCIES="$MODULE_DEPENDENCIES $mod_to_add"
}
+# This function gets the dependencies for a single module. It is a recursive
+# function and returns its results by calling add_module_if_not_duplicate to
+# add modules to the MODULE_DEPENDENCIES variables. The function limits
+# recursion depth to a total of ten which should be sufficient. This prevents
+# fork bombs in case the ModuleInfo.txt files specify cyclic dependencies.
get_a_modules_dependencies() {
if test "$RECURSION_DEPTH" -gt 10 ; then
die 2 "Recursing too deeply on module dependencies"
@@ -179,6 +194,9 @@
add_module_if_not_duplicate "$1"
}
+# This is the public interface for getting module dependencies. It takes a list
+# of module names can calls get_a_modules_dependencies on each. The result is
+# returned in MODULE_DEPENDENCIES variable.
get_module_dependencies() {
msg 2 "Getting module dependencies: $*"
local module=""
@@ -189,6 +207,7 @@
done
}
+# This is used to build a single module.
build_a_module() {
local module="$1"
msg 1 "Building module '$module'"
@@ -200,8 +219,7 @@
local build_cmd="$MODULE_INFO_VALUE MODULE=$module $build_args"
msg 1 "Building Module '$module'"
msg 2 "Build Command: $build_cmd"
- cd $module
+ cd $LLVM_TOP/$module
$build_cmd || die $? "Build of module '$module' failed."
- cd $LLVM_TOP
}
Modified: llvm-top/trunk/options
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/options?rev=40377&r1=40376&r2=40377&view=diff
==============================================================================
--- llvm-top/trunk/options (original)
+++ llvm-top/trunk/options Sat Jul 21 16:08:24 2007
@@ -11,28 +11,42 @@
# Include the library. This will either read the options from the .options
# file or it will set the variables to their default values.
-. ./library.sh
+if test ! -z "$LLVM_TOP" ; then
+ if test -f "$LLVM_TOP/library.sh" ; then
+ . "$LLVM_TOP/library.sh"
+ else
+ echo "Your LLVM_TOP variable is not set to an llvm-top directory"
+ exit 1
+ fi
+elif test -f ./library.sh ; then
+ . ./library.sh
+elif test -f ../library.sh ; then
+ . ../library.sh
+else
+ echo Please run $0 from the llvm-top directory or a module directory.
+ exit 1
+fi
# Process the arguments to set the new values
msg 3 "Processing new option arguments"
for arg in "$@" ; do
case "$arg" in
- LLVM_TOP=*) LLVM_TOP=`echo "$arg" | sed -e 's/LLVM_TOP=//'` ;;
- PREFIX=*) PREFIX=`echo "$arg" | sed -e 's/PREFIX=//'` ;;
- DESTDIR=*) DESTDIR=`echo "$arg" | sed -e 's/DESTDIR=//'` ;;
- VERBOSE=*) VERBOSE=`echo "$arg" | sed -e 's/VERBOSE=//'` ;;
- TOOL_VERBOSE=*) TOOL_VERBOSE=`echo "$arg" | sed -e 's/TOOL_VERBOSE=//'` ;;
- SHARED_LIBS=*) SHARED_LIBS=`echo "$arg" | sed -e 's/SHARED_LIBS=//'` ;;
ARCHIVE_LIBS=*) ARCHIVE_LIBS=`echo "$arg" | sed -e 's/ARCHIVE_LIBS=//'` ;;
- OPTIMIZED=*) OPTIMIZED=`echo "$arg" | sed -e 's/OPTIMIZED=//'` ;;
- DEBUG=*) DEBUG=`echo "$arg" | sed -e 's/DEBUG=//'` ;;
ASSERTS=*) ASSERTS=`echo "$arg" | sed -e 's/ASSERTS=//'` ;;
+ DEBUG=*) DEBUG=`echo "$arg" | sed -e 's/DEBUG=//'` ;;
+ DESTDIR=*) DESTDIR=`echo "$arg" | sed -e 's/DESTDIR=//'` ;;
EXPENSIVE=*) EXPENSIVE=`echo "$arg" | sed -e 's/EXPENSIVE=//'` ;;
+ LLVM_TOP=*) LLVM_TOP=`echo "$arg" | sed -e 's/LLVM_TOP=//'` ;;
+ OPT_FOR_SIZE=*) OPT_FOR_SIZE=`echo "$arg" | sed -e 's/OPT_FOR_SIZE=//'` ;;
+ OPTIMIZED=*) OPTIMIZED=`echo "$arg" | sed -e 's/OPTIMIZED=//'` ;;
+ PREFIX=*) PREFIX=`echo "$arg" | sed -e 's/PREFIX=//'` ;;
PROFILING=*) PROFILING=`echo "$arg" | sed -e 's/PROFILING=//'` ;;
- USEOBJDIR=*) USEOBJDIR=`echo "$arg" | sed -e 's/USEOBJDIR=//'` ;;
+ SHARED_LIBS=*) SHARED_LIBS=`echo "$arg" | sed -e 's/SHARED_LIBS=//'` ;;
STRIP=*) STRIP=`echo "$arg" | sed -e 's/STRIP=//'` ;;
- OPTFORSIZE=*) OPTFORSIZE=`echo "$arg" | sed -e 's/OPTFORSIZE=//'` ;;
- *) die 1 "Unrecognized option: $arg" ;;
+ TOOL_VERBOSE=*) TOOL_VERBOSE=`echo "$arg" | sed -e 's/TOOL_VERBOSE=//'` ;;
+ USE_OBJ_DIR=*) USE_OBJ_DIR=`echo "$arg" | sed -e 's/USE_OBJ_DIR=//'` ;;
+ VERBOSE=*) VERBOSE=`echo "$arg" | sed -e 's/VERBOSE=//'` ;;
+ *) die 1 "Unrecognized option: $arg" ;;
esac
done
@@ -41,21 +55,21 @@
cat <<__EOF__ > "$options"
# LLVM configuration options database.
# This script is generated by "options" and included into library.sh
-LLVM_TOP="$LLVM_TOP"
-PREFIX="$PREFIX"
-DESTDIR="$DESTDIR"
-VERBOSE="$VERBOSE"
-TOOL_VERBOSE="$TOOL_VERBOSE"
-SHARED_LIBS="$SHARED_LIBS"
ARCHIVE_LIBS="$ARCHIVE_LIBS"
-OPTIMIZED="$OPTIMIZED"
-DEBUG="$DEBUG"
ASSERTS="$ASSERTS"
+DEBUG="$DEBUG"
+DESTDIR="$DESTDIR"
EXPENSIVE="$EXPENSIVE"
+LLVM_TOP="$LLVM_TOP"
+OPT_FOR_SIZE="$OPT_FOR_SIZE"
+OPTIMIZED="$OPTIMIZED"
+PREFIX="$PREFIX"
PROFILING="$PROFILING"
-USEOBJDIR="$USEOBJDIR"
STRIP="$STRIP"
-OPTFORSIZE="$OPTFORSIZE"
+SHARED_LIBS="$SHARED_LIBS"
+TOOL_VERBOSE="$TOOL_VERBOSE"
+USE_OBJ_DIR="$USE_OBJ_DIR"
+VERBOSE="$VERBOSE"
__EOF__
# If there were no arguments, just print the options for the user
@@ -63,4 +77,3 @@
if test "$#" -eq 0 ; then
cat "$options" | grep "="
fi
-
Modified: llvm-top/trunk/update
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/update?rev=40377&r1=40376&r2=40377&view=diff
==============================================================================
--- llvm-top/trunk/update (original)
+++ llvm-top/trunk/update Sat Jul 21 16:08:24 2007
@@ -9,8 +9,22 @@
# This script allows you to easily update a set of checked out modules. Just
# specify the modules to be updated (or checked out) on the command line.
-# Get the library.
-. ./library.sh
+# Get the shell function library.
+if test ! -z "$LLVM_TOP" ; then
+ if test -f "$LLVM_TOP/library.sh" ; then
+ . "$LLVM_TOP/library.sh"
+ else
+ echo "Your LLVM_TOP variable is not set to an llvm-top directory"
+ exit 1
+ fi
+elif test -f ./library.sh ; then
+ . ./library.sh
+elif test -f ../library.sh ; then
+ . ../library.sh
+else
+ echo Please run $0 from the llvm-top directory or a module directory.
+ exit 1
+fi
# Get the list of modules
process_arguments "$@"
More information about the llvm-commits
mailing list