As part of the
minimization and
standardization of our code base, gflags usage has been removed from all of the platform and platform2 source code. All code has instead been switched to using base/command_line.h as the command line flag parser. To ease the transition, a small wrapper class in libchromeos called FlagHelper was created to simulate parts of the gflags API. Documentation on it can be viewed on the
libchromeos page or in the comments of the
header file itself. Although the usage is similar to gflags, there are two big differences. First, the flag definition macros and thus the 'FLAGS_<name>' variables themselves must be scoped to the main(...) function. This is to
avoid using global non-POD static variables. Secondly, command line flag passing must be of the form "--flag=value", as space-delimited "--flag value" pairs are not supported by the base/command_line.h parser. I've looked briefly into adding support for space-delimited flag pre-parsing to the FlagHelper wrapper, however at this point, the cons of any implementation outweigh the convenience.
What does this mean for you, as developers? I've searched through the entire source base, and updated all internal command line flag passing between binaries/scripts to be of the form "--flag=value", so at this point, everything should be working as intended. However as several people have found out the hard way recently, when testing your code manually or writing new code or test cases, you must make sure that you're passing flags using the format "--flag=value".