diff --git a/CMakeLists.txt b/CMakeLists.txt index 4db74c3..66650e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 2.6) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") include(CompileCheck) -include(VersionString) # TODO use this +include(VersionString) include(CheckSymbolExists) # Force re-checking libraries if the compiler or compiler flags change. @@ -19,7 +19,7 @@ endif() unset(LIBRARIES) -find_package(Boost REQUIRED COMPONENTS iostreams filesystem date_time) +find_package(Boost REQUIRED COMPONENTS iostreams filesystem date_time system) check_link_library(Boost Boost_LIBRARIES) list(APPEND LIBRARIES "${Boost_LIBRARIES}") link_directories("${Boost_LIBRARY_DIRS}") @@ -128,6 +128,10 @@ include_directories(src ${CMAKE_CURRENT_BINARY_DIR}) configure_file("src/configure.hpp.in" "configure.hpp") +set(VERSION_FILE "${CMAKE_BINARY_DIR}/version.cpp") +version_file("src/version.cpp.in" "${VERSION_FILE}" "VERSION" ".git") +list(APPEND INNOEXTRACT_SOURCES "${VERSION_FILE}") + add_executable(innoextract ${INNOEXTRACT_SOURCES} ${ALL_INCLUDES}) target_link_libraries(innoextract ${LIBRARIES}) @@ -173,9 +177,6 @@ if(PYTHONINTERP_FOUND) # TODO add copyright notices set(STYLE_FILTER ${STYLE_FILTER},-legal/copyright) - # TODO split up main() - set(STYLE_FILTER ${STYLE_FILTER},-readability/fn_size) - add_custom_target(style COMMAND cmake -E chdir "${CMAKE_SOURCE_DIR}" "${PYTHON_EXECUTABLE}" "${CMAKE_MODULE_PATH}/cpplint.py" "--filter=${STYLE_FILTER}" ${INNOEXTRACT_SOURCES} ${ALL_INCLUDES} ) diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..c5f073d --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +Inno Extract 1.0 \ No newline at end of file diff --git a/src/InnoExtract.cpp b/src/InnoExtract.cpp index 84e47ca..334031c 100644 --- a/src/InnoExtract.cpp +++ b/src/InnoExtract.cpp @@ -20,6 +20,8 @@ #include #include +#include "version.hpp" + #include "cli/debug.hpp" #include "loader/offsets.hpp" @@ -54,7 +56,12 @@ int main(int argc, char * argv[]) { // logger::debug = true; if(argc <= 1) { - std::cout << "usage: innoextract " << endl; + cout << "usage: innoextract " << endl; + return 1; + } + + if(!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) { + cout << innoextract_version << endl; return 1; } diff --git a/src/cli/debug.cpp b/src/cli/debug.cpp index 8150f7c..4fda478 100644 --- a/src/cli/debug.cpp +++ b/src/cli/debug.cpp @@ -441,7 +441,8 @@ static void print_header(const setup::header & header) { cout << "Uninstall style: " << color::cyan << header.uninstall_style << color::reset << '\n'; cout << "Dir exists warning: " << color::cyan << header.dir_exists_warning << color::reset << '\n'; - cout << if_not_equal("Privileges required", header.privileges_required, setup::header::NoPrivileges); + cout << if_not_equal("Privileges required", header.privileges_required, + setup::header::NoPrivileges); cout << "Show language dialog: " << color::cyan << header.show_language_dialog << color::reset << '\n'; cout << if_not_equal("Danguage detection", header.language_detection, diff --git a/src/setup/info.cpp b/src/setup/info.cpp index bcaed6d..fdae0b8 100644 --- a/src/setup/info.cpp +++ b/src/setup/info.cpp @@ -127,7 +127,7 @@ void info::load(std::istream & ifs, entry_types e, const setup::version & v) { BOOST_FOREACH(setup::message_entry & entry, messages) { if(entry.language >= 0 ? size_t(entry.language) >= languages.size() - : entry.language != -1) { + : entry.language != -1) { log_warning << "unexpected language index: " << entry.language; continue; } diff --git a/src/setup/version.hpp b/src/setup/version.hpp index 6879fc1..3c1809e 100644 --- a/src/setup/version.hpp +++ b/src/setup/version.hpp @@ -15,7 +15,7 @@ typedef uint32_t version_constant; (::setup::version_constant(a) << 24) \ | (::setup::version_constant(b) << 16) \ | (::setup::version_constant(c) << 8) \ - | (::setup::version_constant(d) ) \ + | (::setup::version_constant(d) << 0) \ ) #define INNO_VERSION(a, b, c) INNO_VERSION_EXT(a, b, c, 0) diff --git a/src/version.cpp.in b/src/version.cpp.in new file mode 100644 index 0000000..27c34f1 --- /dev/null +++ b/src/version.cpp.in @@ -0,0 +1,19 @@ + +#include "version.hpp" + +/*! + * This file is automatically processed by cmake if the version or commit id changes. + * Available variables: + * - BASE_VERSION: The contents of the VERSION file. + * - GIT_COMMIT: The current git commit. This variable is not defined if there is no .git directory. + * - GIT_COMMIT_PREFIX_i: The first i characters of the git commit (i=0..39). + * For the exact syntax see the documentation of the configure_file() cmake command. + */ + +#cmakedefine GIT_COMMIT + +#ifdef GIT_COMMIT +const std::string innoextract_version = "${BASE_VERSION} + ${GIT_COMMIT_PREFIX_5}"; +#else +const std::string innoextract_version = "${BASE_VERSION}"; +#endif diff --git a/src/version.hpp b/src/version.hpp new file mode 100644 index 0000000..6e20f56 --- /dev/null +++ b/src/version.hpp @@ -0,0 +1,9 @@ + +#ifndef INNOEXTRACT_VERSION_HPP +#define INNOEXTRACT_VERSION_HPP + +#include + +extern const std::string innoextract_version; + +#endif // INNOEXTRACT_VERSION_HPP