def _GetEnvAsDict(arch):
  """Gets the saved environment from a file for a given architecture."""
  # The environment is saved as an "environment block" (see CreateProcess()
  # for details, which is the format required for ninja). We convert to a dict
  # here. Drop last 2 NULs, one for list terminator, one for trailing vs.
  # separator.
  pairs = open(arch).read()[:-2].split('\0')
  kvs = [item.split('=', 1) for item in pairs]
  return dict(kvs)