Beispiel #1
0
def _createListItem(s, l, t):
    value, attrs = t[0]
    if type(value) == dict:
        g = Config.Group(attrs)
        g.update(value)
        return g
    elif type(value) == list:
        l = Config.List(attrs)
        l += value
        return [l]
    else:
        return Config.Item(value, attrs)
Beispiel #2
0
def _createGroupItem(s, l, t):
    try:
        name, attrs, value = t[0]
    except ValueError:
        # An empty list is eaten by pyparsing
        name, attrs, value = t[0][0], t[0][1], []
    if type(value) == dict:
        g = Config.Group(attrs)
        g.update(value)
        return name, g
    elif type(value) == list:
        l = Config.List(attrs)
        l += value
        return name, l
    else:
        return name, Config.Item(value, attrs)
Beispiel #3
0
  def compile(self, targetPath):
    # Collect the source and header files
    sources = []
    for item in self.config.get("sources", []):
      sources.append(self.collectItem(os.path.join(targetPath, "src"), item))

    headers = []
    for item in self.config.get("headers", []):
      if not isinstance(item, Config.Group):
        headers.append(self.collectItem(os.path.join(targetPath, "inc"), item))

    resources = []
    for item in self.config.get("resources", []):
      if not isinstance(item, Config.Group):
        resources.append(self.collectItem(os.path.join(targetPath, "resource"), item))

    # Copy the def files over
    #deffiles = {}
    #for key, item in self.config.get("deffiles", {}).items():
    #  if key == "WINSCW":
    #    arch = "bwins"
    #  elif key == "MARM":
    #    arch = "eabi"
    #  elif key == "GCCE":
    #    arch = "bmarm"
    #  else:
    #    raise RuntimeError("Unknown DEF file architecture: %s" % key)
    #  self.collectItem(os.path.join(targetPath, arch), item)
    #  name = os.path.basename(item)
    #  # Yeah, search me.
    #  name = name.replace("u.def", ".def")
    #  deffiles[key] = name

    #Log.notice("%d source files and %d header files collected." % (len(sources), len(headers)))

    # Prepare the code generator and its namespace
    namespace = {
      "targetName":  self.targetName,
      "projectName": self.name,
      "config":      self.config,
      "library":     self.library,
      "sources":     sources,
      "headers":     headers,
    }
    
    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"))
  
    
    # Create the project dirs
    projectPath = os.path.join(targetPath, "group")
    headerPath  = os.path.join(targetPath, "inc")
    Tools.makePath(projectPath)
    Tools.makePath(headerPath)

    # Create the configuration header file
    generate(["templates", "project", "symbian", "tracer_config_symbian.h.tmpl"],
             [headerPath, "tracer_config_symbian.h"])

    # EXE specific files
    if self.config.targettype.lower() == "exe":
      if not "resources" in self.config:
        self.config["resources"] = Config.List()
        
      # Add in the custom resources
      self.config.resources.append(Config.Item(self.name + ".rss"))
      self.config.resources.append(Config.Item(self.name + "_reg.rss", attrs = {"type": "reg"}))
        
      # Create the resource dir
      resourcePath = os.path.join(targetPath, "resource")
      Tools.makePath(resourcePath)
      
      # Create the resource file
      generate(["templates", "project", "symbian", "resource.rss.tmpl"],
               [resourcePath, self.name + ".rss"])
               
      # Create the registration resource file
      generate(["templates", "project", "symbian", "registration.rss.tmpl"],
               [resourcePath, self.name + "_reg.rss"])

      # Create the package file
      generate(["templates", "project", "symbian", "package.pkg.tmpl"],
               [projectPath, self.name + ".pkg"])
               
      # Create the backup registration file
      generate(["templates", "project", "symbian", "backup_registration.xml.tmpl"],
               [projectPath, "backup_registration.xml"])
    else:
      # Create the DEF files
      for arch in ["bwins", "eabi"]:
        defPath = os.path.join(targetPath, arch)
        Tools.makePath(defPath)
        generate(["templates", "project", "symbian", "project.def.tmpl"],
                 [defPath, self.name + "u.def"])

    # Create the bld.inf file
    generate(["templates", "project", "symbian", "bld.inf.tmpl"],
             [projectPath, "bld.inf"])

    # Create the MMP file
    generate(["templates", "project", "symbian", "project.mmp.tmpl"],
             [projectPath, self.name + ".mmp"])
Beispiel #4
0
 def addSourceFile(self, fileName):
     if not "sources" in self.config:
         self.config["sources"] = Config.List()
     self.config.sources.append(Config.Item(fileName))