1// Copyright 2018 The Bazel Authors. All rights reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// print_jdeps is a command line tool to print a jdeps proto. 16package main 17 18import ( 19 "flag" 20 "fmt" 21 "io/ioutil" 22 "log" 23 24 dpb "src/tools/jdeps/proto/deps_go_proto" 25 "google.golang.org/protobuf/proto" 26) 27 28var ( 29 in = flag.String("in", "", "Path to input jdeps file") 30) 31 32func main() { 33 flag.Parse() 34 if *in == "" { 35 log.Fatal("Missing required flags... Must specify --in") 36 } 37 38 bytes, err := ioutil.ReadFile(*in) 39 if err != nil { 40 log.Fatalf("Error reading jdeps: %v", err) 41 } 42 jdeps := &dpb.Dependencies{} 43 if err = proto.Unmarshal(bytes, jdeps); err != nil { 44 log.Fatalf("Error parsing jdeps: %v", err) 45 } 46 47 for _, dep := range jdeps.Dependency { 48 fmt.Println(dep.GetPath()) 49 } 50} 51