Skip to content

Commit

Permalink
ENH: Add --extended-version option to transformix executable
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Dekker committed Jul 8, 2022
1 parent dd12718 commit 81eb3b3
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 19 deletions.
1 change: 1 addition & 0 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ add_executable(transformix_exe
${InstallFilesForExecutables}
)
set_target_properties(transformix_exe PROPERTIES OUTPUT_NAME transformix)
target_compile_definitions(transformix_exe PRIVATE ELX_CMAKE_VERSION="${CMAKE_VERSION}")
target_link_libraries(transformix_exe ${ELASTIX_TARGET_LINK_LIBRARIES})

# The library type (STATIC or SHARED) is determined by the parameter
Expand Down
20 changes: 1 addition & 19 deletions Core/Main/elastix.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,7 @@ main(int argc, char ** argv)
}
else if (argument == "--extended-version")
{
std::cout << "elastix version: " ELASTIX_VERSION_STRING << "\nITK version: " << ITK_VERSION_MAJOR << '.'
<< ITK_VERSION_MINOR << '.' << ITK_VERSION_PATCH << "\nBuild date: " << __DATE__ << ' ' << __TIME__
#ifdef _MSC_FULL_VER
<< "\nCompiler: Visual C++ version " << _MSC_FULL_VER << '.' << _MSC_BUILD
#endif
#ifdef __clang__
<< "\nCompiler: Clang"
# ifdef __VERSION__
<< " version " << __VERSION__
# endif
#endif
#if defined(__GNUC__)
<< "\nCompiler: GCC"
# ifdef __VERSION__
<< " version " << __VERSION__
# endif
#endif
<< "\nMemory address size: " << std::numeric_limits<std::size_t>::digits
<< "-bit\nCMake version: " << ELX_CMAKE_VERSION << std::endl;
elx::PrintExtendedVersionInformation("elastix");
return 0;
}
else
Expand Down
27 changes: 27 additions & 0 deletions Core/Main/elxMainExeUtilities.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
#include "elxMainExeUtilities.h"

#include "xoutmain.h"
#include <Core/elxVersionMacros.h>
#include <itkMacro.h>

// Standard Library header files:
#include <cassert>
#include <exception>
#include <limits>
#include <sstream>
#include <typeinfo>

Expand Down Expand Up @@ -64,3 +66,28 @@ elastix::ReportTerminatingException(const char * const executableName, const std
assert(!"Unhandled exception!");
}
}


void
elastix::PrintExtendedVersionInformation(const char * const executableName)
{
std::cout << executableName << " version: " ELASTIX_VERSION_STRING << "\nITK version: " << ITK_VERSION_MAJOR << '.'
<< ITK_VERSION_MINOR << '.' << ITK_VERSION_PATCH << "\nBuild date: " << __DATE__ << ' ' << __TIME__
#ifdef _MSC_FULL_VER
<< "\nCompiler: Visual C++ version " << _MSC_FULL_VER << '.' << _MSC_BUILD
#endif
#ifdef __clang__
<< "\nCompiler: Clang"
# ifdef __VERSION__
<< " version " << __VERSION__
# endif
#endif
#if defined(__GNUC__)
<< "\nCompiler: GCC"
# ifdef __VERSION__
<< " version " << __VERSION__
# endif
#endif
<< "\nMemory address size: " << std::numeric_limits<std::size_t>::digits
<< "-bit\nCMake version: " << ELX_CMAKE_VERSION << std::endl;
}
4 changes: 4 additions & 0 deletions Core/Main/elxMainExeUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ namespace elastix
void
ReportTerminatingException(const char * const executableName, const std::exception & stdException) noexcept;

/** Prints extended version information to standard output. */
void
PrintExtendedVersionInformation(const char * const executableName);

} // namespace elastix

#endif
5 changes: 5 additions & 0 deletions Core/Main/transformix.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ main(int argc, char ** argv)
std::cout << "transformix version: " ELASTIX_VERSION_STRING << std::endl;
return 0;
}
else if (argument == "--extended-version")
{
elx::PrintExtendedVersionInformation("transformix");
return 0;
}
else
{
std::cout << "Use \"transformix --help\" for information about transformix-usage." << std::endl;
Expand Down
17 changes: 17 additions & 0 deletions Testing/PythonTests/transformix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ def test_version(self) -> None:
"transformix version: " + self.version_string,
)

def test_extended_version(self) -> None:
"""Tests --extended-version"""

completed = subprocess.run(
[str(self.transformix_exe_file_path), "--extended-version"],
capture_output=True,
check=True,
)
self.assertEqual(completed.returncode, 0)
self.assertEqual(completed.stderr, b"")

output: str = completed.stdout.decode()
self.assertTrue("transformix version: " in output)
self.assertTrue("ITK version: " in output)
self.assertTrue("Memory address size: " in output)
self.assertTrue("CMake version: " in output)

def test_missing_tp_commandline_option(self) -> None:
"""Tests missing -tp commandline option"""

Expand Down

0 comments on commit 81eb3b3

Please sign in to comment.