[llvm-commits] [llvm-top] r39911 - in /llvm-top/trunk: Makefile README.txt build configure get library.sh

Reid Spencer rspencer at reidspencer.com
Mon Jul 16 01:13:56 PDT 2007


Author: reid
Date: Mon Jul 16 03:13:56 2007
New Revision: 39911

URL: http://llvm.org/viewvc/llvm-project?rev=39911&view=rev
Log:
Simplify the llvm-top stuff. We now don't bother with configuring each 
project. There are only two scripts: "get" and "build". The makefile was taken
away because it was too cumbersome and redundant with the scripts. The
README.txt file was update to reflect invocation of the scripts instead of 
invoking make. The scripts have had limited testing so far, but seems to work
well. 

If there was not a cyclic dependency of llvm on llvm-gcc-4-0 and vice versa then
it would be possible to do "./build stacker" and you would get this sequence:
   1. checkout llvm
   2. configure/build llvm
   3. checkout llvm-gcc-4-0
   4. configure/build llvm-gcc-4-0
   5. checkout stacker
   6. configure/build stacker

We'll have to resolve the cycle before this can work


Removed:
    llvm-top/trunk/Makefile
    llvm-top/trunk/configure
Modified:
    llvm-top/trunk/README.txt
    llvm-top/trunk/build
    llvm-top/trunk/get
    llvm-top/trunk/library.sh

Removed: llvm-top/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/Makefile?rev=39910&view=auto

==============================================================================
--- llvm-top/trunk/Makefile (original)
+++ llvm-top/trunk/Makefile (removed)
@@ -1,82 +0,0 @@
-#===- ./Makefile -------------------------------------------*- Makefile -*--===#
-# 
-#                     llvm-top Makefile
-#
-# This file was developed by Reid Spencer and is distributed under the
-# University of Illinois Open Source License. See LICENSE.TXT for details.
-# 
-#===------------------------------------------------------------------------===#
-
-# This makefile is used for handling "top level" tasks. The "llvm-top" module
-# should be the first one checked out by an llvm developer. Once it is checked
-# out you have, via this Makefile, a set of tools to assist with building a
-# development environment, including checking out other software, configuration,
-# etc.
-#
-SVN = svn
-
-# Figure out the root of the SVN repository by asking for it from 'svn info'
-SVNROOT = $(shell $(SVN) info . | grep 'Repository Root:' | \
-                   sed -e 's/^Repository Root: //')
-
-
-# Rule to get the modules that $(MODULE) depends on.
-MODULEINFO = $(MODULE)/ModuleInfo.txt
-DEPMODULES = grep -i DepModule: $(MODULEINFO) | sed 's/DepModule: *//g'
-BUILDTARGET = grep -i BuildTarget: $(MODULEINFO) | sed 's/BuildTarget: *//g'
-
-
-.PHONY: checkout
-
-ifndef MODULE
-checkout:
-	@echo ERROR: you must specify a MODULE value to 'make checkout'.
-	@echo ERROR: for example, use: 'make checkout MODULE=llvm'.
-
-build:
-	@echo ERROR: you must specify a MODULE value to 'make build'.
-	@echo ERROR: for example, use: 'make build MODULE=llvm'.
-else
-
-# Check out a module and all its dependencies. Note that this arrangement
-# depends on each module having a file named ModuleInfo.txt that explicitly
-# indicates the other LLVM modules it depends on. See one of those files for
-# examples.
-checkout: $(MODULE)
-
-$(MODULE):
-	$(SVN) co $(SVNROOT)/$(MODULE)/trunk $(MODULE)
-	@if test -f $(MODULEINFO); then \
-	  for mod in `$(DEPMODULES)`; do \
-	    echo -n "NOTE: $(MODULE) module depends on $$mod" ; \
-	    if test -d $$mod ; then \
-	      echo ", but its already checked out." ; \
-	    else \
-	      echo ", checking it out." ; \
-	      $(MAKE) checkout MODULE=$$mod ; \
-	    fi ; \
-          done; \
-        fi
-
-build: $(MODULE) install
-	@if test -f $(MODULEINFO) ; then \
-	  BuildTarget=`$(BUILDTARGET)` ; \
-	  for mod in `$(DEPMODULES)`; do \
-	    echo -n "NOTE: $(MODULE) module depends on $$mod" ; \
-	    if test -d $$mod ; then \
-	      echo ", building it first." ; \
-	    else \
-	      echo ", checking it out now." ; \
-	      $(MAKE) checkout MODULE=$$mod ; \
-	      if test "$$?" -ne 0 ; then exit 1 ; fi \
-	    fi ; \
-	    $(MAKE) build MODULE=$$mod ; \
-	    if test "$$?" -ne 0 ; then exit 1 ; fi \
-          done; \
-        fi ; \
-	echo "Building MODULE $(MODULE)" ; \
-	root=`pwd` ; cd $(MODULE) ; $(MAKE) $$BuildTarget LLVM_TOP=$$root 
-endif
-
-install:
-	@mkdir install

