mirror of
https://github.com/izzy2lost/WeeU.git
synced 2026-07-06 00:19:59 -07:00
Make it easy to build Cemu on BSD (#1632)
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
- [Installing Tool Dependencies](#installing-tool-dependencies)
|
||||
- [Installing Library Dependencies](#installing-library-dependencies)
|
||||
- [Build Cemu using CMake](#build-cemu-using-cmake)
|
||||
- [FreeBSD](#freebsd)
|
||||
- [Installing Dependencies](#installing-dependencies)
|
||||
- [Build Cemu on BSD with CMake](#build-cemu-on-bsd-with-cmake)
|
||||
- [Updating Cemu and source code](#updating-cemu-and-source-code)
|
||||
|
||||
## Windows
|
||||
@@ -185,6 +188,33 @@ Then install the dependencies:
|
||||
#### Troubleshooting steps
|
||||
- If step 3 gives you an error about not being able to find ninja, try appending `-DCMAKE_MAKE_PROGRAM=/usr/local/bin/ninja` to the command and running it again.
|
||||
|
||||
## FreeBSD
|
||||
|
||||
The following instructions to build Cemu on FreeBSD are experimental. Some features available on other platforms are not available on FreeBSD (discord rich presence, bluetooth/support for actual Wii U controllers, auto-updates, etc.)
|
||||
|
||||
To compile Cemu, a recent enough compiler and STL with C++20 support is required! Clang-15 or higher is what we recommend. Any version of FreeBSD 13.3-RELEASE or higher comes bundled with LLVM > version 15 as part of the base system. However, if for whatever reason your system lacks a recent version of LLVM you can install one by executing:
|
||||
|
||||
`sudo pkg install llvm15`
|
||||
|
||||
Or a higher version as desired.
|
||||
|
||||
### Installing Dependencies
|
||||
|
||||
`sudo pkg install boost-libs cmake-core curl glslang gtk3 libzip ninja png pkgconf pugixml rapidjson sdl2 wayland wayland-protocols wx32-gtk3 xorg zstd`
|
||||
|
||||
### Build Cemu on BSD with CMake
|
||||
|
||||
```
|
||||
git clone --recursive https://github.com/cemu-project/Cemu
|
||||
cd Cemu
|
||||
cmake -B build -DCMAKE_BUILD_TYPE=release -DENABLE_BLUEZ=OFF -DENABLE_DISCORD_RPC=OFF -DENABLE_FERAL_GAMEMODE=OFF -DENABLE_HIDAPI=OFF -DENABLE_VCPKG=OFF -G Ninja
|
||||
cmake --build build
|
||||
|
||||
cd build && ninja install
|
||||
```
|
||||
|
||||
You should now have a Cemu executable file in the /bin folder, which you can run using `./bin/Cemu_release`.
|
||||
|
||||
## Updating Cemu and source code
|
||||
1. To update your Cemu local repository, use the command `git pull --recurse-submodules` (run this command on the Cemu root).
|
||||
- This should update your local copy of Cemu and all of its dependencies.
|
||||
|
||||
+2
-2
@@ -159,7 +159,7 @@ if (UNIX AND NOT APPLE)
|
||||
BASENAME viewporter)
|
||||
add_library(CemuWaylandProtocols STATIC ${WAYLAND_PROTOCOL_SRCS})
|
||||
target_include_directories(CemuWaylandProtocols PUBLIC "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
target_include_directories(CemuWaylandProtocols PRIVATE ${Wayland_INCLUDE_DIRS})
|
||||
add_compile_definitions(HAS_WAYLAND)
|
||||
endif()
|
||||
find_package(GTK3 REQUIRED)
|
||||
@@ -234,4 +234,4 @@ if (NOT ZArchive_FOUND)
|
||||
add_subdirectory("dependencies/ZArchive" EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -150,3 +150,7 @@ if(UNIX AND NOT APPLE)
|
||||
# most likely not helpful in debugging problems with cemu code
|
||||
target_link_options(CemuBin PRIVATE "$<$<CONFIG:Release>:-Xlinker;--strip-debug>")
|
||||
endif()
|
||||
|
||||
if (BSD)
|
||||
target_link_libraries(CemuBin PRIVATE execinfo SPIRV-Tools SPIRV-Tools-opt)
|
||||
endif()
|
||||
|
||||
+17
-1
@@ -69,7 +69,7 @@
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#include <sys/sysinfo.h>
|
||||
#elif BOOST_OS_MACOS
|
||||
#elif BOOST_OS_MACOS || BOOST_OS_BSD
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
@@ -473,6 +473,12 @@ namespace CafeSystem
|
||||
int64_t totalRam;
|
||||
size_t size = sizeof(totalRam);
|
||||
int result = sysctlbyname("hw.memsize", &totalRam, &size, NULL, 0);
|
||||
if (result == 0)
|
||||
cemuLog_log(LogType::Force, "RAM: {}MB", (totalRam / 1024LL / 1024LL));
|
||||
#elif BOOST_OS_BSD
|
||||
int64_t totalRam;
|
||||
size_t size = sizeof(totalRam);
|
||||
int result = sysctlbyname("hw.physmem", &totalRam, &size, NULL, 0);
|
||||
if (result == 0)
|
||||
cemuLog_log(LogType::Force, "RAM: {}MB", (totalRam / 1024LL / 1024LL));
|
||||
#endif
|
||||
@@ -523,6 +529,16 @@ namespace CafeSystem
|
||||
platform = "Linux";
|
||||
#elif BOOST_OS_MACOS
|
||||
platform = "MacOS";
|
||||
#elif BOOST_OS_BSD
|
||||
#if defined(__FreeBSD__)
|
||||
platform = "FreeBSD";
|
||||
#elif defined(__OpenBSD__)
|
||||
platform = "OpenBSD";
|
||||
#elif defined(__NetBSD__)
|
||||
platform = "NetBSD";
|
||||
#else
|
||||
platform = "Unknown BSD";
|
||||
#endif
|
||||
#endif
|
||||
cemuLog_log(LogType::Force, "Platform: {}", platform);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ using namespace Latte;
|
||||
namespace LatteAddrLib
|
||||
{
|
||||
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD
|
||||
unsigned char _BitScanReverse(uint32* _Index, uint32 _Mask)
|
||||
{
|
||||
if (!_Mask)
|
||||
@@ -402,4 +402,4 @@ namespace LatteAddrLib
|
||||
return finalMacroTileOffset | pipeOffset | bankOffset;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -241,7 +241,7 @@ void LoadOpenGLImports()
|
||||
#include "Common/GLInclude/glFunctions.h"
|
||||
#undef GLFUNC
|
||||
}
|
||||
#elif BOOST_OS_LINUX
|
||||
#elif BOOST_OS_LINUX || BOOST_OS_BSD
|
||||
GL_IMPORT _GetOpenGLFunction(void* hLib, PFNGLXGETPROCADDRESSPROC func, const char* name)
|
||||
{
|
||||
GL_IMPORT r = (GL_IMPORT)func((const GLubyte*)name);
|
||||
@@ -276,7 +276,7 @@ void LoadOpenGLImports()
|
||||
#undef EGLFUNC
|
||||
}
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_BSD
|
||||
// dummy function for all code that is statically linked with cemu and attempts to use eglSwapInterval
|
||||
// used to suppress wxWidgets calls to eglSwapInterval
|
||||
extern "C"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
#include <glslang/SPIRV/GlslangToSpv.h>
|
||||
#include <util/helpers/helpers.h>
|
||||
#include "util/helpers/helpers.h"
|
||||
|
||||
bool s_isLoadingShadersVk{ false };
|
||||
class FileCache* s_spirvCache{nullptr};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h"
|
||||
#include <numeric> // for std::iota
|
||||
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
@@ -138,7 +138,7 @@ bool InitializeDeviceVulkan(VkDevice device)
|
||||
|
||||
void* dlopen_vulkan_loader()
|
||||
{
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_BSD
|
||||
void* vulkan_so = dlopen("libvulkan.so", RTLD_NOW);
|
||||
if(!vulkan_so)
|
||||
vulkan_so = dlopen("libvulkan.so.1", RTLD_NOW);
|
||||
|
||||
@@ -130,7 +130,7 @@ VKFUNC_DEVICE(vkDestroyPipeline);
|
||||
VKFUNC_DEVICE(vkCmdBindPipeline);
|
||||
|
||||
// swapchain
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_BSD
|
||||
VKFUNC_INSTANCE(vkCreateXlibSurfaceKHR);
|
||||
VKFUNC_INSTANCE(vkCreateXcbSurfaceKHR);
|
||||
#ifdef HAS_WAYLAND
|
||||
|
||||
@@ -110,7 +110,7 @@ std::vector<VulkanRenderer::DeviceInfo> VulkanRenderer::GetDevices()
|
||||
requiredExtensions.emplace_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||
#if BOOST_OS_WINDOWS
|
||||
requiredExtensions.emplace_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
||||
#elif BOOST_OS_LINUX
|
||||
#elif BOOST_OS_LINUX || BOOST_OS_BSD
|
||||
auto backend = WindowSystem::GetWindowInfo().window_main.backend;
|
||||
if(backend == WindowSystem::WindowHandleInfo::Backend::X11)
|
||||
requiredExtensions.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
|
||||
@@ -1307,7 +1307,7 @@ std::vector<const char*> VulkanRenderer::CheckInstanceExtensionSupport(FeatureCo
|
||||
requiredInstanceExtensions.emplace_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||
#if BOOST_OS_WINDOWS
|
||||
requiredInstanceExtensions.emplace_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
||||
#elif BOOST_OS_LINUX
|
||||
#elif BOOST_OS_LINUX || BOOST_OS_BSD
|
||||
auto backend = WindowSystem::GetWindowInfo().window_main.backend;
|
||||
if(backend == WindowSystem::WindowHandleInfo::Backend::X11)
|
||||
requiredInstanceExtensions.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
|
||||
@@ -1394,7 +1394,7 @@ VkSurfaceKHR VulkanRenderer::CreateWinSurface(VkInstance instance, HWND hwindow)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_BSD
|
||||
VkSurfaceKHR VulkanRenderer::CreateXlibSurface(VkInstance instance, Display* dpy, Window window)
|
||||
{
|
||||
VkXlibSurfaceCreateInfoKHR sci{};
|
||||
@@ -1458,8 +1458,7 @@ VkSurfaceKHR VulkanRenderer::CreateFramebufferSurface(VkInstance instance, Windo
|
||||
{
|
||||
#if BOOST_OS_WINDOWS
|
||||
return CreateWinSurface(instance, static_cast<HWND>(windowInfo.surface));
|
||||
#elif BOOST_OS_LINUX
|
||||
|
||||
#elif BOOST_OS_LINUX || BOOST_OS_BSD
|
||||
if(windowInfo.backend == WindowSystem::WindowHandleInfo::Backend::X11)
|
||||
return CreateXlibSurface(instance, static_cast<Display*>(windowInfo.display), reinterpret_cast<Window>(windowInfo.surface));
|
||||
#ifdef HAS_WAYLAND
|
||||
|
||||
@@ -201,7 +201,7 @@ public:
|
||||
#if BOOST_OS_WINDOWS
|
||||
static VkSurfaceKHR CreateWinSurface(VkInstance instance, HWND hwindow);
|
||||
#endif
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_BSD
|
||||
static VkSurfaceKHR CreateXlibSurface(VkInstance instance, Display* dpy, Window window);
|
||||
static VkSurfaceKHR CreateXcbSurface(VkInstance instance, xcb_connection_t* connection, xcb_window_t window);
|
||||
#ifdef HAS_WAYLAND
|
||||
|
||||
+11
-1
@@ -184,6 +184,16 @@ bool memory_isAddressRangeAccessible(MPTR virtualAddress, uint32 size);
|
||||
#define CPU_swapEndianU64(_v) OSSwapInt64((uint64)(_v))
|
||||
#define CPU_swapEndianU32(_v) OSSwapInt32((uint32)(_v))
|
||||
#define CPU_swapEndianU16(_v) OSSwapInt16((uint16)(_v))
|
||||
#elif BOOST_OS_BSD
|
||||
#ifdef __OpenBSD__
|
||||
#define CPU_swapEndianU64(_v) swap64((uint64)(_v))
|
||||
#define CPU_swapEndianU32(_v) swap32((uint32)(_v))
|
||||
#define CPU_swapEndianU16(_v) swap16((uint16)(_v))
|
||||
#else // FreeBSD and NetBSD
|
||||
#define CPU_swapEndianU64(_v) bswap64((uint64)(_v))
|
||||
#define CPU_swapEndianU32(_v) bswap32((uint32)(_v))
|
||||
#define CPU_swapEndianU16(_v) bswap16((uint16)(_v))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// C-style memory access, deprecated. Use memory_read<> and memory_write<> templates instead
|
||||
@@ -266,4 +276,4 @@ namespace MMU
|
||||
|
||||
}
|
||||
|
||||
#define MMU_IsInPPCMemorySpace(__ptr) ((const uint8*)(__ptr) >= memory_base && (const uint8*)(__ptr) < (memory_base + 0x100000000))
|
||||
#define MMU_IsInPPCMemorySpace(__ptr) ((const uint8*)(__ptr) >= memory_base && (const uint8*)(__ptr) < (memory_base + 0x100000000))
|
||||
|
||||
@@ -466,7 +466,7 @@ typedef struct
|
||||
|
||||
static_assert(sizeof(UCParamStruct_t) == 0x54); // unsure
|
||||
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS
|
||||
#if BOOST_OS_LINUX || BOOST_OS_MACOS || BOOST_OS_BSD
|
||||
#define _strcmpi strcasecmp
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include "nsyshid.h"
|
||||
|
||||
#if BOOST_OS_BSD
|
||||
#include <libusb.h>
|
||||
#else
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#endif
|
||||
#include "Backend.h"
|
||||
|
||||
namespace nsyshid::backend::libusb
|
||||
|
||||
@@ -46,7 +46,7 @@ PRIVATE
|
||||
)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
if(LINUX)
|
||||
target_sources(CemuCommon PRIVATE
|
||||
ExceptionHandler/ELFSymbolTable.cpp
|
||||
ExceptionHandler/ELFSymbolTable.h
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "wglext.h"
|
||||
#endif
|
||||
|
||||
#if BOOST_OS_LINUX > 0
|
||||
#if ( BOOST_OS_LINUX || BOOST_OS_BSD ) > 0
|
||||
|
||||
// from Xlib
|
||||
#define Bool int
|
||||
|
||||
@@ -297,7 +297,7 @@ GLFUNC(PFNWGLSWAPINTERVALEXTPROC, wglSwapIntervalEXT)
|
||||
|
||||
// x
|
||||
|
||||
#if BOOST_OS_LINUX
|
||||
#if BOOST_OS_LINUX || BOOST_OS_BSD
|
||||
EGLFUNC(PFNEGLSWAPINTERVALPROC, eglSwapInterval)
|
||||
EGLFUNC(PFNEGLGETCURRENTDISPLAYPROC, eglGetCurrentDisplay)
|
||||
#endif
|
||||
|
||||
@@ -5,8 +5,12 @@
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
#include "Common/windows/platform.h"
|
||||
#elif BOOST_OS_LINUX
|
||||
#elif BOOST_OS_LINUX || BOOST_OS_BSD
|
||||
#if BOOST_OS_LINUX
|
||||
#include <byteswap.h>
|
||||
#elif BOOST_OS_BSD
|
||||
#include <endian.h>
|
||||
#endif
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
@@ -184,6 +184,12 @@ inline uint64 _swapEndianU64(uint64 v)
|
||||
{
|
||||
#if BOOST_OS_MACOS
|
||||
return OSSwapInt64(v);
|
||||
#elif BOOST_OS_BSD
|
||||
#ifdef __OpenBSD__
|
||||
return swap64(v);
|
||||
#else // FreeBSD and NetBSD
|
||||
return bswap64(v);
|
||||
#endif
|
||||
#else
|
||||
return bswap_64(v);
|
||||
#endif
|
||||
@@ -193,6 +199,12 @@ inline uint32 _swapEndianU32(uint32 v)
|
||||
{
|
||||
#if BOOST_OS_MACOS
|
||||
return OSSwapInt32(v);
|
||||
#elif BOOST_OS_BSD
|
||||
#ifdef __OpenBSD__
|
||||
return swap32(v);
|
||||
#else // FreeBSD and NetBSD
|
||||
return bswap32(v);
|
||||
#endif
|
||||
#else
|
||||
return bswap_32(v);
|
||||
#endif
|
||||
@@ -202,6 +214,12 @@ inline sint32 _swapEndianS32(sint32 v)
|
||||
{
|
||||
#if BOOST_OS_MACOS
|
||||
return (sint32)OSSwapInt32((uint32)v);
|
||||
#elif BOOST_OS_BSD
|
||||
#ifdef __OpenBSD__
|
||||
return (sint32)swap32((uint32)v);
|
||||
#else // FreeBSD and NetBSD
|
||||
return (sint32)bswap32((uint32)v);
|
||||
#endif
|
||||
#else
|
||||
return (sint32)bswap_32((uint32)v);
|
||||
#endif
|
||||
@@ -493,6 +511,11 @@ bool match_any_of(T1&& value, Types&&... others)
|
||||
#elif BOOST_OS_MACOS
|
||||
return std::chrono::steady_clock::time_point(
|
||||
std::chrono::nanoseconds(clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW)));
|
||||
#elif BOOST_OS_BSD
|
||||
struct timespec tp;
|
||||
clock_gettime(CLOCK_MONOTONIC, &tp);
|
||||
return std::chrono::steady_clock::time_point(
|
||||
std::chrono::seconds(tp.tv_sec) + std::chrono::nanoseconds(tp.tv_nsec));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ uint32_t GetTickCount()
|
||||
return (1000 * ts.tv_sec + ts.tv_nsec / 1000000);
|
||||
#elif BOOST_OS_MACOS
|
||||
return clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW) / 1000000;
|
||||
#elif BOOST_OS_BSD
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return (1000 * ts.tv_sec + ts.tv_nsec / 1000000);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user