aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-25 21:00:02 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-25 21:00:02 +0000
commitffc224f802d0ce6d8606c4cfe59bc0238a3d2a5b (patch)
treed0e3f66d3178e60504cc9307bbbf2c0c4644e9b8 /tools
parentafb26eef1364826087a1b3f1f93f3cd2e6177bd4 (diff)
Add a minimal --undefok to SkCommandLineFlags.
Similar in spirit to gflags' undefok, I'd like to be able to ignore specific unknown flags. This lets me run the same command line on, say, a branch that's got a new flag and on a clean branch tracking origin/master. This is handy for performance comparison, etc. It's not essential, and if you hate this I can find another way. As an example, I want to compare the runtime of SKP recording with my new code. I've added a flag --skr to bench_record to help this. So I want to compare origin/master: out/Release/bench_record my patch: out/Release/bench_record --skr This lets me run both as out/Release/bench_record --undefok skr --skr, which is handy for scripts and things. BUG=skia: R=scroggo@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/209393015 git-svn-id: http://skia.googlecode.com/svn/trunk@13945 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools')
-rw-r--r--tools/flags/SkCommandLineFlags.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp
index 656a00a76d..9b31b657e5 100644
--- a/tools/flags/SkCommandLineFlags.cpp
+++ b/tools/flags/SkCommandLineFlags.cpp
@@ -8,6 +8,8 @@
#include "SkCommandLineFlags.h"
#include "SkTDArray.h"
+DEFINE_string(undefok, "", "Silently ignore unknown flags listed here instead of crashing.");
+
bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName,
SkCommandLineFlags::StringArray* pStrings,
const char* defaultValue, const char* helpString) {
@@ -285,8 +287,14 @@ void SkCommandLineFlags::Parse(int argc, char** argv) {
flag = flag->next();
}
if (!flagMatched) {
- SkDebugf("Got unknown flag \"%s\". Exiting.\n", argv[i]);
- exit(-1);
+ SkString stripped(argv[i]);
+ while (stripped.startsWith('-')) {
+ stripped.remove(0, 1);
+ }
+ if (!FLAGS_undefok.contains(stripped.c_str())) {
+ SkDebugf("Got unknown flag \"%s\". Exiting.\n", argv[i]);
+ exit(-1);
+ }
}
}
}