Added automatic executable version updates
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -21,7 +21,7 @@ bin/
|
||||
docs/diagrams
|
||||
|
||||
coverage*.info
|
||||
|
||||
packaging/_BUILD
|
||||
|
||||
# CLion
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
|
||||
@@ -16,6 +18,7 @@ set(CLANG_UML_INSTALL_BIN_DIR ${PROJECT_SOURCE_DIR}/bin)
|
||||
set(UML_HEADERS_DIR ${PROJECT_SOURCE_DIR}/src/uml)
|
||||
|
||||
option(LLVM_CONFIG_PATH "Path to custom llvm-config executable")
|
||||
option(GIT_VERSION "clang-uml version" "0.1.0")
|
||||
|
||||
if(LLVM_CONFIG_PATH)
|
||||
message(STATUS "Using llvm-config from ${LLVM_CONFIG_PATH}")
|
||||
@@ -45,6 +48,10 @@ find_package(LLVM REQUIRED CONFIG)
|
||||
set(CLANG_INCLUDE_DIRS "llvm/clang/include")
|
||||
set(CLANG_LIBS clang)
|
||||
|
||||
# Configure executable version
|
||||
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/src/version)
|
||||
configure_file(src/version.h.in ${PROJECT_BINARY_DIR}/src/version/version.h)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
execute_process(COMMAND gcc --print-file-name=include
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
@@ -61,6 +68,8 @@ include_directories(${THIRDPARTY_HEADERS_DIR}/cppast/include)
|
||||
include_directories(${THIRDPARTY_HEADERS_DIR}/cppast/external/type_safe/include)
|
||||
include_directories(${THIRDPARTY_HEADERS_DIR}/cppast/external/type_safe/external/debug_assert)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src/)
|
||||
include_directories(${PROJECT_BINARY_DIR}/src/version)
|
||||
|
||||
|
||||
file(GLOB_RECURSE SOURCES src/*.cc include/*.h)
|
||||
set(MAIN_SOURCE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cc)
|
||||
|
||||
4
Makefile
4
Makefile
@@ -26,12 +26,15 @@ LLVM_CONFIG_PATH ?=
|
||||
CMAKE_CXX_FLAGS ?=
|
||||
CMAKE_EXE_LINKER_FLAGS ?=
|
||||
|
||||
GIT_VERSION ?= $(shell git describe --tags --always --abbrev=7)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf debug release
|
||||
|
||||
debug/CMakeLists.txt:
|
||||
cmake -S . -B debug \
|
||||
-DGIT_VERSION=$(GIT_VERSION) \
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DCMAKE_CXX_FLAGS="$(CMAKE_CXX_FLAGS)" \
|
||||
@@ -40,6 +43,7 @@ debug/CMakeLists.txt:
|
||||
|
||||
release/CMakeLists.txt:
|
||||
cmake -S . -B release \
|
||||
-DGIT_VERSION=$(GIT_VERSION) \
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_CXX_FLAGS="$(CMAKE_CXX_FLAGS)" \
|
||||
|
||||
20
src/main.cc
20
src/main.cc
@@ -21,8 +21,8 @@
|
||||
#include "include_diagram/generators/plantuml/include_diagram_generator.h"
|
||||
#include "package_diagram/generators/plantuml/package_diagram_generator.h"
|
||||
#include "sequence_diagram/generators/plantuml/sequence_diagram_generator.h"
|
||||
|
||||
#include "util/util.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <cli11/CLI11.hpp>
|
||||
#include <cppast/libclang_parser.hpp>
|
||||
@@ -38,6 +38,8 @@
|
||||
using namespace clanguml;
|
||||
using config::config;
|
||||
|
||||
void print_version();
|
||||
|
||||
void print_diagrams_list(const clanguml::config::config &cfg);
|
||||
|
||||
bool check_output_directory(const std::string &dir);
|
||||
@@ -55,6 +57,7 @@ int main(int argc, const char *argv[])
|
||||
std::vector<std::string> diagram_names{};
|
||||
std::optional<std::string> output_directory;
|
||||
unsigned int thread_count{0};
|
||||
bool show_version{false};
|
||||
bool verbose{false};
|
||||
bool list_diagrams{false};
|
||||
|
||||
@@ -68,12 +71,18 @@ int main(int argc, const char *argv[])
|
||||
"Override output directory specified in config file");
|
||||
app.add_option("-t,--thread-count", thread_count,
|
||||
"Thread pool size (0 = hardware concurrency)");
|
||||
app.add_flag("-V,--version", show_version, "Print version and exit");
|
||||
app.add_flag("-v,--verbose", verbose, "Verbose logging");
|
||||
app.add_flag("-l,--list-diagrams", list_diagrams,
|
||||
"Print list of diagrams defined in the config file");
|
||||
|
||||
CLI11_PARSE(app, argc, argv);
|
||||
|
||||
if (show_version) {
|
||||
print_version();
|
||||
return 0;
|
||||
}
|
||||
|
||||
clanguml::util::setup_logging(verbose);
|
||||
|
||||
clanguml::config::config config;
|
||||
@@ -223,6 +232,15 @@ bool check_output_directory(const std::string &dir)
|
||||
return true;
|
||||
}
|
||||
|
||||
void print_version()
|
||||
{
|
||||
std::cout << "clang-uml " << clanguml::version::CLANG_UML_VERSION << '\n';
|
||||
std::cout << "Copyright (C) 2021-2022 Bartek Kryza <bkryza@gmail.com>"
|
||||
<< '\n';
|
||||
std::cout << "Built with libclang: "
|
||||
<< clanguml::version::CLANG_UML_LIBCLANG_VERSION << std::endl;
|
||||
}
|
||||
|
||||
void print_diagrams_list(const clanguml::config::config &cfg)
|
||||
{
|
||||
using std::cout;
|
||||
|
||||
23
src/version.h.in
Normal file
23
src/version.h.in
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* src/version.h
|
||||
*
|
||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace clanguml::version {
|
||||
static constexpr auto CLANG_UML_VERSION = "@GIT_VERSION@";
|
||||
static constexpr auto CLANG_UML_LIBCLANG_VERSION = "@LIBCLANG_VERSION_STRING@";
|
||||
} // namespace clanguml::version
|
||||
Reference in New Issue
Block a user