mirror of
https://github.com/aristocratos/btop.git
synced 2024-05-23 21:59:43 +12:00
Merge pull request #734 from imwints/build-info
This commit is contained in:
commit
6c66740290
3
.github/ISSUE_TEMPLATE/bug_report.md
vendored
3
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
@ -28,10 +28,9 @@ Any bug that can be solved by just reading the [prerequisites](https://github.co
|
||||||
[If applicable, add screenshots to help explain your problem.]
|
[If applicable, add screenshots to help explain your problem.]
|
||||||
|
|
||||||
**Info (please complete the following information):**
|
**Info (please complete the following information):**
|
||||||
- btop++ version: `btop -v`
|
- btop++ version: `btop --version`
|
||||||
- If using snap: `snap info btop`
|
- If using snap: `snap info btop`
|
||||||
- Binary: [self compiled or static binary from release]
|
- Binary: [self compiled or static binary from release]
|
||||||
- (If compiled) Compiler and version:
|
|
||||||
- Architecture: [x86_64, aarch64, etc.] `uname -m`
|
- Architecture: [x86_64, aarch64, etc.] `uname -m`
|
||||||
- Platform: [Linux, FreeBSD, OsX]
|
- Platform: [Linux, FreeBSD, OsX]
|
||||||
- (Linux) Kernel: `uname -r`
|
- (Linux) Kernel: `uname -r`
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -49,6 +49,8 @@ stage/
|
||||||
build
|
build
|
||||||
bin
|
bin
|
||||||
btop
|
btop
|
||||||
|
/obj/
|
||||||
|
config.h
|
||||||
.*/
|
.*/
|
||||||
|
|
||||||
# Optional libraries
|
# Optional libraries
|
||||||
|
|
|
@ -77,6 +77,21 @@ if(NOT CXX_HAVE_RANGES)
|
||||||
message(FATAL_ERROR "The compiler doesn't support <ranges>")
|
message(FATAL_ERROR "The compiler doesn't support <ranges>")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Generate build info
|
||||||
|
execute_process(
|
||||||
|
COMMAND "git" "rev-parse" "--short" "HEAD"
|
||||||
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
|
OUTPUT_VARIABLE GIT_COMMIT
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
||||||
|
set(CONFIGURE_COMMAND
|
||||||
|
"cmake -DBTOP_STATIC=${BTOP_STATIC} -DBTOP_USE_MOLD=${BTOP_USE_MOLD} -DBTOP_FORTIFY=${BTOP_FORTIFY} -DBTOP_GPU=${BTOP_GPU}"
|
||||||
|
)
|
||||||
|
get_filename_component(CXX_COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME)
|
||||||
|
set(COMPILER "${CXX_COMPILER_BASENAME}")
|
||||||
|
set(COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION}")
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY IMMEDIATE)
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
# Check for and enable LTO
|
# Check for and enable LTO
|
||||||
check_ipo_supported(RESULT ipo_supported)
|
check_ipo_supported(RESULT ipo_supported)
|
||||||
if(ipo_supported AND BTOP_LTO)
|
if(ipo_supported AND BTOP_LTO)
|
||||||
|
|
21
Makefile
21
Makefile
|
@ -163,6 +163,12 @@ else
|
||||||
LTO := $(THREADS)
|
LTO := $(THREADS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
GIT_COMMIT := $(shell git rev-parse --short HEAD 2> /dev/null || true)
|
||||||
|
CONFIGURE_COMMAND := $(MAKE) STATIC=$(STATIC) FORTIFY_SOURCE=$(FORTIFY_SOURCE)
|
||||||
|
ifeq ($(PLATFORM_LC),linux)
|
||||||
|
CONFIGURE_COMMAND += GPU_SUPPORT=$(GPU_SUPPORT) RSMI_STATIC=$(RSMI_STATIC)
|
||||||
|
endif
|
||||||
|
|
||||||
#? The Directories, Source, Includes, Objects and Binary
|
#? The Directories, Source, Includes, Objects and Binary
|
||||||
SRCDIR := src
|
SRCDIR := src
|
||||||
INCDIRS := include $(wildcard lib/**/include)
|
INCDIRS := include $(wildcard lib/**/include)
|
||||||
|
@ -182,7 +188,7 @@ OPTFLAGS := -O2 -ftree-vectorize -flto=$(LTO)
|
||||||
LDCXXFLAGS := -pthread -DFMT_HEADER_ONLY -D_GLIBCXX_ASSERTIONS -D_FILE_OFFSET_BITS=64 $(GOODFLAGS) $(ADDFLAGS)
|
LDCXXFLAGS := -pthread -DFMT_HEADER_ONLY -D_GLIBCXX_ASSERTIONS -D_FILE_OFFSET_BITS=64 $(GOODFLAGS) $(ADDFLAGS)
|
||||||
override CXXFLAGS += $(REQFLAGS) $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS)
|
override CXXFLAGS += $(REQFLAGS) $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS)
|
||||||
override LDFLAGS += $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS)
|
override LDFLAGS += $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS)
|
||||||
INC := $(foreach incdir,$(INCDIRS),-isystem $(incdir)) -I$(SRCDIR)
|
INC := $(foreach incdir,$(INCDIRS),-isystem $(incdir)) -I$(SRCDIR) -I$(BUILDDIR)
|
||||||
SU_USER := root
|
SU_USER := root
|
||||||
|
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
|
@ -222,7 +228,7 @@ endif
|
||||||
|
|
||||||
#? Default Make
|
#? Default Make
|
||||||
.ONESHELL:
|
.ONESHELL:
|
||||||
all: | info rocm_smi info-quiet directories btop
|
all: | info rocm_smi info-quiet directories config.h btop
|
||||||
|
|
||||||
ifneq ($(QUIET),true)
|
ifneq ($(QUIET),true)
|
||||||
info:
|
info:
|
||||||
|
@ -267,6 +273,13 @@ directories:
|
||||||
@$(VERBOSE) || printf "mkdir -p $(BUILDDIR)/$(PLATFORM_DIR)\n"
|
@$(VERBOSE) || printf "mkdir -p $(BUILDDIR)/$(PLATFORM_DIR)\n"
|
||||||
@mkdir -p $(BUILDDIR)/$(PLATFORM_DIR)
|
@mkdir -p $(BUILDDIR)/$(PLATFORM_DIR)
|
||||||
|
|
||||||
|
config.h: $(BUILDDIR)/config.h
|
||||||
|
|
||||||
|
$(BUILDDIR)/config.h: $(SRCDIR)/config.h.in | directories
|
||||||
|
@$(QUIET) || printf "\033[1mConfiguring $(BUILDDIR)/config.h\033[0m\n"
|
||||||
|
@$(VERBOSE) || printf 'sed -e "s|@GIT_COMMIT@|$(GIT_COMMIT)|" -e "s|@CONFIGURE_COMMAND@|$(CONFIGURE_COMMAND)|" -e "s|@COMPILER@|$(CXX)|" -e "s|@COMPILER_VERSION@|$(CXX_VERSION)|" $< | tee $@ > /dev/null\n'
|
||||||
|
@sed -e "s|@GIT_COMMIT@|$(GIT_COMMIT)|" -e "s|@CONFIGURE_COMMAND@|$(CONFIGURE_COMMAND)|" -e "s|@COMPILER@|$(CXX)|" -e "s|@COMPILER_VERSION@|$(CXX_VERSION)|" $< | tee $@ > /dev/null
|
||||||
|
|
||||||
#? Clean only Objects
|
#? Clean only Objects
|
||||||
clean:
|
clean:
|
||||||
@printf "\033[1;91mRemoving: \033[1;97mbuilt objects...\033[0m\n"
|
@printf "\033[1;91mRemoving: \033[1;97mbuilt objects...\033[0m\n"
|
||||||
|
@ -362,7 +375,7 @@ btop: $(OBJECTS) | rocm_smi directories
|
||||||
|
|
||||||
#? Compile
|
#? Compile
|
||||||
.ONESHELL:
|
.ONESHELL:
|
||||||
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT) | rocm_smi directories
|
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT) | rocm_smi directories config.h
|
||||||
@sleep 0.3 2>/dev/null || true
|
@sleep 0.3 2>/dev/null || true
|
||||||
@TSTAMP=$$(date +%s 2>/dev/null || echo "0")
|
@TSTAMP=$$(date +%s 2>/dev/null || echo "0")
|
||||||
@$(QUIET) || printf "\033[1;97mCompiling $<\033[0m\n"
|
@$(QUIET) || printf "\033[1;97mCompiling $<\033[0m\n"
|
||||||
|
@ -371,4 +384,4 @@ $(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT) | rocm_smi directories
|
||||||
@printf "\033[1;92m$$($(PROGRESS))$(P)\033[10D\033[5C-> \033[1;37m$@ \033[100D\033[38C\033[1;93m(\033[1;97m$$(du -ah $@ | cut -f1)iB\033[1;93m) \033[92m(\033[97m$$($(DATE_CMD) -d @$$(expr $$($(DATE_CMD) +%s 2>/dev/null || echo "0") - $${TSTAMP} 2>/dev/null) -u +%Mm:%Ss 2>/dev/null | sed 's/^00m://' || echo '')\033[92m)\033[0m\n"
|
@printf "\033[1;92m$$($(PROGRESS))$(P)\033[10D\033[5C-> \033[1;37m$@ \033[100D\033[38C\033[1;93m(\033[1;97m$$(du -ah $@ | cut -f1)iB\033[1;93m) \033[92m(\033[97m$$($(DATE_CMD) -d @$$(expr $$($(DATE_CMD) +%s 2>/dev/null || echo "0") - $${TSTAMP} 2>/dev/null) -u +%Mm:%Ss 2>/dev/null | sed 's/^00m://' || echo '')\033[92m)\033[0m\n"
|
||||||
|
|
||||||
#? Non-File Targets
|
#? Non-File Targets
|
||||||
.PHONY: all msg help pre
|
.PHONY: all config.h msg help pre
|
||||||
|
|
22
src/btop.cpp
22
src/btop.cpp
|
@ -52,6 +52,7 @@ tab-size = 4
|
||||||
#include "btop_theme.hpp"
|
#include "btop_theme.hpp"
|
||||||
#include "btop_draw.hpp"
|
#include "btop_draw.hpp"
|
||||||
#include "btop_menu.hpp"
|
#include "btop_menu.hpp"
|
||||||
|
#include "config.h"
|
||||||
#include "fmt/core.h"
|
#include "fmt/core.h"
|
||||||
#include "fmt/ostream.h"
|
#include "fmt/ostream.h"
|
||||||
|
|
||||||
|
@ -117,6 +118,19 @@ namespace Global {
|
||||||
int arg_update = 0;
|
int arg_update = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_version() {
|
||||||
|
if constexpr (GIT_COMMIT.empty()) {
|
||||||
|
fmt::print("btop version: {}\n", Global::Version);
|
||||||
|
} else {
|
||||||
|
fmt::print("btop version: {}+{}\n", Global::Version, GIT_COMMIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_version_with_build_info() {
|
||||||
|
print_version();
|
||||||
|
fmt::print("Compiled with: {} ({})\nConfigured with: {}\n", COMPILER, COMPILER_VERSION, CONFIGURE_COMMAND);
|
||||||
|
}
|
||||||
|
|
||||||
//* A simple argument parser
|
//* A simple argument parser
|
||||||
void argumentParser(const int argc, char **argv) {
|
void argumentParser(const int argc, char **argv) {
|
||||||
for(int i = 1; i < argc; i++) {
|
for(int i = 1; i < argc; i++) {
|
||||||
|
@ -138,8 +152,12 @@ void argumentParser(const int argc, char **argv) {
|
||||||
);
|
);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if (is_in(argument, "-v", "--version")) {
|
else if (is_in(argument, "-v")) {
|
||||||
fmt::println("btop version: {}", Global::Version);
|
print_version();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
else if (is_in(argument, "--version")) {
|
||||||
|
print_version_with_build_info();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if (is_in(argument, "-lc", "--low-color")) {
|
else if (is_in(argument, "-lc", "--low-color")) {
|
||||||
|
|
10
src/config.h.in
Normal file
10
src/config.h.in
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
constexpr std::string_view GIT_COMMIT = "@GIT_COMMIT@";
|
||||||
|
constexpr std::string_view COMPILER = "@COMPILER@";
|
||||||
|
constexpr std::string_view COMPILER_VERSION = "@COMPILER_VERSION@";
|
||||||
|
constexpr std::string_view CONFIGURE_COMMAND = "@CONFIGURE_COMMAND@";
|
Loading…
Reference in a new issue