mirror of
https://github.com/azahar-emu/azahar.git
synced 2026-06-06 02:33:44 -04:00
cmake: Version info generation improvements
- Allow GIT-COMMIT and GIT-TAG files to override real git info (useful for testing version-related functionality such as update checks) - Always re-configure scm_rev.cpp when configuring with CMake (fixes an issue where the version number would just not update in incremental builds)
This commit is contained in:
parent
93e831decb
commit
efccedbbd2
4 changed files with 20 additions and 71 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -56,3 +56,7 @@ repo/
|
||||||
.ccache/
|
.ccache/
|
||||||
node_modules/
|
node_modules/
|
||||||
VULKAN_SDK/
|
VULKAN_SDK/
|
||||||
|
|
||||||
|
# Version info files
|
||||||
|
GIT-COMMIT
|
||||||
|
GIT-TAG
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
macro(generate_build_info)
|
macro(generate_build_info)
|
||||||
|
find_package(Git QUIET)
|
||||||
|
|
||||||
# Gets a UTC timstamp and sets the provided variable to it
|
# Gets a UTC timstamp and sets the provided variable to it
|
||||||
function(get_timestamp _var)
|
function(get_timestamp _var)
|
||||||
string(TIMESTAMP timestamp UTC)
|
string(TIMESTAMP timestamp UTC)
|
||||||
|
|
@ -6,9 +8,14 @@ macro(generate_build_info)
|
||||||
endfunction()
|
endfunction()
|
||||||
get_timestamp(BUILD_DATE)
|
get_timestamp(BUILD_DATE)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${SRC_DIR}/externals/cmake-modules")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules")
|
||||||
|
|
||||||
if (EXISTS "${SRC_DIR}/.git/objects")
|
if (EXISTS "${CMAKE_SOURCE_DIR}/GIT-COMMIT" AND EXISTS "${CMAKE_SOURCE_DIR}/GIT-TAG")
|
||||||
|
file(READ "${CMAKE_SOURCE_DIR}/GIT-COMMIT" GIT_REV_RAW LIMIT 64)
|
||||||
|
string(STRIP "${GIT_REV_RAW}" GIT_REV)
|
||||||
|
string(SUBSTRING "${GIT_REV_RAW}" 0 9 GIT_DESC)
|
||||||
|
set(GIT_BRANCH "HEAD")
|
||||||
|
elseif (EXISTS "${CMAKE_SOURCE_DIR}/.git/objects")
|
||||||
# Find the package here with the known path so that the GetGit commands can find it as well
|
# Find the package here with the known path so that the GetGit commands can find it as well
|
||||||
find_package(Git QUIET PATHS "${GIT_EXECUTABLE}")
|
find_package(Git QUIET PATHS "${GIT_EXECUTABLE}")
|
||||||
|
|
||||||
|
|
@ -17,12 +24,6 @@ macro(generate_build_info)
|
||||||
get_git_head_revision(GIT_REF_SPEC GIT_REV)
|
get_git_head_revision(GIT_REF_SPEC GIT_REV)
|
||||||
git_describe(GIT_DESC --always --long --dirty)
|
git_describe(GIT_DESC --always --long --dirty)
|
||||||
git_branch_name(GIT_BRANCH)
|
git_branch_name(GIT_BRANCH)
|
||||||
elseif (EXISTS "${SRC_DIR}/GIT-COMMIT" AND EXISTS "${SRC_DIR}/GIT-TAG")
|
|
||||||
# unified source archive
|
|
||||||
file(READ "${SRC_DIR}/GIT-COMMIT" GIT_REV_RAW LIMIT 64)
|
|
||||||
string(STRIP "${GIT_REV_RAW}" GIT_REV)
|
|
||||||
string(SUBSTRING "${GIT_REV_RAW}" 0 9 GIT_DESC)
|
|
||||||
set(GIT_BRANCH "HEAD")
|
|
||||||
else()
|
else()
|
||||||
# self-packed archive?
|
# self-packed archive?
|
||||||
set(GIT_REV "UNKNOWN")
|
set(GIT_REV "UNKNOWN")
|
||||||
|
|
@ -39,8 +40,8 @@ macro(generate_build_info)
|
||||||
if ($ENV{GITHUB_REF_TYPE} STREQUAL "tag")
|
if ($ENV{GITHUB_REF_TYPE} STREQUAL "tag")
|
||||||
set(GIT_TAG $ENV{GITHUB_REF_NAME})
|
set(GIT_TAG $ENV{GITHUB_REF_NAME})
|
||||||
endif()
|
endif()
|
||||||
elseif (EXISTS "${SRC_DIR}/GIT-COMMIT" AND EXISTS "${SRC_DIR}/GIT-TAG")
|
elseif (EXISTS "${CMAKE_SOURCE_DIR}/GIT-COMMIT" AND EXISTS "${CMAKE_SOURCE_DIR}/GIT-TAG")
|
||||||
file(READ "${SRC_DIR}/GIT-TAG" GIT_TAG)
|
file(READ "${CMAKE_SOURCE_DIR}/GIT-TAG" GIT_TAG)
|
||||||
string(STRIP ${GIT_TAG} GIT_TAG)
|
string(STRIP ${GIT_TAG} GIT_TAG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
list(APPEND CMAKE_MODULE_PATH "${SRC_DIR}/CMakeModules")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules")
|
||||||
|
|
||||||
include(GenerateBuildInfo)
|
include(GenerateBuildInfo)
|
||||||
generate_build_info()
|
generate_build_info()
|
||||||
|
|
||||||
# The variable SRC_DIR must be passed into the script (since it uses the current build directory for all values of CMAKE_*_DIR)
|
# The variable SRC_DIR must be passed into the script (since it uses the current build directory for all values of CMAKE_*_DIR)
|
||||||
set(VIDEO_CORE "${SRC_DIR}/src/video_core")
|
set(VIDEO_CORE "${CMAKE_SOURCE_DIR}/src/video_core")
|
||||||
set(HASH_FILES
|
set(HASH_FILES
|
||||||
"${VIDEO_CORE}/renderer_opengl/gl_shader_disk_cache.cpp"
|
"${VIDEO_CORE}/renderer_opengl/gl_shader_disk_cache.cpp"
|
||||||
"${VIDEO_CORE}/renderer_opengl/gl_shader_disk_cache.h"
|
"${VIDEO_CORE}/renderer_opengl/gl_shader_disk_cache.h"
|
||||||
|
|
@ -47,4 +48,4 @@ foreach (F IN LISTS HASH_FILES)
|
||||||
set(COMBINED "${COMBINED}${TMP}")
|
set(COMBINED "${COMBINED}${TMP}")
|
||||||
endforeach()
|
endforeach()
|
||||||
string(MD5 SHADER_CACHE_VERSION "${COMBINED}")
|
string(MD5 SHADER_CACHE_VERSION "${COMBINED}")
|
||||||
configure_file("${SRC_DIR}/src/common/scm_rev.cpp.in" "scm_rev.cpp" @ONLY)
|
configure_file("${CMAKE_SOURCE_DIR}/src/common/scm_rev.cpp.in" "scm_rev.cpp" @ONLY)
|
||||||
|
|
|
||||||
|
|
@ -1,61 +1,4 @@
|
||||||
# Add a custom command to generate a new shader_cache_version hash when any of the following files change
|
include(GenerateSCMRev)
|
||||||
# NOTE: This is an approximation of what files affect shader generation, its possible something else
|
|
||||||
# could affect the result, but much more unlikely than the following files. Keeping a list of files
|
|
||||||
# like this allows for much better caching since it doesn't force the user to recompile binary shaders every update
|
|
||||||
set(VIDEO_CORE "${CMAKE_SOURCE_DIR}/src/video_core")
|
|
||||||
|
|
||||||
# Pass the path to git to the GenerateSCMRev.cmake as well
|
|
||||||
find_package(Git QUIET)
|
|
||||||
|
|
||||||
add_custom_command(OUTPUT scm_rev.cpp
|
|
||||||
COMMAND ${CMAKE_COMMAND}
|
|
||||||
-DSRC_DIR="${CMAKE_SOURCE_DIR}"
|
|
||||||
-DGIT_EXECUTABLE="${GIT_EXECUTABLE}"
|
|
||||||
-P "${CMAKE_SOURCE_DIR}/CMakeModules/GenerateSCMRev.cmake"
|
|
||||||
DEPENDS
|
|
||||||
# WARNING! It was too much work to try and make a common location for this list,
|
|
||||||
# so if you need to change it, please update CMakeModules/GenerateSCMRev.cmake as well
|
|
||||||
"${VIDEO_CORE}/renderer_opengl/gl_shader_disk_cache.cpp"
|
|
||||||
"${VIDEO_CORE}/renderer_opengl/gl_shader_disk_cache.h"
|
|
||||||
"${VIDEO_CORE}/renderer_opengl/gl_shader_util.cpp"
|
|
||||||
"${VIDEO_CORE}/renderer_opengl/gl_shader_util.h"
|
|
||||||
"${VIDEO_CORE}/renderer_vulkan/vk_shader_disk_cache.cpp"
|
|
||||||
"${VIDEO_CORE}/renderer_vulkan/vk_shader_disk_cache.h"
|
|
||||||
"${VIDEO_CORE}/renderer_vulkan/vk_pipeline_cache.cpp"
|
|
||||||
"${VIDEO_CORE}/renderer_vulkan/vk_pipeline_cache.h"
|
|
||||||
"${VIDEO_CORE}/renderer_vulkan/vk_shader_util.cpp"
|
|
||||||
"${VIDEO_CORE}/renderer_vulkan/vk_shader_util.h"
|
|
||||||
"${VIDEO_CORE}/shader/generator/glsl_fs_shader_gen.cpp"
|
|
||||||
"${VIDEO_CORE}/shader/generator/glsl_fs_shader_gen.h"
|
|
||||||
"${VIDEO_CORE}/shader/generator/glsl_shader_decompiler.cpp"
|
|
||||||
"${VIDEO_CORE}/shader/generator/glsl_shader_decompiler.h"
|
|
||||||
"${VIDEO_CORE}/shader/generator/glsl_shader_gen.cpp"
|
|
||||||
"${VIDEO_CORE}/shader/generator/glsl_shader_gen.h"
|
|
||||||
"${VIDEO_CORE}/shader/generator/pica_fs_config.cpp"
|
|
||||||
"${VIDEO_CORE}/shader/generator/pica_fs_config.h"
|
|
||||||
"${VIDEO_CORE}/shader/generator/profile.h"
|
|
||||||
"${VIDEO_CORE}/shader/generator/shader_gen.cpp"
|
|
||||||
"${VIDEO_CORE}/shader/generator/shader_gen.h"
|
|
||||||
"${VIDEO_CORE}/shader/generator/shader_uniforms.cpp"
|
|
||||||
"${VIDEO_CORE}/shader/generator/shader_uniforms.h"
|
|
||||||
"${VIDEO_CORE}/shader/generator/spv_fs_shader_gen.cpp"
|
|
||||||
"${VIDEO_CORE}/shader/generator/spv_fs_shader_gen.h"
|
|
||||||
"${VIDEO_CORE}/shader/shader.cpp"
|
|
||||||
"${VIDEO_CORE}/shader/shader.h"
|
|
||||||
"${VIDEO_CORE}/pica/regs_framebuffer.h"
|
|
||||||
"${VIDEO_CORE}/pica/regs_lighting.h"
|
|
||||||
"${VIDEO_CORE}/pica/regs_pipeline.h"
|
|
||||||
"${VIDEO_CORE}/pica/regs_rasterizer.h"
|
|
||||||
"${VIDEO_CORE}/pica/regs_shader.h"
|
|
||||||
"${VIDEO_CORE}/pica/regs_texturing.h"
|
|
||||||
"${VIDEO_CORE}/pica/regs_internal.cpp"
|
|
||||||
"${VIDEO_CORE}/pica/regs_internal.h"
|
|
||||||
# and also check that the scm_rev files haven't changed
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.h"
|
|
||||||
# technically we should regenerate if the git version changed, but its not worth the effort imo
|
|
||||||
"${CMAKE_SOURCE_DIR}/CMakeModules/GenerateSCMRev.cmake"
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(citra_common STATIC
|
add_library(citra_common STATIC
|
||||||
aarch64/cpu_detect.cpp
|
aarch64/cpu_detect.cpp
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue