Skip to content

Commit

Permalink
Merge pull request #1950 from chuckatkins/bpls-version
Browse files Browse the repository at this point in the history
Add version information to bpls
  • Loading branch information
Chuck Atkins authored Jan 30, 2020
2 parents 0c1bd3f + c518455 commit 4da1eca
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 5 deletions.
11 changes: 10 additions & 1 deletion cmake/ADIOSFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ function(setup_version BASE)
OUTPUT_VARIABLE out
ERROR_QUIET
)
if(res EQUAL 0 AND out MATCHES "[^-]*-([^-]*)-g[a-f0-9]*")
if(res EQUAL 0 AND out MATCHES "[^-]*-([^-]*)-g([a-f0-9]*)")
set(ver_tweak ${CMAKE_MATCH_1})
set(ver_gitsha ${CMAKE_MATCH_2})
endif()
endif()
endif()

if(ver_tweak)
set(ADIOS2_VERSION ${BASE}.${ver_tweak} PARENT_SCOPE)
else()
set(ADIOS2_VERSION ${BASE} PARENT_SCOPE)
endif()

if(ver_gitsha)
set(ADIOS2_VERSION_GIT_SHA ${ver_gitsha} PARENT_SCOPE)
else()
unset(ADIOS2_VERSION_GIT_SHA PARENT_SCOPE)
endif()

set(ADIOS2_LIBRARY_VERSION ${BASE} PARENT_SCOPE)
endfunction()

Expand Down
7 changes: 7 additions & 0 deletions source/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/verinfo.h.in
${PROJECT_BINARY_DIR}/verinfo.h
@ONLY
)

# BPLS
add_executable(bpls ./bpls/bpls.cpp)
target_link_libraries(bpls adios2 adios2sys_interface pugixml)
target_include_directories(bpls PRIVATE ${PROJECT_BINARY_DIR})
install(TARGETS bpls EXPORT adios2
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
Expand Down
53 changes: 49 additions & 4 deletions source/utils/bpls/bpls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#endif

#include "bpls.h"
#include "verinfo.h"

#include <cinttypes>
#include <cstdio>
Expand Down Expand Up @@ -180,7 +181,12 @@ void display_help()
"doing.\n"
" Use multiple -v to increase logging "
"level.\n"
"Typical use: bpls -lav <file>\n");
" --version Print version information; compatible "
" with\n"
" --verbose for additional information, "
"i.e.\n"
" -v --version.\n"
"\nTypical use: bpls -lav <file>\n");
}

bool option_help_was_called = false;
Expand All @@ -200,6 +206,42 @@ int optioncb_verbose(const char *argument, const char *value, void *call_data)
return 1;
}

int optioncb_version(const char *argument, const char *value, void *call_data)
{
if (verbose == 0)
{
printf(ADIOS2_VERSION_STR "\n");
option_help_was_called = true;
return 1;
}

printf("blps: ADIOS file introspection utility\n");
printf("\nBuild configuration:\n");
if (strlen(ADIOS_INFO_VER_GIT) > 0)
{
printf("ADIOS version: %s (%s)\n", ADIOS2_VERSION_STR,
ADIOS_INFO_VER_GIT);
}
else
{
printf("ADIOS version: %s\n", ADIOS2_VERSION_STR);
}
if (strlen(ADIOS_INFO_COMPILER_WRAP) > 0)
{
printf("C++ Compiler: %s %s (%s)\n", ADIOS_INFO_COMPILER_ID,
ADIOS_INFO_COMPILER_VER, ADIOS_INFO_COMPILER_WRAP);
}
else
{
printf("C++ Compiler: %s %s\n", ADIOS_INFO_COMPILER_ID,
ADIOS_INFO_COMPILER_VER);
}
printf("Target OS: %s\n", ADIOS_INFO_SYSTEM);
printf("Target Arch: %s\n", ADIOS_INFO_ARCH);
option_help_was_called = true;
return 1;
}

int process_unused_args(adios2sys::CommandLineArguments &arg)
{
int nuargs;
Expand Down Expand Up @@ -284,11 +326,14 @@ int bplsMain(int argc, char *argv[])
arg.Initialize(argc, argv);
typedef adios2sys::CommandLineArguments argT;
arg.StoreUnusedArguments(true);
arg.AddCallback("--help", argT::NO_ARGUMENT, optioncb_help, &arg, "Help");
arg.AddCallback("-h", argT::NO_ARGUMENT, optioncb_help, &arg, "");
arg.AddCallback("-v", argT::NO_ARGUMENT, optioncb_verbose, nullptr, "");
arg.AddCallback("--verbose", argT::NO_ARGUMENT, optioncb_verbose, nullptr,
"Print information about what bpls is doing");
arg.AddCallback("-v", argT::NO_ARGUMENT, optioncb_verbose, nullptr, "");
arg.AddCallback("--help", argT::NO_ARGUMENT, optioncb_help, &arg, "Help");
arg.AddCallback("-h", argT::NO_ARGUMENT, optioncb_help, &arg, "");
arg.AddCallback("--version", argT::NO_ARGUMENT, optioncb_version, &arg,
"Print version information (add -verbose for additional"
" information)");
arg.AddBooleanArgument("--dump", &dump,
"Dump matched variables/attributes");
arg.AddBooleanArgument("-d", &dump, "");
Expand Down
6 changes: 6 additions & 0 deletions source/utils/verinfo.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#define ADIOS_INFO_VER_GIT "@ADIOS2_VERSION_GIT_SHA@"
#define ADIOS_INFO_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@"
#define ADIOS_INFO_COMPILER_VER "@CMAKE_CXX_COMPILER_VERSION@"
#define ADIOS_INFO_COMPILER_WRAP "@CMAKE_CXX_COMPILER_WRAPPER@"
#define ADIOS_INFO_SYSTEM "@CMAKE_SYSTEM@"
#define ADIOS_INFO_ARCH "@CMAKE_SYSTEM_PROCESSOR@"
4 changes: 4 additions & 0 deletions testing/utils/cwriter/TestUtilsCWriter.bplsh.expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ Help options
--help | -h Print this help.
--verbose | -v Print log about what this program is doing.
Use multiple -v to increase logging level.
--version Print version information; compatible with
--verbose for additional information, i.e.
-v --version.

Typical use: bpls -lav <file>

0 comments on commit 4da1eca

Please sign in to comment.