summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2014-04-23 18:43:57 -0700
committerGravatar bunnei2014-04-23 18:43:57 -0700
commit4405a53cf3b669e84b1d953d35e89ec29b916293 (patch)
treef6d4370cfce75d9922e75d99c82e1935c6b723c9
parentfixes to build on linux (diff)
downloadyuzu-4405a53cf3b669e84b1d953d35e89ec29b916293.tar.gz
yuzu-4405a53cf3b669e84b1d953d35e89ec29b916293.tar.xz
yuzu-4405a53cf3b669e84b1d953d35e89ec29b916293.zip
added scm rev generation on Linux/cmake
-rw-r--r--.gitignore2
-rw-r--r--CMakeLists.txt6
-rw-r--r--externals/cmake-modules/GetGitRevisionDescription.cmake130
-rw-r--r--externals/cmake-modules/GetGitRevisionDescription.cmake.in38
-rw-r--r--src/common/CMakeLists.txt4
-rw-r--r--src/common/common.h4
-rw-r--r--src/common/emu_window.h3
-rw-r--r--src/common/scm_rev.cpp.in18
-rw-r--r--src/common/scm_rev.h14
-rw-r--r--src/common/version.cpp45
10 files changed, 211 insertions, 53 deletions
diff --git a/.gitignore b/.gitignore
index 8a794aa0a..1b124ad3e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,5 +23,3 @@ ipch/
23build/ 23build/
24bin/ 24bin/
25 25
26# GIT revision number
27src/common/scm_rev.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ed678d619..83a819a7f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,6 +29,12 @@ if(NOT DISABLE_QT4)
29 endif() 29 endif()
30endif() 30endif()
31 31
32# generate git revision information
33list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules/")
34include(GetGitRevisionDescription)
35get_git_head_revision(GIT_REF_SPEC GIT_REV)
36git_describe(GIT_DESC --always --long --dirty)
37
32# external includes 38# external includes
33include_directories(${OPENGL_INCLUDE_DIR}) 39include_directories(${OPENGL_INCLUDE_DIR})
34 40
diff --git a/externals/cmake-modules/GetGitRevisionDescription.cmake b/externals/cmake-modules/GetGitRevisionDescription.cmake
new file mode 100644
index 000000000..2b9cde061
--- /dev/null
+++ b/externals/cmake-modules/GetGitRevisionDescription.cmake
@@ -0,0 +1,130 @@
1# - Returns a version string from Git
2#
3# These functions force a re-configure on each git commit so that you can
4# trust the values of the variables in your build system.
5#
6# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
7#
8# Returns the refspec and sha hash of the current head revision
9#
10# git_describe(<var> [<additional arguments to git describe> ...])
11#
12# Returns the results of git describe on the source tree, and adjusting
13# the output so that it tests false if an error occurs.
14#
15# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
16#
17# Returns the results of git describe --exact-match on the source tree,
18# and adjusting the output so that it tests false if there was no exact
19# matching tag.
20#
21# Requires CMake 2.6 or newer (uses the 'function' command)
22#
23# Original Author:
24# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
25# http://academic.cleardefinition.com
26# Iowa State University HCI Graduate Program/VRAC
27#
28# Copyright Iowa State University 2009-2010.
29# Distributed under the Boost Software License, Version 1.0.
30# (See accompanying file LICENSE_1_0.txt or copy at
31# http://www.boost.org/LICENSE_1_0.txt)
32
33if(__get_git_revision_description)
34 return()
35endif()
36set(__get_git_revision_description YES)
37
38# We must run the following at "include" time, not at function call time,
39# to find the path to this module rather than the path to a calling list file
40get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
41
42function(get_git_head_revision _refspecvar _hashvar)
43 set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
44 set(GIT_DIR "${GIT_PARENT_DIR}/.git")
45 while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
46 set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
47 get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
48 if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
49 # We have reached the root directory, we are not in git
50 set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
51 set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
52 return()
53 endif()
54 set(GIT_DIR "${GIT_PARENT_DIR}/.git")
55 endwhile()
56 # check if this is a submodule
57 if(NOT IS_DIRECTORY ${GIT_DIR})
58 file(READ ${GIT_DIR} submodule)
59 string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
60 get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
61 get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
62 endif()
63 set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
64 if(NOT EXISTS "${GIT_DATA}")
65 file(MAKE_DIRECTORY "${GIT_DATA}")
66 endif()
67
68 if(NOT EXISTS "${GIT_DIR}/HEAD")
69 return()
70 endif()
71 set(HEAD_FILE "${GIT_DATA}/HEAD")
72 configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
73
74 configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
75 "${GIT_DATA}/grabRef.cmake"
76 @ONLY)
77 include("${GIT_DATA}/grabRef.cmake")
78
79 set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
80 set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
81endfunction()
82
83function(git_describe _var)
84 if(NOT GIT_FOUND)
85 find_package(Git QUIET)
86 endif()
87 #get_git_head_revision(refspec hash)
88 if(NOT GIT_FOUND)
89 set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
90 return()
91 endif()
92 #if(NOT hash)
93 # set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
94 # return()
95 #endif()
96
97 # TODO sanitize
98 #if((${ARGN}" MATCHES "&&") OR
99 # (ARGN MATCHES "||") OR
100 # (ARGN MATCHES "\\;"))
101 # message("Please report the following error to the project!")
102 # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
103 #endif()
104
105 #message(STATUS "Arguments to execute_process: ${ARGN}")
106
107 execute_process(COMMAND
108 "${GIT_EXECUTABLE}"
109 describe
110 ${hash}
111 ${ARGN}
112 WORKING_DIRECTORY
113 "${CMAKE_SOURCE_DIR}"
114 RESULT_VARIABLE
115 res
116 OUTPUT_VARIABLE
117 out
118 ERROR_QUIET
119 OUTPUT_STRIP_TRAILING_WHITESPACE)
120 if(NOT res EQUAL 0)
121 set(out "${out}-${res}-NOTFOUND")
122 endif()
123
124 set(${_var} "${out}" PARENT_SCOPE)
125endfunction()
126
127function(git_get_exact_tag _var)
128 git_describe(out --exact-match ${ARGN})
129 set(${_var} "${out}" PARENT_SCOPE)
130endfunction()
diff --git a/externals/cmake-modules/GetGitRevisionDescription.cmake.in b/externals/cmake-modules/GetGitRevisionDescription.cmake.in
new file mode 100644
index 000000000..888ce13aa
--- /dev/null
+++ b/externals/cmake-modules/GetGitRevisionDescription.cmake.in
@@ -0,0 +1,38 @@
1#
2# Internal file for GetGitRevisionDescription.cmake
3#
4# Requires CMake 2.6 or newer (uses the 'function' command)
5#
6# Original Author:
7# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
8# http://academic.cleardefinition.com
9# Iowa State University HCI Graduate Program/VRAC
10#
11# Copyright Iowa State University 2009-2010.
12# Distributed under the Boost Software License, Version 1.0.
13# (See accompanying file LICENSE_1_0.txt or copy at
14# http://www.boost.org/LICENSE_1_0.txt)
15
16set(HEAD_HASH)
17
18file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
19
20string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
21if(HEAD_CONTENTS MATCHES "ref")
22 # named branch
23 string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
24 if(EXISTS "@GIT_DIR@/${HEAD_REF}")
25 configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
26 elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
27 configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
28 set(HEAD_HASH "${HEAD_REF}")
29 endif()
30else()
31 # detached HEAD
32 configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
33endif()
34
35if(NOT HEAD_HASH)
36 file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
37 string(STRIP "${HEAD_HASH}" HEAD_HASH)
38endif()
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 738144927..1495e433b 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -1,3 +1,5 @@
1configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/scm_rev.cpp" @ONLY)
2
1set(SRCS break_points.cpp 3set(SRCS break_points.cpp
2 console_listener.cpp 4 console_listener.cpp
3 extended_trace.cpp 5 extended_trace.cpp
@@ -15,6 +17,6 @@ set(SRCS break_points.cpp
15 thread.cpp 17 thread.cpp
16 timer.cpp 18 timer.cpp
17 utf8.cpp 19 utf8.cpp
18 version.cpp) 20 ${CMAKE_CURRENT_BINARY_DIR}/scm_rev.cpp)
19 21
20add_library(common STATIC ${SRCS}) 22add_library(common STATIC ${SRCS})
diff --git a/src/common/common.h b/src/common/common.h
index 64a0d7812..a281b21cc 100644
--- a/src/common/common.h
+++ b/src/common/common.h
@@ -12,10 +12,6 @@
12#include <stdio.h> 12#include <stdio.h>
13#include <string.h> 13#include <string.h>
14 14
15// SVN version number
16extern const char *g_scm_rev_str;
17extern const char *g_netplay_citra_ver;
18
19// Force enable logging in the right modes. For some reason, something had changed 15// Force enable logging in the right modes. For some reason, something had changed
20// so that debugfast no longer logged. 16// so that debugfast no longer logged.
21#if defined(_DEBUG) || defined(DEBUGFAST) 17#if defined(_DEBUG) || defined(DEBUGFAST)
diff --git a/src/common/emu_window.h b/src/common/emu_window.h
index e70b99ec1..c53d6d7a2 100644
--- a/src/common/emu_window.h
+++ b/src/common/emu_window.h
@@ -5,6 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include "common/common.h" 7#include "common/common.h"
8#include "common/scm_rev.h"
8 9
9// Abstraction class used to provide an interface between emulation code and the frontend (e.g. SDL, 10// Abstraction class used to provide an interface between emulation code and the frontend (e.g. SDL,
10// QGLWidget, GLFW, etc...) 11// QGLWidget, GLFW, etc...)
@@ -66,7 +67,7 @@ public:
66protected: 67protected:
67 EmuWindow() : m_client_area_width(640), m_client_area_height(480) { 68 EmuWindow() : m_client_area_width(640), m_client_area_height(480) {
68 char window_title[255]; 69 char window_title[255];
69 sprintf(window_title, "citra-%s", g_scm_rev_str); 70 sprintf(window_title, "citra-%s", Common::g_scm_desc);
70 m_window_title = window_title; 71 m_window_title = window_title;
71 } 72 }
72 virtual ~EmuWindow() {} 73 virtual ~EmuWindow() {}
diff --git a/src/common/scm_rev.cpp.in b/src/common/scm_rev.cpp.in
new file mode 100644
index 000000000..9e2bcfdd8
--- /dev/null
+++ b/src/common/scm_rev.cpp.in
@@ -0,0 +1,18 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include "common/scm_rev.h"
6
7#define GIT_REV "@GIT_REV@"
8#define GIT_REF_SPEC "@GIT_REF_SPEC@"
9#define GIT_DESC "@GIT_DESC@"
10
11namespace Common {
12
13const char g_scm_rev[] = GIT_REV;
14const char g_scm_ref_spec[] = GIT_REF_SPEC;
15const char g_scm_desc[] = GIT_DESC;
16
17} // namespace
18
diff --git a/src/common/scm_rev.h b/src/common/scm_rev.h
new file mode 100644
index 000000000..7f5ce119c
--- /dev/null
+++ b/src/common/scm_rev.h
@@ -0,0 +1,14 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7namespace Common {
8
9extern const char g_scm_rev[];
10extern const char g_scm_ref_spec[];
11extern const char g_scm_desc[];
12
13} // namespace
14
diff --git a/src/common/version.cpp b/src/common/version.cpp
deleted file mode 100644
index 2e0c7390c..000000000
--- a/src/common/version.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
1// Copyright 2013 Dolphin Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include "common/common.h"
6#include "common/scm_rev.h"
7
8#ifdef _DEBUG
9 #define BUILD_TYPE_STR "Debug "
10#elif defined DEBUGFAST
11 #define BUILD_TYPE_STR "DebugFast "
12#else
13 #define BUILD_TYPE_STR ""
14#endif
15
16const char *g_scm_rev_str =
17#if !SCM_IS_MASTER
18 "[" SCM_BRANCH_STR "] "
19#endif
20
21#ifdef __INTEL_COMPILER
22 BUILD_TYPE_STR SCM_DESC_STR "-ICC";
23#else
24 BUILD_TYPE_STR SCM_DESC_STR;
25#endif
26
27#ifdef _M_X64
28#define NP_ARCH "x64"
29#else
30#ifdef _M_ARM
31#define NP_ARCH "ARM"
32#else
33#define NP_ARCH "x86"
34#endif
35#endif
36
37#ifdef _WIN32
38const char *g_netplay_citra_ver = SCM_DESC_STR " W" NP_ARCH;
39#elif __APPLE__
40const char *g_netplay_citra_ver = SCM_DESC_STR " M" NP_ARCH;
41#else
42const char *g_netplay_citra_ver = SCM_DESC_STR " L" NP_ARCH;
43#endif
44
45const char *scm_rev_git_str = SCM_REV_STR;