Modified: llvm-top/trunk/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/README.txt?rev=39911&r1=39910&r2=39911&view=diff

==============================================================================
--- llvm-top/trunk/README.txt (original)
+++ llvm-top/trunk/README.txt Mon Jul 16 03:13:56 2007
@@ -11,25 +11,36 @@
    svn co http://llvm.org/svn/llvm-project/llvm-top/trunk llvm-top
 
 Once you've done that, you can then check out a module (and all its
-dependencies) with the 'make checkout MODULE=modulename' command.  For example:
+dependencies) with the get script located here. For example:
 
-  make checkout MODULE=llvm-gcc-4.0
+  ./get llvm-gcc-4-0
 
-Checks out llvm-gcc-4.0 (the llvm C/C++/ObjC compiler built with the GCC 4.0
-front-end) and all the things it depends on.  Other modules available are:
+which will check out both llvm and llvm-gcc-4-0 because the latter depends on
+the former.
 
-  test-suite - The llvm test suite
-  stacker    - The stacker front end (a 'Forth-like' language)
-  hlvm       - High Level Virtual Machine
+Similarly you can build any module just by using the build script located
+here. For example:
 
-You can check out any number of modules.
+  ./build llvm-gcc-4-0 ENABLE_OPTIMIZED=1 PREFIX=/my/install/dir VERBOSE=1
 
+As you might guess, this will check out both llvm and llvm-gcc-4-0 if they
+haven't been and then configure and build them according to the arguments 
+that you specified. 
 
-Once you check out the modules, use the "make" command to automatically
-configure and build the projects you checked out.
+The modules available are:
 
-...
+  llvm-top     - This directory
+  llvm         - The core llvm software
+  llvm-gcc-4-0 - The C/C++/Obj-C front end for llvm, based on GCC 4.0
+  llvm-gcc-4-2 - The C/C++/Obj-C front end for llvm, based on GCC 4.2
+  test-suite   - The llvm test suite
+  stacker      - The stacker front end (a 'Forth-like' language)
+  hlvm         - High Level Virtual Machine (nascent)
+  java         - Java Front End (unfinished, out of date)
 
+You can check out any number of modules using the "get" script.
+
+-----------------------------------------------------------------------------
 
 Some Other Useful URLS
 ======================

Modified: llvm-top/trunk/build
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/build?rev=39911&r1=39910&r2=39911&view=diff

==============================================================================
--- llvm-top/trunk/build (original)
+++ llvm-top/trunk/build Mon Jul 16 03:13:56 2007
@@ -30,11 +30,14 @@
 # in appropriate variables for later use.
 for arg in "$@" ; do 
   case "$arg" in
-    --*)
-      CONFIGURE_ARGS="$CONFIGURE_ARGS $arg"
+    VERBOSE=*)
+      VERBOSE=`echo "$VERBOSE" | sed -e 's/VERBOSE=//'`
+      ;;
+    -*)
+      BUILD_OPTS="$BUILD_ARGS $arg"
       ;;
     *=*)
-      BUILD_ARGS="$BUILD_ARGS $arg"
+      BUILD_PARMS="$BUILD_PARAMS $arg"
       ;;
     *)
       MODULE_NAMES="$MODULE_NAMES $arg"
@@ -44,43 +47,32 @@
 # Get (and possibly check out) the set of modules and their dependencies. This
 # sets the MODULE_DEPENDENCIES variable to the set of module names that should
 # be configured, in the correct order (least dependent first, no duplicates).
