def gold_build_config(args):
  """ Extracts key value pairs from the arguments handed to 'gn gen'
      and returns them as a dictionary. Since these are used as
      parameters in Gold we strip common prefixes and disregard
      some arguments. i.e. 'use_goma' since we don't care about how
      a binary was built.  Only arguments that follow the
      'key=value' pattern are considered.
  """
  black_list = ["use_goma", "goma_dir", "use_sysroot", "is_component_build"]
  strip_prefixes = ["is_", "pdf_enable_", "pdf_use_", "pdf_"]
  build_config = {}
  for arg in args:
    # Catch multiple k/v pairs separated by spaces.
    parts = arg.split()
    for p in parts:
      kv = [x.strip() for x in p.split("=")]
      if len(kv) == 2:
        k,v = kv
        if k not in black_list:
          for prefix in strip_prefixes:
            if k.startswith(prefix):
              k = k[len(prefix):]
              break
          build_config[k] = v
  return build_config