CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/android/git-version-gen.sh
Views: 1401
1
#!/bin/bash
2
## Copyright (c) 2012- PPSSPP Project.
3
4
## This program is free software: you can redistribute it and/or modify
5
## it under the terms of the GNU General Public License as published by
6
## the Free Software Foundation, version 2.0 or later versions.
7
8
## This program is distributed in the hope that it will be useful,
9
## but WITHOUT ANY WARRANTY; without even the implied warranty of
10
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
## GNU General Public License 2.0 for more details.
12
13
## A copy of the GPL 2.0 should have been included with the program.
14
## If not, see http://www.gnu.org/licenses/
15
16
## Official git repository and contact information can be found at
17
## https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
18
19
GIT_VERSION_FILE=$(dirname $0)/../git-version.cpp
20
21
if [ -e "$GIT_VERSION_FILE" ]; then
22
# Skip updating the file if PPSSPP_GIT_VERSION_NO_UPDATE is 1.
23
results=$(grep '^#define PPSSPP_GIT_VERSION_NO_UPDATE 1' "$GIT_VERSION_FILE")
24
if [ "$results" != "" ]; then
25
exit 0
26
fi
27
fi
28
29
GIT_VERSION=$(git describe --always)
30
if [ "$GIT_VERSION" == "" ]; then
31
echo "Unable to update git-version.cpp, git not on path." 1>&2
32
33
echo "// This is a generated file." > "$GIT_VERSION_FILE"
34
echo >> "$GIT_VERSION_FILE"
35
echo 'const char *PPSSPP_GIT_VERSION = "unknown";' >> "$GIT_VERSION_FILE"
36
exit 0
37
fi
38
39
# Don't modify the file if it already has the current version.
40
if [ -e "$GIT_VERSION_FILE" ]; then
41
results=$(grep "$GIT_VERSION" "$GIT_VERSION_FILE")
42
if [ "$results" != "" ]; then
43
exit 0
44
fi
45
fi
46
47
echo "// This is a generated file." > "$GIT_VERSION_FILE"
48
echo >> "$GIT_VERSION_FILE"
49
echo 'const char *PPSSPP_GIT_VERSION = "'"$GIT_VERSION"'";' >> "$GIT_VERSION_FILE"
50
echo >> "$GIT_VERSION_FILE"
51
echo "// If you don't want this file to update/recompile, change to 1." >> "$GIT_VERSION_FILE"
52
echo "#define PPSSPP_GIT_VERSION_NO_UPDATE 0" >> "$GIT_VERSION_FILE"
53
54