You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by le...@apache.org on 2005/07/12 00:14:42 UTC

svn commit: r215891 - in /gump/branches/Gump3: metadata/ pygump/python/gump/ pygump/python/gump/engine/ pygump/python/gump/model/ pygump/python/gump/plugins/ pygump/python/gump/plugins/java/

Author: leosimons
Date: Mon Jul 11 15:14:40 2005
New Revision: 215891

URL: http://svn.apache.org/viewcvs?rev=215891&view=rev
Log:
Implement a <path/> output and a <includes/> output that allow projects to export 'native' style stuff. Add a 'jdk' installed package to vmgump.xml using that new functionality. Ain't it cool how easy that was? This is the first step to Gump compiling a jdk to use for compiling other stuff (eg, bootstrapping kaffe), or towards gump compiling python to run itself :-)

Modified:
    gump/branches/Gump3/metadata/vmgump.xml
    gump/branches/Gump3/pygump/python/gump/config.py
    gump/branches/Gump3/pygump/python/gump/engine/objectifier.py
    gump/branches/Gump3/pygump/python/gump/model/__init__.py
    gump/branches/Gump3/pygump/python/gump/model/util.py
    gump/branches/Gump3/pygump/python/gump/plugins/builder.py
    gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py

Modified: gump/branches/Gump3/metadata/vmgump.xml
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/metadata/vmgump.xml?rev=215891&r1=215890&r2=215891&view=diff
==============================================================================
--- gump/branches/Gump3/metadata/vmgump.xml (original)
+++ gump/branches/Gump3/metadata/vmgump.xml Mon Jul 11 15:14:40 2005
@@ -120,6 +120,27 @@
 </modules>
 
 <projects>
+    <project name="jdk" path="jdk">
+        <!-- installed package -->
+        <!-- outputs -->
+        <path name="bin"/>
+        <includes name="include"/>
+        <jar name="lib/tools.jar" id="tools"/>
+    </project>
+
+    <project name="jaxp" path="jaxp-1_3-20050622-gump-20050710">
+        <!-- installed package -->
+        <!-- outputs -->
+        <jar name="jaxp-api.jar" id="jaxp-api" type="boot"/>
+        <jar name="dom.jar" id="dom" type="boot"/>
+        <jar name="sax.jar" id="sax" type="boot"/>
+        <jar name="xercesImpl.jar" id="xml-parser" type="boot"/>
+        <jar name="xalan.jar" id="xalan" type="boot"/>
+        
+        <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
+    </project>
+
     <project name="gump-unit-tests">
         <module name="gump"/>
         
@@ -130,10 +151,7 @@
             <env name="PYTHONPATH"/>
             <env name="GUMP_WORKDIR"/>
             <env name="GUMP_HOSTNAME"/>
-            <arg name="bla" reference="home" project="bootstrap-ant"/>
         </script> 
-        
-        <depend project="bootstrap-ant"/>
     </project>
     
     <project name="bootstrap-ant">
@@ -146,6 +164,9 @@
         <home nested="bootstrap"/>
         <jar name="lib/ant.jar"/>
         <jar name="lib/ant-launcher.jar" id="ant-launcher"/>
+
+        <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
     </project>
     
     <project name="ant">
@@ -155,6 +176,7 @@
         <ant/>
         
         <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
         <depend project="bootstrap-ant"/>
     </project>
 
@@ -169,6 +191,7 @@
         <jar name="xml-apis.jar" type="boot"/>
         
         <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
         <depend project="bootstrap-ant"/>
         <depend project="jaxp"/>
     </project>
@@ -184,6 +207,7 @@
         <jar name="which.jar" id="which"/>
         
         <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
         <depend project="xml-apis"/>
         <depend project="xml-xerces"/>
         <depend project="bootstrap-ant"/>
@@ -200,21 +224,12 @@
         <jar name="resolver.jar"/>
 
         <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
         <depend project="jaxp"/>
         <depend project="xml-apis"/>
         <depend project="bootstrap-ant" inherit="runtime"/>
     </project>
     
