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