options.py

Go to the documentation of this file.
00001 # Copyright 2006  Timo Savola
00002 #
00003 # This program is free software; you can redistribute it and/or modify
00004 # it under the terms of the GNU Lesser General Public License as published
00005 # by the Free Software Foundation; either version 2.1 of the License, or
00006 # (at your option) any later version.
00007 
00008 import os
00009 import gobject
00010 
00011 import project
00012 import execution
00013 
00014 class GuessOptions (project.OptionsExtension):
00015         rules = None
00016 
00017         def __init__(self, path, match):
00018                 project.OptionsExtension.__init__(self)
00019                 self.root = path
00020 
00021         def _get_path(self, name):
00022                 return os.path.join(self.root, name)
00023 
00024         def build(self, batch, name=None):
00025                 if os.path.exists(os.path.join(self.root, 'SConstruct')):
00026                         args = ['scons']
00027                         if name:
00028                                 args.append(name)
00029                 else:
00030                         args = ['make']
00031                         if name:
00032                                 if os.path.isdir(os.path.join(self.root, name)):
00033                                         args += ['-C', name]
00034                                 else:
00035                                         dir, file = os.path.split(name)
00036                                         if dir:
00037                                                 args += ['-C', dir]
00038                                         args.append(file)
00039 
00040                 job = execution.Job(args, workdir=self.root)
00041                 batch.add(job)
00042 
00043         def clean(self, batch, name=None):
00044                 if os.path.exists(os.path.join(self.root, 'SConstruct')):
00045                         args = ['scons', '-c']
00046                         if name:
00047                                 args.append(name)
00048                 else:
00049                         args = ['make', 'clean']
00050                         if name:
00051                                 args += ['-C', name]
00052 
00053                 job = execution.Job(args, workdir=self.root)
00054                 batch.add(job)
00055 
00056         def run(self, batch, name=None):
00057                 if name:
00058                         dir, file = os.path.split(name)
00059                         if not dir:
00060                                 name = os.path.join('.', file)
00061 
00062                         job = execution.Job([name], workdir=self.root)
00063                         batch.add(job)
00064 
00065 gobject.type_register(GuessOptions)
00066 
00067 class PythonOptions (GuessOptions):
00068         rules = (
00069                 'EncodeOptions.py',
00070                 './$(DIRNAME).encode.py',
00071         )
00072 
00073         def __init__(self, path, match):
00074                 GuessOptions.__init__(self, path, match)
00075 
00076                 if match:
00077                         execfile(match, self.__dict__)
00078 
00079 gobject.type_register(PythonOptions)

Generated on Thu Jan 18 09:47:40 2007 for Encode by  doxygen 1.4.7