Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file contains genCmd which parses a set of .mojom files and runs the | 5 // This file contains genCmd which parses a set of .mojom files and runs the |
| 6 // code generators in order to emit generated bindings for the provided files. | 6 // code generators in order to emit generated bindings for the provided files. |
| 7 // | 7 // |
| 8 // The gen command is invoked as follows: | 8 // The gen command is invoked as follows: |
| 9 // | 9 // |
| 10 // mojom gen [-I <include_dirs>] | 10 // mojom gen [-I <include_dirs>] |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 "[--src-root-path <path_to_src_root>] "+ | 90 "[--src-root-path <path_to_src_root>] "+ |
| 91 "[--generators <generator_list>] "+ | 91 "[--generators <generator_list>] "+ |
| 92 "[--no-gen-imports] "+ | 92 "[--no-gen-imports] "+ |
| 93 "<mojom_file>\n\n", filepath.Base(args[0])) | 93 "<mojom_file>\n\n", filepath.Base(args[0])) |
| 94 fmt.Fprintf(os.Stderr, UsageString(flagSet)) | 94 fmt.Fprintf(os.Stderr, UsageString(flagSet)) |
| 95 fmt.Fprintf(os.Stderr, "Arguments with the --gen-arg- prefix wil l be passed "+ | 95 fmt.Fprintf(os.Stderr, "Arguments with the --gen-arg- prefix wil l be passed "+ |
| 96 "to every generator. So for instance, to pass --arg=valu e, you would "+ | 96 "to every generator. So for instance, to pass --arg=valu e, you would "+ |
| 97 "use --gen-arg-arg=value. To pass --arg, you would use - -gen-arg-arg.\n") | 97 "use --gen-arg-arg=value. To pass --arg, you would use - -gen-arg-arg.\n") |
| 98 } | 98 } |
| 99 | 99 |
| 100 » if err := flagSet.Parse(args[2:]); err != nil { | 100 » // If err is not ErrHelp, the only way to figure out what it was is to l ook at |
| 101 » // the message provided for users. | |
|
vardhan
2016/04/15 22:53:35
that's unfortunate
| |
| 102 » if err := flagSet.Parse(args[2:]); err != nil && !strings.HasPrefix(err. Error(), "flag provided but not defined") { | |
| 101 if err != flag.ErrHelp { | 103 if err != flag.ErrHelp { |
| 102 fmt.Fprintln(os.Stderr, err.Error()) | 104 fmt.Fprintln(os.Stderr, err.Error()) |
| 103 } | 105 } |
| 104 printUsage() | 106 printUsage() |
| 105 os.Exit(1) | 107 os.Exit(1) |
| 106 } | 108 } |
| 107 generatorPaths := findGeneratorPaths(mojomGenPaths(), generatorNames) | 109 generatorPaths := findGeneratorPaths(mojomGenPaths(), generatorNames) |
| 108 | 110 |
| 109 var fileNames []string | 111 var fileNames []string |
| 110 var extraArgs []string | 112 var extraArgs []string |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 // is found, the empty string is returned. | 232 // is found, the empty string is returned. |
| 231 func findGeneratorPath(paths []string, generatorName string) string { | 233 func findGeneratorPath(paths []string, generatorName string) string { |
| 232 for _, path := range paths { | 234 for _, path := range paths { |
| 233 genPath := filepath.Join(path, generatorName) | 235 genPath := filepath.Join(path, generatorName) |
| 234 if fileInfo, err := os.Stat(genPath); err == nil && !fileInfo.Is Dir() { | 236 if fileInfo, err := os.Stat(genPath); err == nil && !fileInfo.Is Dir() { |
| 235 return genPath | 237 return genPath |
| 236 } | 238 } |
| 237 } | 239 } |
| 238 return "" | 240 return "" |
| 239 } | 241 } |
| OLD | NEW |