Пример #1
0
def _current_source_location():
    """Return source location in current BUILD file"""
    from blade import build_manager  # pylint: disable=import-outside-toplevel
    source_dir = Path(build_manager.instance.get_current_source_path())
    return source_location(os.path.join(str(source_dir), 'BUILD'))
Пример #2
0
 def fatal(self, msg):
     # NOTE: VSCode's problem matcher doesn't recognize 'fatal', use 'error' instead
     console.fatal('%s: error: %s' %
                   (source_location(self.current_file_name), msg),
                   prefix=False)
Пример #3
0
 def error(self, msg):
     console.error('%s: error: %s' %
                   (source_location(self.current_file_name), msg),
                   prefix=False)
Пример #4
0
 def warning(self, msg):
     console.warning('%s: warning: %s' %
                     (source_location(self.current_file_name), msg),
                     prefix=False)
Пример #5
0
 def info(self, msg):
     console.info('%s: info: %s' %
                  (source_location(self.current_file_name), msg),
                  prefix=False)
Пример #6
0
    def __init__(self, name, type, srcs, src_exts, deps, visibility, tags,
                 kwargs):
        """Init method.

        Init the target.

        """
        from blade import build_manager  # pylint: disable=import-outside-toplevel
        self.blade = build_manager.instance
        self.target_database = self.blade.get_target_database()

        self.type = type
        self.name = name

        current_source_path = self.blade.get_current_source_path()
        self.path = current_source_path
        self.build_dir = self.blade.get_build_dir()
        self.target_dir = os.path.normpath(
            os.path.join(self.build_dir, current_source_path))

        # The unique key of this target, for internal use mainly.
        self.key = '%s:%s' % (current_source_path, name)
        # The full qualified target id, to be displayed in diagnostic message
        self.fullname = '//' + self.key
        self.source_location = source_location(
            os.path.join(current_source_path, 'BUILD'))
        self.srcs = srcs
        self.deps = []

        # Expanded dependencies, includes direct and indirect dependies.
        self.expanded_deps = [
        ]  # Provide type info then make lints happy(not-an-iterable).
        self.expanded_deps = None  # Set to None to indicate not constructed.

        self.dependents = set()  # Target keys which depends on this
        self.expanded_dependents = set(
        )  # Expanded target keys which depends on this
        self._implicit_deps = set()
        self._visibility = set()
        self._visibility_is_default = True

        if not name:
            self.fatal('Missing "name"')

        # Keep track of target filess generated by this target. Note that one target rule
        # may correspond to several target files, such as:
        # proto_library: static lib/shared lib/jar variables
        self.__targets = {}
        self.__default_target = ''
        self.__clean_list = []  # Paths to be cleaned

        # Target releated attributes, they should be set only before generating build rules.
        self.attr = {}

        # For temporary, mutable fields only, their values should not relate to fingerprint
        self.data = {}

        self.tags = set()

        # TODO: Remove it, make a `TestTargetMixin`
        self.attr['test_timeout'] = config.get_item('global_config',
                                                    'test_timeout')

        self._check_name()
        self._check_kwargs(kwargs)
        self._check_srcs(src_exts)
        self._init_target_deps(deps)
        self._init_visibility(visibility)
        self._add_tags(*tags)
        self.__build_code = None
        self.__fingerprint = None  # Cached fingerprint