GenerateSCMRev.cmake 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 ($ENV{CI})
  18. if ($ENV{TRAVIS})
  19. set(BUILD_REPOSITORY $ENV{TRAVIS_REPO_SLUG})
  20. set(BUILD_TAG $ENV{TRAVIS_TAG})
  21. elseif($ENV{APPVEYOR})
  22. set(BUILD_REPOSITORY $ENV{APPVEYOR_REPO_NAME})
  23. set(BUILD_TAG $ENV{APPVEYOR_REPO_TAG_NAME})
  24. endif()
  25. # regex capture the string nightly or canary into CMAKE_MATCH_1
  26. string(REGEX MATCH "citra-emu/citra-?(.*)" OUTVAR ${BUILD_REPOSITORY})
  27. if (${CMAKE_MATCH_COUNT} GREATER 0)
  28. # capitalize the first letter of each word in the repo name.
  29. string(REPLACE "-" ";" REPO_NAME_LIST ${CMAKE_MATCH_1})
  30. foreach(WORD ${REPO_NAME_LIST})
  31. string(SUBSTRING ${WORD} 0 1 FIRST_LETTER)
  32. string(SUBSTRING ${WORD} 1 -1 REMAINDER)
  33. string(TOUPPER ${FIRST_LETTER} FIRST_LETTER)
  34. set(REPO_NAME "${REPO_NAME}${FIRST_LETTER}${REMAINDER}")
  35. endforeach()
  36. if (BUILD_TAG)
  37. string(REGEX MATCH "${CMAKE_MATCH_1}-([0-9]+)" OUTVAR ${BUILD_TAG})
  38. if (${CMAKE_MATCH_COUNT} GREATER 0)
  39. set(BUILD_VERSION ${CMAKE_MATCH_1})
  40. endif()
  41. if (BUILD_VERSION)
  42. # This leaves a trailing space on the last word, but we actually want that
  43. # because of how it's styled in the title bar.
  44. set(BUILD_FULLNAME "${REPO_NAME} ${BUILD_VERSION} ")
  45. else()
  46. set(BUILD_FULLNAME "")
  47. endif()
  48. endif()
  49. endif()
  50. endif()
  51. # The variable SRC_DIR must be passed into the script (since it uses the current build directory for all values of CMAKE_*_DIR)
  52. set(VIDEO_CORE "${SRC_DIR}/src/video_core")
  53. set(HASH_FILES
  54. "${VIDEO_CORE}/renderer_opengl/gl_shader_cache.cpp"
  55. "${VIDEO_CORE}/renderer_opengl/gl_shader_cache.h"
  56. "${VIDEO_CORE}/renderer_opengl/gl_shader_decompiler.cpp"
  57. "${VIDEO_CORE}/renderer_opengl/gl_shader_decompiler.h"
  58. "${VIDEO_CORE}/renderer_opengl/gl_shader_disk_cache.cpp"
  59. "${VIDEO_CORE}/renderer_opengl/gl_shader_disk_cache.h"
  60. "${VIDEO_CORE}/renderer_opengl/gl_shader_gen.cpp"
  61. "${VIDEO_CORE}/renderer_opengl/gl_shader_gen.h"
  62. "${VIDEO_CORE}/shader/decode/arithmetic.cpp"
  63. "${VIDEO_CORE}/shader/decode/arithmetic_half.cpp"
  64. "${VIDEO_CORE}/shader/decode/arithmetic_half_immediate.cpp"
  65. "${VIDEO_CORE}/shader/decode/arithmetic_immediate.cpp"
  66. "${VIDEO_CORE}/shader/decode/arithmetic_integer.cpp"
  67. "${VIDEO_CORE}/shader/decode/arithmetic_integer_immediate.cpp"
  68. "${VIDEO_CORE}/shader/decode/bfe.cpp"
  69. "${VIDEO_CORE}/shader/decode/bfi.cpp"
  70. "${VIDEO_CORE}/shader/decode/conversion.cpp"
  71. "${VIDEO_CORE}/shader/decode/ffma.cpp"
  72. "${VIDEO_CORE}/shader/decode/float_set.cpp"
  73. "${VIDEO_CORE}/shader/decode/float_set_predicate.cpp"
  74. "${VIDEO_CORE}/shader/decode/half_set.cpp"
  75. "${VIDEO_CORE}/shader/decode/half_set_predicate.cpp"
  76. "${VIDEO_CORE}/shader/decode/hfma2.cpp"
  77. "${VIDEO_CORE}/shader/decode/integer_set.cpp"
  78. "${VIDEO_CORE}/shader/decode/integer_set_predicate.cpp"
  79. "${VIDEO_CORE}/shader/decode/memory.cpp"
  80. "${VIDEO_CORE}/shader/decode/other.cpp"
  81. "${VIDEO_CORE}/shader/decode/predicate_set_predicate.cpp"
  82. "${VIDEO_CORE}/shader/decode/predicate_set_register.cpp"
  83. "${VIDEO_CORE}/shader/decode/register_set_predicate.cpp"
  84. "${VIDEO_CORE}/shader/decode/shift.cpp"
  85. "${VIDEO_CORE}/shader/decode/video.cpp"
  86. "${VIDEO_CORE}/shader/decode/xmad.cpp"
  87. "${VIDEO_CORE}/shader/decode.cpp"
  88. "${VIDEO_CORE}/shader/shader_ir.cpp"
  89. "${VIDEO_CORE}/shader/shader_ir.h"
  90. "${VIDEO_CORE}/shader/track.cpp"
  91. )
  92. set(COMBINED "")
  93. foreach (F IN LISTS HASH_FILES)
  94. file(READ ${F} TMP)
  95. set(COMBINED "${COMBINED}${TMP}")
  96. endforeach()
  97. string(MD5 SHADER_CACHE_VERSION "${COMBINED}")
  98. configure_file("${SRC_DIR}/src/common/scm_rev.cpp.in" "scm_rev.cpp" @ONLY)