From fc48fdbd97e43f3bf09633ed52a4bc6c859c2ac4 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 2 Mar 2013 12:03:06 -0800 Subject: [PATCH] Add git-version.c generation for Qt. --- Qt/Core.pro | 8 +++++++ Qt/git-version-gen.sh | 52 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100755 Qt/git-version-gen.sh diff --git a/Qt/Core.pro b/Qt/Core.pro index 69f6bb9fc8..feb0bfcda9 100755 --- a/Qt/Core.pro +++ b/Qt/Core.pro @@ -4,6 +4,14 @@ TARGET = Core TEMPLATE = lib CONFIG += staticlib +version.target = ../git-version.c +version.commands = $$PWD/git-version-gen.sh +version.depends = ../.git + +QMAKE_EXTRA_TARGETS += version +PRE_TARGETDEPS += ../git-version.c +SOURCES += ../git-version.c + include(Settings.pri) INCLUDEPATH += ../native ../Core/MIPS ../ diff --git a/Qt/git-version-gen.sh b/Qt/git-version-gen.sh new file mode 100755 index 0000000000..1f0e259fb9 --- /dev/null +++ b/Qt/git-version-gen.sh @@ -0,0 +1,52 @@ +#!/bin/bash +## Copyright (c) 2012- PPSSPP Project. + +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, version 2.0 or later versions. + +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License 2.0 for more details. + +## A copy of the GPL 2.0 should have been included with the program. +## If not, see http://www.gnu.org/licenses/ + +## Official git repository and contact information can be found at +## https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +GIT_VERSION_FILE=$(dirname $0)/../git-version.c + +if [ -e "$GIT_VERSION_FILE" ]; then + # Skip updating the file if PPSSPP_GIT_VERSION_NO_UPDATE is 1. + results=$(grep '^#define PPSSPP_GIT_VERSION_NO_UPDATE 1' "$GIT_VERSION_FILE") + if [ "$results" != "" ]; then + exit 0 + fi +fi + +GIT_VERSION=$(git describe --always) +if [ "$GIT_VERSION" == "" ]; then + echo "Unable to update git-version.c, git not on path." 1>&2 + + echo "// This is a generated file." > "$GIT_VERSION_FILE" + echo >> "$GIT_VERSION_FILE" + echo 'const char *PPSSPP_GIT_VERSION = "unknown";' >> "$GIT_VERSION_FILE" + exit 0 +fi + +# Don't modify the file if it already has the current version. +if [ -e "$GIT_VERSION_FILE" ]; then + results=$(grep "$GIT_VERSION" "$GIT_VERSION_FILE") + if [ "$results" != "" ]; then + exit 0 + fi +fi + +echo "// This is a generated file." > "$GIT_VERSION_FILE" +echo >> "$GIT_VERSION_FILE" +echo 'const char *PPSSPP_GIT_VERSION = "'"$GIT_VERSION"'";' >> "$GIT_VERSION_FILE" +echo >> "$GIT_VERSION_FILE" +echo "// If you don't want this file to update/recompile, change to 1." >> "$GIT_VERSION_FILE" +echo "#define PPSSPP_GIT_VERSION_NO_UPDATE 0" >> "$GIT_VERSION_FILE"