-    <project name="jaxp" path="jaxp-1_3-20050622-gump-20050710">
-        <!-- installed package -->
-        <!-- outputs -->
-        <jar name="jaxp-api.jar" id="jaxp-api" type="boot"/>
-        <jar name="dom.jar" id="dom" type="boot"/>
-        <jar name="sax.jar" id="sax" type="boot"/>
-        <jar name="xercesImpl.jar" id="xml-parser" type="boot"/>
-        <jar name="xalan.jar" id="xalan" type="boot"/>
-    </project>
-
     <project name="xml-xerces">
         <module name="xml-xerces"/>
         
@@ -226,6 +241,7 @@
         <jar name="xercesImpl.jar" id="xml-parser" type="boot"/>
         
         <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
         <depend project="bootstrap-ant"/>
         <depend project="xjavac"/>
         <depend project="xml-commons-resolver"/>
@@ -255,6 +271,7 @@
         <jar name="serializer.jar" id="serializer" type="boot"/>
         
         <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
         <depend project="bootstrap-ant"/>
         <depend project="xml-xerces"/>
         <depend project="java_cup" runtime="true"/>
@@ -278,6 +295,7 @@
         <jar name="serializer.jar" id="serializer" type="boot"/>
 
         <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
         <depend project="bootstrap-ant"/>
         <depend project="xml-xerces"/>
         <depend project="java_cup" runtime="true"/>
@@ -288,19 +306,27 @@
 
     <project name="java_cup">
         <module name="xml-xalan"/>
+        <!-- per-module installed package -->
         
         <!-- outputs -->
         <home nested="java"/>
         <jar name="bin/java_cup.jar"/>
         <jar name="bin/runtime.jar"/>
+        
+        <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
     </project>
 
     <project name="jlex">
         <module name="xml-xalan"/>
+        <!-- per-module installed package -->
         
         <!-- outputs -->
         <home nested="java"/>
         <jar name="bin/JLex.jar"/>
+
+        <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
     </project>
     
     <project name="bcel">
@@ -313,6 +339,7 @@
         <jar name="bin/bcel.jar"/>
 
         <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
         <depend project="bootstrap-ant" inherit="runtime"/>
         <depend project="xml-apis"/>
         <depend project="xml-xerces"/>
@@ -333,6 +360,7 @@
         <jar name="jakarta-regexp-1.4-dev.jar" id="regexp"/>
         
         <!-- dependencies -->
+        <depend project="jdk" runtime="true"/>
         <depend project="bootstrap-ant" inherit="runtime"/>
         <depend project="xml-apis"/>
         <depend project="xml-xerces"/>

Modified: gump/branches/Gump3/pygump/python/gump/config.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/config.py?rev=215891&r1=215890&r2=215891&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/config.py (original)
+++ gump/branches/Gump3/pygump/python/gump/config.py Mon Jul 11 15:14:40 2005
@@ -105,6 +105,9 @@
         log.info("Not running updates! (pass --do-updates to enable them)")
         
     if config.do_build:
+        from gump.model import Ant
+        from gump.model import Script
+
         # by contract, rmdir always needs to go before mkdir!
         from gump.plugins.dirbuilder import RmdirBuilderPlugin
         plugins.append(RmdirBuilderPlugin())
@@ -113,10 +116,12 @@
     
         buildlog = get_logger(config, "plugin.builder")
     
+        from gump.plugins.builder import PathPlugin
+        plugins.append(PathPlugin(buildlog, Ant))
+        plugins.append(PathPlugin(buildlog, Script))
         from gump.plugins.builder import ScriptBuilderPlugin
         plugins.append(ScriptBuilderPlugin(buildlog))
         from gump.plugins.java.builder import ClasspathPlugin
-        from gump.model import Ant
         plugins.append(ClasspathPlugin(buildlog,Ant))
         from gump.plugins.java.builder import AntPlugin
         plugins.append(AntPlugin(buildlog))

Modified: gump/branches/Gump3/pygump/python/gump/engine/objectifier.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/objectifier.py?rev=215891&r1=215890&r2=215891&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/objectifier.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/objectifier.py Mon Jul 11 15:14:40 2005
@@ -351,21 +351,43 @@
 
 
 def _create_outputs(project, project_definition):    
