Anonymous avatar Anonymous committed 353bacf

Handle problems more strictly. Teach toolshelf about ant.

Comments (0)

Files changed (3)

   you were going to install from source without `toolshelf`, you'd have to
   fiddle with your build environment anyway, so it's no worse than that.)
 
+* Some executables load resources, and expect those resources to be in
+  certain locations.  If the executable looks for those resources in locations
+  that are relative to the path to the executable, that's good; the executable
+  and the resources will both be in the docked source, and it should find
+  them.  Or, if it looks for them on a search path, that's also not so bad.
+  But sometimes they look for resources relative to the current working
+  directory -- in which case there's little point being able to invoke the
+  executable, from the search path, while in another directory.  (`toolshelf`
+  may one day grow a feature to handle this.)  And if they look for resources
+  in fixed locations, well, that's not so good, and there's not a lot one can
+  do about that, aside from maybe forking the project and fixing it.
+
 * Most operating systems impose a fixed limit on the size of an environment
   variable, and the search path is stored in an environment variable.  Thus
   you can hit a limit if you dock a large number of sources and/or sources
 If there is a script called `build.sh` or `make.sh`, it will run that.
 Otherwise...
 
-If there's an `autogen.sh` but no `configure`, it runs that first, to
+If there's an `autogen.sh` but no `configure`, it runs that first, to
 create `configure`.
 
 ♦ If there's no `autogen.sh`, but there is a `configure.in`, it runs
 
 If there's a `Makefile`, it runs `make`.
 
-If there's a `build.xml`, it runs `ant` instead.
+If there's a `build.xml`, it runs `ant` instead.
 
 ### "Cookies" ###
 

catalog/catseye-stars.catalog

 
 gh:rascal999/chip8-emulator
 gh:pikhq/cmako
+gh:JohnEarnest/Mako
                  self.project, self.type, self.hints))
 
     @classmethod
-    def from_catalog(klass, filename, problems):
-        try:
-            file = open(filename)
-        except IOError as e:
-            problems.append(e)
-            return []
+    def from_catalog(klass, filename):
+        note('Reading catalog %s' % filename)
         sources = []
-        for line in file:
-            line = line.strip()
-            if line == '' or line.startswith('#'):
-                continue
-            sources += Source.from_spec(line, problems)
-        file.close()
+        with open(filename, 'r') as file:
+            for line in file:
+                line = line.strip()
+                if line == '' or line.startswith('#'):
+                    continue
+                sources += Source.from_spec(line)
         return sources
 
     @classmethod
-    def from_specs(klass, names, problems):
+    def from_specs(klass, names):
         sources = []
         for name in names:
-            sources += klass.from_spec(name, problems)
+            sources += klass.from_spec(name)
         return sources
 
     @classmethod
-    def from_spec(klass, name, problems):
+    def from_spec(klass, name):
         """Parse an external source specifier and return a list of
         Source objects.
 
           @local/file/name           read list of sources from file
           @@foo                      read list in .toolshelf/catalog/foo
 
-        If problems are encountered while parsing the source spec,
-        they will be added to the problems parameter, assumed to be
-        a list-like object.
-
         """
         if name.startswith('@@'):
             filename = os.path.join(
                 TOOLSHELF, '.toolshelf', 'catalog', name[2:] + '.catalog'
             )
-            return klass.from_catalog(filename, problems)
+            return klass.from_catalog(filename)
         if name.startswith('@'):
-            return klass.from_catalog(name[1:], problems)
+            return klass.from_catalog(os.path.join(CWD, name[1:]))
 
-        try:
-            kwargs = parse_source_spec(name)
-            return [Source(**kwargs)]
-        except Exception as e:
-            problems.append(repr(e))
-            return []
+        kwargs = parse_source_spec(name)
+        return [Source(**kwargs)]
 
     @property
     def distfile(self):
             run('./build.sh')
         elif os.path.isfile('make.sh'):
             run('./make.sh')
+        elif os.path.isfile('build.xml'):
+            run('ant')
         else:
-            if os.path.isfile('autogen.sh'):
+            if (os.path.isfile('autogen.sh') and
+                not os.path.isfile('configure')):
                 run('./autogen.sh')
             if os.path.isfile('configure'):
                 run('./configure')
 
 
 def dock_cmd(result, args):
-    problems = []
-    sources = Source.from_specs(args, problems)
-    # TODO: improve this
-    if problems:
-        raise SourceSpecError(repr(problems))
+    sources = Source.from_specs(args)
     for source in sources:
         if source.docked:
             print "%s already docked." % source.name
 
 
 def build_cmd(result, args):
-    problems = []
     specs = expand_docked_specs(args)
-    sources = Source.from_specs(specs, problems)
-    # TODO: improve this
-    if problems:
-        raise SourceSpecError(repr(problems))
+    sources = Source.from_specs(specs)
     for source in sources:
         source.build()
     path_cmd(result, ['rebuild'] + [s.name for s in sources])
 
 
 def update_cmd(result, args):
-    problems = []
     specs = expand_docked_specs(args)
-    sources = Source.from_specs(specs, problems)
-    # TODO: improve this
-    if problems:
-        raise SourceSpecError(repr(problems))
+    sources = Source.from_specs(specs)
     for source in sources:
         source.update()
         source.build()
 
     if args[0] == 'rebuild':
         specs = expand_docked_specs(args[1:], default_all=True)
-        problems = []
-        sources = Source.from_specs(specs, problems)
-        # TODO: improve this
-        if problems:
-            raise SourceSpecError(repr(problems))
+        sources = Source.from_specs(specs)
         p = Path()
         clean_path(p, sources, all=(specs == ['all']))
         note("Adding the following executables to your PATH...")
         p.write(result)
     elif args[0] == 'disable':
         specs = expand_docked_specs(args[1:], default_all=True)
-        problems = []
-        sources = Source.from_specs(specs, problems)
-        # TODO: improve this
-        if problems:
-            raise SourceSpecError(repr(problems))
+        sources = Source.from_specs(specs)
         p = Path()
         clean_path(p, sources, all=(specs == ['all']))
         p.write(result)
     elif args[0] == 'show':
         specs = expand_docked_specs(args[1:], default_all=True)
-        problems = []
-        sources = Source.from_specs(specs, problems)
-        # TODO: improve this
-        if problems:
-            raise SourceSpecError(repr(problems))
+        sources = Source.from_specs(specs)
         p = Path()
         for component in p.components:
             for source in sources:
 
 
 def cd_cmd(result, args):
-    problems = []
     specs = expand_docked_specs(args)
-    sources = Source.from_specs(specs, problems)
-    # TODO: improve this
-    if problems:
-        raise SourceSpecError(repr(problems))
+    sources = Source.from_specs(specs)
     if len(sources) != 1:
         raise CommandLineSyntaxError(
             "'cd' subcommand requires exactly one source\n"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.