[Android] Unified xenia-app with windowed apps and build prerequisites

This commit is contained in:
Triang3l 2022-07-11 21:45:57 +03:00
parent b41bb35a20
commit 037310f8dc
18 changed files with 176 additions and 43 deletions

View File

@ -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',
])

View File

@ -13,8 +13,7 @@ import jp.xenia.XeniaRuntimeException;
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 =

View File

@ -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",
@ -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")
@ -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

View File

@ -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",
@ -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",
})
@ -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",
@ -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"

View File

@ -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
@ -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"
@ -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);
}
@ -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);

View File

@ -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;

View File

@ -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",
},
}
},
})

View File

@ -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"
@ -21,8 +22,6 @@
#include "third_party/catch/include/catch.hpp"
#define XENIA_TEST_X64 1
namespace xe {
namespace cpu {
namespace testing {
@ -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>(

View File

@ -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",

View File

@ -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",

View File

@ -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"
@ -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"
@ -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);
@ -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())) {

View File

@ -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",
})
@ -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",

View File

@ -18,7 +18,7 @@ project("xenia-ui-d3d12")
group("demos")
project("xenia-ui-window-d3d12-demo")
uuid("3b9686a7-0f04-4e17-8b00-aeb78ae1107c")
kind("WindowedApp")
single_library_windowed_app_kind()
language("C++")
links({
"fmt",

View File

@ -0,0 +1,37 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2022 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include <memory>
#include "xenia/ui/file_picker.h"
namespace xe {
namespace ui {
// TODO(Triang3l): An asynchronous file picker with a callback, starting an
// activity for an ACTION_OPEN_DOCUMENT or an ACTION_OPEN_DOCUMENT_TREE intent.
// This intent, however, provides a content URI, not the file path directly.
// Accessing the file via the Storage Access Framework doesn't require the
// READ_EXTERNAL_STORAGE permission, unlike opening a file by its path directly.
// A file descriptor can be opened for the URI using
// Context.getContentResolver().openFileDescriptor (it will return a
// ParcelFileDescriptor, and a FileDescriptor can be obtained using its
// getFileDescriptor() method).
class AndroidFilePicker : public FilePicker {
public:
bool Show(Window* parent_window) override { return false; }
};
std::unique_ptr<FilePicker> FilePicker::Create() {
return std::make_unique<AndroidFilePicker>();
}
} // namespace ui
} // namespace xe

View File

@ -22,7 +22,7 @@ project("xenia-ui-vulkan")
group("demos")
project("xenia-ui-window-vulkan-demo")
uuid("97598f13-3177-454c-8e58-c59e2b6ede27")
kind("WindowedApp")
single_library_windowed_app_kind()
language("C++")
links({
"fmt",

View File

@ -5,4 +5,5 @@ include("scripts/force_compile_as_c.lua")
include("scripts/force_compile_as_cc.lua")
include("scripts/pkg_config.lua")
include("scripts/platform_files.lua")
include("scripts/single_library.lua")
include("scripts/test_suite.lua")

View File

@ -0,0 +1,20 @@
SINGLE_LIBRARY_PLATFORM_PATTERNS = {
"Android-*",
};
SINGLE_LIBRARY_FILTER =
"platforms:" .. table.concat(SINGLE_LIBRARY_PLATFORM_PATTERNS, " or ");
NOT_SINGLE_LIBRARY_FILTER = table.translate(
SINGLE_LIBRARY_PLATFORM_PATTERNS,
function(pattern)
return "platforms:not " .. pattern;
end);
function single_library_windowed_app_kind()
filter(SINGLE_LIBRARY_FILTER);
kind("StaticLib");
wholelib("On");
filter(NOT_SINGLE_LIBRARY_FILTER);
kind("WindowedApp");
filter({});
end

View File

@ -24,8 +24,14 @@ local function combined_test_suite(test_suite_name, project_root, base_path, con
libdirs(merge_arrays(config["libdirs"], {
project_root.."/"..build_bin,
}))
links(merge_arrays(config["links"], {
}))
links(config["links"])
if config.filtered_links ~= nil then
for _, filtered_links in ipairs(config.filtered_links) do
filter(filtered_links.filter)
links(filtered_links.links)
end
filter({})
end
defines({
"XE_TEST_SUITE_NAME=\""..test_suite_name.."\"",
})
@ -57,8 +63,14 @@ local function split_test_suite(test_suite_name, project_root, base_path, config
libdirs(merge_arrays(config["libdirs"], {
project_root.."/"..build_bin,
}))
links(merge_arrays(config["links"], {
}))
links(config["links"])
if config.filtered_links ~= nil then
for _, filtered_links in ipairs(config.filtered_links) do
filter(filtered_links.filter)
links(filtered_links.links)
end
filter({})
end
files({
project_root.."/"..build_tools_src.."/test_suite_main.cc",
file_path,