+msg 1 "Checking out dependencies"
 MODULE_DEPENDENCIES=""
-get_dependencies $MODULE_NAMES
+get_module_dependencies $MODULE_NAMES
 
-build_module() {
+build_a_module() {
   module="$1"
-  build_opts="$2"
-  if test ! -d "$module" ; then
-    die 1 "Module $module did not get checked out!"
-  fi
-  LLVM_TOP=`pwd`
-  MODULE_INFO="$LLVM_TOP/$module/ModuleInfo.txt"
-  if test -f "$MODULE_INFO" ; then
-    build_command=`grep -i BuildCmd: $MODULE_INFO | sed -e 's/BuildCmd: //'`
-  fi
-  if test -z "$build_command" ; then
-    msg 0 "Module $module has no BuildCmd entry so it won't be built."
+  get_module_info $module BuildCmd
+  if test -z "$MODULE_INFO_VALUE" ; then
+    msg 0 "Module $module has no BuildCmd entry so it will not be built."
     return 0
   fi
+  build_command="$MODULE_INFO_VALUE"
+  build_command="$build_command $BUILD_OPTS"
+  build_command="$build_command LLVM_TOP='$LLVM_TOP' PREFIX='$INSTALL_PREFIX'" 
+  build_command="$build_command $BUILD_PARAMS"
+  msg 1 "Building Module $module with this command:"
+  msg 1 "  $build_command"
   cd $module
-  build_command=`echo $build_command $build_opts | sed \
-      -e "s#@LLVM_TOP@#$LLVM_TOP#g" \
-      -e "s#@BUILD_OPTS@#$build_opts#g"`
-  if test "$?" -ne 0 ; then 
-    die $? "Failed to generate build command"
-  fi
-  msg 0 "Building Module $module with this command:"
-  msg 0 "  $build_command"
   $build_command || die $? "Can't build $module"
   cd $LLVM_TOP
 }
 # Now that we have a list of dependent modules, we must configure each of them
 # according to the specifications of the module.
 for mod in $MODULE_DEPENDENCIES ; do
-  configure_module "$mod" "$CONFIGURE_ARGS"
-  build_module "$mod" "$BUILD_ARGS"
+  build_a_module "$mod"
 done
 
 # Just indicate what modules we configured
-msg 0 Modules built:"$MODULE_DEPENDENCIES".
-
+msg 1 Modules built:"$MODULE_DEPENDENCIES".

Removed: llvm-top/trunk/configure
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/configure?rev=39910&view=auto

==============================================================================
--- llvm-top/trunk/configure (original)
+++ llvm-top/trunk/configure (removed)
@@ -1,52 +0,0 @@
-#!/bin/sh
-#                               configure script
-# 
-# This file was developed by Reid Spencer and is distributed under the
-# University of Illinois Open Source License. See LICENSE.TXT for details.
-# 
-#===------------------------------------------------------------------------===#
-# This script allows LLVM modules to be configured including processing 
-# dependencies and optional configuration parameters. Use it like this:
-#
-#    cd llvm-top
-#    ./configure {module_names} {configure_options}
-#
-# where:
-#    {module_names} is a list of modules you want to configure (e.g. llvm, hlvm)
-#    {configure_options} is any options you want to pass to *all* the modules
-#      when they run their configure commands
-#
-# Note that the script will checkout and configure any dependent modules as well
-# as the ones specified in {module_names} so it is only necessary to specify the
-# minimal set you're interested in.
-
-# Get the library code
-. ./library.sh
-
-# 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
-# in appropriate variables for later use.
-for arg in "$@" ; do 
-  case "$arg" in
-    -*)
-      CONFIGURE_ARGS="$CONFIGURE_ARGS $arg"
-      ;;
-    *)
-      MODULE_NAMES="$MODULE_NAMES $arg"
-  esac
-done
-
-# Get (and possibly check out) the set of modules and their dependencies. This
-# sets the MODULE_DEPENDENCIES variable to the set of module names that should
-# be configured, in the correct order (least dependent first, no duplicates).
-MODULE_DEPENDENCIES=""
-get_dependencies $MODULE_NAMES
-
-# Now that we have a list of dependent modules, we must configure each of them
-# according to the specifications of the module.
-for mod in $MODULE_DEPENDENCIES ; do
-  configure_module "$mod" "$CONFIGURE_ARGS"
-done
-
-# Just indicate what modules we configured
-msg 0 Modules configured:"$MODULE_DEPENDENCIES".

