Exemple #1
0
def make_aquery_output(actions, artifact_paths):
  action_graph = analysis_pb2.ActionGraphContainer()
  for artifact_path in artifact_paths:
    next_id = len(action_graph.artifacts)
    artifact = action_graph.artifacts.add()
    artifact.id = str(next_id)
    artifact.exec_path = artifact_path
  for next_action in actions:
    action = action_graph.actions.add()
    action.output_ids.extend(next_action["output_ids"])
    action.arguments.extend(next_action["arguments"])
  return action_graph
def main(unused_argv):
  before_file = to_absolute_path(flags.FLAGS.before)
  after_file = to_absolute_path(flags.FLAGS.after)
  input_type = flags.FLAGS.input_type
  attrs = flags.FLAGS.attrs

  before_proto = analysis_pb2.ActionGraphContainer()
  after_proto = analysis_pb2.ActionGraphContainer()
  if input_type == "proto":
    with open(before_file, "rb") as f:
      before_proto.ParseFromString(f.read())
    with open(after_file, "rb") as f:
      after_proto.ParseFromString(f.read())
  else:
    with open(before_file, "r") as f:
      before_text = f.read()
      text_format.Merge(before_text, before_proto)
    with open(after_file, "r") as f:
      after_text = f.read()
      text_format.Merge(after_text, after_proto)

  _aquery_diff(before_proto, after_proto, attrs, before_file, after_file)