Esempio n. 1
0
def builder():
  buildLogger.setLevel(logging.INFO)
  procLogger.setLevel(logging.WARNING)
  
  parser = OptionParser(conflict_handler="resolve", usage="%prog [options] source")
  parser.set_defaults(installPath="/opt", doConfigure=True, doBuild=True, doInstall=True, doClean=False, verbose=False, doRetry=True, sudo=False, devel=False, save=True, merge=False)
  common = OptionGroup(parser, "Common Options")
  common.add_option("-d", "--devel", action="store_true", help="Build the project in development mode", dest="devel")
  common.add_option("--prefix", type="string", help="Install prefix", dest="installPath")
  common.add_option("-s","--source-path", type="string", help="Path to source", dest="source")
  common.add_option("-b","--build-path", type="string", help="Build path", dest="build")
  common.add_option("-v", "--verbose", action="callback", help="Verbose", callback=setVerbosity)
  common.add_option("-N", "--name", type="string", help="Name of project")
  common.add_option("--configure", action="store_true", help="Run configuration", dest="doConfigure")
  common.add_option("--no-configure", action="store_false", help="Don't run configuration", dest="doConfigure")
  common.add_option("--compile", action="store_true", help="Compile", dest="doBuild")
  common.add_option("--no-compile", action="store_false", help="Don't compile", dest="doBuild")
  common.add_option("--install", action="store_true", help="Install", dest="doInstall")
  common.add_option("--no-install", action="store_false", help="Don't install", dest="doInstall")
  common.add_option("-S", "--sudo", action="store_true", help="Run install with sudo", dest="sudo")
  common.add_option("--retry", action="store_true", help="Clean the build and try building again after a failure.", dest="doRetry")
  common.add_option("--no-retry", action="store_false", help="Don't clean the build before retrying", dest="doRetry")
  common.add_option("--clean", action="store_true", help="Clean the build directory", dest="doClean")
  common.add_option("--no-clean", action="store_false", help="Don't clean the build directory", dest="doClean")
  common.add_option("--save", action="store_true", help="Save these settings between runs", dest="save")
  common.add_option("--no-save", action="store_false", help="Don't save settings.", dest="save")
  common.add_option("--load", action="store_true", help="Load saved options", dest="load")
  common.add_option("--no-load", action="store_false", help="Don't load saved options", dest="load")
  common.add_option("--merge", action="store_true", help="Load user options first, with saved options overwriting them.", dest="merge")
  parser.add_option_group(common)
  BuildSystem.buildArgs(parser)
  BuildContext.buildArgs(parser)
  (options,args) = parser.parse_args()
  if len(args) > 0:
      options.source = args.pop()
  if options.source == None:
      options.source = os.getcwd()
  cxt = BuildContext.factory(options)
  try:
    cxt.load()
  except NotImplementedError:
    buildLogger.warn("Loading options not supported.")
  try:
    cxt.save()
  except NotImplementedError:
    buildLogger.warn("Saving options not supported.")
  return BuildSystem.factory(cxt)
Esempio n. 2
0
import logging
import Autotools
import BuildSystem
import subprocess
import os

class IMakefileSystem(Autotools.AutotoolsSystem):
    @staticmethod
    def canHandle(context):
        return os.path.exists(context.source+"/Imakefile")
    
    @staticmethod
    def parseArgs(options):
        return options
    
    def configure(self):
        os.chdir(self.buildDir())
        ret = subprocess.call("xmkmf")
        return ret == 0

BuildSystem.register(IMakefileSystem)
Esempio n. 3
0
    def CopyOutputFile(self, output, index, dest_path):

        source = output.GetOutputFiles(self)[index]
        dest = os.path.join(dest_path, os.path.basename(source))
        return BuildSystem.CopyNode(output, source, dest)
Esempio n. 4
0
    def CopyFile(self, source, dest_path):

        dest = os.path.join(dest_path, os.path.basename(source))
        output = self.NewFile(source)
        return BuildSystem.CopyNode(output, source, dest)
Esempio n. 5
0
    def OutputFile(self, env, node):

        return BuildSystem.OutputFileNode(env, node)
Esempio n. 6
0
    def NewFile(self, filename):

        # Always add to the file map
        crc = self.BuildMetadata.AddToFileMap(filename)
        return BuildSystem.FileNode(crc)
Esempio n. 7
0
        return True
  
  def make(self):
    os.chdir(self.buildDir())
    ret = self.runCommand(["make",self.cxt.make_target])
    if ret == 0:
        return True
    return False
  
  def install(self):
    os.chdir(self.buildDir())
    if self.cxt.sudo:
        ret = self.runCommand(["sudo","make","install"])
    else:
        ret = self.runCommand(["make","install"])
    if ret == 0:
        return True
    return False
  
  def clean(self):
    os.chdir(self.buildDir())
    ret = self.runCommand(["make","distclean"])
    if ret == 0:
        return True
    ret = self.runCommand(["make", "clean"])
    if ret == 0:
        return True
    return False

BuildSystem.register(AutotoolsSystem)
Esempio n. 8
0
 def clean(self):
   realBuilder = BuildSystem.factory(self.buildContext)
   return realBuilder.clean()
Esempio n. 9
0
 def install(self):
   realBuilder = BuildSystem.factory(self.buildContext)
   realBuilder.addCallback('stdout',self.makeProgress)
   return realBuilder.install()
Esempio n. 10
0
    
  def configure(self):
    if not os.path.exists(self.buildDir()):
      os.mkdir(self.buildDir())
    os.chdir(self.buildDir())
    ret = self.runCommand(["cmake","-DCMAKE_INSTALL_PREFIX=%s"%(self.installPath())]+self.cxt.cmake_defines+[self.srcDir(),])
    if ret == 0:
      return True
  
  def make(self):
    realBuilder = BuildSystem.factory(self.buildContext)
    realBuilder.addCallback('stdout',self.makeProgress)
    return realBuilder.make()
  
  def makeProgress(self, line):
    progress = re.search('^\[([ 0-9]{3})%\]', line)
    if progress != None:
        self.logging.info("Progress: %s%%",progress.group(1).strip())
        self.doCallback("progress", progress.group(1).strip())
  
  def install(self):
    realBuilder = BuildSystem.factory(self.buildContext)
    realBuilder.addCallback('stdout',self.makeProgress)
    return realBuilder.install()
    
  def clean(self):
    realBuilder = BuildSystem.factory(self.buildContext)
    return realBuilder.clean()

BuildSystem.register(CMakeSystem)