Ejemplo n.º 1
0
 def generate(self, projectName, targetPath):
   tempPath = tempfile.mkdtemp()
   try:
     # Create a build
     build = self.project.platform.createBuild(self.config, self.library, projectName, self.name)
     
     # If there is at least one C++ function, generate only C++ code
     if "c++" in self.getLanguages() or self.config.get("language", "c") == "c++":
       playerSourceName       = "player_gen.cpp"
     else:
       playerSourceName       = "player_gen.c"
       self.library.language  = "c"
     
     # Generate the player
     playerSourcePath = os.path.join(tempPath, playerSourceName)
     g = Generator.CSourcePlayerGenerator(self.config, self.project.platform, [self.library],
                                          templatePath = Resource.getPath("templates"))
     output = open(playerSourcePath, "w")
     g.generate(outputFile = output)
     output.close()
 
     # Add the generated source file to the configuration
     self.addSourceFile(playerSourcePath)
     
     # Finalize the build
     build.compile(targetPath = targetPath)
   finally:
     try:
       shutil.rmtree(tempPath)
     except:
       Log.warn("Unable to clean up temporary directory '%s'" % tempPath)
Ejemplo n.º 2
0
 def __init__(self, analyzer):
     self.analyzer = analyzer
     self.library = self.analyzer.project.targets["code"].library
     apiName = analyzer.project.config.name
     self.binary = os.path.join(Resource.getPath("bin"),
                                apiName + "-unix-player")
     self.args = []
Ejemplo n.º 3
0
    def __init__(self, project, name, template=None, configName=None):
        """
    Constructor.
    
    @param       project   Project instance which this target is a part of.
    @param       name      Name of this target.
    @param       template  An optional target name to copy the configuration
                           and library from. If not given, the global project
                           configuration and library is used.
    @param     configName  Target configuration file name in the targets directory.
                           A value of None defaults to the target name
    """
        self.project = project

        if template:
            assert template in project.targets
            self.config = project.targets[template].config
            self.library = project.targets[template].library
        else:
            self.config = project.config
            self.library = project.library

        # Create local copies of things we're going to modify
        self.config = copy.deepcopy(self.config)
        self.library = copy.deepcopy(self.library)
        self.name = name

        # Read the target-specific configuration
        if configName is None:
            configName = self.name

        conf = Resource.getPath("targets",
                                "%s.conf" % configName,
                                required=False)
        if conf:
            self.config.loadFile(conf)

        if self.project.platform.name in self.config:
            # First merge the target config into the platform config
            if self.name in self.config[self.project.platform.name]:
                self.config[self.project.platform.name].merge(
                    self.config[self.project.platform.name][self.name])

            # Then merge the platform config to the global config
            self.config.merge(self.config[self.project.platform.name])

            # Remove the platform specific section since we won't need it anymore
            del self.config[self.project.platform.name]

        if self.name in self.config:
            # Finally merge the target config to the global config
            self.config.merge(self.config[self.name])

            # Remove the target specific section since we won't need it anymore
            del self.config[self.name]
Ejemplo n.º 4
0
  def __init__(self, config, name):
    self.name            = name
    self.requireOrdinals = False
    self.exportLinkage   = None
    self.entryLinkage    = None
    self.language        = None

    # Read the platform-specific configuration
    conf = Resource.getPath("platforms", "%s.conf" % self.name, required = False)
    if conf:
      config.loadFile(conf)
Ejemplo n.º 5
0
  def __init__(self, project, name, template = None, configName = None):
    """
    Constructor.
    
    @param       project   Project instance which this target is a part of.
    @param       name      Name of this target.
    @param       template  An optional target name to copy the configuration
                           and library from. If not given, the global project
                           configuration and library is used.
    @param     configName  Target configuration file name in the targets directory.
                           A value of None defaults to the target name
    """
    self.project = project
    
    if template:
      assert template in project.targets
      self.config  = project.targets[template].config
      self.library = project.targets[template].library
    else:
      self.config  = project.config
      self.library = project.library
      
    # Create local copies of things we're going to modify
    self.config   = copy.deepcopy(self.config)
    self.library  = copy.deepcopy(self.library)
    self.name     = name
    
    # Read the target-specific configuration
    if configName is None:
      configName = self.name
    
    conf = Resource.getPath("targets", "%s.conf" % configName, required = False)
    if conf:
      self.config.loadFile(conf)

    if self.project.platform.name in self.config:
      # First merge the target config into the platform config
      if self.name in self.config[self.project.platform.name]:
        self.config[self.project.platform.name].merge(self.config[self.project.platform.name][self.name])

      # Then merge the platform config to the global config
      self.config.merge(self.config[self.project.platform.name])

      # Remove the platform specific section since we won't need it anymore
      del self.config[self.project.platform.name]

    if self.name in self.config:
      # Finally merge the target config to the global config
      self.config.merge(self.config[self.name])

      # Remove the target specific section since we won't need it anymore
      del self.config[self.name]
