GenerateSCMRev.cmake 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. # Find the package here with the known path so that the GetGit commands can find it as well
  8. find_package(Git QUIET PATHS "${GIT_EXECUTABLE}")
  9. # generate git/build information
  10. include(GetGitRevisionDescription)
  11. get_git_head_revision(GIT_REF_SPEC GIT_REV)
  12. git_describe(GIT_DESC --always --long --dirty)
  13. git_branch_name(GIT_BRANCH)
  14. get_timestamp(BUILD_DATE)
  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. # The variable SRC_DIR must be passed into the script (since it uses the current build directory for all values of CMAKE_*_DIR)
  47. set(VIDEO_CORE "${SRC_DIR}/src/video_core")
  48. set(HASH_FILES
  49. "${VIDEO_CORE}/renderer_opengl/gl_shader_cache.cpp"
  50. "${VIDEO_CORE}/renderer_opengl/gl_shader_cache.h"
  51. "${VIDEO_CORE}/renderer_opengl/gl_shader_decompiler.cpp"
  52. "${VIDEO_CORE}/renderer_opengl/gl_shader_decompiler.h"
  53. "${VIDEO_CORE}/renderer_opengl/gl_shader_disk_cache.cpp"
  54. "${VIDEO_CORE}/renderer_opengl/gl_shader_disk_cache.h"
  55. "${VIDEO_CORE}/renderer_opengl/gl_shader_gen.cpp"
  56. "${VIDEO_CORE}/renderer_opengl/gl_shader_gen.h"
  57. "${VIDEO_CORE}/shader/decode/arithmetic.cpp"
  58. "${VIDEO_CORE}/shader/decode/arithmetic_half.cpp"
  59. "${VIDEO_CORE}/shader/decode/arithmetic_half_immediate.cpp"
  60. "${VIDEO_CORE}/shader/decode/arithmetic_immediate.cpp"
  61. "${VIDEO_CORE}/shader/decode/arithmetic_integer.cpp"
  62. "${VIDEO_CORE}/shader/decode/arithmetic_integer_immediate.cpp"
  63. "${VIDEO_CORE}/shader/decode/bfe.cpp"
  64. "${VIDEO_CORE}/shader/decode/bfi.cpp"
  65. "${VIDEO_CORE}/shader/decode/conversion.cpp"
  66. "${VIDEO_CORE}/shader/decode/ffma.cpp"
  67. "${VIDEO_CORE}/shader/decode/float_set.cpp"
  68. "${VIDEO_CORE}/shader/decode/float_set_predicate.cpp"
  69. "${VIDEO_CORE}/shader/decode/half_set.cpp"
  70. "${VIDEO_CORE}/shader/decode/half_set_predicate.cpp"
  71. "${VIDEO_CORE}/shader/decode/hfma2.cpp"
  72. "${VIDEO_CORE}/shader/decode/image.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/warp.cpp"
  84. "${VIDEO_CORE}/shader/decode/xmad.cpp"
  85. "${VIDEO_CORE}/shader/ast.cpp"
  86. "${VIDEO_CORE}/shader/ast.h"
  87. "${VIDEO_CORE}/shader/compiler_settings.cpp"
  88. "${VIDEO_CORE}/shader/compiler_settings.h"
  89. "${VIDEO_CORE}/shader/const_buffer_locker.cpp"
  90. "${VIDEO_CORE}/shader/const_buffer_locker.h"
  91. "${VIDEO_CORE}/shader/control_flow.cpp"
  92. "${VIDEO_CORE}/shader/control_flow.h"
  93. "${VIDEO_CORE}/shader/decode.cpp"
  94. "${VIDEO_CORE}/shader/expr.cpp"
  95. "${VIDEO_CORE}/shader/expr.h"
  96. "${VIDEO_CORE}/shader/node.h"
  97. "${VIDEO_CORE}/shader/node_helper.cpp"
  98. "${VIDEO_CORE}/shader/node_helper.h"
  99. "${VIDEO_CORE}/shader/shader_ir.cpp"
  100. "${VIDEO_CORE}/shader/shader_ir.h"
  101. "${VIDEO_CORE}/shader/track.cpp"
  102. )
  103. set(COMBINED "")
  104. foreach (F IN LISTS HASH_FILES)
  105. file(READ ${F} TMP)
  106. set(COMBINED "${COMBINED}${TMP}")
  107. endforeach()
  108. string(MD5 SHADER_CACHE_VERSION "${COMBINED}")
  109. configure_file("${SRC_DIR}/src/common/scm_rev.cpp.in" "scm_rev.cpp" @ONLY)