GenerateSCMRev.cmake 4.0 KB

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