Adding build version information to main window/log.
This commit is contained in:
parent
5f61c6ad07
commit
5de82887fa
26
README.md
26
README.md
|
@ -33,24 +33,24 @@ legally purchased devices and games and information made public on the internet
|
|||
|
||||
Windows 8.1+ with Python 2.7 and [Visual Studio 2015](https://www.visualstudio.com/downloads/download-visual-studio-vs) and the Windows SDKs installed:
|
||||
|
||||
> git clone https://github.com/benvanik/xenia.git
|
||||
> cd xenia
|
||||
> xb setup
|
||||
> git clone https://github.com/benvanik/xenia.git
|
||||
> cd xenia
|
||||
> xb setup
|
||||
|
||||
# Pull latest changes, rebase, and update submodules and premake:
|
||||
> xb pull
|
||||
# Pull latest changes, rebase, and update submodules and premake:
|
||||
> xb pull
|
||||
|
||||
# Build on command line:
|
||||
> xb build
|
||||
# Build on command line:
|
||||
> xb build
|
||||
|
||||
# Run premake and open Visual Studio (run the 'xenia-app' project):
|
||||
> xb devenv
|
||||
# Run premake and open Visual Studio (run the 'xenia-app' project):
|
||||
> xb devenv
|
||||
|
||||
# Run premake to update the sln/vcproj's:
|
||||
> xb premake
|
||||
# Run premake to update the sln/vcproj's:
|
||||
> xb premake
|
||||
|
||||
# Format code to the style guide:
|
||||
> xb format
|
||||
# Format code to the style guide:
|
||||
> xb format
|
||||
|
||||
When fetching updates use `xb pull` to automatically fetch everything and
|
||||
run premake for project files/etc.
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
#include "xenia/app/emulator_window.h"
|
||||
|
||||
// Autogenerated by `xb premake`.
|
||||
#include "build/version.h"
|
||||
|
||||
#include "third_party/imgui/imgui.h"
|
||||
#include "xenia/base/clock.h"
|
||||
#include "xenia/base/logging.h"
|
||||
|
@ -33,7 +36,11 @@ const std::wstring kBaseTitle = L"xenia";
|
|||
EmulatorWindow::EmulatorWindow(Emulator* emulator)
|
||||
: emulator_(emulator),
|
||||
loop_(ui::Loop::Create()),
|
||||
window_(ui::Window::Create(loop_.get(), kBaseTitle)) {}
|
||||
window_(ui::Window::Create(loop_.get(), kBaseTitle)) {
|
||||
base_title_ = kBaseTitle + L" (" + xe::to_wstring(XE_BUILD_BRANCH) + L"/" +
|
||||
xe::to_wstring(XE_BUILD_COMMIT_SHORT) + L"/" +
|
||||
xe::to_wstring(XE_BUILD_DATE) + L")";
|
||||
}
|
||||
|
||||
EmulatorWindow::~EmulatorWindow() {
|
||||
loop_->PostSynchronous([this]() { window_.reset(); });
|
||||
|
@ -189,6 +196,21 @@ bool EmulatorWindow::Initialize() {
|
|||
// Help menu.
|
||||
auto help_menu = MenuItem::Create(MenuItem::Type::kPopup, L"&Help");
|
||||
{
|
||||
help_menu->AddChild(MenuItem::Create(
|
||||
MenuItem::Type::kString, L"Build commit on GitHub...", [this]() {
|
||||
std::string url =
|
||||
std::string("https://github.com/benvanik/xenia/tree/") +
|
||||
XE_BUILD_COMMIT + "/";
|
||||
LaunchBrowser(url.c_str());
|
||||
}));
|
||||
help_menu->AddChild(MenuItem::Create(
|
||||
MenuItem::Type::kString, L"Recent changes on GitHub...", [this]() {
|
||||
std::string url =
|
||||
std::string("https://github.com/benvanik/xenia/compare/") +
|
||||
XE_BUILD_COMMIT + "..." + XE_BUILD_BRANCH;
|
||||
LaunchBrowser(url.c_str());
|
||||
}));
|
||||
help_menu->AddChild(MenuItem::Create(MenuItem::Type::kSeparator));
|
||||
help_menu->AddChild(
|
||||
MenuItem::Create(MenuItem::Type::kString, L"&Website...", L"F1",
|
||||
std::bind(&EmulatorWindow::ShowHelpWebsite, this)));
|
||||
|
@ -253,7 +275,7 @@ void EmulatorWindow::ToggleFullscreen() {
|
|||
void EmulatorWindow::ShowHelpWebsite() { LaunchBrowser("http://xenia.jp"); }
|
||||
|
||||
void EmulatorWindow::UpdateTitle() {
|
||||
std::wstring title(kBaseTitle);
|
||||
std::wstring title(base_title_);
|
||||
if (Clock::guest_time_scalar() != 1.0) {
|
||||
title += L" (@";
|
||||
title += xe::to_wstring(std::to_string(Clock::guest_time_scalar()));
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#define XENIA_APP_EMULATOR_WINDOW_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "xenia/ui/loop.h"
|
||||
#include "xenia/ui/menu_item.h"
|
||||
|
@ -52,6 +53,7 @@ class EmulatorWindow {
|
|||
Emulator* emulator_;
|
||||
std::unique_ptr<ui::Loop> loop_;
|
||||
std::unique_ptr<ui::Window> window_;
|
||||
std::wstring base_title_;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
#include <gflags/gflags.h>
|
||||
#include <io.h>
|
||||
|
||||
// Autogenerated by `xb premake`.
|
||||
#include "build/version.h"
|
||||
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/platform_win.h"
|
||||
#include "xenia/base/string.h"
|
||||
|
@ -88,6 +91,10 @@ int Main() {
|
|||
// Initialize logging. Needs parsed FLAGS.
|
||||
xe::InitializeLogging(entry_info.name);
|
||||
|
||||
// Print version info.
|
||||
XELOGI("Build: %s / %s on %s", XE_BUILD_BRANCH, XE_BUILD_COMMIT,
|
||||
XE_BUILD_DATE);
|
||||
|
||||
// Call app-provided entry point.
|
||||
int result = entry_info.entry_point(args);
|
||||
|
||||
|
|
52
xenia-build
52
xenia-build
|
@ -178,6 +178,57 @@ def shell_call(command, throw_on_error=True, stdout_path=None):
|
|||
return result
|
||||
|
||||
|
||||
def get_git_head_info():
|
||||
"""Queries the current branch and commit checksum from git.
|
||||
|
||||
Returns:
|
||||
(branch_name, commit, commit_short)
|
||||
If the user is not on any branch the name will be 'detached'.
|
||||
"""
|
||||
p = subprocess.Popen([
|
||||
'git',
|
||||
'symbolic-ref',
|
||||
'--short',
|
||||
'-q',
|
||||
'HEAD',
|
||||
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(stdout, stderr) = p.communicate()
|
||||
branch_name = stdout.strip() or 'detached'
|
||||
p = subprocess.Popen([
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(stdout, stderr) = p.communicate()
|
||||
commit = stdout.strip() or 'unknown'
|
||||
p = subprocess.Popen([
|
||||
'git',
|
||||
'rev-parse',
|
||||
'--short',
|
||||
'HEAD',
|
||||
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(stdout, stderr) = p.communicate()
|
||||
commit_short = stdout.strip() or 'unknown'
|
||||
return (branch_name, commit, commit_short)
|
||||
|
||||
|
||||
def generate_version_h():
|
||||
"""Generates a build/version.h file that contains current git info.
|
||||
"""
|
||||
(branch_name, commit, commit_short) = get_git_head_info()
|
||||
contents = '''// Autogenerated by `xb premake`.
|
||||
#ifndef GENERATED_VERSION_H_
|
||||
#define GENERATED_VERSION_H_
|
||||
#define XE_BUILD_BRANCH "%s"
|
||||
#define XE_BUILD_COMMIT "%s"
|
||||
#define XE_BUILD_COMMIT_SHORT "%s"
|
||||
#define XE_BUILD_DATE __DATE__
|
||||
#endif // GENERATED_VERSION_H_
|
||||
''' % (branch_name, commit, commit_short)
|
||||
with open('build/version.h', 'w') as f:
|
||||
f.write(contents)
|
||||
|
||||
|
||||
def git_submodule_update():
|
||||
"""Runs a full recursive git submodule init and update.
|
||||
|
||||
|
@ -253,6 +304,7 @@ def run_premake(target_os, action):
|
|||
'--verbose',
|
||||
action,
|
||||
])
|
||||
generate_version_h()
|
||||
|
||||
|
||||
def run_premake_clean():
|
||||
|
|
Loading…
Reference in New Issue