Ejemplo n.º 6
0
  def generate(self, projectName, targetPath):
    # If there is at least one C++ function, generate only C++ code
    if "c++" in self.getLanguages() or self.config.get("language", "c") == "c++":
      playerSourceName       = "%s.cpp" % projectName
    else:
      playerSourceName       = "%s.c" % projectName
      self.library.language  = "c"

    Tools.makePath(targetPath)
    
    # Generate the player
    playerSourcePath = os.path.join(targetPath, playerSourceName)
    g = Generator.PlayerGenerator(self.config, self.project.platform, [self.library],
                                  templatePath = Resource.getPath("templates"))
    output = open(playerSourcePath, "w")
    g.generate(outputFile = output)
    output.close()
Ejemplo n.º 7
0
    def generate(self, projectName, targetPath):
        # If there is at least one C++ function, generate only C++ code
        if "c++" in self.getLanguages() or self.config.get("language",
                                                           "c") == "c++":
            playerSourceName = "%s.cpp" % projectName
        else:
            playerSourceName = "%s.c" % projectName
            self.library.language = "c"

        Tools.makePath(targetPath)

        # Generate the player
        playerSourcePath = os.path.join(targetPath, playerSourceName)
        g = Generator.PlayerGenerator(
            self.config,
            self.project.platform, [self.library],
            templatePath=Resource.getPath("templates"))
        output = open(playerSourcePath, "w")
        g.generate(outputFile=output)
        output.close()
Ejemplo n.º 8
0
def getAvailablePluginModules(pluginPath = None):
  """
  Determine the available plugin modules on the system.
  
  @returns a list of found plugins
  """
  if pluginPath is None:
    pluginPath = Resource.getPath("plugins", required = True)
    
  if pluginPath is None:
    return []
    
  if not pluginPath in sys.path:
    sys.path.append(pluginPath)
    
  plugins = []
  for name in os.listdir(pluginPath):
    try:
      if os.path.isfile(os.path.join(pluginPath, name, "__init__.py")):
        plugins.append(__import__(name))
    except ImportError, e:
      Log.error("Unable to load plugin %s: %s" % (name, e))
Ejemplo n.º 9
0
def getAvailablePluginModules(pluginPath=None):
    """
  Determine the available plugin modules on the system.
  
  @returns a list of found plugins
  """
    if pluginPath is None:
        pluginPath = Resource.getPath("plugins", required=True)

    if pluginPath is None:
        return []

    if not pluginPath in sys.path:
        sys.path.append(pluginPath)

    plugins = []
    for name in os.listdir(pluginPath):
        try:
            if os.path.isfile(os.path.join(pluginPath, name, "__init__.py")):
                plugins.append(__import__(name))
        except ImportError, e:
            Log.error("Unable to load plugin %s: %s" % (name, e))
Ejemplo n.º 10
0
    def generate(self, projectName, targetPath):
        tempPath = tempfile.mkdtemp()
        try:
            # Create a build
            build = self.project.platform.createBuild(self.config,
                                                      self.library,
                                                      projectName, self.name)

            # If there is at least one C++ function, generate only C++ code
            if "c++" in self.getLanguages() or self.config.get(
                    "language", "c") == "c++":
                playerSourceName = "player_gen.cpp"
            else:
                playerSourceName = "player_gen.c"
                self.library.language = "c"

            # Generate the player
            playerSourcePath = os.path.join(tempPath, playerSourceName)
            g = Generator.CSourcePlayerGenerator(
                self.config,
                self.project.platform, [self.library],
                templatePath=Resource.getPath("templates"))
            output = open(playerSourcePath, "w")
            g.generate(outputFile=output)
            output.close()

            # Add the generated source file to the configuration
            self.addSourceFile(playerSourcePath)

            # Finalize the build
            build.compile(targetPath=targetPath)
        finally:
            try:
                shutil.rmtree(tempPath)
            except:
                Log.warn("Unable to clean up temporary directory '%s'" %
                         tempPath)
Ejemplo n.º 11
0
def getAvailableProjectFiles():
  projectFiles = sorted(glob.glob(os.path.join(Resource.getPath("lib/tracy"), "*.tcy")))
  projectNames = [os.path.basename(p) for p in projectFiles]
  projectNames = [p.split(".")[0] for p in projectNames]
  return zip(projectFiles, projectNames)
Ejemplo n.º 12
0
def getAvailableProjectFiles():
    projectFiles = sorted(
        glob.glob(os.path.join(Resource.getPath("lib/tracy"), "*.tcy")))
    projectNames = [os.path.basename(p) for p in projectFiles]
    projectNames = [p.split(".")[0] for p in projectNames]
    return zip(projectFiles, projectNames)
Ejemplo n.º 13
0
 def generate(templatePath, outputPath):
   Generator.generate(templates = [Resource.getPath(*templatePath)],
                      namespace = namespace,
                      outputFile = open(os.path.join(*outputPath), "w"))
Ejemplo n.º 14
0
 def generate(templatePath, outputPath):
   Log.debug("Generating %s" % (outputPath[-1]))
   Generator.generate(templates = [Resource.getPath(*templatePath)],
                      namespace = namespace,
                      outputFile = open(os.path.join(*outputPath), "w"))
Ejemplo n.º 15
0
 def __init__(self, analyzer):
     self.analyzer = analyzer
     self.library = self.analyzer.project.targets["code"].library
     apiName = analyzer.project.config.name
     self.binary = os.path.join(Resource.getPath("bin"), apiName + "-win32-player.exe")