diff --git a/.gitignore b/.gitignore index 86e02e32ae..e01eb254a1 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,9 @@ Release Windows/x64 Windows/ipch +# For Mac +.DS_Store + # For ppsspp.ini, etc. *.ini @@ -37,6 +40,7 @@ gen libs obj build*/ +/git-version.c .pspsh.hist __testoutput.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index cfabb3510d..b3dbfd8d2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,6 +136,7 @@ if(NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") elseif(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") endif() if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7.0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") @@ -823,11 +824,23 @@ add_library(${CoreLibName} ${CoreLinkType} Core/Util/ppge_atlas.cpp Core/Util/ppge_atlas.h $ - Globals.h) + Globals.h + git-version.cpp) target_link_libraries(${CoreLibName} Common native kirk cityhash ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES}) setup_target_project(${CoreLibName} Core) +# Generate git-version.cpp at build time. +add_custom_target(GitVersion ALL + DEPENDS something_that_never_exists) +add_custom_command(OUTPUT something_that_never_exists + COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} + -P ${CMAKE_CURRENT_SOURCE_DIR}/git-version.cmake) + +set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/git-version.cpp + PROPERTIES GENERATED TRUE) +add_dependencies(${CoreLibName} GitVersion) + add_library(GPU OBJECT GPU/GLES/DisplayListInterpreter.cpp GPU/GLES/DisplayListInterpreter.h diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index 3bbd94a384..6592c9a63c 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -85,6 +85,7 @@ set(SRCS PSPMixer.cpp System.cpp Core.cpp + ../git-version.cpp ) if(ARM) @@ -115,6 +116,17 @@ add_library(core STATIC ${SRCS}) target_link_libraries(core general common) target_link_libraries(core general base) +# Generate git-version.cpp at build time. +add_custom_target(GitVersion ALL + DEPENDS something_that_never_exists) +add_custom_command(OUTPUT something_that_never_exists + COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/.. + -P ${CMAKE_CURRENT_SOURCE_DIR}/../git-version.cmake) + +set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/../git-version.cpp + PROPERTIES GENERATED TRUE) +add_dependencies(core GitVersion) + if(UNIX) add_definitions(-fPIC) add_definitions(-std=gnu++0x) diff --git a/Core/Config.h b/Core/Config.h index e3d4139a19..8468158d46 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -20,8 +20,7 @@ #include #include -#define PPSSPP_VERSION_STR "0.6.1" - +extern const char *PPSSPP_GIT_VERSION; struct SState { diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index c744df54b3..7b4f9b0247 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -74,6 +74,10 @@ true + + ../Windows/git-version-gen.cmd + Updating git-version.cpp + @@ -87,6 +91,10 @@ true + + ../Windows/git-version-gen.cmd + Updating git-version.cpp + @@ -104,6 +112,11 @@ true true + + + ../Windows/git-version-gen.cmd + Updating git-version.cpp + @@ -120,11 +133,16 @@ true true + + ../Windows/git-version-gen.cmd + Updating git-version.cpp + + diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index 04d25d780a..fd4a7beda0 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -382,6 +382,7 @@ Font + diff --git a/Core/HLE/sceKernelVTimer.cpp b/Core/HLE/sceKernelVTimer.cpp index 4cb68c4305..eedd35e5fb 100644 --- a/Core/HLE/sceKernelVTimer.cpp +++ b/Core/HLE/sceKernelVTimer.cpp @@ -358,6 +358,8 @@ u32 sceKernelStopVTimer(u32 uid) { __stopVTimer(vt); return 1; } + + return error; } u32 sceKernelSetVTimerHandler(u32 uid, u32 scheduleAddr, u32 handlerFuncAddr, u32 commonAddr) { diff --git a/Core/MIPS/ARM/ArmCompVFPU.cpp b/Core/MIPS/ARM/ArmCompVFPU.cpp index 19cb4b6bbc..a9da1e75fa 100644 --- a/Core/MIPS/ARM/ArmCompVFPU.cpp +++ b/Core/MIPS/ARM/ArmCompVFPU.cpp @@ -120,7 +120,7 @@ namespace MIPSComp } void Jit::GetVectorRegsPrefixD(u8 *regs, VectorSize sz, int vectorReg) { - _assert_(js.prefixDFlag & JitState::PREFIX_KNOWN); + _assert_(js.prefixDFlag & ArmJitState::PREFIX_KNOWN); GetVectorRegs(regs, sz, vectorReg); if (js.prefixD == 0) @@ -136,7 +136,7 @@ namespace MIPSComp } void Jit::ApplyPrefixD(const u8 *vregs, VectorSize sz) { - _assert_(js.prefixDFlag & JitState::PREFIX_KNOWN); + _assert_(js.prefixDFlag & ArmJitState::PREFIX_KNOWN); if (!js.prefixD) return; int n = GetNumVectorElements(sz); diff --git a/Core/MIPS/ARM/ArmJit.h b/Core/MIPS/ARM/ArmJit.h index 358e6a83d1..8d9f4046c1 100644 --- a/Core/MIPS/ARM/ArmJit.h +++ b/Core/MIPS/ARM/ArmJit.h @@ -107,11 +107,11 @@ struct ArmJitState } } u8 VfpuWriteMask() const { - _assert_(prefixDFlag & JitState::PREFIX_KNOWN); + _assert_(prefixDFlag & PREFIX_KNOWN); return (prefixD >> 8) & 0xF; } bool VfpuWriteMask(int i) const { - _assert_(prefixDFlag & JitState::PREFIX_KNOWN); + _assert_(prefixDFlag & PREFIX_KNOWN); return (prefixD >> (8 + i)) & 1; } }; @@ -224,12 +224,12 @@ private: void ApplyPrefixST(u8 *vregs, u32 prefix, VectorSize sz); void ApplyPrefixD(const u8 *vregs, VectorSize sz); void GetVectorRegsPrefixS(u8 *regs, VectorSize sz, int vectorReg) { - _assert_(js.prefixSFlag & JitState::PREFIX_KNOWN); + _assert_(js.prefixSFlag & ArmJitState::PREFIX_KNOWN); GetVectorRegs(regs, sz, vectorReg); ApplyPrefixST(regs, js.prefixS, sz); } void GetVectorRegsPrefixT(u8 *regs, VectorSize sz, int vectorReg) { - _assert_(js.prefixTFlag & JitState::PREFIX_KNOWN); + _assert_(js.prefixTFlag & ArmJitState::PREFIX_KNOWN); GetVectorRegs(regs, sz, vectorReg); ApplyPrefixST(regs, js.prefixT, sz); } diff --git a/Core/System.cpp b/Core/System.cpp index 11fa6032a6..8a0581b7bf 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -32,6 +32,7 @@ #include "HLE/sceKernel.h" #include "HLE/sceKernelMemory.h" #include "HLE/sceAudio.h" +#include "Config.h" #include "Core.h" #include "CoreTiming.h" #include "CoreParameter.h" @@ -47,6 +48,8 @@ static PSPMixer *mixer; bool PSP_Init(const CoreParameter &coreParam, std::string *error_string) { + INFO_LOG(HLE, "PPSSPP %s", PPSSPP_GIT_VERSION); + coreParameter = coreParam; currentCPU = &mipsr4k; numCPUs = 1; diff --git a/Qt/Core.pro b/Qt/Core.pro index 69f6bb9fc8..f2060f8f24 100755 --- a/Qt/Core.pro +++ b/Qt/Core.pro @@ -4,6 +4,14 @@ TARGET = Core TEMPLATE = lib CONFIG += staticlib +version.target = ../git-version.cpp +version.commands = $$PWD/git-version-gen.sh +version.depends = ../.git + +QMAKE_EXTRA_TARGETS += version +PRE_TARGETDEPS += ../git-version.cpp +SOURCES += ../git-version.cpp + include(Settings.pri) INCLUDEPATH += ../native ../Core/MIPS ../ diff --git a/Qt/QtHost.cpp b/Qt/QtHost.cpp index 4295edf126..a5f04cb818 100644 --- a/Qt/QtHost.cpp +++ b/Qt/QtHost.cpp @@ -43,7 +43,7 @@ void QtHost::ShutdownGL() void QtHost::SetWindowTitle(const char *message) { - QString title = "PPSSPP " + QString(PPSSPP_VERSION_STR) + " - " + QString::fromUtf8(message); + QString title = "PPSSPP " + QString(PPSSPP_GIT_VERSION) + " - " + QString::fromUtf8(message); mainWindow->setWindowTitle(title); } diff --git a/Qt/git-version-gen.sh b/Qt/git-version-gen.sh new file mode 100755 index 0000000000..d441c38379 --- /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.cpp + +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.cpp, 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" diff --git a/Qt/mainwindow.cpp b/Qt/mainwindow.cpp index 498aaf4f41..eaec0249aa 100644 --- a/Qt/mainwindow.cpp +++ b/Qt/mainwindow.cpp @@ -884,7 +884,7 @@ void MainWindow::SetZoom(float zoom) { void MainWindow::SetGameTitle(QString text) { - QString title = "PPSSPP " + QString(PPSSPP_VERSION_STR); + QString title = "PPSSPP " + QString(PPSSPP_GIT_VERSION); if (text != "") title += QString(" - %1").arg(text); diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index cef4e558e6..7f17e86137 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -38,9 +38,7 @@ void WindowsHost::ShutdownGL() void WindowsHost::SetWindowTitle(const char *message) { - // Really need a better way to deal with versions. - std::string title = "PPSSPP " PPSSPP_VERSION_STR " - "; - title += message; + std::string title = std::string("PPSSPP ") + PPSSPP_GIT_VERSION + " - " + message; int size = MultiByteToWideChar(CP_UTF8, 0, message, (int) title.size(), NULL, 0); if (size > 0) diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 57208e3872..998b21bdb2 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -844,14 +844,13 @@ namespace MainWindow void SetPlaying(const char *text) { + char temp[256]; if (text == 0) - SetWindowText(hwndMain, "PPSSPP " PPSSPP_VERSION_STR); + snprintf(temp, 256, "PPSSPP %s", PPSSPP_GIT_VERSION); else - { - char temp[256]; - sprintf(temp, "%s - %s", text, "PPSSPP " PPSSPP_VERSION_STR); - SetWindowText(hwndMain,temp); - } + snprintf(temp, 256, "%s - PPSSPP %s", text, PPSSPP_GIT_VERSION); + temp[255] = '\0'; + SetWindowText(hwndMain, temp); } void SaveStateActionFinished(bool result, void *userdata) diff --git a/Windows/git-version-gen.cmd b/Windows/git-version-gen.cmd new file mode 100644 index 0000000000..b5d21bf512 --- /dev/null +++ b/Windows/git-version-gen.cmd @@ -0,0 +1,61 @@ +@echo off +rem // Copyright (c) 2012- PPSSPP Project. + +rem // This program is free software: you can redistribute it and/or modify +rem // it under the terms of the GNU General Public License as published by +rem // the Free Software Foundation, version 2.0 or later versions. + +rem // This program is distributed in the hope that it will be useful, +rem // but WITHOUT ANY WARRANTY; without even the implied warranty of +rem // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +rem // GNU General Public License 2.0 for more details. + +rem // A copy of the GPL 2.0 should have been included with the program. +rem // If not, see http://www.gnu.org/licenses/ + +rem // Official git repository and contact information can be found at +rem // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +setlocal + +set GIT_VERSION_FILE=%~p0..\git-version.cpp +if "%GIT%" == "" ( + set GIT=git +) + +if exist "%GIT_VERSION_FILE%" ( + rem // Skip updating the file if PPSSPP_GIT_VERSION_NO_UPDATE is 1. + findstr /B /C:"#define PPSSPP_GIT_VERSION_NO_UPDATE 1" "%GIT_VERSION_FILE%" > NUL + if not errorlevel 1 ( + goto done + ) +) + +"%GIT%" describe --always > NUL 2> NUL +if errorlevel 1 ( + echo Unable to update git-version.cpp, %GIT% not on path. + + echo // This is a generated file. > "%GIT_VERSION_FILE%" + echo. >> "%GIT_VERSION_FILE%" + echo const char *PPSSPP_GIT_VERSION = "unknown"; >> "%GIT_VERSION_FILE%" + goto done +) + +for /F %%I IN ('"%GIT%" describe --always') do set GIT_VERSION=%%I + +rem // Don't modify the file if it already has the current version. +if exist "%GIT_VERSION_FILE%" ( + findstr /C:"%GIT_VERSION%" "%GIT_VERSION_FILE%" > NUL + if not errorlevel 1 ( + goto done + ) +) + +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%" + +:done diff --git a/android/jni/MenuScreens.cpp b/android/jni/MenuScreens.cpp index f937860ad3..e9efc45834 100644 --- a/android/jni/MenuScreens.cpp +++ b/android/jni/MenuScreens.cpp @@ -168,7 +168,7 @@ void MenuScreen::render() { ui_draw2d.DrawTextShadow(UBUNTU48, "PPSSPP", dp_xres + xoff - w/2, 80, 0xFFFFFFFF, ALIGN_HCENTER | ALIGN_BOTTOM); ui_draw2d.SetFontScale(0.7f, 0.7f); - ui_draw2d.DrawTextShadow(UBUNTU24, PPSSPP_VERSION_STR, dp_xres + xoff, 80, 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_BOTTOM); + ui_draw2d.DrawTextShadow(UBUNTU24, PPSSPP_GIT_VERSION, dp_xres + xoff, 80, 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_BOTTOM); ui_draw2d.SetFontScale(1.0f, 1.0f); VLinear vlinear(dp_xres + xoff, 95, 20); @@ -444,9 +444,9 @@ void CreditsScreen::update(InputState &input_state) { frames_++; } -static const char *credits[] = +static char *credits[] = { - "PPSSPP " PPSSPP_VERSION_STR, + "PPSSPP", "", "", "A fast and portable PSP emulator", @@ -506,6 +506,11 @@ static const char *credits[] = }; void CreditsScreen::render() { + // TODO: This is kinda ugly, done on every frame... + char temp[256]; + snprinf(temp, 256, "PPSSPP %s", PPSSPP_GIT_VERSION); + credits[0] = temp; + UIShader_Prepare(); UIBegin(); DrawBackground(1.0f); diff --git a/git-version.cmake b/git-version.cmake new file mode 100644 index 0000000000..d55f76ae5c --- /dev/null +++ b/git-version.cmake @@ -0,0 +1,42 @@ +set(GIT_VERSION_FILE "${SOURCE_DIR}/git-version.cpp") +set(GIT_VERSION "unknown") +set(GIT_VERSION_UPDATE "1") + +find_package(Git) +if(GIT_FOUND) + execute_process(COMMAND ${GIT_EXECUTABLE} describe --always + RESULT_VARIABLE exit_code + OUTPUT_VARIABLE GIT_VERSION) + if(NOT ${exit_code} EQUAL 0) + message(WARNING "git describe failed, unable to include version.") + endif() + string(STRIP ${GIT_VERSION} GIT_VERSION) +else() + message(WARNING "git not found, unable to include version.") +endif() + +if(EXISTS ${GIT_VERSION_FILE}) + # Don't update if marked not to update. + file(STRINGS ${GIT_VERSION_FILE} match + REGEX "PPSSPP_GIT_VERSION_NO_UPDATE = 1") + if(NOT $[match} EQUAL "") + set(GIT_VERSION_UPDATE "0") + endif() + + # Don't update if it's already the same. + file(STRINGS ${GIT_VERSION_FILE} match + REGEX "${GIT_VERSION}") + if(NOT $[match} EQUAL "") + set(GIT_VERSION_UPDATE "0") + endif() +endif() + +set(code_string "// This is a generated file.\n\n" + "const char *PPSSPP_GIT_VERSION = \"${GIT_VERSION}\"\;\n\n" + "// If you don't want this file to update/recompile, change to 1.\n" + "#define PPSSPP_GIT_VERSION_NO_UPDATE 0\n") + +message(WARNING "UPDATE: ${GIT_VERSION_FILE}") +if ("${GIT_VERSION_UPDATE}" EQUAL "1") + file(WRITE ${GIT_VERSION_FILE} ${code_string}) +endif() \ No newline at end of file