Change the name of SkFlags to SkCommandLineFlags.

This name is more specific to what it actually does.

Also move the code into tools/flags, to (slightly) better organize
the massive tools folder.

Update the programs that use it to use the new names.

No functionality changes.

BUG=https://code.google.com/p/skia/issues/detail?id=1173

Review URL: https://codereview.chromium.org/12440067

git-svn-id: http://skia.googlecode.com/svn/trunk@8304 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
scroggo@google.com 2013-03-21 19:43:15 +00:00
parent cc9aad5787
commit d9ba9a05d6
10 changed files with 40 additions and 38 deletions

View File

@ -19,11 +19,11 @@
#include "SkBitmap.h"
#include "SkBitmapChecksummer.h"
#include "SkColorPriv.h"
#include "SkCommandLineFlags.h"
#include "SkData.h"
#include "SkDeferredCanvas.h"
#include "SkDevice.h"
#include "SkDrawFilter.h"
#include "SkFlags.h"
#include "SkGPipe.h"
#include "SkGraphics.h"
#include "SkImageDecoder.h"
@ -1405,8 +1405,8 @@ int tool_main(int argc, char** argv) {
SkString usage;
usage.printf("Run the golden master tests.\n");
SkFlags::SetUsage(usage.c_str());
SkFlags::ParseCommandLine(argc, argv);
SkCommandLineFlags::SetUsage(usage.c_str());
SkCommandLineFlags::Parse(argc, argv);
gmmain.fUseFileHierarchy = FLAGS_hierarchy;
if (FLAGS_mismatchPath.count() == 1) {

View File

@ -6,8 +6,8 @@
'target_name': 'flags',
'type': 'static_library',
'sources': [
'../tools/SkFlags.h',
'../tools/SkFlags.cpp',
'../tools/flags/SkCommandLineFlags.h',
'../tools/flags/SkCommandLineFlags.cpp',
],
'dependencies': [
'skia_base_libs.gyp:skia_base_libs',
@ -15,7 +15,7 @@
],
'direct_dependent_settings': {
'include_dirs': [
'../tools/',
'../tools/flags',
],
}
},

View File

@ -98,6 +98,7 @@
'tools.gyp:picture_renderer',
'tools.gyp:picture_utils',
'ports.gyp:ports',
'flags.gyp:flags',
],
},
{
@ -122,6 +123,7 @@
'tools.gyp:picture_renderer',
'bench.gyp:bench_timer',
'ports.gyp:ports',
'flags.gyp:flags',
],
},
{

View File

@ -12,8 +12,8 @@
#include "picture_utils.h"
#include "SkBitmapFactory.h"
#include "SkCommandLineFlags.h"
#include "SkData.h"
#include "SkFlags.h"
#include "SkImage.h"
#include "SkImageDecoder.h"
#include "SkLruImageCache.h"

View File

@ -20,8 +20,8 @@ enum PictureTool {
};
/**
* Uses SkFlags to parse the command line, and returns a PictureRenderer
* reflecting the flags used. Assumes that SkFlags::ParseCommandLine has
* Uses SkCommandLineFlags to parse the command line, and returns a PictureRenderer
* reflecting the flags used. Assumes that SkCommandLineFlags::Parse has
* been called.
* @param error If there is an error or warning, it will be stored in error.
* @param tool Which tool is being used.

View File

@ -10,7 +10,7 @@
#include "PictureBenchmark.h"
#include "PictureRenderingFlags.h"
#include "SkBenchLogger.h"
#include "SkFlags.h"
#include "SkCommandLineFlags.h"
#include "SkGraphics.h"
#include "SkImageDecoder.h"
#if LAZY_CACHE_STATS
@ -390,8 +390,8 @@ int tool_main(int argc, char** argv) {
usage.printf("Time drawing .skp files.\n"
"\tPossible arguments for --filter: [%s]\n\t\t[%s]",
filterTypesUsage().c_str(), filterFlagsUsage().c_str());
SkFlags::SetUsage(usage.c_str());
SkFlags::ParseCommandLine(argc, argv);
SkCommandLineFlags::SetUsage(usage.c_str());
SkCommandLineFlags::Parse(argc, argv);
if (FLAGS_repeat < 1) {
SkString error;

View File

@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
#include "SkFlags.h"
#include "SkCommandLineFlags.h"
static bool string_is_in(const char* target, const char* set[], size_t len) {
for (size_t i = 0; i < len; i++) {
@ -79,10 +79,10 @@ bool SkFlagInfo::match(const char* string) {
return false;
}
SkFlagInfo* SkFlags::gHead;
SkString SkFlags::gUsage;
SkFlagInfo* SkCommandLineFlags::gHead;
SkString SkCommandLineFlags::gUsage;
void SkFlags::SetUsage(const char* usage) {
void SkCommandLineFlags::SetUsage(const char* usage) {
gUsage.set(usage);
}
@ -139,11 +139,11 @@ static void print_help_for_flag(const SkFlagInfo* flag) {
SkDebugf("\n");
}
void SkFlags::ParseCommandLine(int argc, char** argv) {
void SkCommandLineFlags::Parse(int argc, char** argv) {
// Only allow calling this function once.
static bool gOnce;
if (gOnce) {
SkDebugf("ParseCommandLine should only be called once at the beginning"
SkDebugf("Parse should only be called once at the beginning"
" of main!\n");
SkASSERT(false);
return;
@ -168,7 +168,7 @@ void SkFlags::ParseCommandLine(int argc, char** argv) {
SkDebugf("%s\n%s\n", argv[0], gUsage.c_str());
}
SkDebugf("Flags:\n");
SkFlagInfo* flag = SkFlags::gHead;
SkFlagInfo* flag = SkCommandLineFlags::gHead;
while (flag != NULL) {
// If no flags followed --help, print them all
bool printFlag = 0 == helpFlags.count();

View File

@ -5,14 +5,14 @@
* found in the LICENSE file.
*/
#ifndef SK_FLAGS_H
#define SK_FLAGS_H
#ifndef SK_COMMAND_LINE_FLAGS_H
#define SK_COMMAND_LINE_FLAGS_H
#include "SkString.h"
#include "SkTDArray.h"
/**
* Including this file (and compiling SkFlags.cpp) provides command line
* Including this file (and compiling SkCommandLineFlags.cpp) provides command line
* parsing. In order to use it, use the following macros in global
* namespace:
*
@ -21,8 +21,8 @@
* DEFINE_int32(name, defaultValue, helpString);
* DEFINE_double(name, defaultValue, helpString);
*
* Then, in main, call SkFlags::SetUsage() to describe usage and call
* SkFlags::ParseCommandLine() to parse the flags. Henceforth, each flag can
* Then, in main, call SkCommandLineFlags::SetUsage() to describe usage and call
* SkCommandLineFlags::Parse() to parse the flags. Henceforth, each flag can
* be referenced using
*
* FLAGS_name
@ -85,8 +85,8 @@
*
* Inspired by gflags (https://code.google.com/p/gflags/). Is not quite as
* robust as gflags, but suits our purposes. For example, allows creating
* a flag -h or -help which will never be used, since SkFlags handles it.
* SkFlags will also allow creating --flag and --noflag. Uses the same input
* a flag -h or -help which will never be used, since SkCommandLineFlags handles it.
* SkCommandLineFlags will also allow creating --flag and --noflag. Uses the same input
* format as gflags and creates similarly named variables (i.e. FLAGS_name).
* Strings are handled differently (resulting variable will be an array of
* strings) so that a flag can be followed by multiple parameters.
@ -95,12 +95,12 @@
class SkFlagInfo;
class SkFlags {
class SkCommandLineFlags {
public:
/**
* Call to set the help message to be displayed. Should be called before
* ParseCommandLine.
* Parse.
*/
static void SetUsage(const char* usage);
@ -108,7 +108,7 @@ public:
* Call at the beginning of main to parse flags created by DEFINE_x, above.
* Must only be called once.
*/
static void ParseCommandLine(int argc, char** argv);
static void Parse(int argc, char** argv);
private:
static SkFlagInfo* gHead;
@ -344,8 +344,8 @@ private:
, fDoubleValue(NULL)
, fDefaultDouble(0)
, fStrings(NULL) {
fNext = SkFlags::gHead;
SkFlags::gHead = this;
fNext = SkCommandLineFlags::gHead;
SkCommandLineFlags::gHead = this;
}
// Name of the flag, without initial dashes
SkString fName;
@ -365,4 +365,4 @@ private:
// In order to keep a linked list.
SkFlagInfo* fNext;
};
#endif // SK_FLAGS_H
#endif // SK_COMMAND_LINE_FLAGS_H

