diff options
Diffstat (limited to 'CMakeModules/GenerateSCMRev.cmake')
| -rw-r--r-- | CMakeModules/GenerateSCMRev.cmake | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/CMakeModules/GenerateSCMRev.cmake b/CMakeModules/GenerateSCMRev.cmake new file mode 100644 index 000000000..08315a1f1 --- /dev/null +++ b/CMakeModules/GenerateSCMRev.cmake | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | # Gets a UTC timstamp and sets the provided variable to it | ||
| 2 | function(get_timestamp _var) | ||
| 3 | string(TIMESTAMP timestamp UTC) | ||
| 4 | set(${_var} "${timestamp}" PARENT_SCOPE) | ||
| 5 | endfunction() | ||
| 6 | |||
| 7 | list(APPEND CMAKE_MODULE_PATH "${SRC_DIR}/externals/cmake-modules") | ||
| 8 | # generate git/build information | ||
| 9 | include(GetGitRevisionDescription) | ||
| 10 | get_git_head_revision(GIT_REF_SPEC GIT_REV) | ||
| 11 | git_describe(GIT_DESC --always --long --dirty) | ||
| 12 | git_branch_name(GIT_BRANCH) | ||
| 13 | get_timestamp(BUILD_DATE) | ||
| 14 | |||
| 15 | # Generate cpp with Git revision from template | ||
| 16 | # Also if this is a CI build, add the build name (ie: Nightly, Canary) to the scm_rev file as well | ||
| 17 | set(REPO_NAME "") | ||
| 18 | set(BUILD_VERSION "0") | ||
| 19 | if (BUILD_REPOSITORY) | ||
| 20 | # regex capture the string nightly or canary into CMAKE_MATCH_1 | ||
| 21 | string(REGEX MATCH "yuzu-emu/yuzu-?(.*)" OUTVAR ${BUILD_REPOSITORY}) | ||
| 22 | if (${CMAKE_MATCH_COUNT} GREATER 0) | ||
| 23 | # capitalize the first letter of each word in the repo name. | ||
| 24 | string(REPLACE "-" ";" REPO_NAME_LIST ${CMAKE_MATCH_1}) | ||
| 25 | foreach(WORD ${REPO_NAME_LIST}) | ||
| 26 | string(SUBSTRING ${WORD} 0 1 FIRST_LETTER) | ||
| 27 | string(SUBSTRING ${WORD} 1 -1 REMAINDER) | ||
| 28 | string(TOUPPER ${FIRST_LETTER} FIRST_LETTER) | ||
| 29 | set(REPO_NAME "${REPO_NAME}${FIRST_LETTER}${REMAINDER}") | ||
| 30 | endforeach() | ||
| 31 | if (BUILD_TAG) | ||
| 32 | string(REGEX MATCH "${CMAKE_MATCH_1}-([0-9]+)" OUTVAR ${BUILD_TAG}) | ||
| 33 | if (${CMAKE_MATCH_COUNT} GREATER 0) | ||
| 34 | set(BUILD_VERSION ${CMAKE_MATCH_1}) | ||
| 35 | endif() | ||
| 36 | if (BUILD_VERSION) | ||
| 37 | # This leaves a trailing space on the last word, but we actually want that | ||
| 38 | # because of how it's styled in the title bar. | ||
| 39 | set(BUILD_FULLNAME "${REPO_NAME} ${BUILD_VERSION} ") | ||
| 40 | else() | ||
| 41 | set(BUILD_FULLNAME "") | ||
| 42 | endif() | ||
| 43 | endif() | ||
| 44 | endif() | ||
| 45 | endif() | ||
| 46 | |||
| 47 | # The variable SRC_DIR must be passed into the script (since it uses the current build directory for all values of CMAKE_*_DIR) | ||
| 48 | set(VIDEO_CORE "${SRC_DIR}/src/video_core") | ||
| 49 | set(HASH_FILES | ||
| 50 | "${VIDEO_CORE}/renderer_opengl/gl_shader_cache.cpp" | ||
| 51 | "${VIDEO_CORE}/renderer_opengl/gl_shader_cache.h" | ||
| 52 | "${VIDEO_CORE}/renderer_opengl/gl_shader_decompiler.cpp" | ||
| 53 | "${VIDEO_CORE}/renderer_opengl/gl_shader_decompiler.h" | ||
| 54 | "${VIDEO_CORE}/renderer_opengl/gl_shader_disk_cache.cpp" | ||
| 55 | "${VIDEO_CORE}/renderer_opengl/gl_shader_disk_cache.h" | ||
| 56 | "${VIDEO_CORE}/renderer_opengl/gl_shader_gen.cpp" | ||
| 57 | "${VIDEO_CORE}/renderer_opengl/gl_shader_gen.h" | ||
| 58 | "${VIDEO_CORE}/shader/decode/arithmetic.cpp" | ||
| 59 | "${VIDEO_CORE}/shader/decode/arithmetic_half.cpp" | ||
| 60 | "${VIDEO_CORE}/shader/decode/arithmetic_half_immediate.cpp" | ||
| 61 | "${VIDEO_CORE}/shader/decode/arithmetic_immediate.cpp" | ||
| 62 | "${VIDEO_CORE}/shader/decode/arithmetic_integer.cpp" | ||
| 63 | "${VIDEO_CORE}/shader/decode/arithmetic_integer_immediate.cpp" | ||
| 64 | "${VIDEO_CORE}/shader/decode/bfe.cpp" | ||
| 65 | "${VIDEO_CORE}/shader/decode/bfi.cpp" | ||
| 66 | "${VIDEO_CORE}/shader/decode/conversion.cpp" | ||
| 67 | "${VIDEO_CORE}/shader/decode/ffma.cpp" | ||
| 68 | "${VIDEO_CORE}/shader/decode/float_set.cpp" | ||
| 69 | "${VIDEO_CORE}/shader/decode/float_set_predicate.cpp" | ||
| 70 | "${VIDEO_CORE}/shader/decode/half_set.cpp" | ||
| 71 | "${VIDEO_CORE}/shader/decode/half_set_predicate.cpp" | ||
| 72 | "${VIDEO_CORE}/shader/decode/hfma2.cpp" | ||
| 73 | "${VIDEO_CORE}/shader/decode/integer_set.cpp" | ||
| 74 | "${VIDEO_CORE}/shader/decode/integer_set_predicate.cpp" | ||
| 75 | "${VIDEO_CORE}/shader/decode/memory.cpp" | ||
| 76 | "${VIDEO_CORE}/shader/decode/texture.cpp" | ||
| 77 | "${VIDEO_CORE}/shader/decode/other.cpp" | ||
| 78 | "${VIDEO_CORE}/shader/decode/predicate_set_predicate.cpp" | ||
| 79 | "${VIDEO_CORE}/shader/decode/predicate_set_register.cpp" | ||
| 80 | "${VIDEO_CORE}/shader/decode/register_set_predicate.cpp" | ||
| 81 | "${VIDEO_CORE}/shader/decode/shift.cpp" | ||
| 82 | "${VIDEO_CORE}/shader/decode/video.cpp" | ||
| 83 | "${VIDEO_CORE}/shader/decode/xmad.cpp" | ||
| 84 | "${VIDEO_CORE}/shader/decode.cpp" | ||
| 85 | "${VIDEO_CORE}/shader/shader_ir.cpp" | ||
| 86 | "${VIDEO_CORE}/shader/shader_ir.h" | ||
| 87 | "${VIDEO_CORE}/shader/track.cpp" | ||
| 88 | ) | ||
| 89 | set(COMBINED "") | ||
| 90 | foreach (F IN LISTS HASH_FILES) | ||
| 91 | file(READ ${F} TMP) | ||
| 92 | set(COMBINED "${COMBINED}${TMP}") | ||
| 93 | endforeach() | ||
| 94 | string(MD5 SHADER_CACHE_VERSION "${COMBINED}") | ||
| 95 | configure_file("${SRC_DIR}/src/common/scm_rev.cpp.in" "scm_rev.cpp" @ONLY) | ||