Modified: llvm-top/trunk/get
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/get?rev=39911&r1=39910&r2=39911&view=diff

==============================================================================
--- llvm-top/trunk/get (original)
+++ llvm-top/trunk/get Mon Jul 16 03:13:56 2007
@@ -12,7 +12,7 @@
 
 # Getting the module dependencies also causes them to be checked out.
 MODULE_DEPENDENCIES=""
-get_dependencies "$@"
+get_module_dependencies "$@"
 
 # Report what happened.
 msg 0 Modules checked out:"$MODULE_DEPENDENCIES".

Modified: llvm-top/trunk/library.sh
URL: http://llvm.org/viewvc/llvm-project/llvm-top/trunk/library.sh?rev=39911&r1=39910&r2=39911&view=diff

==============================================================================
--- llvm-top/trunk/library.sh (original)
+++ llvm-top/trunk/library.sh Mon Jul 16 03:13:56 2007
@@ -1,4 +1,5 @@
-#                        llvm-top common script
+#!/bin/sh
+#                   llvm-top common function library
 # 
 # This file was developed by Reid Spencer and is distributed under the
 # University of Illinois Open Source License. See LICENSE.TXT for details.
@@ -10,7 +11,11 @@
 
 # The arguments to all scripts are
 # Define where subversion is. We assume by default its in the path.
-SVN=svn
+SVN=`which svn`
+
+# Get the llvm-top directory before anyone has a chance to cd out of it
+LLVM_TOP=`pwd`
+INSTALL_PREFIX="$LLVM_TOP/install"
 
 # A command to figure out the root of the SVN repository by asking for it from
 # the 'svn info' command. To use, execute it in a script with something like
@@ -20,22 +25,7 @@
 # output from the library
 VERBOSE=0
 
-# Rule to get the modules that $(MODULE) depends on.
-#MODULEINFO = $(MODULE)/ModuleInfo.txt
-#DEPMODULES = grep -i DepModule: $(MODULEINFO) | sed 's/DepModule: *//g'
-#BUILDTARGET = grep -i BuildTarget: $(MODULEINFO) | sed 's/BuildTarget: *//g'
-#CONFIGTARGET = grep -i ConfigTarget: $(MODULEINFO) | sed 's/ConfigTarget: *//g'
-
-# Figure out the root of the SVN repository by asking for it from 'svn info'
-#SVNROOT = $(shell $(SVN) info . | grep 'Repository Root:' | \
-#                   sed -e 's/^Repository Root: //')
-
-
-# Check out a module and all its dependencies. Note that this arrangement
-# depends on each module having a file named ModuleInfo.txt that explicitly
-# indicates the other LLVM modules it depends on. See one of those files for
-# examples.
-
+# Generate an informative message to the user based on the verbosity level
 msg() {
   level=$1
   shift
@@ -44,6 +34,7 @@
   fi
 }
 
+# Die with an error message
 die() {
   EXIT_CODE=$1
   shift
@@ -51,33 +42,65 @@
   exit $EXIT_CODE
 }
 