-    # Working directories for this project (containing java classes)
+    _create_work_outputs(project, project_definition)
+    _create_jar_outputs(project, project_definition)
+    _create_binary_path_outputs(project, project_definition)
+    _create_includes_path_outputs(project, project_definition)
+    #TODO more outputs
+
+
+def _create_work_outputs(project, project_definition):
     works = project_definition.getElementsByTagName("work")
     for work in works:
         path = _extract_path(project, work)
         project.add_output(Classdir(project, path))
 
-    # Jars
+
+def _create_jar_outputs(project, project_definition):
     jars = project_definition.getElementsByTagName("jar")
     for jar in jars:
         name = jar.getAttribute("name")
         id = jar.getAttribute("id")
         add_to_bootclass_path = jar.getAttribute("type") == "boot"
         project.add_output(Jar(project, name, id, add_to_bootclass_path))
-    
-    #TODO more outputs
+
+
+def _create_binary_path_outputs(project, project_definition):
+    paths = project_definition.getElementsByTagName("path")
+    for path in paths:
+        name = path.getAttribute("name")
+        id = path.getAttribute("id")
+        project.add_output(BinariesPath(project, name, id=id))
+
+
+def _create_includes_path_outputs(project, project_definition):
+    paths = project_definition.getElementsByTagName("includes")
+    for path in paths:
+        name = path.getAttribute("name")
+        id = path.getAttribute("id")
+        project.add_output(IncludesPath(project, name, id=id))
 
 
 def _create_dependencies(project_definition, projectlist):

Modified: gump/branches/Gump3/pygump/python/gump/model/__init__.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/model/__init__.py?rev=215891&r1=215890&r2=215891&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/__init__.py Mon Jul 11 15:14:40 2005
@@ -666,4 +666,50 @@
     def __str__(self):
         return "<Jar:%s,id=%s,add_to_bootclass_path=%s>" % (self.name, self.id, self.add_to_bootclass_path)
 
+class Path(Output):
+    """Model a directory containing things of use to other projects.
+
+    Has the following properties:
+
+        - all the properties an Output has
+        - name -- the path to the directory relative to the project its home
+                  directory.
+    """
+    def __init__(self, project, name, id=None):
+        assert isinstance(name, basestring)
+        Output.__init__(self, project, id)
+        self.name = name
+    
+    def __str__(self):
+        return "<Path:%s,id=%s>" % (self.name, self.id)
+
+class BinariesPath(Path):
+    """Model a directory containing scripts and/or binaries that can be run
+       by other projects..
+
+    Has the following properties:
+
+        - all the properties a Directory has
+    """
+    def __init__(self, project, name, id=None):
+        Path.__init__(self, project, name, id)
+    
+    def __str__(self):
+        return "<BinariesPath:%s,id=%s>" % (self.name, self.id)
+
+class IncludesPath(Path):
+    """Model a directory containing header files that can be linked against by
+       other projects.
+
+    Has the following properties:
+
+        - all the properties a Directory has
+    """
+    def __init__(self, project, name, id=None):
+        Path.__init__(self, project, name, id)
+    
+    def __str__(self):
+        return "<IncludesPath:%s,id=%s>" % (self.name, self.id)
+
+
 #TODO: more outputs

Modified: gump/branches/Gump3/pygump/python/gump/model/util.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/model/util.py?rev=215891&r1=215890&r2=215891&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/util.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/util.py Mon Jul 11 15:14:40 2005
@@ -23,7 +23,8 @@
 from os.path import join
 import os
 
-from gump.model import ModelObject, Error, Dependency, CvsModule, SvnModule, Project, ExceptionInfo, Classdir, Jar, \
+from gump.model import ModelObject, Error, Dependency, CvsModule, SvnModule, Project, ExceptionInfo, BinariesPath, \
+     Classdir, Jar, \
      DEPENDENCY_INHERIT_ALL, DEPENDENCY_INHERIT_HARD, DEPENDENCY_INHERIT_JARS, DEPENDENCY_INHERIT_RUNTIME
 
 UPDATE_TYPE_CHECKOUT="checkout"
@@ -183,6 +184,23 @@
     return False
     
 
