<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_build_flags(cls, build_flags_from_option, is_flagged, target):
 """Merge build flags with global < target < command-line order Build flags can be defined as globals (in `pants.ini`), as arguments to a Target, and via the command-line. """

    # If self.get_options().build_flags returns a quoted string, remove the outer quotes,
    # which happens for flags passed from the command-line.
    if (build_flags_from_option.startswith('\'') and build_flags_from_option.endswith('\'')) or \
        (build_flags_from_option.startswith('"') and build_flags_from_option.endswith('"')):
      bfo = build_flags_from_option[1:-1]
    else:
      bfo = build_flags_from_option
    global_build_flags, ephemeral_build_flags = ('', bfo) if is_flagged else (bfo, '')
    target_build_flags = target.build_flags if getattr(target, 'build_flags', None) else ''
    joined_build_flags = ' '.join([global_build_flags, target_build_flags, ephemeral_build_flags])
    return cls._split_build_flags(joined_build_flags)