Skip to content

Commit

Permalink
Get application version from git
Browse files Browse the repository at this point in the history
  • Loading branch information
jonian committed Aug 20, 2024
1 parent b099728 commit fbd8195
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 5 deletions.
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()

project(Alber)
set(PANDA3DS_VERSION "0.8")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

if(APPLE)
Expand Down Expand Up @@ -60,6 +61,30 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND ENABLE_USER_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS-")
endif()

find_package(Git)
if(GIT_FOUND)
execute_process(
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0
OUTPUT_VARIABLE PANDA3DS_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --tags
OUTPUT_VARIABLE git_version_tag OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT PANDA3DS_VERSION STREQUAL git_version_tag)
execute_process(
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --always --abbrev=7
OUTPUT_VARIABLE git_version_rev OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(PANDA3DS_VERSION "${PANDA3DS_VERSION}.${git_version_rev}")
unset(git_version_rev)
endif()
string(REGEX REPLACE "^v" "" PANDA3DS_VERSION "${PANDA3DS_VERSION}")
unset(git_version_tag)
endif()
configure_file(${PROJECT_SOURCE_DIR}/include/version.hpp.in ${CMAKE_BINARY_DIR}/include/version.hpp)
include_directories(${CMAKE_BINARY_DIR}/include/)

add_library(AlberCore STATIC)

include_directories(${PROJECT_SOURCE_DIR}/include/)
Expand Down
1 change: 1 addition & 0 deletions include/version.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define PANDA3DS_VERSION "${PANDA3DS_VERSION}"
3 changes: 2 additions & 1 deletion src/hydra_core.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <version.hpp>
#include <emulator.hpp>
#include <hydra/core.hxx>
#include <renderer_gl/renderer_gl.hpp>
Expand Down Expand Up @@ -150,7 +151,7 @@ HC_API const char* getInfo(hydra::InfoType type) {
case hydra::InfoType::SystemName: return "Nintendo 3DS";
case hydra::InfoType::Description: return "HLE 3DS emulator. There's a little Alber in your computer and he runs Nintendo 3DS games.";
case hydra::InfoType::Author: return "wheremyfoodat (Peach)";
case hydra::InfoType::Version: return "0.7";
case hydra::InfoType::Version: return PANDA3DS_VERSION;
case hydra::InfoType::License: return "GPLv3";
case hydra::InfoType::Website: return "https://panda3ds.com/";
case hydra::InfoType::Extensions: return "3ds,cci,cxi,app,3dsx,elf,axf";
Expand Down
3 changes: 2 additions & 1 deletion src/libretro_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <libretro.h>

#include <version.hpp>
#include <emulator.hpp>
#include <renderer_gl/renderer_gl.hpp>

Expand Down Expand Up @@ -200,7 +201,7 @@ static void ConfigCheckVariables() {
void retro_get_system_info(retro_system_info* info) {
info->need_fullpath = true;
info->valid_extensions = "3ds|3dsx|elf|axf|cci|cxi|app";
info->library_version = "0.8";
info->library_version = PANDA3DS_VERSION;
info->library_name = "Panda3DS";
info->block_extract = true;
}
Expand Down
4 changes: 4 additions & 0 deletions src/panda_qt/about_window.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "panda_qt/about_window.hpp"
#include "version.hpp"

#include <QLabel>
#include <QTextEdit>
Expand All @@ -17,6 +18,8 @@ AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) {
QStringLiteral(R"(
<p style='font-size:38pt; font-weight:400;'>Panda3DS</p>
<p style='font-size:18pt;'>v%VERSION_STRING%</p>
<p>
%ABOUT_PANDA3DS%<br>
<a href='https://panda3ds.com/'>%SUPPORT%</a><br>
Expand All @@ -26,6 +29,7 @@ AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) {
<a>%AUTHORS%</a>
</p>
)")
.replace(QStringLiteral("%VERSION_STRING%"), PANDA3DS_VERSION)
.replace(QStringLiteral("%ABOUT_PANDA3DS%"), tr("Panda3DS is a free and open source Nintendo 3DS emulator, for Windows, MacOS and Linux"))
.replace(QStringLiteral("%SUPPORT%"), tr("Visit panda3ds.com for help with Panda3DS and links to our official support sites."))
.replace(
Expand Down
3 changes: 2 additions & 1 deletion src/panda_qt/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
#include <cstdio>
#include <fstream>

#include "version.hpp"
#include "cheats.hpp"
#include "input_mappings.hpp"
#include "sdl_sensors.hpp"
#include "services/dsp.hpp"

MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent), keyboardMappings(InputMappings::defaultKeyboardMappings()) {
setWindowTitle("Alber");
setWindowTitle("Alber - " PANDA3DS_VERSION);
// Enable drop events for loading ROMs
setAcceptDrops(true);
resize(800, 240 * 4);
Expand Down
6 changes: 4 additions & 2 deletions src/panda_sdl/frontend_sdl.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "panda_sdl/frontend_sdl.hpp"
#include "version.hpp"

#include <glad/gl.h>

Expand Down Expand Up @@ -32,14 +33,15 @@ FrontendSDL::FrontendSDL() : keyboardMappings(InputMappings::defaultKeyboardMapp
#ifdef PANDA3DS_ENABLE_OPENGL
needOpenGL = needOpenGL || (config.rendererType == RendererType::OpenGL);
#endif
std::string windowTitle = "Alber - " PANDA3DS_VERSION;

if (needOpenGL) {
// Demand 3.3 core for software renderer, or 4.1 core for OpenGL renderer (max available on MacOS)
// MacOS gets mad if we don't explicitly demand a core profile
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, config.rendererType == RendererType::Software ? 3 : 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, config.rendererType == RendererType::Software ? 3 : 1);
window = SDL_CreateWindow("Alber", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 400, 480, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
window = SDL_CreateWindow(windowTitle, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 400, 480, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);

if (window == nullptr) {
Helpers::panic("Window creation failed: %s", SDL_GetError());
Expand All @@ -59,7 +61,7 @@ FrontendSDL::FrontendSDL() : keyboardMappings(InputMappings::defaultKeyboardMapp

#ifdef PANDA3DS_ENABLE_VULKAN
if (config.rendererType == RendererType::Vulkan) {
window = SDL_CreateWindow("Alber", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 400, 480, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);
window = SDL_CreateWindow(windowTitle, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 400, 480, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);

if (window == nullptr) {
Helpers::warn("Window creation failed: %s", SDL_GetError());
Expand Down

0 comments on commit fbd8195

Please sign in to comment.