+def calculate_path(project):
+    """This method looks at a a project and builds a PATH based on the <path/>
+       directives of its dependencies."""
+    path = ""
+    for rel in project.dependencies:
+        for p in [output for output in rel.dependency.outputs if isinstance(output, BinariesPath)]:
+            path += os.path.join(get_project_directory(rel.dependency),p.name) + os.pathsep
+
+    if os.environ.has_key('PATH'):
+        path = path + os.environ['PATH']
+    else:
+        path = path[:-1] # get rid of ':'
+
+    return path     
+    
+
+
 def calculate_classpath(project, recurse=True, runtimeonly=False):
     """This ugly beast of a method looks at a project and its dependencies and
     builds a classpath and a bootclasspath based on its <work/> directives
@@ -212,7 +230,8 @@
 
             filter_by_id = info.specific_output_ids and len(info.specific_output_ids) > 0
         
-            for output in [o for o in dependency.outputs if o not in visited_outputs]:
+            for output in [o for o in dependency.outputs if o not in visited_outputs
+                           and (isinstance(o, Jar) or isinstance(o, Classdir))]:
                 visited_outputs.append(o)
                 
                 # exclude unspecified outputs

Modified: gump/branches/Gump3/pygump/python/gump/plugins/builder.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/builder.py?rev=215891&r1=215890&r2=215891&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/builder.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/builder.py Mon Jul 11 15:14:40 2005
@@ -26,9 +26,10 @@
 import shutil
 
 from gump.model import Script, Error, Project, Ant, Dependency
-from gump.model.util import get_project_directory
+from gump.model.util import get_project_directory, calculate_path
 from gump.plugins import AbstractPlugin
 from gump.util.executor import Popen, PIPE, STDOUT
+from gump.util import ansicolor
 
 #DEFAULT_SCRIPT_SHELL = "sh"
 if sys.platform == "win32":
@@ -118,12 +119,28 @@
         try: shutil.rmtree(self.tempdir)
         except: pass
 
+
+class PathPlugin(BuilderPlugin):
+    """Generate the PATH to be used with the specified command."""
+    def __init__(self, log, CommandClazz):
+        BuilderPlugin.__init__(self, log, CommandClazz, self.set_path)
+        
+    def set_path(self, project, command):
+        path = calculate_path(project)
+        command.path = path
+
+
 class ScriptBuilderPlugin(BuilderPlugin):
     """Execute all "script" commands for all projects."""
     def __init__(self, log):
         BuilderPlugin.__init__(self, log, Script, self._do_script)
         
     def _do_script(self, project, script):
+        # environment
+        script.env['PATH'] = script.path
+        self.log.debug("        PATH is '%s%s%s'" % \
+                       (ansicolor.Blue, script.env['PATH'], ansicolor.Black))
+        
         # working directory
         projectpath = get_project_directory(project)
         if script.basedir:

Modified: gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py?rev=215891&r1=215890&r2=215891&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/java/builder.py Mon Jul 11 15:14:40 2005
@@ -49,9 +49,13 @@
         
     def _do_ant(self, project, ant):                
         # environment
-        self.log.debug("        CLASSPATH is '%s%s%s'" % \
-                       (ansicolor.Blue, ":".join(ant.classpath), ansicolor.Black))
         ant.env['CLASSPATH'] = os.pathsep.join(ant.classpath)
+        self.log.debug("        CLASSPATH is '%s%s%s'" % \
+                       (ansicolor.Blue, ant.env['CLASSPATH'], ansicolor.Black))
+
+        ant.env['PATH'] = ant.path
+        self.log.debug("        PATH is '%s%s%s'" % \
+                       (ansicolor.Blue, ant.env['PATH'], ansicolor.Black))
         
         # working directory
         projectpath = get_project_directory(project)
@@ -59,7 +63,7 @@
             projectpath = os.path.join(projectpath, ant.basedir)
         
         # command line
-        args = [join(ant.env["JAVA_HOME"], "bin", "java")]
+        args = ["java"]
         
         if ant.boot_classpath and len(ant.boot_classpath) > 0:
             args.append('-Xbootclasspath/p:' + ':'.join(ant.boot_classpath))