예제 #1
0
    def __init__(self,
                 name,
                 sources,
                 dependencies,
                 excludes=None,
                 buildflags=None,
                 is_meta=False,
                 configurations=None):
        InternalTarget.__init__(self, name, dependencies, is_meta)
        TargetWithSources.__init__(self, name, is_meta)

        self.declared_dependencies = set(dependencies or [])
        self.add_label('jvm')
        self.sources = self._resolve_paths(self.target_base, sources) or []
        for source in self.sources:
            rel_path = os.path.join(self.target_base, source)
            TargetWithSources.register_source(rel_path, self)
        self.excludes = excludes or []
        self.buildflags = buildflags or []

        custom_antxml = '%s.xml' % self.name
        buildfile = self.address.buildfile.full_path
        custom_antxml_path = os.path.join(os.path.dirname(buildfile),
                                          custom_antxml)
        self.custom_antxml_path = custom_antxml_path if os.path.exists(
            custom_antxml_path) else None

        self.configurations = configurations
예제 #2
0
    def __init__(self, name, sources=None, resources=None):
        TargetWithSources.__init__(self, name, sources=sources)

        if resources is not None:

            def is_resources(item):
                return (isinstance(item, Target) and all(
                    map(lambda tgt: isinstance(tgt, Resources),
                        filter(lambda tgt: is_concrete(tgt), item.resolve()))))

            if is_resources(resources):
                self.resources = list(self.resolve_all(resources, Resources))
            elif isinstance(resources, Sequence) and all(
                    map(is_resources, resources)):
                self.resources = list(self.resolve_all(resources, Resources))
            else:
                # Handle parallel resource dir globs.
                # For example, for a java_library target base of src/main/java:
                #   src/main/java/com/twitter/base/BUILD
                # We get:
                #   sibling_resources_base = src/main/resources
                #   base_relpath = com/twitter/base
                #   resources_dir = src/main/resources/com/twitter/base
                #
                # TODO(John Sirois): migrate projects to Resources and remove support for old style assumed
                # parallel resources dirs
                sibling_resources_base = os.path.join(
                    os.path.dirname(self.target_base), 'resources')
                base_relpath = os.path.relpath(self.address.buildfile.relpath,
                                               self.target_base)
                resources_dir = os.path.join(sibling_resources_base,
                                             base_relpath)
                with ParseContext.temp(basedir=resources_dir):
                    self.resources = [Resources(name, resources)]
예제 #3
0
파일: doc.py 프로젝트: adamsxu/commons
  def __init__(self, name, source, dependencies=None, resources=None):
    InternalTarget.__init__(self, name, dependencies, is_meta=False)
    TargetWithSources.__init__(self, name)

    self.source = self._resolve_paths(self.target_base, [source]).pop()
    self.resources = self._resolve_paths(self.target_base, resources) if resources else []
    self._wikis = {}
예제 #4
0
파일: resources.py 프로젝트: alfss/commons
  def __init__(self, name, sources=None, resources=None, exclusives=None):
    TargetWithSources.__init__(self, name, sources=sources, exclusives=exclusives)

    if resources is not None:
      def is_resources(item):
        if not isinstance(item, Target):
          return False
        concrete_targets = [t for t in item.resolve() if t.is_concrete]
        return all(isinstance(t, Resources) for t in concrete_targets)

      if is_resources(resources):
        self.resources = list(self.resolve_all(resources, Resources))
      elif isinstance(resources, Sequence) and all(map(is_resources, resources)):
        self.resources = list(self.resolve_all(resources, Resources))
      else:
        # Handle parallel resource dir globs.
        # For example, for a java_library target base of src/main/java:
        #   src/main/java/com/twitter/base/BUILD
        # We get:
        #   sibling_resources_base = src/main/resources
        #   base_relpath = com/twitter/base
        #   resources_dir = src/main/resources/com/twitter/base
        #
        # TODO(John Sirois): migrate projects to Resources and remove support for old style assumed
        # parallel resources dirs
        sibling_resources_base = os.path.join(os.path.dirname(self.target_base), 'resources')
        base_relpath = os.path.relpath(self.address.buildfile.relpath, self.target_base)
        resources_dir = os.path.join(sibling_resources_base, base_relpath)
        with ParseContext.temp(basedir=resources_dir):
          self.resources = [Resources(name, resources)]
