summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Maennich <maennich@google.com>2021-11-24 14:47:58 +0000
committerMatthias Maennich <maennich@google.com>2021-11-24 15:56:14 +0000
commitdc7bd73742bc1b7c75194f47a5b74f5a50e7a3c2 (patch)
treed2e702ff03a050b339fd0c117e43d103822a9bdd
parentde9ce22247b6130722945e1317f88704fb6ae574 (diff)
downloadbuild-tools-dc7bd73742bc1b7c75194f47a5b74f5a50e7a3c2.tar.gz
interceptor: consistent constant naming
Signed-off-by: Matthias Maennich <maennich@google.com> Change-Id: I884c21e272e6a3f1ede59b2c5833fdb3983e2879
-rw-r--r--interceptor/analysis.cc8
-rw-r--r--interceptor/interceptor.cc4
-rw-r--r--interceptor/interceptor.h4
-rw-r--r--interceptor/main.cc4
4 files changed, 10 insertions, 10 deletions
diff --git a/interceptor/analysis.cc b/interceptor/analysis.cc
index e230096..a5a0c65 100644
--- a/interceptor/analysis.cc
+++ b/interceptor/analysis.cc
@@ -120,10 +120,10 @@ void text_to_file(const interceptor::Log& log, const fs::path& output) {
}
void compdb_to_file(const interceptor::Log& log, const fs::path& output) {
- static const std::unordered_set<std::string_view> COMPILE_EXTENSIONS = {
+ static const std::unordered_set<std::string_view> kCompileExtensions = {
".c", ".cc", ".cpp", ".cxx", ".S",
};
- static const std::unordered_set<std::string_view> COMPILERS = {
+ static const std::unordered_set<std::string_view> kCompilers = {
"clang",
"clang++",
"gcc",
@@ -134,7 +134,7 @@ void compdb_to_file(const interceptor::Log& log, const fs::path& output) {
for (const auto& command : log.commands()) {
// skip anything that is not a compiler invocation
- if (!COMPILERS.count(fs::path(command.args(0)).filename().native())) {
+ if (!kCompilers.count(fs::path(command.args(0)).filename().native())) {
continue;
}
@@ -159,7 +159,7 @@ void compdb_to_file(const interceptor::Log& log, const fs::path& output) {
for (const auto& input : command.inputs()) {
// skip anything that does not look like a source file (object files,
// force included headers, etc.)
- if (!COMPILE_EXTENSIONS.count(fs::path(input).extension().native())) {
+ if (!kCompileExtensions.count(fs::path(input).extension().native())) {
continue;
}
diff --git a/interceptor/interceptor.cc b/interceptor/interceptor.cc
index 1acb7b2..1789437 100644
--- a/interceptor/interceptor.cc
+++ b/interceptor/interceptor.cc
@@ -93,7 +93,7 @@ static Command instantiate_command(const char* program, char* const argv[], char
static void make_relative(Command* command) {
// determine the ROOT_DIR
std::string root_dir;
- if (auto it = command->env_vars().find(ENV_root_dir); it != command->env_vars().cend()) {
+ if (auto it = command->env_vars().find(kEnvRootDirectory); it != command->env_vars().cend()) {
root_dir = it->second;
if (root_dir[root_dir.size() - 1] != '/') {
root_dir += '/';
@@ -313,7 +313,7 @@ static void process_command(const char* filename, char* const argv[], char* cons
static void log(const interceptor::Command& command) {
const auto& env = command.env_vars();
- if (const auto env_it = env.find(ENV_command_log); env_it != env.cend()) {
+ if (const auto env_it = env.find(kEnvCommandLog); env_it != env.cend()) {
std::ofstream file;
file.open(std::string(env_it->second),
std::ofstream::out | std::ofstream::app | std::ofstream::binary);
diff --git a/interceptor/interceptor.h b/interceptor/interceptor.h
index 27ded28..8c97022 100644
--- a/interceptor/interceptor.h
+++ b/interceptor/interceptor.h
@@ -24,8 +24,8 @@
#include "log.pb.h"
// Options passed via environment variables from the interceptor starter
-constexpr static auto ENV_command_log = "INTERCEPTOR_command_log";
-constexpr static auto ENV_root_dir = "INTERCEPTOR_root_dir";
+constexpr static auto kEnvCommandLog = "INTERCEPTOR_command_log";
+constexpr static auto kEnvRootDirectory = "INTERCEPTOR_root_directory";
namespace interceptor {
diff --git a/interceptor/main.cc b/interceptor/main.cc
index 36cb1bd..55b7f44 100644
--- a/interceptor/main.cc
+++ b/interceptor/main.cc
@@ -99,7 +99,7 @@ static fs::path setup_root_dir() {
result = fs::current_path();
}
- setenv(ENV_root_dir, result.c_str(), 1);
+ setenv(kEnvRootDirectory, result.c_str(), 1);
return result;
}
@@ -112,7 +112,7 @@ class CommandLog {
CommandLog(decltype(command_log_file_) command_log_file, const fs::path& root_dir)
: command_log_file_(std::move(command_log_file)), root_dir_(root_dir) {
if (command_log_file_) {
- setenv(ENV_command_log, command_log_file_->c_str(), 1);
+ setenv(kEnvCommandLog, command_log_file_->c_str(), 1);
std::ofstream command_log(command_log_file_->c_str(), std::ios_base::trunc);
if (!command_log) {
std::cerr << "Could not open command log for writing: " << *command_log_file_ << "\n";