diff --git a/.github/workflows/bandit.yml b/.github/workflows/bandit.yml index 995b5da22..80b383665 100644 --- a/.github/workflows/bandit.yml +++ b/.github/workflows/bandit.yml @@ -24,6 +24,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Install Bandit run: python3 -m pip install bandit diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index 0853fc848..31cfba774 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -74,6 +74,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Install apt packages run: | @@ -180,6 +182,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Initialize vcpkg uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5 @@ -250,6 +254,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Configure build run: > @@ -290,6 +296,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Configure build run: > @@ -325,6 +333,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Install Python requirements run: python3 -m pip install -r third_party/requirements.txt diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index e6268a0fc..de48173bf 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -27,6 +27,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Install apt packages if: matrix.os == 'ubuntu-latest' diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d59a45089..b449eb23e 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -43,6 +43,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Initialize CodeQL uses: github/codeql-action/init@b7bf0a3ed3ecfa44160715d7c442788f65f0f923 # v3.23.2 diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 8bc624f87..f6fe2ad26 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -24,6 +24,7 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: ref: ${{ github.ref }} + fetch-depth: 0 - name: Install apt packages run: | diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c768746fe..4fdd89766 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -21,6 +21,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Install doxygen run: | diff --git a/.github/workflows/fast.yml b/.github/workflows/fast.yml index 76f4f09ab..a42f0b694 100644 --- a/.github/workflows/fast.yml +++ b/.github/workflows/fast.yml @@ -59,6 +59,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Initialize vcpkg if: matrix.os == 'windows-latest' @@ -139,3 +141,11 @@ jobs: if: matrix.os == 'windows-latest' run: ${{github.workspace}}/.github/scripts/check_dll_flags.ps1 ${{env.BUILD_DIR}}/src/proxy_lib/Release/umf_proxy.dll shell: pwsh + + # TODO: We could add some script to verify metadata of dll's (selected fields, perhaps) + # ref. https://superuser.com/questions/381276/what-are-some-nice-command-line-ways-to-inspect-dll-exe-details + - name: Print metadata of our dll's + if: matrix.os == 'windows-latest' + run: | + get-command ${{github.workspace}}/build/bin/Release/umf.dll | format-list + get-command ${{github.workspace}}/build/src/proxy_lib/Release/umf_proxy.dll | format-list diff --git a/.github/workflows/gpu.yml b/.github/workflows/gpu.yml index 444ebdfe4..3024b9f7e 100644 --- a/.github/workflows/gpu.yml +++ b/.github/workflows/gpu.yml @@ -36,6 +36,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Get information about platform if: matrix.os == 'Ubuntu' diff --git a/.github/workflows/multi_numa.yml b/.github/workflows/multi_numa.yml index 4b8079c61..a9433018e 100644 --- a/.github/workflows/multi_numa.yml +++ b/.github/workflows/multi_numa.yml @@ -20,6 +20,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Get information about platform run: .github/scripts/get_system_info.sh diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c03cd0d0e..28a07c3a9 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -24,6 +24,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Install apt packages run: | @@ -59,6 +61,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Install apt packages run: | diff --git a/.github/workflows/pr_push.yml b/.github/workflows/pr_push.yml index 525e4ac9e..c35664a56 100644 --- a/.github/workflows/pr_push.yml +++ b/.github/workflows/pr_push.yml @@ -22,6 +22,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Install apt packages run: | @@ -55,6 +57,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Install doxygen run: | diff --git a/.github/workflows/proxy_lib.yml b/.github/workflows/proxy_lib.yml index 43309b153..8d73569f0 100644 --- a/.github/workflows/proxy_lib.yml +++ b/.github/workflows/proxy_lib.yml @@ -25,6 +25,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Install apt packages run: | diff --git a/.github/workflows/qemu.yml b/.github/workflows/qemu.yml index 946a7edd2..f8916c7de 100644 --- a/.github/workflows/qemu.yml +++ b/.github/workflows/qemu.yml @@ -17,6 +17,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + - name: Enable KVM run: | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index d3a4cd4b8..06ad492eb 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -23,6 +23,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Install apt packages run: | @@ -88,6 +90,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 # Use the latest MSVC toolset available, when compiling UMF with ASan. # Running binaries compiled with older toolsets results in a diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 5c38a247b..b28bb150e 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -27,6 +27,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Run analysis uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1 diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index ec2e2d2b1..07265fc17 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -14,6 +14,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Run a spell check uses: crate-ci/typos@b63f421581dce830bda2f597a678cb7776b41877 # v1.18.2 diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index 2839ef1c1..1c3e63120 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -31,6 +31,8 @@ jobs: steps: - name: Clone the git repo uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Run Trivy uses: aquasecurity/trivy-action@84384bd6e777ef152729993b8145ea352e9dd3ef # v0.17.0 diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 99552f9a1..0ca9bf779 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -17,6 +17,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 - name: Install apt packages run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 0957649eb..e84a45097 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,32 +3,35 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR) -project( - umf - VERSION 0.1.0 - LANGUAGES C) - # needed when UMF is used as an external project set(UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) list(APPEND CMAKE_MODULE_PATH "${UMF_CMAKE_SOURCE_DIR}/cmake") -include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake) +include(helpers) + +# We use semver aligned version, set via git tags. We parse git output to +# establih the version of UMF to be used in CMake, Win dll's, and within the +# code (e.g. in logger). We have 3-component releases (e.g. 1.5.1) plus release +# candidates and git info. Function below sets all variables related to version. +set_version_variables() +message(STATUS "UMF version: ${UMF_VERSION}") + +# version we set in CMake is abbreviated just to major.minor.patch +project( + umf + VERSION ${UMF_CMAKE_VERSION} + LANGUAGES C) + +if(CMAKE_PROJECT_VERSION_PATCH GREATER 0) + # set extra variable for Windows dll metadata + set(UMF_VERSION_BUGFIX 1) +endif() include(CTest) include(CMakePackageConfigHelpers) include(GNUInstallDirs) find_package(PkgConfig) -# CMAKE_PROJECT_VERSION[_MAJOR|_MINOR|_PATCH] variables are set via 'project' -# command. They cannot contain any "pre-release" part, though. We use custom -# "UMF_SRC_VERSION" to store more accurate (source) version - this var should be -# used, e.g., for creating packages. -set_source_version() -message( - STATUS - "UMF version: ${CMAKE_PROJECT_VERSION} (source version: ${UMF_SRC_VERSION})" -) - # Build Options option(UMF_BUILD_SHARED_LIBRARY "Build UMF as shared library" OFF) option(UMF_BUILD_LEVEL_ZERO_PROVIDER "Build Level Zero memory provider" ON) diff --git a/RELEASE_STEPS.md b/RELEASE_STEPS.md index ad463caf0..e88ca9c2d 100644 --- a/RELEASE_STEPS.md +++ b/RELEASE_STEPS.md @@ -40,7 +40,7 @@ Do changes for a release: - Add an entry to ChangeLog, remember to change the day of the week in the release date - For major releases mention API and ABI compatibility with the previous release - Update project's version in a few places: - - Set the new $VERSION in `project` function in the top-level `CMakeLists.txt` + - For major and minor releases: `UMF_VERSION_CURRENT` in `include/umf/base.h` (the API version) - `release` variable in `scripts/docs_config/conf.py` (for docs) - `UMF_VERSION` variable in `.github/workflows/basic.yml` (for installation test) - For major releases update ABI version in `.map` and `.def` files diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake index f401cfb48..bb9b703d8 100644 --- a/cmake/helpers.cmake +++ b/cmake/helpers.cmake @@ -10,68 +10,158 @@ include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) -# src version shows the current version, as reported by 'git describe', unless -# 'git' is not available, then fall back to the top-level defined version -function(set_source_version) +# This function establishes version variables based on the git describe output. +# If there's no git available in the system, the version will be set to "0.0.0". +# If git reports only a hash, the version will be set to "0.0.0.git.". +# Otherwise we'll use 3-component version: major.minor.patch, just for CMake's +# sake. A few extra variables will be set for Win dll metadata. +# +# Important note: CMake does not support rc or git information. According to +# semver rules, 1.5.1-rc1 should be less than 1.5.1, but it seems hard to +# achieve such comparison in CMake. So, for CMake's sake we only set 3-component +# version in variable "UMF_CMAKE_VERSION", ignoring the rc and git information. +# It's only used to set SOVERSION and creating "umf-config.cmake" file. +# +# For Windows versioning in dll metadata, we use 4-component version plus a few +# additional variables. REVISION has to be an integer and is calculated as: +# REVISION = rc_no * 1000 + git_commit_no (commits count after the last release) +# +# For all other usages (beside CMake and Win dll), we use semver aligned version +# "UMF_VERSION", which is in line with our tags (e.g. "1.5.0-rc2"). +# +# Example parsing of git output: +# cmake-format: off +# +-----------------------+-------+-------+-------+----------+--------+---------+------------+ +# | \ CMake:| Major | Minor | Patch | | | | | +# +-----------------------+-------+-------+-------+----------+--------+---------+------------+ +# | git describe \ Win32:| MAJOR | MINOR | BUILD | REVISION | BUGFIX | PRIVATE | PRERELEASE | +# +-----------------------+-------+-------+-------+----------+--------+---------+------------+ +# | 1.5.0-rc2-0-gb8f7a32 | 1 | 5 | 0 | 2000 | | | true | +# | 1.5.0-rc2 | 1 | 5 | 0 | 2000 | | | true | +# | 1.5.0-rc3-6-gb8f7a32 | 1 | 5 | 0 | 3006 | | true | true | +# | 1.5.0-0-gb8f7a32 | 1 | 5 | 0 | 0 | | | | +# | 1.5.0 | 1 | 5 | 0 | 0 | | | | +# | 1.5.0-6-123345678 | 1 | 5 | 0 | 6 | | true | | +# | 1.5.2-rc1-0-gb8f7a32 | 1 | 5 | 2 | 1000 | true | | true | +# | 1.5.2-rc4-6-gb8f7a32 | 1 | 5 | 2 | 4006 | true | true | true | +# | 1.5.2-0-gb8f7a32 | 1 | 5 | 2 | 0 | true | | | +# | 1.5.2-6-gb8f7a32 | 1 | 5 | 2 | 6 | true | true | | +# | gb8f7a32 | 0 | 0 | 0 | 0 | | true | | +# | ? (no git) | 0 | 0 | 0 | 0 | | true | | +# +-----------------------+-------+-------+-------+----------+--------+---------+------------+ +# cmake-format: on +function(set_version_variables) + # default values + set(UMF_VERSION_PRERELEASE + 0 + PARENT_SCOPE) + set(UMF_VERSION_PRIVATE + 1 + PARENT_SCOPE) + set(UMF_VERSION_BUGFIX + 0 + PARENT_SCOPE) + set(UMF_VERSION_REVISION + 0 + PARENT_SCOPE) + set(UMF_CMAKE_VERSION + "0.0.0" + PARENT_SCOPE) + set(UMF_VERSION + "0.0.0" + PARENT_SCOPE) + execute_process( COMMAND git describe --always OUTPUT_VARIABLE GIT_VERSION WORKING_DIRECTORY ${UMF_CMAKE_SOURCE_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) - if(GIT_VERSION) - # 1.5.0 - we're on a tag - string(REGEX MATCHALL "\^([0-9]+\.[0-9]+\.[0-9]+)\$" MATCHES - ${GIT_VERSION}) - if(MATCHES) - set(UMF_SRC_VERSION - "${CMAKE_MATCH_1}" - PARENT_SCOPE) - return() - endif() + if(NOT GIT_VERSION) + # no git or it reported no version. Use default ver: "0.0.0" + return() + endif() - # 1.5.0-rc1 - we're on a RC tag - string(REGEX MATCHALL "\^([0-9]+\.[0-9]+\.[0-9]+\-rc[0-9]+)\$" MATCHES - ${GIT_VERSION}) - if(MATCHES) - set(UMF_SRC_VERSION - "${CMAKE_MATCH_1}" - PARENT_SCOPE) - return() - endif() + # v1.5.0 - we're exactly on a tag -> UMF ver: "1.5.0" + string(REGEX MATCHALL "\^v([0-9]+\.[0-9]+\.[0-9]+)\$" MATCHES + ${GIT_VERSION}) + if(MATCHES) + set(UMF_VERSION + "${CMAKE_MATCH_1}" + PARENT_SCOPE) + set(UMF_CMAKE_VERSION + "${CMAKE_MATCH_1}" + PARENT_SCOPE) + set(UMF_VERSION_PRIVATE + 0 + PARENT_SCOPE) + return() + endif() - # 1.5.0-rc1-19-gb8f78a329 -> 1.5.0-rc1.git19.gb8f78a329 - string(REGEX MATCHALL "([0-9.]*)-rc([0-9]*)-([0-9]*)-([0-9a-g]*)" - MATCHES ${GIT_VERSION}) - if(MATCHES) - set(UMF_SRC_VERSION - "${CMAKE_MATCH_1}-rc${CMAKE_MATCH_2}.git${CMAKE_MATCH_3}.${CMAKE_MATCH_4}" - PARENT_SCOPE) - return() - endif() + # v1.5.0-rc1 - we're on a RC tag -> UMF ver: "1.5.0-rc1" + string(REGEX MATCHALL "\^v([0-9]+\.[0-9]+\.[0-9]+)-rc([0-9]+)\$" MATCHES + ${GIT_VERSION}) + if(MATCHES) + set(UMF_VERSION + "${CMAKE_MATCH_1}-rc${CMAKE_MATCH_2}" + PARENT_SCOPE) + set(UMF_CMAKE_VERSION + "${CMAKE_MATCH_1}" + PARENT_SCOPE) + math(EXPR revision "${CMAKE_MATCH_2} * 1000") + set(UMF_VERSION_REVISION + ${revision} + PARENT_SCOPE) + set(UMF_VERSION_PRERELEASE + 1 + PARENT_SCOPE) + set(UMF_VERSION_PRIVATE + 0 + PARENT_SCOPE) + return() + endif() - # 1.5.0-19-gb8f78a329 -> 1.5.0-git19.gb8f78a329 - string(REGEX MATCHALL "([0-9.]*)-([0-9]*)-([0-9a-g]*)" MATCHES - ${GIT_VERSION}) - if(MATCHES) - set(UMF_SRC_VERSION - "${CMAKE_MATCH_1}-git${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" - PARENT_SCOPE) - return() - endif() + # v1.5.0-rc1-19-gb8f7a32 -> UMF ver: "1.5.0-rc1.git19.gb8f7a32" + string(REGEX MATCHALL "v([0-9.]*)-rc([0-9]*)-([0-9]*)-([0-9a-g]*)" MATCHES + ${GIT_VERSION}) + if(MATCHES) + set(UMF_VERSION + "${CMAKE_MATCH_1}-rc${CMAKE_MATCH_2}.git${CMAKE_MATCH_3}.${CMAKE_MATCH_4}" + PARENT_SCOPE) + set(UMF_CMAKE_VERSION + "${CMAKE_MATCH_1}" + PARENT_SCOPE) + math(EXPR revision "${CMAKE_MATCH_2} * 1000 + ${CMAKE_MATCH_3}") + set(UMF_VERSION_REVISION + ${revision} + PARENT_SCOPE) + set(UMF_VERSION_PRERELEASE + 1 + PARENT_SCOPE) + return() + endif() - # no full version is available (e.g. only a hash commit) or a pattern - # was not recognized - set(UMF_SRC_VERSION - "${CMAKE_PROJECT_VERSION}.git.${GIT_VERSION}" + # v1.5.0-19-gb8f7a32 -> UMF ver: "1.5.0-git19.gb8f7a32" + string(REGEX MATCHALL "v([0-9.]*)-([0-9]*)-([0-9a-g]*)" MATCHES + ${GIT_VERSION}) + if(MATCHES) + set(UMF_VERSION + "${CMAKE_MATCH_1}-git${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" + PARENT_SCOPE) + set(UMF_CMAKE_VERSION + "${CMAKE_MATCH_1}" PARENT_SCOPE) - else() - # git reported no version. Use version set up in the top-level CMake - # with a "devel" suffix - set(UMF_SRC_VERSION - "${CMAKE_PROJECT_VERSION}-devel" + set(UMF_VERSION_REVISION + ${CMAKE_MATCH_2} PARENT_SCOPE) + return() endif() + + # no full version is available (e.g. only a hash commit) or a pattern was + # not recognized -> UMF ver: "0.0.0.git." + set(UMF_VERSION + "0.0.0.git.${GIT_VERSION}" + PARENT_SCOPE) endfunction() # Sets ${ret} to version of program specified by ${name} in major.minor format diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a856ac826..c261ac6ed 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,6 +4,11 @@ include(${UMF_CMAKE_SOURCE_DIR}/cmake/helpers.cmake) +# Compile definitions for UMF library. +# +# TODO: Cleanup the compile definitions across all the CMake files +set(UMF_COMMON_COMPILE_DEFINITIONS UMF_VERSION=${UMF_VERSION}) + if(UMF_BUILD_LEVEL_ZERO_PROVIDER) include(FetchContent) @@ -78,11 +83,6 @@ set(UMF_SOURCES_MACOSX libumf_linux.c) set(UMF_SOURCES_WINDOWS libumf_windows.c) -# Compile definitions for UMF library. -# -# TODO: Cleanup the compile definitions across all the CMake files -set(UMF_PRIVATE_COMPILE_DEFINITIONS UMF_SRC_VERSION=${UMF_SRC_VERSION}) - set(UMF_SOURCES_COMMON_LINUX_MACOSX provider/provider_os_memory.c provider/provider_os_memory_posix.c @@ -128,8 +128,8 @@ if(UMF_BUILD_SHARED_LIBRARY) LIBS ${UMF_LIBS} hwloc LINUX_MAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libumf.map WINDOWS_DEF_FILE ${CMAKE_CURRENT_BINARY_DIR}/libumf.def) - set(UMF_PRIVATE_COMPILE_DEFINITIONS ${UMF_PRIVATE_COMPILE_DEFINITIONS} - "UMF_SHARED_LIBRARY") + set(UMF_COMMON_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS} + "UMF_SHARED_LIBRARY") set_target_properties( umf PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_UMF_OUTPUT_DIRECTORY} @@ -149,7 +149,7 @@ endif() target_link_directories(umf PRIVATE ${UMF_PRIVATE_LIBRARY_DIRS}) -target_compile_definitions(umf PRIVATE ${UMF_PRIVATE_COMPILE_DEFINITIONS}) +target_compile_definitions(umf PRIVATE ${UMF_COMMON_COMPILE_DEFINITIONS}) if(UMF_BUILD_LEVEL_ZERO_PROVIDER) target_sources(umf PRIVATE provider/provider_level_zero.c) diff --git a/src/libumf.rc.in b/src/libumf.rc.in index f4ddd3653..9d0677f6d 100644 --- a/src/libumf.rc.in +++ b/src/libumf.rc.in @@ -8,18 +8,38 @@ #include "umf/base.h" -#define UMF_VERNUMBERS @CMAKE_PROJECT_VERSION_MAJOR@,@CMAKE_PROJECT_VERSION_MINOR@,@CMAKE_PROJECT_VERSION_PATCH@,0 -#define UMF_VERSION "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@" +#define UMF_VERNUMBERS @CMAKE_PROJECT_VERSION_MAJOR@,@CMAKE_PROJECT_VERSION_MINOR@,@CMAKE_PROJECT_VERSION_PATCH@,@UMF_VERSION_REVISION@ +#define UMF_VERSION "@UMF_VERSION@" + +#ifdef _DEBUG +#define VERSION_DEBUG VS_FF_DEBUG +#else +#define VERSION_DEBUG 0 +#endif + +#if @UMF_VERSION_PRERELEASE@ +#define VERSION_PRERELEASE VS_FF_PRERELEASE +#else +#define VERSION_PRERELEASE 0 +#endif + +#if @UMF_VERSION_PRIVATE@ +#define VERSION_PRIVATE VS_FF_PRIVATEBUILD +#else +#define VERSION_PRIVATE 0 +#endif + +#if @UMF_VERSION_BUGFIX@ +#define VERSION_PATCHED VS_FF_PATCHED +#else +#define VERSION_PATCHED 0 +#endif VS_VERSION_INFO VERSIONINFO FILEVERSION UMF_VERNUMBERS PRODUCTVERSION UMF_VERNUMBERS FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0 -#endif + FILEFLAGS (VERSION_DEBUG | VERSION_PRIVATE | VERSION_PRERELEASE | VERSION_PATCHED) FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE 0 diff --git a/src/pool/CMakeLists.txt b/src/pool/CMakeLists.txt index 787cc1ea9..bdd196b04 100644 --- a/src/pool/CMakeLists.txt +++ b/src/pool/CMakeLists.txt @@ -4,10 +4,11 @@ if(UMF_BUILD_SHARED_LIBRARY) set(POOL_EXTRA_SRCS ${BA_SOURCES}) - set(POOL_COMPILE_DEFINITIONS UMF_SHARED_LIBRARY) set(POOL_EXTRA_LIBS $) endif() +set(POOL_COMPILE_DEFINITIONS ${UMF_COMMON_COMPILE_DEFINITIONS}) + # libumf_pool_disjoint if(UMF_BUILD_LIBUMF_POOL_DISJOINT) add_umf_library( diff --git a/src/proxy_lib/CMakeLists.txt b/src/proxy_lib/CMakeLists.txt index 0d36e0258..379a454d0 100644 --- a/src/proxy_lib/CMakeLists.txt +++ b/src/proxy_lib/CMakeLists.txt @@ -39,7 +39,7 @@ add_library(${PROJECT_NAME}::proxy ALIAS umf_proxy) target_link_directories(umf_proxy PRIVATE ${LIBHWLOC_LIBRARY_DIRS}) -target_compile_definitions(umf_proxy PRIVATE UMF_SRC_VERSION=${UMF_SRC_VERSION}) +target_compile_definitions(umf_proxy PRIVATE ${UMF_COMMON_COMPILE_DEFINITIONS}) if(PROXY_LIB_USES_SCALABLE_POOL) target_compile_definitions(umf_proxy PRIVATE PROXY_LIB_USES_SCALABLE_POOL=1) diff --git a/src/proxy_lib/proxy_lib.rc.in b/src/proxy_lib/proxy_lib.rc.in index d8f3fec27..66910afc4 100644 --- a/src/proxy_lib/proxy_lib.rc.in +++ b/src/proxy_lib/proxy_lib.rc.in @@ -8,18 +8,38 @@ #include "umf/base.h" -#define UMF_VERNUMBERS @CMAKE_PROJECT_VERSION_MAJOR@,@CMAKE_PROJECT_VERSION_MINOR@,@CMAKE_PROJECT_VERSION_PATCH@,0 -#define UMF_VERSION "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@" +#define UMF_VERNUMBERS @CMAKE_PROJECT_VERSION_MAJOR@,@CMAKE_PROJECT_VERSION_MINOR@,@CMAKE_PROJECT_VERSION_PATCH@,@UMF_VERSION_REVISION@ +#define UMF_VERSION "@UMF_VERSION@" + +#ifdef _DEBUG +#define VERSION_DEBUG VS_FF_DEBUG +#else +#define VERSION_DEBUG 0 +#endif + +#if @UMF_VERSION_PRERELEASE@ +#define VERSION_PRERELEASE VS_FF_PRERELEASE +#else +#define VERSION_PRERELEASE 0 +#endif + +#if @UMF_VERSION_PRIVATE@ +#define VERSION_PRIVATE VS_FF_PRIVATEBUILD +#else +#define VERSION_PRIVATE 0 +#endif + +#if @UMF_VERSION_BUGFIX@ +#define VERSION_PATCHED VS_FF_PATCHED +#else +#define VERSION_PATCHED 0 +#endif VS_VERSION_INFO VERSIONINFO FILEVERSION UMF_VERNUMBERS PRODUCTVERSION UMF_VERNUMBERS FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0 -#endif + FILEFLAGS (VERSION_DEBUG | VERSION_PRIVATE | VERSION_PRERELEASE | VERSION_PATCHED) FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE 0 diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 051cdbc35..78cd0e129 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -52,5 +52,10 @@ target_include_directories( $) if(USE_VALGRIND) - target_compile_definitions(umf_utils INTERFACE UMF_VG_ENABLED=1) + set(UMF_UTILS_INTERFACE_DEFS "UMF_VG_ENABLED=1") endif() + +set(UMF_UTILS_INTERFACE_DEFS ${UMF_UTILS_INTERFACE_DEFS} + ${UMF_COMMON_COMPILE_DEFINITIONS}) + +target_compile_definitions(umf_utils INTERFACE ${UMF_UTILS_INTERFACE_DEFS}) diff --git a/src/utils/utils_log.c b/src/utils/utils_log.c index d8e8023c6..ca16014f0 100644 --- a/src/utils/utils_log.c +++ b/src/utils/utils_log.c @@ -305,20 +305,18 @@ void util_log_init(void) { loggerConfig.flushLevel = LOG_FATAL; } -#ifdef UMF_SRC_VERSION +#ifdef UMF_VERSION // convert a define to a C string #define STR_(X) #X #define STR(X) STR_(X) -#define STR_UMF_SRC_VERSION "src version: " STR(UMF_SRC_VERSION) ", " -#else /* !UMF_SRC_VERSION */ -#define STR_UMF_SRC_VERSION "" -#endif /* !UMF_SRC_VERSION */ +#define STR_UMF_VERSION "UMF version: " STR(UMF_VERSION) ", " +#else /* !UMF_VERSION */ +#error "UMF_VERSION not defined!" +#endif /* !UMF_VERSION */ - int umf_ver = umfGetCurrentVersion(); LOG_INFO( - "Logger enabled (umf version: %i.%i, " STR_UMF_SRC_VERSION + "Logger enabled (" STR_UMF_VERSION "level: %s, flush: %s, pid: %s, timestamp: %s)", - UMF_MAJOR_VERSION(umf_ver), UMF_MINOR_VERSION(umf_ver), level_to_str(loggerConfig.level), level_to_str(loggerConfig.flushLevel), bool_to_str(loggerConfig.pid), bool_to_str(loggerConfig.timestamp)); } diff --git a/test/utils/utils_log.cpp b/test/utils/utils_log.cpp index 235ae7816..3e899e685 100644 --- a/test/utils/utils_log.cpp +++ b/test/utils/utils_log.cpp @@ -107,6 +107,7 @@ const char *env_variable = ""; #define strerror_s(A, B, C) mock_strerror_windows(A, B, C) //getenv returns 'char *' not 'const char *' so we need explicit cast to drop const #define getenv(X) strstr(X, "UMF_LOG") ? (char *)env_variable : getenv(X) +#define UMF_VERSION "test version" #include "utils/utils_log.c" #undef util_env_var #undef fopen