-
-
Save cole-h/ec8e4334e6595c2848252e9dda54941d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 7a6b99fb713e2abe6e24b591114b798683a240e2 Mon Sep 17 00:00:00 2001 | |
From: Cole Helbling | |
Date: Sun, 6 Sep 2020 11:38:47 -0700 | |
Subject: [PATCH] Fix various issues | |
Fixes: | |
* incorrect toJSON() for LogFormat | |
* both `--option log-format` and `--log-format` function in the same way | |
* this was tough because it means libstore needs to link to libmain | |
for access to the loggers stuff, which also requires us to | |
ALLOW_UNDEFINED | |
--- | |
src/libmain/common-args.cc | 11 ----------- | |
src/libmain/loggers.cc | 2 +- | |
src/libstore/globals.cc | 17 +++++++++++++++-- | |
src/libstore/globals.hh | 2 +- | |
src/libstore/local.mk | 4 +++- | |
5 files changed, 20 insertions(+), 16 deletions(-) | |
diff --git a/src/libmain/common-args.cc b/src/libmain/common-args.cc | |
index 90e6d7b7a..95b1fdb01 100644 | |
--- a/src/libmain/common-args.cc | |
+++ b/src/libmain/common-args.cc | |
@@ -49,17 +49,6 @@ MixCommonArgs::MixCommonArgs(const string & programName) | |
} | |
}); | |
- addFlag({ | |
- .longName = "log-format", | |
- .description = "format of log output; `raw`, `internal-json`, `bar` " | |
- "or `bar-with-logs`", | |
- .labels = {"format"}, | |
- .handler = {[&](std::string format) { | |
- settings.logFormat.set(format); | |
- createDefaultLogger(); | |
- }}, | |
- }); | |
- | |
addFlag({ | |
.longName = "max-jobs", | |
.shortName = 'j', | |
diff --git a/src/libmain/loggers.cc b/src/libmain/loggers.cc | |
index 8a533136b..61f71f627 100644 | |
--- a/src/libmain/loggers.cc | |
+++ b/src/libmain/loggers.cc | |
@@ -6,7 +6,7 @@ | |
namespace nix { | |
Logger * makeDefaultLogger() { | |
- switch (settings.logFormat.get()) { | |
+ switch (settings.logFormat) { | |
case LogFormat::raw: | |
return makeSimpleLogger(false); | |
case LogFormat::rawWithLogs: | |
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc | |
index 296b5beb1..ecaf7f1ce 100644 | |
--- a/src/libstore/globals.cc | |
+++ b/src/libstore/globals.cc | |
@@ -2,6 +2,7 @@ | |
#include "util.hh" | |
#include "archive.hh" | |
#include "args.hh" | |
+#include "loggers.hh" | |
#include | |
#include | |
@@ -202,6 +203,8 @@ template<> void BaseSetting::set(const std::string & str) | |
else if (str == "bar-with-logs") | |
value = LogFormat::barWithLogs; | |
else throw UsageError("option '%s' has an invalid value '%s'", name, str); | |
+ | |
+ createDefaultLogger(); | |
} | |
template<> std::string BaseSetting::to_string() const | |
@@ -214,13 +217,23 @@ template<> std::string BaseSetting::to_string() const | |
else abort(); | |
} | |
-template<> void BaseSetting::toJSON(JSONPlaceholder & out) | |
+template<> nlohmann::json BaseSetting::toJSON() | |
{ | |
- AbstractSetting::toJSON(out); | |
+ return AbstractSetting::toJSON(); | |
} | |
template<> void BaseSetting::convertToArg(Args & args, const std::string & category) | |
{ | |
+ args.addFlag({ | |
+ .longName = name, | |
+ .description = "format of log output; `raw`, `raw-with-logs`, `internal-json`, `bar`, " | |
+ "or `bar-with-logs`", | |
+ .category = category, | |
+ .labels = {"format"}, | |
+ .handler = {[&](std::string format) { | |
+ settings.logFormat.set(format); | |
+ }} | |
+ }); | |
} | |
void MaxBuildJobsSetting::set(const std::string & str) | |
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh | |
index 3bbcc1ee8..260051749 100644 | |
--- a/src/libstore/globals.hh | |
+++ b/src/libstore/globals.hh | |
@@ -866,7 +866,7 @@ public: | |
"Experimental Nix features to enable."}; | |
Setting logFormat{this, LogFormat::bar, "log-format", | |
- "Default build output logging format; \"raw\", \"internal-json\", \"bar\" or \"bar-with-logs\"."}; | |
+ "Default build output logging format; \"raw\", \"raw-with-logs\", \"internal-json\", \"bar\", or \"bar-with-logs\"."}; | |
bool isExperimentalFeatureEnabled(const std::string & name); | |
diff --git a/src/libstore/local.mk b/src/libstore/local.mk | |
index d266c8efe..6d5495f99 100644 | |
--- a/src/libstore/local.mk | |
+++ b/src/libstore/local.mk | |
@@ -8,6 +8,8 @@ libstore_SOURCES := $(wildcard $(d)/*.cc $(d)/builtins/*.cc) | |
libstore_LIBS = libutil | |
+libstore_ALLOW_UNDEFINED = 1 | |
+ | |
libstore_LDFLAGS = $(SQLITE3_LIBS) -lbz2 $(LIBCURL_LIBS) $(SODIUM_LIBS) -pthread | |
ifneq ($(OS), FreeBSD) | |
libstore_LDFLAGS += -ldl | |
@@ -32,7 +34,7 @@ ifeq ($(HAVE_SECCOMP), 1) | |
endif | |
libstore_CXXFLAGS += \ | |
- -I src/libutil -I src/libstore \ | |
+ -I src/libmain -I src/libutil -I src/libstore \ | |
-DNIX_PREFIX=\"$(prefix)\" \ | |
-DNIX_STORE_DIR=\"$(storedir)\" \ | |
-DNIX_DATA_DIR=\"$(datadir)\" \ | |
-- | |
2.28.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment