[Registry Parser] Support -dep_file with -config_file.
CB-289 #comment
Previously we only supported generating a GN depfile when the registry
parser was given a directory of registry files, but we also need to
support generating a depfile in the case that the registry parser is
given only a single registry file.
Change-Id: I04527a402c723518040185ae4517e342aa0f9e75
diff --git a/config/config_parser/src/config_parser_main.go b/config/config_parser/src/config_parser_main.go
index 901fd7e..fbdca44 100644
--- a/config/config_parser/src/config_parser_main.go
+++ b/config/config_parser/src/config_parser_main.go
@@ -114,8 +114,8 @@
glog.Exit("'output_file' does not make sense if 'check_only' is set.")
}
- if *depFile != "" && *configDir == "" {
- glog.Exit("-dep_file requires -config_dir")
+ if *depFile != "" && (*configDir == "" && *configFile == "") {
+ glog.Exit("-dep_file requires -config_dir or -config_file")
}
if *depFile != "" && (*outFile == "" && *outFilename == "") {
@@ -146,12 +146,17 @@
outFormats := strings.FieldsFunc(*outFormat, func(c rune) bool { return c == ' ' })
if *depFile != "" {
- files, err := config_parser.GetConfigFilesListFromConfigDir(configLocation)
- if err != nil {
- glog.Exit(err)
+ var configFiles []string
+ if *configFile != "" {
+ configFiles = append(configFiles, *configFile)
+ } else if *configDir != "" {
+ var err error
+ configFiles, err = config_parser.GetConfigFilesListFromConfigDir(*configDir)
+ if err != nil {
+ glog.Exit(err)
+ }
}
-
- if err := writeDepFile(outFormats, files, *depFile); err != nil {
+ if err := writeDepFile(outFormats, configFiles, *depFile); err != nil {
glog.Exit(err)
}
}