Move over to ABSL logging and flags.
Removes gperftools too since that wants gflags.
Here come the fireworks.
Change-Id: I79cb7bcf60f1047fbfa28bfffc21a0fd692e4b1c
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/starter/starterd.cc b/aos/starter/starterd.cc
index 64858d4..127bf41 100644
--- a/aos/starter/starterd.cc
+++ b/aos/starter/starterd.cc
@@ -4,8 +4,9 @@
#include <ostream>
#include <string>
-#include "gflags/gflags.h"
-#include "glog/logging.h"
+#include "absl/flags/flag.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
#include "aos/configuration.h"
#include "aos/events/event_loop.h"
@@ -14,33 +15,34 @@
#include "aos/starter/starterd_lib.h"
#include "aos/util/file.h"
-DEFINE_string(config, "aos_config.json", "File path of aos configuration");
-DEFINE_string(user, "",
- "Starter runs as though this user ran a SUID binary if set.");
-DEFINE_string(version_string, "",
- "Version to report for starterd and subprocesses.");
+ABSL_FLAG(std::string, config, "aos_config.json",
+ "File path of aos configuration");
+ABSL_FLAG(std::string, user, "",
+ "Starter runs as though this user ran a SUID binary if set.");
+ABSL_FLAG(std::string, version_string, "",
+ "Version to report for starterd and subprocesses.");
-DECLARE_string(shm_base);
-DEFINE_bool(purge_shm_base, false,
- "If true, delete everything in --shm_base before starting.");
+ABSL_DECLARE_FLAG(std::string, shm_base);
+ABSL_FLAG(bool, purge_shm_base, false,
+ "If true, delete everything in --shm_base before starting.");
int main(int argc, char **argv) {
aos::InitGoogle(&argc, &argv);
- if (FLAGS_purge_shm_base) {
- aos::util::UnlinkRecursive(FLAGS_shm_base);
+ if (absl::GetFlag(FLAGS_purge_shm_base)) {
+ aos::util::UnlinkRecursive(absl::GetFlag(FLAGS_shm_base));
}
- if (!FLAGS_user.empty()) {
+ if (!absl::GetFlag(FLAGS_user).empty()) {
uid_t uid;
uid_t gid;
{
- struct passwd *user_data = getpwnam(FLAGS_user.c_str());
+ struct passwd *user_data = getpwnam(absl::GetFlag(FLAGS_user).c_str());
if (user_data != nullptr) {
uid = user_data->pw_uid;
gid = user_data->pw_gid;
} else {
- LOG(FATAL) << "Could not find user " << FLAGS_user;
+ LOG(FATAL) << "Could not find user " << absl::GetFlag(FLAGS_user);
return 1;
}
}
@@ -51,24 +53,24 @@
constexpr int kUnchanged = -1;
if (setresgid(/* ruid */ gid, /* euid */ gid,
/* suid */ kUnchanged) != 0) {
- PLOG(FATAL) << "Failed to change GID to " << FLAGS_user << ", group "
- << gid;
+ PLOG(FATAL) << "Failed to change GID to " << absl::GetFlag(FLAGS_user)
+ << ", group " << gid;
}
if (setresuid(/* ruid */ uid, /* euid */ uid,
/* suid */ kUnchanged) != 0) {
- PLOG(FATAL) << "Failed to change UID to " << FLAGS_user;
+ PLOG(FATAL) << "Failed to change UID to " << absl::GetFlag(FLAGS_user);
}
}
aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig(FLAGS_config);
+ aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config));
const aos::Configuration *config_msg = &config.message();
aos::starter::Starter starter(config_msg);
- if (!FLAGS_version_string.empty()) {
- starter.event_loop()->SetVersionString(FLAGS_version_string);
+ if (!absl::GetFlag(FLAGS_version_string).empty()) {
+ starter.event_loop()->SetVersionString(absl::GetFlag(FLAGS_version_string));
}
starter.Run();