mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-23 16:22:58 +03:00
Merge pull request #471 from aol-nnov/automate-version-generation
Automate version generation
This commit is contained in:
commit
c5b9ac265d
@ -4,5 +4,6 @@ install:
|
||||
- set QTDIR=C:\Qt\5.12\mingw73_64
|
||||
- set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw730_64\bin;%PATH%
|
||||
build_script:
|
||||
- git fetch --prune --tags
|
||||
- qmake LimeReport.pro
|
||||
- mingw32-make
|
||||
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
limereport/version.h.in export-subst
|
38
.github/workflows/cmake.yml
vendored
38
.github/workflows/cmake.yml
vendored
@ -23,7 +23,14 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-tags: true
|
||||
|
||||
# https://github.com/actions/checkout/issues/1781
|
||||
# workaround https://github.com/actions/checkout/issues/1471#issuecomment-1755560284
|
||||
- name: Fetch tags
|
||||
run: git fetch --prune --unshallow --tags
|
||||
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v3
|
||||
@ -57,7 +64,14 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-tags: true
|
||||
|
||||
# https://github.com/actions/checkout/issues/1781
|
||||
# workaround https://github.com/actions/checkout/issues/1471#issuecomment-1755560284
|
||||
- name: Fetch tags
|
||||
run: git fetch --prune --unshallow --tags
|
||||
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v3
|
||||
@ -94,7 +108,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-tags: true
|
||||
|
||||
- name: Install MinGW-w64 packages Qt5
|
||||
if: "startsWith(matrix.qt_version, '5')"
|
||||
@ -107,6 +123,7 @@ jobs:
|
||||
cc:p
|
||||
cmake:p
|
||||
ninja:p
|
||||
git:
|
||||
qt${{ matrix.qt_version }}-base:p
|
||||
qt${{ matrix.qt_version }}-svg:p
|
||||
qt${{ matrix.qt_version }}-tools:p
|
||||
@ -123,11 +140,17 @@ jobs:
|
||||
cc:p
|
||||
cmake:p
|
||||
ninja:p
|
||||
git:
|
||||
qt${{ matrix.qt_version }}-base:p
|
||||
qt${{ matrix.qt_version }}-svg:p
|
||||
qt${{ matrix.qt_version }}-tools:p
|
||||
qt${{ matrix.qt_version }}-declarative:p
|
||||
|
||||
# https://github.com/actions/checkout/issues/1781
|
||||
# workaround https://github.com/actions/checkout/issues/1471#issuecomment-1755560284
|
||||
- name: Fetch tags
|
||||
run: git fetch --prune --unshallow --tags
|
||||
|
||||
- name: Configure CMake for Qt5
|
||||
if: "startsWith(matrix.qt_version, '5')"
|
||||
run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DLIMEREPORT_STATIC=${{ matrix.static }} -DLIMEREPORT_DEMO=ON -B "${{github.workspace}}/build"
|
||||
@ -151,7 +174,14 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-tags: true
|
||||
|
||||
# https://github.com/actions/checkout/issues/1781
|
||||
# workaround https://github.com/actions/checkout/issues/1471#issuecomment-1755560284
|
||||
- name: Fetch tags
|
||||
run: git fetch --prune --unshallow --tags
|
||||
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v3
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -289,5 +289,6 @@ $RECYCLE.BIN/
|
||||
|
||||
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
|
||||
|
||||
limereport/version.h
|
||||
/build/
|
||||
*.app
|
||||
|
@ -1,10 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(limereport)
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${CMAKE_MODULE_PATH}")
|
||||
include(GenerateVersionHeader)
|
||||
|
||||
set(DEFAULT_ITEM_PADDING 0)
|
||||
set(LIMEREPORT_VERSION_MAJOR 1)
|
||||
set(LIMEREPORT_VERSION_MINOR 7)
|
||||
set(LIMEREPORT_VERSION_RELEASE 14)
|
||||
|
||||
option(ENABLE_ZINT "Enable libzint build for barcode support" OFF)
|
||||
option(LIMEREPORT_STATIC "Build LimeReport as static library" OFF)
|
||||
@ -349,14 +349,12 @@ set(EXTRA_FILES
|
||||
${PROJECT_NAME}/lrpreparedpagesintf.h
|
||||
)
|
||||
|
||||
configure_file(config.h.in config.h @ONLY)
|
||||
|
||||
set(GLOBAL_HEADERS
|
||||
${PROJECT_NAME}/LimeReport
|
||||
${PROJECT_NAME}/LRCallbackDS
|
||||
${PROJECT_NAME}/LRDataManager
|
||||
${PROJECT_NAME}/LRScriptManager
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config.h
|
||||
${CMAKE_BINARY_DIR}/limereport/version.h
|
||||
)
|
||||
|
||||
set(PROJECT_NAME ${PROJECT_NAME}-qt${QT_VERSION_MAJOR})
|
||||
@ -371,8 +369,6 @@ else()
|
||||
target_compile_definitions( ${PROJECT_NAME} INTERFACE -DLIMEREPORT_IMPORTS)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC -DCMAKE_CONFIG)
|
||||
|
||||
if(Qt${QT_VERSION_MAJOR}UiTools_FOUND)
|
||||
target_compile_definitions( ${PROJECT_NAME} PRIVATE -DHAVE_UI_LOADER)
|
||||
target_link_libraries( ${PROJECT_NAME} PUBLIC
|
||||
@ -396,6 +392,7 @@ target_compile_definitions( ${PROJECT_NAME} PRIVATE -DDEFAULT_ITEM_PADDING=${DEF
|
||||
|
||||
target_include_directories( ${PROJECT_NAME} PRIVATE
|
||||
limereport/
|
||||
${CMAKE_BINARY_DIR}/limereport
|
||||
limereport/base
|
||||
limereport/bands
|
||||
limereport/databrowser
|
||||
|
28
cmake/modules/GenerateVersionHeader.cmake
Normal file
28
cmake/modules/GenerateVersionHeader.cmake
Normal file
@ -0,0 +1,28 @@
|
||||
find_package(Git)
|
||||
|
||||
if(GIT_EXECUTABLE)
|
||||
# Generate a git-describe version string from Git repository tags
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_DESCRIBE_VERSION
|
||||
RESULT_VARIABLE GIT_DESCRIBE_ERROR_CODE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(NOT GIT_DESCRIBE_ERROR_CODE)
|
||||
set(GIT_VERSION ${GIT_DESCRIBE_VERSION})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Final fallback: Just use a bogus version string that is semantically older
|
||||
# than anything else and spit out a warning to the developer.
|
||||
if(NOT DEFINED GIT_VERSION)
|
||||
set(GIT_VERSION 0.0.0-unknown)
|
||||
message(WARNING "Failed to determine version from Git tags. Using default version \"${GIT_VERSION}\".")
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/limereport/version.h.in
|
||||
${CMAKE_BINARY_DIR}/limereport/version.h
|
||||
@ONLY)
|
||||
|
@ -139,13 +139,6 @@ UI_SOURCES_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/ui
|
||||
OBJECTS_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/obj
|
||||
RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
|
||||
|
||||
LIMEREPORT_VERSION_MAJOR = 1
|
||||
LIMEREPORT_VERSION_MINOR = 7
|
||||
LIMEREPORT_VERSION_RELEASE = 14
|
||||
|
||||
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
|
||||
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"
|
||||
|
||||
QT *= xml sql
|
||||
|
||||
REPORT_PATH = $$PWD/limereport
|
||||
|
@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#cmakedefine LIMEREPORT_VERSION_MAJOR "@LIMEREPORT_VERSION_MAJOR@"
|
||||
#cmakedefine LIMEREPORT_VERSION_MINOR "@LIMEREPORT_VERSION_MINOR@"
|
||||
#cmakedefine LIMEREPORT_VERSION_RELEASE "@LIMEREPORT_VERSION_RELEASE@"
|
||||
|
||||
#define LIMEREPORT_VERSION_STR LIMEREPORT_VERSION_MAJOR"." LIMEREPORT_VERSION_MINOR"." LIMEREPORT_VERSION_RELEASE
|
@ -6,6 +6,7 @@
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QCommandLineParser>
|
||||
#include "../limereport/version.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
|
@ -213,3 +213,19 @@ FORMS += \
|
||||
RESOURCES += \
|
||||
$$REPORT_PATH/report.qrc \
|
||||
$$REPORT_PATH/items/items.qrc
|
||||
|
||||
system("git --version") {
|
||||
LR_VERSION = $$system("git --git-dir=$$PWD/../.git describe --tags --dirty")
|
||||
} else {
|
||||
LR_VERSION = "0.0.0-unknown"
|
||||
}
|
||||
|
||||
VERSION_TEMPLATE = $$PWD/version.h.in
|
||||
|
||||
generateversion.depends = FORCE
|
||||
generateversion.input = VERSION_TEMPLATE
|
||||
generateversion.output = $$OUT_PWD/version.h
|
||||
generateversion.commands = $$QMAKE_STREAM_EDITOR \'s/@GIT_VERSION@/$$LR_VERSION/\' ${QMAKE_FILE_IN} > ${QMAKE_FILE_OUT}
|
||||
generateversion.CONFIG = no_link target_predeps
|
||||
|
||||
QMAKE_EXTRA_COMPILERS += generateversion
|
||||
|
@ -27,9 +27,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifdef CMAKE_CONFIG
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include "version.h"
|
||||
#include "lraboutdialog.h"
|
||||
#include "ui_lraboutdialog.h"
|
||||
|
||||
|
9
limereport/version.h.in
Normal file
9
limereport/version.h.in
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
// git will put "#define GIT_ARCHIVE 1" on the next line inside archives. $Format:%n#define GIT_ARCHIVE 1$
|
||||
|
||||
#ifdef GIT_ARCHIVE
|
||||
#define LIMEREPORT_VERSION_STR "$Format:%(describe:tags=true)$"
|
||||
#else
|
||||
#define LIMEREPORT_VERSION_STR "@GIT_VERSION@"
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user