View File

@ -8,7 +8,7 @@
#include "CopyTilesRenderer.h"
#include "SkBitmap.h"
#include "SkDevice.h"
#include "SkFlags.h"
#include "SkCommandLineFlags.h"
#include "SkGraphics.h"
#include "SkImageDecoder.h"
#include "SkImageEncoder.h"
@ -274,8 +274,8 @@ static int process_input(const char* input, const SkString* outputDir,
int tool_main(int argc, char** argv);
int tool_main(int argc, char** argv) {
SkFlags::SetUsage("Render .skp files.");
SkFlags::ParseCommandLine(argc, argv);
SkCommandLineFlags::SetUsage("Render .skp files.");
SkCommandLineFlags::Parse(argc, argv);
if (FLAGS_r.isEmpty()) {
SkDebugf(".skp files or directories are required.\n");

View File

@ -6,7 +6,7 @@
*/
#include "SkCanvas.h"
#include "SkFlags.h"
#include "SkCommandLineFlags.h"
#include "SkGraphics.h"
#include "SkImageEncoder.h"
#include "SkString.h"
@ -16,8 +16,8 @@ DEFINE_string(t, "Hello", "The string to write.");
int tool_main(int argc, char** argv);
int tool_main(int argc, char** argv) {
SkFlags::SetUsage("");
SkFlags::ParseCommandLine(argc, argv);
SkCommandLineFlags::SetUsage("");
SkCommandLineFlags::Parse(argc, argv);
SkAutoGraphics ag;
SkString path("skhello.png");