-checkout() {
+
+# Check out a single module. 
+checkout_a_module() {
   module=$1
+  if test -d "$module" ; then
+    msg 0 "Module $module is already checked out."
+    return 0
+  fi
+  if test -e "$module" ; then
+    msg 0 "Module $module is not a directory! Checkout skipped."
+    return 0
+  fi
   msg 1 "Checking out module $module"
-  $SVN checkout $SVNROOT/$module/trunk $module || \
-    die $? "Checkout of module $module failed."
+  if test "$module" == "llvm-gcc-4-0" ; then
+    $SVN checkout svn://anonsvn.opensource.apple.com/svn/llvm/trunk $module ||
+      die $? "Checkout of module $module failed."
+  else
+    $SVN checkout $SVNROOT/$module/trunk $module || \
+      die $? "Checkout of module $module failed."
+  fi
   return 0
 }
 
-get_dependencies() {
-  for module in $* ; do
-    if test ! -d "$module" ; then
-      checkout "$module" || die $? "Checkout failed."
-    fi
-    mi="$module/ModuleInfo.txt"
-    dep_modules=""
-    if test -f "$mi" ; then
-      dep_modules=`grep -i DepModule: $mi | sed -e 's/DepModule: *//g'`
-      if test "$?" -ne 0 ; then 
-        die $? "Searching file '$mi' failed."
-      fi
-    else
-      msg 0 "Module $module has not ModuleInfo.txt file"
+# This function extracts a module info item from a ModuleInfo.txt file. If
+# the module isn't already checked out, then it gets checked out. The value
+# of the info item is returned in the MODULE_INFO_VALUE variable.
+get_module_info() {
+  module="$1"
+  item_name="$2"
+  if test ! -d "$module" ; then
+    checkout_a_module "$module" || die $? "Checkout failed."
+  fi
+  module_info="$module/ModuleInfo.txt"
+  if test -f "$module_info" ; then
+    item_value=`grep -i "$item_name:" $module_info | \
+                sed -e "s/$item_name: *//g"`
+    if test "$?" -ne 0 ; then 
+      die $? "Searching file '$module_info for $item_name' failed."
     fi
-    if test ! -z "$dep_modules" ; then
-      msg 1 "Module '$module' depends on $dep_modules"
-      deps=`get_dependencies $dep_modules` || die $? "get_dependencies failed"
-      for dep in $dep_modules ; do
+  else
+    msg 0 "Module $module has no ModuleInfo.txt file (ignored)."
+  fi
+  MODULE_INFO_VALUE="$item_value"
+}
+
+# This function gets the dependencies of all the dependent modules of the
+# list of modules passed as arguments. If a module is not checked out, it will
+# be checked out. This process repeats recursively until all the dependencies
+# have been satisfied. Upon exit the MODULE_DEPENDENCIES variable contains
+# the list of module names from least dependent to most dependent in the
+# correct configure/build order.
+get_module_dependencies() {
+  for module in $* ; do
+    get_module_info $module DepModule
+    if test ! -z "$MODULE_INFO_VALUE" ; then
+      msg 1 "Module '$module' depends on $MODULE_INFO_VALUE"
+      deps=`get_module_dependencies $MODULE_INFO_VALUE` || \
+         die $? "get_dependencies failed"
+      for dep in $MODULE_INFO_VALUE ; do
         matching=`echo "$MODULE_DEPENDENCIES" | grep "$dep"`
         if test -z "$matching" ; then
           MODULE_DEPENDENCIES="$MODULE_DEPENDENCIES $dep"
@@ -91,39 +114,3 @@
   done
   return 0
 }
-
-configure_module() {
-  module="$1"
-  config_opts="$2"
-  if test ! -d "$module" ; then
-    die 1 "Module $module did not get checked out!"
-  fi
-  LLVM_TOP=`pwd`
-  MODULE_INFO="$LLVM_TOP/$module/ModuleInfo.txt"
-  INSTALL_PREFIX="$LLVM_TOP/install"
-  if test -f "$MODULE_INFO" ; then
-    config_command=`grep -i ConfigCmd: $MODULE_INFO | sed -e 's/ConfigCmd: //'`
-    config_file=`grep -i ConfigFile: $mi | sed -e 's/ConfigFile: //'`
-  fi
-  if test -z "$config_command" ; then
-    msg 0 "Module $module has no ConfigCmd entry so it won't be configured"
-    return 0
-  fi
-  cd $module
-  if test -e "$config_file" ; then
-    msg 0 "Module $module is already configured"
-  else
-    config_command=`echo $config_command $config_opts | sed \
-      -e "s#@LLVM_TOP@#$LLVM_TOP#g" \
-      -e "s#@INSTALL_PREFIX@#$INSTALL_PREFIX#g" \
-      -e "s#@CONFIG_OPTS@#$config_opts#g"`
-    if test "$?" -ne 0 ; then 
-      die $? "Failed to generate configure command"
-    fi
-    msg 0 "Configuring Module $module with this command:"
-    msg 0 "  $config_command"
-    $config_command || die $? "Can't configure $module"
-  fi
-  cd $LLVM_TOP
-}
-





More information about the llvm-commits mailing list