More string swapping and cleaning up main().

This commit is contained in:
Ben Vanik
2014-08-16 16:34:04 -07:00
parent 18ee972b47
commit 7c5fa88661
41 changed files with 326 additions and 413 deletions

View File

@@ -13,6 +13,7 @@
#include <alloy/frontend/ppc/ppc_context.h>
#include <alloy/frontend/ppc/ppc_frontend.h>
#include <alloy/runtime/raw_module.h>
#include <poly/main.h>
#include <poly/poly.h>
#include <xenia/cpu/xenon_memory.h>
@@ -75,7 +76,7 @@ class ThreadState : public alloy::runtime::ThreadState {
// TODO(benvanik): simple memory? move more into core?
int main(int argc, xechar_t** argv) {
int main(std::vector<std::wstring>& args) {
xe::Profiler::Initialize();
xe::Profiler::ThreadEnter("main");
@@ -122,7 +123,4 @@ int main(int argc, xechar_t** argv) {
} // namespace sandbox
} // namespace alloy
// TODO(benvanik): move main thunk into poly
// ehhh
#include <xenia/platform.cc>
XE_MAIN_THUNK(alloy::sandbox::main, "alloy-sandbox");
DEFINE_ENTRY_POINT(L"alloy-sandbox", L"?", alloy::sandbox::main);

View File

@@ -5,6 +5,12 @@
'target_name': 'alloy-sandbox',
'type': 'executable',
'msvs_settings': {
'VCLinkerTool': {
'SubSystem': '1'
},
},
'dependencies': [
'alloy',
'xenia',

View File

@@ -10,6 +10,7 @@
#include <memory>
#include <gflags/gflags.h>
#include <poly/main.h>
#include <poly/poly.h>
#include <xdb/postmortem_debug_target.h>
#include <xdb/xdb.h>
@@ -21,7 +22,7 @@ namespace xc {
using xdb::PostmortemDebugTarget;
int main(int argc, xechar_t** argv) {
int main(std::vector<std::wstring>& args) {
// Create platform abstraction layer.
xe_pal_options_t pal_options;
xe_zero_struct(&pal_options, sizeof(pal_options));
@@ -46,6 +47,4 @@ int main(int argc, xechar_t** argv) {
} // namespace xc
// TODO(benvanik): move main thunk into poly
// ehhh
XE_MAIN_WINDOW_THUNK(xc::main, L"xenia-compare", "xenia-compare");
DEFINE_ENTRY_POINT(L"xenia-compare", L"xenia-compare", xc::main);

View File

@@ -7,8 +7,8 @@
'msvs_settings': {
'VCLinkerTool': {
'SubSystem': '2'
}
'SubSystem': '1'
},
},
'dependencies': [

View File

@@ -12,6 +12,7 @@
#include <memory>
#include <gflags/gflags.h>
#include <poly/main.h>
#include <poly/poly.h>
#include <third_party/wxWidgets/include/wx/wx.h>
#include <xdb/ui/xdb_app.h>
@@ -22,7 +23,7 @@ DEFINE_string(content_file, "",
namespace xdb {
int main(int argc, xechar_t** argv) {
int main(std::vector<std::wstring>& args) {
// Create platform abstraction layer.
xe_pal_options_t pal_options;
xe_zero_struct(&pal_options, sizeof(pal_options));
@@ -67,6 +68,4 @@ int main(int argc, xechar_t** argv) {
} // namespace xdb
// TODO(benvanik): move main thunk into poly
// ehhh
XE_MAIN_WINDOW_THUNK(xdb::main, L"xenia-debug", "xenia-debug");
DEFINE_ENTRY_POINT(L"xenia-debug", L"xenia-debug", xdb::main);

View File

@@ -8,7 +8,7 @@
'msvs_settings': {
'VCLinkerTool': {
'SubSystem': '2'
}
},
},
'dependencies': [

View File

@@ -10,16 +10,13 @@
#include <xenia/xenia.h>
#include <gflags/gflags.h>
#include <poly/main.h>
using namespace xe;
DEFINE_string(target, "", "Specifies the target .xex or .iso to execute.");
DEFINE_string(target, "",
"Specifies the target .xex or .iso to execute.");
int xenia_run(int argc, xechar_t** argv) {
int xenia_run(std::vector<std::wstring>& args) {
int result_code = 1;
Profiler::Initialize();
@@ -28,33 +25,28 @@ int xenia_run(int argc, xechar_t** argv) {
Emulator* emulator = NULL;
// Grab path from the flag or unnamed argument.
if (!FLAGS_target.size() && argc < 2) {
if (!FLAGS_target.size() && args.size() < 2) {
google::ShowUsageWithFlags("xenia-run");
XEFATAL("Pass a file to launch.");
return 1;
}
const xechar_t* path = NULL;
std::wstring path;
if (FLAGS_target.size()) {
// Passed as a named argument.
// TODO(benvanik): find something better than gflags that supports unicode.
xechar_t buffer[poly::max_path];
XEIGNORE(xestrwiden(buffer, sizeof(buffer), FLAGS_target.c_str()));
path = buffer;
path = poly::to_wstring(FLAGS_target);
} else {
// Passed as an unnamed argument.
path = argv[1];
path = args[1];
}
// Normalize the path and make absolute.
std::wstring abs_path = poly::to_absolute_path(path);
// Create platform abstraction layer.
xe_pal_options_t pal_options;
xe_zero_struct(&pal_options, sizeof(pal_options));
XEEXPECTZERO(xe_pal_init(pal_options));
// Normalize the path and make absolute.
// TODO(benvanik): move this someplace common.
xechar_t abs_path[poly::max_path];
xe_path_get_absolute(path, abs_path, XECOUNT(abs_path));
// Create the emulator.
emulator = new Emulator(L"");
XEEXPECTNOTNULL(emulator);
@@ -93,4 +85,5 @@ XECLEANUP:
Profiler::Shutdown();
return result_code;
}
XE_MAIN_WINDOW_THUNK(xenia_run, L"xenia-run", "xenia-run some.xex");
DEFINE_ENTRY_POINT(L"xenia-run", L"xenia-run some.xex", xenia_run);

View File

@@ -8,7 +8,7 @@
'msvs_settings': {
'VCLinkerTool': {
'SubSystem': '2'
}
},
},
'dependencies': [

View File

@@ -14,6 +14,8 @@
#endif // !WIN32
#include <gflags/gflags.h>
#include <poly/main.h>
using namespace std;
using namespace xe;
@@ -273,7 +275,7 @@ int xenia_test(int argc, xechar_t **argv) {
if (argc >= 2) {
test_name = argv[1];
}
string test_name_str;
if (test_name) {
#if XE_WCHAR
@@ -290,4 +292,5 @@ int xenia_test(int argc, xechar_t **argv) {
return result_code;
}
XE_MAIN_THUNK(xenia_test, "xenia-test some.xex");
DEFINE_ENTRY_POINT(L"xenia-test", L"xenia-test some.xex", xenia_test);

View File

@@ -5,6 +5,12 @@
'target_name': 'xenia-test',
'type': 'executable',
'msvs_settings': {
'VCLinkerTool': {
'SubSystem': '1',
},
},
'dependencies': [
'xenia',
],