Skip to content

Commit

Permalink
[Android] Unified xenia-app with windowed apps and build prerequisites
Browse files Browse the repository at this point in the history
  • Loading branch information
Triang3l committed Jul 11, 2022
1 parent b41bb35 commit 037310f
Show file tree
Hide file tree
Showing 18 changed files with 176 additions and 43 deletions.
15 changes: 7 additions & 8 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,36 @@ def targets_android(platform):
'mspack',
'snappy',
'xxhash',
'xenia-core',
'xenia-app',
# 'xenia-app-discord',
'xenia-apu',
'xenia-apu-nop',
'xenia-base',
'xenia-base-tests',
'xenia-core',
'xenia-cpu',
# 'xenia-cpu-tests',
# 'xenia-cpu-ppc-tests',
'xenia-cpu-tests',
'xenia-cpu-ppc-tests',
# 'xenia-cpu-backend-x64',
# 'xenia-debug-ui',
'xenia-gpu',
'xenia-gpu-shader-compiler',
'xenia-gpu-null',
'xenia-gpu-vulkan',
# 'xenia-gpu-vulkan-trace-viewer',
'xenia-gpu-vulkan-trace-viewer',
'xenia-gpu-vulkan-trace-dump',
'xenia-hid',
# 'xenia-hid-demo',
'xenia-hid-demo',
'xenia-hid-nop',
'xenia-kernel',
'xenia-ui',
'xenia-ui-vulkan',
# 'xenia-ui-window-vulkan-demo',
'xenia-ui-window-vulkan-demo',
'xenia-vfs',
'xenia-vfs-dump',
]
if platform == 'Android-x86_64':
targets.extend([
'xenia-cpu-tests',
'xenia-cpu-ppc-tests',
'xenia-cpu-backend-x64',
'xenia-debug-ui',
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

public abstract class WindowedAppActivity extends Activity {
static {
// TODO(Triang3l): Move all demos to libxenia.so.
System.loadLibrary("xenia-ui-window-vulkan-demo");
System.loadLibrary("xenia-app");
}

private final WindowSurfaceOnLayoutChangeListener mWindowSurfaceOnLayoutChangeListener =
Expand Down
11 changes: 7 additions & 4 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ filter("platforms:Android-*")
systemversion("24")
cppstl("c++")
staticruntime("On")
-- Hidden visibility is needed to prevent dynamic relocations in FFmpeg
-- AArch64 Neon libavcodec assembly with PIC (accesses extern lookup tables
-- using `adrp` and `add`, without the Global Object Table, expecting that all
-- FFmpeg symbols that aren't a part of the FFmpeg API are hidden by FFmpeg's
-- original build system) by resolving those relocations at link time instead.
visibility("Hidden")
links({
"android",
"dl",
Expand Down Expand Up @@ -272,6 +278,7 @@ workspace("xenia")
end

include("src/xenia")
include("src/xenia/app")
include("src/xenia/app/discord")
include("src/xenia/apu")
include("src/xenia/apu/nop")
Expand All @@ -293,10 +300,6 @@ workspace("xenia")
include("src/xenia/apu/sdl")
include("src/xenia/helper/sdl")
include("src/xenia/hid/sdl")

-- TODO(Triang3l): src/xenia/app has a dependency on xenia-helper-sdl, bring
-- it back later.
include("src/xenia/app")
end

if os.istarget("windows") then
Expand Down
50 changes: 41 additions & 9 deletions src/xenia/app/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,18 @@ include(project_root.."/tools/build")
group("src")
project("xenia-app")
uuid("d7e98620-d007-4ad8-9dbd-b47c8853a17f")
kind("WindowedApp")
targetname("xenia")
language("C++")
links({
"xenia-app-discord",
"xenia-apu",
"xenia-apu-nop",
"xenia-apu-sdl",
"xenia-base",
"xenia-core",
"xenia-cpu",
"xenia-debug-ui",
"xenia-gpu",
"xenia-gpu-null",
"xenia-gpu-vulkan",
"xenia-helper-sdl",
"xenia-hid",
"xenia-hid-nop",
"xenia-hid-sdl",
"xenia-kernel",
"xenia-ui",
"xenia-ui-vulkan",
Expand All @@ -48,7 +41,6 @@ project("xenia-app")
})
local_platform_files()
files({
"xenia_main.cc",
"../base/main_init_"..platform_suffix..".cc",
"../ui/windowed_app_main_"..platform_suffix..".cc",
})
Expand All @@ -57,19 +49,53 @@ project("xenia-app")
project_root,
})

filter(SINGLE_LIBRARY_FILTER)
-- Unified library containing all apps as StaticLibs, not just the main
-- emulator windowed app.
kind("SharedLib")
links({
"xenia-gpu-vulkan-trace-viewer",
"xenia-hid-demo",
"xenia-ui-window-vulkan-demo",
})
filter(NOT_SINGLE_LIBRARY_FILTER)
kind("WindowedApp")

-- `targetname` is broken if building from Gradle, works only for toggling the
-- `lib` prefix, as Gradle uses LOCAL_MODULE_FILENAME, not a derivative of
-- LOCAL_MODULE, to specify the targets to build when executing ndk-build.
filter("platforms:not Android-*")
targetname("xenia")

filter("architecture:x86_64")
links({
"xenia-cpu-backend-x64",
})

-- TODO(Triang3l): The emulator itself on Android.
filter("platforms:not Android-*")
files({
"xenia_main.cc",
})

filter("platforms:Windows")
files({
"main_resources.rc",
})

filter("files:../base/main_init_"..platform_suffix..".cc")
filter({"architecture:x86_64", "files:../base/main_init_"..platform_suffix..".cc"})
vectorextensions("IA32") -- Disable AVX for main_init_win.cc so our AVX check doesn't use AVX instructions.

filter("platforms:not Android-*")
links({
"xenia-app-discord",
"xenia-apu-sdl",
-- TODO(Triang3l): CPU debugger on Android.
"xenia-debug-ui",
"xenia-helper-sdl",
"xenia-hid-sdl",
})

filter("platforms:Linux")
links({
"X11",
Expand All @@ -87,6 +113,12 @@ project("xenia-app")
"xenia-ui-d3d12",
})

filter({"platforms:Windows", SINGLE_LIBRARY_FILTER})
links({
"xenia-gpu-d3d12-trace-viewer",
"xenia-ui-window-d3d12-demo",
})

filter("platforms:Windows")
-- Only create the .user file if it doesn't already exist.
local user_file = project_root.."/build/xenia-app.vcxproj.user"
Expand Down
8 changes: 8 additions & 0 deletions src/xenia/app/xenia_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@

// Available audio systems:
#include "xenia/apu/nop/nop_audio_system.h"
#if !XE_PLATFORM_ANDROID
#include "xenia/apu/sdl/sdl_audio_system.h"
#endif // !XE_PLATFORM_ANDROID
#if XE_PLATFORM_WIN32
#include "xenia/apu/xaudio2/xaudio2_audio_system.h"
#endif // XE_PLATFORM_WIN32
Expand All @@ -50,7 +52,9 @@

// Available input drivers:
#include "xenia/hid/nop/nop_hid.h"
#if !XE_PLATFORM_ANDROID
#include "xenia/hid/sdl/sdl_hid.h"
#endif // !XE_PLATFORM_ANDROID
#if XE_PLATFORM_WIN32
#include "xenia/hid/winkey/winkey_hid.h"
#include "xenia/hid/xinput/xinput_hid.h"
Expand Down Expand Up @@ -253,7 +257,9 @@ std::unique_ptr<apu::AudioSystem> EmulatorApp::CreateAudioSystem(
#if XE_PLATFORM_WIN32
factory.Add<apu::xaudio2::XAudio2AudioSystem>("xaudio2");
#endif // XE_PLATFORM_WIN32
#if !XE_PLATFORM_ANDROID
factory.Add<apu::sdl::SDLAudioSystem>("sdl");
#endif // !XE_PLATFORM_ANDROID
factory.Add<apu::nop::NopAudioSystem>("nop");
return factory.Create(cvars::apu, processor);
}
Expand Down Expand Up @@ -350,7 +356,9 @@ std::vector<std::unique_ptr<hid::InputDriver>> EmulatorApp::CreateInputDrivers(
#if XE_PLATFORM_WIN32
factory.Add("xinput", xe::hid::xinput::Create);
#endif // XE_PLATFORM_WIN32
#if !XE_PLATFORM_ANDROID
factory.Add("sdl", xe::hid::sdl::Create);
#endif // !XE_PLATFORM_ANDROID
#if XE_PLATFORM_WIN32
// WinKey input driver should always be the last input driver added!
factory.Add("winkey", xe::hid::winkey::Create);
Expand Down
2 changes: 2 additions & 0 deletions src/xenia/cpu/ppc/testing/ppc_testing_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ bool RunTests(const std::string_view test_name) {
int failed_count = 0;
int passed_count = 0;

#if XE_ARCH_AMD64
XELOGI("Instruction feature mask {}.", cvars::x64_extension_mask);
#endif // XE_ARCH_AMD64

auto test_path_root = cvars::test_path;
std::vector<std::filesystem::path> test_files;
Expand Down
9 changes: 8 additions & 1 deletion src/xenia/cpu/testing/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ test_suite("xenia-cpu-tests", project_root, ".", {
"xenia-base",
"xenia-core",
"xenia-cpu",
"xenia-cpu-backend-x64",

-- TODO(benvanik): cut these dependencies?
"xenia-kernel",
"xenia-ui", -- needed by xenia-base
},
filtered_links = {
{
filter = 'architecture:x86_64',
links = {
"xenia-cpu-backend-x64",
},
}
},
})
18 changes: 10 additions & 8 deletions src/xenia/cpu/testing/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <vector>

#include "xenia/base/platform.h"
#include "xenia/cpu/backend/x64/x64_backend.h"
#include "xenia/cpu/hir/hir_builder.h"
#include "xenia/cpu/ppc/ppc_context.h"
Expand All @@ -21,8 +22,6 @@

#include "third_party/catch/include/catch.hpp"

#define XENIA_TEST_X64 1

namespace xe {
namespace cpu {
namespace testing {
Expand All @@ -36,14 +35,17 @@ class TestFunction {
memory.reset(new Memory());
memory->Initialize();

#if XENIA_TEST_X64
{
auto backend = std::make_unique<xe::cpu::backend::x64::X64Backend>();
auto processor = std::make_unique<Processor>(memory.get(), nullptr);
processor->Setup(std::move(backend));
processors.emplace_back(std::move(processor));
std::unique_ptr<xe::cpu::backend::Backend> backend;
#if XE_ARCH_AMD64
backend.reset(new xe::cpu::backend::x64::X64Backend());
#endif // XE_ARCH
if (backend) {
auto processor = std::make_unique<Processor>(memory.get(), nullptr);
processor->Setup(std::move(backend));
processors.emplace_back(std::move(processor));
}
}
#endif // XENIA_TEST_X64

for (auto& processor : processors) {
auto module = std::make_unique<xe::cpu::TestModule>(
Expand Down
2 changes: 1 addition & 1 deletion src/xenia/gpu/d3d12/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ project("xenia-gpu-d3d12")
group("src")
project("xenia-gpu-d3d12-trace-viewer")
uuid("7b5b9fcb-7bf1-43ff-a774-d4c41c8706be")
kind("WindowedApp")
single_library_windowed_app_kind()
language("C++")
links({
"xenia-apu",
Expand Down
2 changes: 1 addition & 1 deletion src/xenia/gpu/vulkan/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ project("xenia-gpu-vulkan")
group("src")
project("xenia-gpu-vulkan-trace-viewer")
uuid("86a1dddc-a26a-4885-8c55-cf745225d93e")
kind("WindowedApp")
single_library_windowed_app_kind()
language("C++")
links({
"xenia-apu",
Expand Down
7 changes: 7 additions & 0 deletions src/xenia/hid/hid_demo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "xenia/base/clock.h"
#include "xenia/base/cvar.h"
#include "xenia/base/logging.h"
#include "xenia/base/platform.h"
#include "xenia/base/threading.h"
#include "xenia/hid/hid_flags.h"
#include "xenia/hid/input_system.h"
Expand All @@ -36,7 +37,9 @@

// Available input drivers:
#include "xenia/hid/nop/nop_hid.h"
#if !XE_PLATFORM_ANDROID
#include "xenia/hid/sdl/sdl_hid.h"
#endif // !XE_PLATFORM_ANDROID
#if XE_PLATFORM_WIN32
#include "xenia/hid/winkey/winkey_hid.h"
#include "xenia/hid/xinput/xinput_hid.h"
Expand Down Expand Up @@ -122,11 +125,13 @@ std::vector<std::unique_ptr<hid::InputDriver>> HidDemoApp::CreateInputDrivers(
std::vector<std::unique_ptr<hid::InputDriver>> drivers;
if (cvars::hid.compare("nop") == 0) {
drivers.emplace_back(xe::hid::nop::Create(window, kZOrderHidInput));
#if !XE_PLATFORM_ANDROID
} else if (cvars::hid.compare("sdl") == 0) {
auto driver = xe::hid::sdl::Create(window, kZOrderHidInput);
if (XSUCCEEDED(driver->Setup())) {
drivers.emplace_back(std::move(driver));
}
#endif // !XE_PLATFORM_ANDROID
#if XE_PLATFORM_WIN32
} else if (cvars::hid.compare("winkey") == 0) {
auto driver = xe::hid::winkey::Create(window, kZOrderHidInput);
Expand All @@ -140,10 +145,12 @@ std::vector<std::unique_ptr<hid::InputDriver>> HidDemoApp::CreateInputDrivers(
}
#endif // XE_PLATFORM_WIN32
} else {
#if !XE_PLATFORM_ANDROID
auto sdl_driver = xe::hid::sdl::Create(window, kZOrderHidInput);
if (sdl_driver && XSUCCEEDED(sdl_driver->Setup())) {
drivers.emplace_back(std::move(sdl_driver));
}
#endif // !XE_PLATFORM_ANDROID
#if XE_PLATFORM_WIN32
auto xinput_driver = xe::hid::xinput::Create(window, kZOrderHidInput);
if (xinput_driver && XSUCCEEDED(xinput_driver->Setup())) {
Expand Down
10 changes: 7 additions & 3 deletions src/xenia/hid/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ project("xenia-hid")
group("demos")
project("xenia-hid-demo")
uuid("a56a209c-16d5-4913-85f9-86976fe7fddf")
kind("WindowedApp")
single_library_windowed_app_kind()
language("C++")
links({
"fmt",
"imgui",
"xenia-base",
"xenia-helper-sdl",
"xenia-hid",
"xenia-hid-nop",
"xenia-hid-sdl",
"xenia-ui",
"xenia-ui-vulkan",
})
Expand All @@ -41,6 +39,12 @@ project("xenia-hid-demo")
project_root,
})

filter("platforms:not Android-*")
links({
"xenia-helper-sdl",
"xenia-hid-sdl",
})

filter("platforms:Linux")
links({
"SDL2",
Expand Down
Loading

0 comments on commit 037310f

Please sign in to comment.