Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ if get_option('json-schema-checks')
endif
if get_option('kaitai-struct-checks')
subproject('kaitai-struct-checks')

if get_option('color')
add_project_arguments('-DNIX_COLOR', language: ['c', 'cpp'])
endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This meson.build is only used for the dev shell.

7 changes: 7 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ option(
value : true,
description : 'Check JSON schema validity of schemas and examples (requires jv)',
)

option(
'color',
type : 'boolean',
value : true,
description : 'Output ANSI escape sequences',
)
Comment on lines +45 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't do anything, since the top-level meson.options is only used for the dev-shell (and other packaging approaches by downstream distros).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware, this is for other packaging approaches.

13 changes: 13 additions & 0 deletions src/libutil/include/nix/util/ansicolor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace nix {

#ifdef NIX_COLOR
#define ANSI_NORMAL "\e[0m"
#define ANSI_BOLD "\e[1m"
#define ANSI_FAINT "\e[2m"
Expand All @@ -18,5 +19,17 @@ namespace nix {
#define ANSI_BLUE "\e[34;1m"
#define ANSI_MAGENTA "\e[35;1m"
#define ANSI_CYAN "\e[36;1m"
#else
#define ANSI_NORMAL ""
#define ANSI_BOLD ""
#define ANSI_FAINT ""
#define ANSI_ITALIC ""
#define ANSI_RED ""
#define ANSI_GREEN ""
#define ANSI_WARNING ""
#define ANSI_BLUE ""
#define ANSI_MAGENTA ""
#define ANSI_CYAN ""
#endif

} // namespace nix