Adding build version information to main window/log.
This commit is contained in:
parent
5f61c6ad07
commit
5de82887fa
28
README.md
28
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:
|
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
|
> git clone https://github.com/benvanik/xenia.git
|
||||||
> cd xenia
|
> cd xenia
|
||||||
> xb setup
|
> xb setup
|
||||||
|
|
||||||
# Pull latest changes, rebase, and update submodules and premake:
|
# Pull latest changes, rebase, and update submodules and premake:
|
||||||
> xb pull
|
> xb pull
|
||||||
|
|
||||||
# Build on command line:
|
# Build on command line:
|
||||||
> xb build
|
> xb build
|
||||||
|
|
||||||
# Run premake and open Visual Studio (run the 'xenia-app' project):
|
# Run premake and open Visual Studio (run the 'xenia-app' project):
|
||||||
> xb devenv
|
> xb devenv
|
||||||
|
|
||||||
# Run premake to update the sln/vcproj's:
|
# Run premake to update the sln/vcproj's:
|
||||||
> xb premake
|
> xb premake
|
||||||
|
|
||||||
# Format code to the style guide:
|
# Format code to the style guide:
|
||||||
> xb format
|
> xb format
|
||||||
|
|
||||||
When fetching updates use `xb pull` to automatically fetch everything and
|
When fetching updates use `xb pull` to automatically fetch everything and
|
||||||
run premake for project files/etc.
|
run premake for project files/etc.
|
||||||
|
@ -87,4 +87,4 @@ For more see the main [frequently asked questions](http://xenia.jp/faq/) page.
|
||||||
|
|
||||||
### Can I get an exe?
|
### Can I get an exe?
|
||||||
|
|
||||||
Not yet.
|
Not yet.
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
|
|
||||||
#include "xenia/app/emulator_window.h"
|
#include "xenia/app/emulator_window.h"
|
||||||
|
|
||||||
|
// Autogenerated by `xb premake`.
|
||||||
|
#include "build/version.h"
|
||||||
|
|
||||||
#include "third_party/imgui/imgui.h"
|
#include "third_party/imgui/imgui.h"
|
||||||
#include "xenia/base/clock.h"
|
#include "xenia/base/clock.h"
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
|
@ -33,7 +36,11 @@ const std::wstring kBaseTitle = L"xenia";
|
||||||
EmulatorWindow::EmulatorWindow(Emulator* emulator)
|
EmulatorWindow::EmulatorWindow(Emulator* emulator)
|
||||||
: emulator_(emulator),
|
: emulator_(emulator),
|
||||||
loop_(ui::Loop::Create()),
|
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() {
|
EmulatorWindow::~EmulatorWindow() {
|
||||||
loop_->PostSynchronous([this]() { window_.reset(); });
|
loop_->PostSynchronous([this]() { window_.reset(); });
|
||||||
|
@ -189,6 +196,21 @@ bool EmulatorWindow::Initialize() {
|
||||||
// Help menu.
|
// Help menu.
|
||||||
auto help_menu = MenuItem::Create(MenuItem::Type::kPopup, L"&Help");
|
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(
|
help_menu->AddChild(
|
||||||
MenuItem::Create(MenuItem::Type::kString, L"&Website...", L"F1",
|
MenuItem::Create(MenuItem::Type::kString, L"&Website...", L"F1",
|
||||||
std::bind(&EmulatorWindow::ShowHelpWebsite, this)));
|
std::bind(&EmulatorWindow::ShowHelpWebsite, this)));
|
||||||
|
@ -253,7 +275,7 @@ void EmulatorWindow::ToggleFullscreen() {
|
||||||
void EmulatorWindow::ShowHelpWebsite() { LaunchBrowser("http://xenia.jp"); }
|
void EmulatorWindow::ShowHelpWebsite() { LaunchBrowser("http://xenia.jp"); }
|
||||||
|
|
||||||
void EmulatorWindow::UpdateTitle() {
|
void EmulatorWindow::UpdateTitle() {
|
||||||
std::wstring title(kBaseTitle);
|
std::wstring title(base_title_);
|
||||||
if (Clock::guest_time_scalar() != 1.0) {
|
if (Clock::guest_time_scalar() != 1.0) {
|
||||||
title += L" (@";
|
title += L" (@";
|
||||||
title += xe::to_wstring(std::to_string(Clock::guest_time_scalar()));
|
title += xe::to_wstring(std::to_string(Clock::guest_time_scalar()));
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#define XENIA_APP_EMULATOR_WINDOW_H_
|
#define XENIA_APP_EMULATOR_WINDOW_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "xenia/ui/loop.h"
|
#include "xenia/ui/loop.h"
|
||||||
#include "xenia/ui/menu_item.h"
|
#include "xenia/ui/menu_item.h"
|
||||||
|
@ -52,6 +53,7 @@ class EmulatorWindow {
|
||||||
Emulator* emulator_;
|
Emulator* emulator_;
|
||||||
std::unique_ptr<ui::Loop> loop_;
|
std::unique_ptr<ui::Loop> loop_;
|
||||||
std::unique_ptr<ui::Window> window_;
|
std::unique_ptr<ui::Window> window_;
|
||||||
|
std::wstring base_title_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
#include <gflags/gflags.h>
|
#include <gflags/gflags.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
|
// Autogenerated by `xb premake`.
|
||||||
|
#include "build/version.h"
|
||||||
|
|
||||||
#include "xenia/base/logging.h"
|
#include "xenia/base/logging.h"
|
||||||
#include "xenia/base/platform_win.h"
|
#include "xenia/base/platform_win.h"
|
||||||
#include "xenia/base/string.h"
|
#include "xenia/base/string.h"
|
||||||
|
@ -88,6 +91,10 @@ int Main() {
|
||||||
// Initialize logging. Needs parsed FLAGS.
|
// Initialize logging. Needs parsed FLAGS.
|
||||||
xe::InitializeLogging(entry_info.name);
|
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.
|
// Call app-provided entry point.
|
||||||
int result = entry_info.entry_point(args);
|
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
|
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():
|
def git_submodule_update():
|
||||||
"""Runs a full recursive git submodule init and update.
|
"""Runs a full recursive git submodule init and update.
|
||||||
|
|
||||||
|
@ -253,6 +304,7 @@ def run_premake(target_os, action):
|
||||||
'--verbose',
|
'--verbose',
|
||||||
action,
|
action,
|
||||||
])
|
])
|
||||||
|
generate_version_h()
|
||||||
|
|
||||||
|
|
||||||
def run_premake_clean():
|
def run_premake_clean():
|
||||||
|
|
Loading…
Reference in New Issue