예제 #5
0
  def __init__(self, name, sources, resources=None, dependencies=None):
    TargetWithSources.__init__(self, name)

    self.add_label('python')
    self.sources = self._resolve_paths(self.target_base, sources)
    self.resources = self._resolve_paths(self.target_base, resources) if resources else OrderedSet()
    self.dependencies = OrderedSet(dependencies) if dependencies else OrderedSet()
예제 #6
0
파일: doc.py 프로젝트: avadh/commons
 def __init__(self, name, dependencies=(), sources=None, resources=None):
   InternalTarget.__init__(self, name, dependencies, None)
   TargetWithSources.__init__(self, name)
   if not sources:
     raise TargetDefinitionException(self, 'No sources specified')
   self.name = name
   self.sources = self._resolve_paths(self.target_base, sources)
   self.resources = self._resolve_paths(self.target_base, resources) if resources else []
예제 #7
0
    def __init__(self, name, sources, resources=None, dependencies=None):
        TargetWithSources.__init__(self, name)

        self.sources = self._resolve_paths(self.target_base, sources)
        self.resources = self._resolve_paths(
            self.target_base, resources) if resources else OrderedSet()
        self.dependencies = OrderedSet(
            dependencies) if dependencies else OrderedSet()
예제 #8
0
 def __init__(self, name, dependencies=(), sources=None, resources=None):
     InternalTarget.__init__(self, name, dependencies, None)
     TargetWithSources.__init__(self, name)
     if not sources:
         raise TargetDefinitionException(self, 'No sources specified')
     self.name = name
     self.sources = self._resolve_paths(self.target_base, sources)
     self.resources = self._resolve_paths(self.target_base,
                                          resources) if resources else []
예제 #9
0
 def __init__(self, name, dependencies=None, num_sources=0, exclusives=None):
   with ParseContext.temp():
     InternalTarget.__init__(self, name, dependencies, exclusives=exclusives)
     TargetWithSources.__init__(self, name, exclusives=exclusives)
   self.num_sources = num_sources
   self.declared_exclusives = defaultdict(set)
   if exclusives is not None:
     for k in exclusives:
       self.declared_exclusives[k] = set([exclusives[k]])
   self.exclusives = None
예제 #10
0
    def __init__(self, name, source, dependencies=None, resources=None):
        InternalTarget.__init__(self, name, dependencies, is_meta=False)
        TargetWithSources.__init__(self, name)

        self.sources = self._resolve_paths(self.target_base, [source])
        self._source = self.sources.pop()

        self.resources = self._resolve_paths(self.target_base,
                                             resources) if resources else []
        self._wikis = {}
예제 #11
0
    def __init__(self, name, sources, resources=None, dependencies=None):
        TargetWithSources.__init__(self, name)

        processed_dependencies = resolve(dependencies)

        self.add_label('python')
        self.sources = self._resolve_paths(self.target_base, sources)
        self.resources = self._resolve_paths(
            self.target_base, resources) if resources else OrderedSet()
        self.dependencies = OrderedSet(
            processed_dependencies) if processed_dependencies else OrderedSet(
            )
예제 #12
0
  def __init__(self, name, sources, dependencies, excludes=None, buildflags=None, is_meta=False):
    InternalTarget.__init__(self, name, dependencies, is_meta)
    TargetWithSources.__init__(self, name, is_meta)

    self.sources = self._resolve_paths(self.target_base, sources) or []
    self.excludes = excludes or []
    self.buildflags = buildflags or []

    custom_antxml = '%s.xml' % self.name
    buildfile = self.address.buildfile.full_path
    custom_antxml_path = os.path.join(os.path.dirname(buildfile), custom_antxml)
    self.custom_antxml_path = custom_antxml_path if os.path.exists(custom_antxml_path) else None