]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/build/runtime/utfcpp-prefix/tmp/utfcpp-gitupdate.cmake
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / build / runtime / utfcpp-prefix / tmp / utfcpp-gitupdate.cmake
1 \r
2 execute_process(\r
3   COMMAND "C:/Program Files/Git/cmd/git.exe" rev-list --max-count=1 HEAD\r
4   WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
5   RESULT_VARIABLE error_code\r
6   OUTPUT_VARIABLE head_sha\r
7   OUTPUT_STRIP_TRAILING_WHITESPACE\r
8   )\r
9 if(error_code)\r
10   message(FATAL_ERROR "Failed to get the hash for HEAD")\r
11 endif()\r
12 \r
13 execute_process(\r
14   COMMAND "C:/Program Files/Git/cmd/git.exe" show-ref v3.1.1\r
15   WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
16   OUTPUT_VARIABLE show_ref_output\r
17   )\r
18 # If a remote ref is asked for, which can possibly move around,\r
19 # we must always do a fetch and checkout.\r
20 if("${show_ref_output}" MATCHES "remotes")\r
21   set(is_remote_ref 1)\r
22 else()\r
23   set(is_remote_ref 0)\r
24 endif()\r
25 \r
26 # Tag is in the form <remote>/<tag> (i.e. origin/master) we must strip\r
27 # the remote from the tag.\r
28 if("${show_ref_output}" MATCHES "refs/remotes/v3.1.1")\r
29   string(REGEX MATCH "^([^/]+)/(.+)$" _unused "v3.1.1")\r
30   set(git_remote "${CMAKE_MATCH_1}")\r
31   set(git_tag "${CMAKE_MATCH_2}")\r
32 else()\r
33   set(git_remote "origin")\r
34   set(git_tag "v3.1.1")\r
35 endif()\r
36 \r
37 # This will fail if the tag does not exist (it probably has not been fetched\r
38 # yet).\r
39 execute_process(\r
40   COMMAND "C:/Program Files/Git/cmd/git.exe" rev-list --max-count=1 v3.1.1\r
41   WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
42   RESULT_VARIABLE error_code\r
43   OUTPUT_VARIABLE tag_sha\r
44   OUTPUT_STRIP_TRAILING_WHITESPACE\r
45   )\r
46 \r
47 # Is the hash checkout out that we want?\r
48 if(error_code OR is_remote_ref OR NOT ("${tag_sha}" STREQUAL "${head_sha}"))\r
49   execute_process(\r
50     COMMAND "C:/Program Files/Git/cmd/git.exe" fetch\r
51     WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
52     RESULT_VARIABLE error_code\r
53     )\r
54   if(error_code)\r
55     message(FATAL_ERROR "Failed to fetch repository 'git://github.com/nemtrif/utfcpp'")\r
56   endif()\r
57 \r
58   if(is_remote_ref)\r
59     # Check if stash is needed\r
60     execute_process(\r
61       COMMAND "C:/Program Files/Git/cmd/git.exe" status --porcelain\r
62       WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
63       RESULT_VARIABLE error_code\r
64       OUTPUT_VARIABLE repo_status\r
65       )\r
66     if(error_code)\r
67       message(FATAL_ERROR "Failed to get the status")\r
68     endif()\r
69     string(LENGTH "${repo_status}" need_stash)\r
70 \r
71     # If not in clean state, stash changes in order to be able to be able to\r
72     # perform git pull --rebase\r
73     if(need_stash)\r
74       execute_process(\r
75         COMMAND "C:/Program Files/Git/cmd/git.exe" stash save --all;--quiet\r
76         WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
77         RESULT_VARIABLE error_code\r
78         )\r
79       if(error_code)\r
80         message(FATAL_ERROR "Failed to stash changes")\r
81       endif()\r
82     endif()\r
83 \r
84     # Pull changes from the remote branch\r
85     execute_process(\r
86       COMMAND "C:/Program Files/Git/cmd/git.exe" rebase ${git_remote}/${git_tag}\r
87       WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
88       RESULT_VARIABLE error_code\r
89       )\r
90     if(error_code)\r
91       # Rebase failed: Restore previous state.\r
92       execute_process(\r
93         COMMAND "C:/Program Files/Git/cmd/git.exe" rebase --abort\r
94         WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
95       )\r
96       if(need_stash)\r
97         execute_process(\r
98           COMMAND "C:/Program Files/Git/cmd/git.exe" stash pop --index --quiet\r
99           WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
100           )\r
101       endif()\r
102       message(FATAL_ERROR "\nFailed to rebase in: 'C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp/'.\nYou will have to resolve the conflicts manually")\r
103     endif()\r
104 \r
105     if(need_stash)\r
106       execute_process(\r
107         COMMAND "C:/Program Files/Git/cmd/git.exe" stash pop --index --quiet\r
108         WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
109         RESULT_VARIABLE error_code\r
110         )\r
111       if(error_code)\r
112         # Stash pop --index failed: Try again dropping the index\r
113         execute_process(\r
114           COMMAND "C:/Program Files/Git/cmd/git.exe" reset --hard --quiet\r
115           WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
116           RESULT_VARIABLE error_code\r
117           )\r
118         execute_process(\r
119           COMMAND "C:/Program Files/Git/cmd/git.exe" stash pop --quiet\r
120           WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
121           RESULT_VARIABLE error_code\r
122           )\r
123         if(error_code)\r
124           # Stash pop failed: Restore previous state.\r
125           execute_process(\r
126             COMMAND "C:/Program Files/Git/cmd/git.exe" reset --hard --quiet ${head_sha}\r
127             WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
128           )\r
129           execute_process(\r
130             COMMAND "C:/Program Files/Git/cmd/git.exe" stash pop --index --quiet\r
131             WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
132           )\r
133           message(FATAL_ERROR "\nFailed to unstash changes in: 'C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp/'.\nYou will have to resolve the conflicts manually")\r
134         endif()\r
135       endif()\r
136     endif()\r
137   else()\r
138     execute_process(\r
139       COMMAND "C:/Program Files/Git/cmd/git.exe" checkout v3.1.1\r
140       WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp"\r
141       RESULT_VARIABLE error_code\r
142       )\r
143     if(error_code)\r
144       message(FATAL_ERROR "Failed to checkout tag: 'v3.1.1'")\r
145     endif()\r
146   endif()\r
147 \r
148   set(init_submodules TRUE)\r
149   if(init_submodules)\r
150     execute_process(\r
151       COMMAND "C:/Program Files/Git/cmd/git.exe" submodule update --recursive --init \r
152       WORKING_DIRECTORY "C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp/"\r
153       RESULT_VARIABLE error_code\r
154       )\r
155   endif()\r
156   if(error_code)\r
157     message(FATAL_ERROR "Failed to update submodules in: 'C:/Users/Patrick/Documents/Studium/master/sem2/projekt/toc/antlr4-cpp-runtime-4.9.2-source/build/runtime/thirdparty/utfcpp/'")\r
158   endif()\r
159 endif()\r
160 \r