Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: show build information with --version option #85

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ TODO.org
bin
build
compile_commands.json
.vscode/settings.json
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,32 @@ endif()

project(SignalEstimator)

set(PROJECT_VERSION 0.1.0)

# Compilation information
option(BUILD_GUI "build Qt GUI" ON)
option(ENABLE_SANITIZERS "enable sanitizers" OFF)
option(ENABLE_WERROR "enable -Werror" OFF)

execute_process(
COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE GCC_TRIPLET
OUTPUT_STRIP_TRAILING_WHITESPACE
)

set(TOOLCHAIN_PREFIX "" CACHE STRING "target host triplet, e.g. aarch64-linux-gnu")

string(TIMESTAMP CURRENT_DATE "%b %d %Y")
string(TIMESTAMP CURRENT_TIME "%H:%M:%S")

add_compile_definitions(
PROJECT_VERSION="${PROJECT_VERSION}"
TARGET_TRIPLET="${GCC_TRIPLET}"
BUILD_DATE="${CURRENT_DATE}"
BUILD_TIME="${CURRENT_TIME}"
)


include("cmake/SetupToolchain.cmake")
include("cmake/ThirdParty.cmake")

Expand Down
12 changes: 11 additions & 1 deletion src/cli/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

using namespace signal_estimator;


int main(int argc, char** argv) {
Config config;
std::string mode = "latency_corr";
Expand All @@ -23,11 +24,15 @@ int main(int argc, char** argv) {
output_format = PcmFormat().to_string();
int verbosity = 0;
bool list_supported = false;
bool show_version = false;

CLI::App app { "Measure characteristics of a looped back signal",
"signal-estimator" };

app.formatter(std::make_shared<Formatter>());
app.formatter(std::make_shared<Formatter>());

app.add_flag(
"-V,--version",show_version, "Show software version");

app.add_flag(
"-L,--list-supported", list_supported, "Print supported features and exit");
Expand Down Expand Up @@ -189,6 +194,11 @@ int main(int argc, char** argv) {
return EXIT_SUCCESS;
}

if(show_version){
print_compilation_information(std::cerr);
return EXIT_SUCCESS;
}

// parse mode
const std::map<std::string, Mode> mode_map {
{ "latency_corr", Mode::LatencyCorr },
Expand Down
7 changes: 5 additions & 2 deletions src/cli/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ void print_supported_formats(std::ostream& out) {
}
}
}

} // namespace signal_estimator
void print_compilation_information(std::ostream& out) {
out<<"Signal Estimator "<< PROJECT_VERSION << "\n";
out << "Built for " << TARGET_TRIPLET <<" at "<<BUILD_DATE<<" "<<BUILD_TIME << "\n";
}
}
2 changes: 2 additions & 0 deletions src/cli/Print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ namespace signal_estimator {

void print_supported_formats(std::ostream& out);

void print_compilation_information(std::ostream& out);

} // namespace signal_estimator