From 3a8164ac4e7c460f3a7cf03ade53418c514b68f3 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Wed, 30 Mar 2016 09:28:44 +0200 Subject: [PATCH 1/3] plugins: add a dynamic/static loader --- pcsx2/PluginManager.cpp | 173 ++++++++++++++++++++++++++++++---------- pcsx2/Plugins.h | 49 +++++++++++- 2 files changed, 176 insertions(+), 46 deletions(-) diff --git a/pcsx2/PluginManager.cpp b/pcsx2/PluginManager.cpp index 1a29b8db19..e2052e2faa 100644 --- a/pcsx2/PluginManager.cpp +++ b/pcsx2/PluginManager.cpp @@ -829,6 +829,87 @@ static void PS2E_CALLBACK pcsx2_OSD_WriteLn( int icon, const char* msg ) return; // not implemented... } +// --------------------------------------------------------------------------------- +// DynamicStaticLibrary +// --------------------------------------------------------------------------------- +StaticLibrary::StaticLibrary(PluginsEnum_t _pid) : pid(_pid) +{ +} + +bool StaticLibrary::Load(const wxString& name) +{ + return true; +} + +void* StaticLibrary::GetSymbol(const wxString &name) +{ +#define RETURN_SYMBOL(s) if (name == #s) return (void*)&s; + +#define RETURN_COMMON_SYMBOL(p) \ + RETURN_SYMBOL(p##init) \ + RETURN_SYMBOL(p##close) \ + RETURN_SYMBOL(p##shutdown) \ + RETURN_SYMBOL(p##keyEvent) \ + RETURN_SYMBOL(p##setSettingsDir) \ + RETURN_SYMBOL(p##setLogDir) \ + RETURN_SYMBOL(p##freeze) \ + RETURN_SYMBOL(p##test) \ + RETURN_SYMBOL(p##configure) \ + RETURN_SYMBOL(p##about) + +#ifdef BUILTIN_GS_PLUGIN + RETURN_COMMON_SYMBOL(GS); +#endif +#ifdef BUILTIN_PAD_PLUGIN + RETURN_COMMON_SYMBOL(PAD); +#endif +#ifdef BUILTIN_SPU2_PLUGIN + RETURN_COMMON_SYMBOL(SPU2); +#endif +#ifdef BUILTIN_CDVD_PLUGIN + RETURN_COMMON_SYMBOL(CDVD); +#endif +#ifdef BUILTIN_DEV9_PLUGIN + RETURN_COMMON_SYMBOL(DEV9); +#endif +#ifdef BUILTIN_USB_PLUGIN + RETURN_COMMON_SYMBOL(USB); +#endif +#ifdef BUILTIN_FW_PLUGIN + RETURN_COMMON_SYMBOL(FW); +#endif + + +#undef RETURN_COMMON_SYMBOL +#undef RETURN_SYMBOL + + return NULL; +} + +bool StaticLibrary::HasSymbol(const wxString &name) +{ + return false; +} + +DynamicLibrary::DynamicLibrary() : Lib() +{ +} + +bool DynamicLibrary::Load(const wxString& name) +{ + return Lib.Load(name); +} + +void* DynamicLibrary::GetSymbol(const wxString &name) +{ + return Lib.GetSymbol(name); +} + +bool DynamicLibrary::HasSymbol(const wxString &name) +{ + return Lib.HasSymbol(name); +} + // --------------------------------------------------------------------------------- // PluginStatus_t Implementations // --------------------------------------------------------------------------------- @@ -839,57 +920,65 @@ SysCorePlugins::PluginStatus_t::PluginStatus_t( PluginsEnum_t _pid, const wxStri IsInitialized = false; IsOpened = false; - - if( Filename.IsEmpty() ) - throw Exception::PluginInitError( pid ).SetDiagMsg( L"Empty plugin filename" ); - - if( !wxFile::Exists( Filename ) ) - throw Exception::PluginLoadError( pid ).SetStreamName(srcfile) - .SetBothMsgs(pxL("The configured %s plugin file was not found")); - - if( !Lib.Load( Filename ) ) - throw Exception::PluginLoadError( pid ).SetStreamName(Filename) - .SetBothMsgs(pxL("The configured %s plugin file is not a valid dynamic library")); + IsStatic = false; + Lib = new DynamicLibrary(); - // Try to enumerate the new v2.0 plugin interface first. - // If that fails, fall back on the old style interface. + if (IsStatic) { + BindCommon( pid ); - //m_libs[i].GetSymbol( L"PS2E_InitAPI" ); // on the TODO list! + } else { + if( Filename.IsEmpty() ) + throw Exception::PluginInitError( pid ).SetDiagMsg( L"Empty plugin filename" ); - - // 2.0 API Failed; Enumerate the Old Stuff! --> + if( !wxFile::Exists( Filename ) ) + throw Exception::PluginLoadError( pid ).SetStreamName(srcfile) + .SetBothMsgs(pxL("The configured %s plugin file was not found")); - _PS2EgetLibName GetLibName = (_PS2EgetLibName) Lib.GetSymbol( L"PS2EgetLibName" ); - _PS2EgetLibVersion2 GetLibVersion2 = (_PS2EgetLibVersion2) Lib.GetSymbol( L"PS2EgetLibVersion2" ); + if( !Lib->Load( Filename ) ) + throw Exception::PluginLoadError( pid ).SetStreamName(Filename) + .SetBothMsgs(pxL("The configured %s plugin file is not a valid dynamic library")); - if( GetLibName == NULL || GetLibVersion2 == NULL ) - throw Exception::PluginLoadError( pid ).SetStreamName(Filename) - .SetDiagMsg(L"%s plugin init failed: Method binding failure on GetLibName or GetLibVersion2.") - .SetUserMsg(_( "The configured %s plugin is not a PCSX2 plugin, or is for an older unsupported version of PCSX2.")); - // Only Windows GSdx uses this. Should be removed in future after GSdx no longer relies on it to show the new config dialog. + // Try to enumerate the new v2.0 plugin interface first. + // If that fails, fall back on the old style interface. + + //m_libs[i].GetSymbol( L"PS2E_InitAPI" ); // on the TODO list! + + + // 2.0 API Failed; Enumerate the Old Stuff! --> + + _PS2EgetLibName GetLibName = (_PS2EgetLibName) Lib->GetSymbol( L"PS2EgetLibName" ); + _PS2EgetLibVersion2 GetLibVersion2 = (_PS2EgetLibVersion2) Lib->GetSymbol( L"PS2EgetLibVersion2" ); + + if( GetLibName == NULL || GetLibVersion2 == NULL ) + throw Exception::PluginLoadError( pid ).SetStreamName(Filename) + .SetDiagMsg(L"%s plugin init failed: Method binding failure on GetLibName or GetLibVersion2.") + .SetUserMsg(_( "The configured %s plugin is not a PCSX2 plugin, or is for an older unsupported version of PCSX2.")); + + // Only Windows GSdx uses this. Should be removed in future after GSdx no longer relies on it to show the new config dialog. #ifdef _WIN32 - // Since only Windows Gsdx has this symbol, that means every other plugin is going to cause error messages to be logged. - // Let's not do that for a hack function. - if (Lib.HasSymbol(L"PS2EsetEmuVersion")) { - _PS2EsetEmuVersion SetEmuVersion = (_PS2EsetEmuVersion)Lib.GetSymbol(L"PS2EsetEmuVersion"); - if (SetEmuVersion) - SetEmuVersion("PCSX2", (PCSX2_VersionHi << 24) | (PCSX2_VersionMid << 16) | (PCSX2_VersionLo << 8) | 0); - } + // Since only Windows Gsdx has this symbol, that means every other plugin is going to cause error messages to be logged. + // Let's not do that for a hack function. + if (Lib->HasSymbol(L"PS2EsetEmuVersion")) { + _PS2EsetEmuVersion SetEmuVersion = (_PS2EsetEmuVersion)Lib->GetSymbol(L"PS2EsetEmuVersion"); + if (SetEmuVersion) + SetEmuVersion("PCSX2", (PCSX2_VersionHi << 24) | (PCSX2_VersionMid << 16) | (PCSX2_VersionLo << 8) | 0); + } #endif - Name = fromUTF8( GetLibName() ); - int version = GetLibVersion2( tbl_PluginInfo[pid].typemask ); - Version.Printf( L"%d.%d.%d", (version>>8)&0xff, version&0xff, (version>>24)&0xff ); + Name = fromUTF8( GetLibName() ); + int version = GetLibVersion2( tbl_PluginInfo[pid].typemask ); + Version.Printf( L"%d.%d.%d", (version>>8)&0xff, version&0xff, (version>>24)&0xff ); + // Bind Required Functions + // (generate critical error if binding fails) - // Bind Required Functions - // (generate critical error if binding fails) + BindCommon( pid ); + BindRequired( pid ); + BindOptional( pid ); + } - BindCommon( pid ); - BindRequired( pid ); - BindOptional( pid ); // Run Plugin's Functionality Test. // A lot of plugins don't bother to implement this function and return 0 (success) @@ -911,7 +1000,7 @@ void SysCorePlugins::PluginStatus_t::BindCommon( PluginsEnum_t pid ) while( current->MethodName != NULL ) { - *target = (VoidMethod*)Lib.GetSymbol( current->GetMethodName( pid ) ); + *target = (VoidMethod*)Lib->GetSymbol( current->GetMethodName( pid ) ); if( *target == NULL ) *target = current->Fallback; @@ -931,13 +1020,12 @@ void SysCorePlugins::PluginStatus_t::BindCommon( PluginsEnum_t pid ) void SysCorePlugins::PluginStatus_t::BindRequired( PluginsEnum_t pid ) { const LegacyApi_ReqMethod* current = s_MethMessReq[pid]; - const wxDynamicLibrary& lib = Lib; wxDoNotLogInThisScope please; while( current->MethodName != NULL ) { - *(current->Dest) = (VoidMethod*)lib.GetSymbol( current->GetMethodName() ); + *(current->Dest) = (VoidMethod*)Lib->GetSymbol( current->GetMethodName() ); if( *(current->Dest) == NULL ) *(current->Dest) = current->Fallback; @@ -956,13 +1044,12 @@ void SysCorePlugins::PluginStatus_t::BindRequired( PluginsEnum_t pid ) void SysCorePlugins::PluginStatus_t::BindOptional( PluginsEnum_t pid ) { const LegacyApi_OptMethod* current = s_MethMessOpt[pid]; - const wxDynamicLibrary& lib = Lib; wxDoNotLogInThisScope please; while( current->MethodName != NULL ) { - *(current->Dest) = (VoidMethod*)lib.GetSymbol( current->GetMethodName() ); + *(current->Dest) = (VoidMethod*)Lib->GetSymbol( current->GetMethodName() ); current++; } } diff --git a/pcsx2/Plugins.h b/pcsx2/Plugins.h index 1bfe4f6629..4fb8cad386 100644 --- a/pcsx2/Plugins.h +++ b/pcsx2/Plugins.h @@ -253,6 +253,46 @@ extern SysPluginBindings SysPlugins; // SysCorePlugins Class // -------------------------------------------------------------------------------------- // +class DynamicStaticLibrary +{ + public: + + DynamicStaticLibrary() {}; + virtual ~DynamicStaticLibrary() {}; + + virtual bool Load(const wxString& name) = 0; + virtual void* GetSymbol(const wxString &name) = 0; + virtual bool HasSymbol(const wxString &name) = 0; +}; + +class StaticLibrary : public DynamicStaticLibrary +{ + PluginsEnum_t pid; + + public: + + StaticLibrary(PluginsEnum_t _pid); + virtual ~StaticLibrary() {}; + + bool Load(const wxString& name); + void* GetSymbol(const wxString &name); + bool HasSymbol(const wxString &name); +}; + +class DynamicLibrary : public DynamicStaticLibrary +{ + wxDynamicLibrary Lib; + + public: + + DynamicLibrary(); + virtual ~DynamicLibrary() {}; + + bool Load(const wxString& name); + void* GetSymbol(const wxString &name); + bool HasSymbol(const wxString &name); +}; + class SysCorePlugins { DeclareNoncopyableObject( SysCorePlugins ); @@ -265,24 +305,27 @@ protected: bool IsInitialized; bool IsOpened; + bool IsStatic; wxString Filename; wxString Name; wxString Version; LegacyPluginAPI_Common CommonBindings; - wxDynamicLibrary Lib; + DynamicStaticLibrary* Lib; public: PluginStatus_t() { IsInitialized = false; IsOpened = false; + IsStatic = false; + Lib = NULL; } PluginStatus_t( PluginsEnum_t _pid, const wxString& srcfile ); - virtual ~PluginStatus_t() throw() { } - + virtual ~PluginStatus_t() throw() { delete Lib; } + protected: void BindCommon( PluginsEnum_t pid ); void BindRequired( PluginsEnum_t pid ); From f010f9458b04339dd2aaecbe48ccd29af65f682e Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Wed, 30 Mar 2016 09:47:27 +0200 Subject: [PATCH 2/3] plugin: add define to select builtin plugin --- common/include/PS2Edefs.h | 26 ++++++++++++++++------ pcsx2/PluginManager.cpp | 45 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/common/include/PS2Edefs.h b/common/include/PS2Edefs.h index e73c620ff6..1b27e0c3dd 100644 --- a/common/include/PS2Edefs.h +++ b/common/include/PS2Edefs.h @@ -228,7 +228,7 @@ extern "C" { // if this file is included with this define // the next api will not be skipped by the compiler -#ifdef GSdefs +#if defined(GSdefs) || defined(BUILTIN_GS_PLUGIN) // basic funcs @@ -287,7 +287,7 @@ s32 CALLBACK GStest(); // if this file is included with this define // the next api will not be skipped by the compiler -#ifdef PADdefs +#if defined(PADdefs) || defined(BUILTIN_PAD_PLUGIN) // basic funcs @@ -334,7 +334,7 @@ s32 CALLBACK PADtest(); // if this file is included with this define // the next api will not be skipped by the compiler -#ifdef SPU2defs +#if defined(SPU2defs) || defined(BUILTIN_SPU2_PLUGIN) // basic funcs @@ -396,7 +396,7 @@ s32 CALLBACK SPU2test(); // if this file is included with this define // the next api will not be skipped by the compiler -#ifdef CDVDdefs +#if defined(CDVDdefs) || defined(BUILTIN_CDVD_PLUGIN) // basic funcs @@ -445,7 +445,7 @@ s32 CALLBACK CDVDgetDualInfo(s32* dualType, u32* _layer1start); // if this file is included with this define // the next api will not be skipped by the compiler -#ifdef DEV9defs +#if defined(DEV9defs) || defined(BUILTIN_DEV9_PLUGIN) // basic funcs @@ -490,7 +490,7 @@ s32 CALLBACK DEV9test(); // if this file is included with this define // the next api will not be skipped by the compiler -#ifdef USBdefs +#if defined(USBdefs) || defined(BUILTIN_USB_PLUGIN) // basic funcs @@ -528,7 +528,7 @@ s32 CALLBACK USBtest(); // if this file is included with this define // the next api will not be skipped by the compiler -#ifdef FWdefs +#if defined(BUILTIN_FW_PLUGIN) || defined(BUILTIN_FW_PLUGIN) // basic funcs // NOTE: The read/write functions CANNOT use XMM/MMX regs @@ -722,6 +722,7 @@ typedef void (CALLBACK* _FWirqCallback)(void (*callback)()); #ifdef PLUGINfuncs // GS +#ifndef BUILTIN_GS_PLUGIN extern _GSopen GSopen; extern _GSopen2 GSopen2; extern _GSvsync GSvsync; @@ -749,8 +750,10 @@ extern _GSsetVsync GSsetVsync; extern _GSsetupRecording GSsetupRecording; extern _GSreset GSreset; extern _GSwriteCSR GSwriteCSR; +#endif // PAD +#ifndef BUILTIN_PAD_PLUGIN extern _PADopen PADopen; extern _PADstartPoll PADstartPoll; extern _PADpoll PADpoll; @@ -761,8 +764,10 @@ extern _PADgsDriverInfo PADgsDriverInfo; extern _PADsetSlot PADsetSlot; extern _PADqueryMtap PADqueryMtap; extern _PADWriteEvent PADWriteEvent; +#endif // SPU2 +#ifndef BUILTIN_SPU2_PLUGIN extern _SPU2open SPU2open; extern _SPU2reset SPU2reset; extern _SPU2write SPU2write; @@ -794,8 +799,10 @@ extern _SPU2setClockPtr SPU2setClockPtr; extern _SPU2setTimeStretcher SPU2setTimeStretcher; extern _SPU2async SPU2async; +#endif // DEV9 +#ifndef BUILTIN_DEV9_PLUGIN extern _DEV9open DEV9open; extern _DEV9read8 DEV9read8; extern _DEV9read16 DEV9read16; @@ -814,8 +821,10 @@ extern _DEV9writeDMA8Mem DEV9writeDMA8Mem; extern _DEV9irqCallback DEV9irqCallback; extern _DEV9irqHandler DEV9irqHandler; extern _DEV9async DEV9async; +#endif // USB +#ifndef BUILTIN_USB_PLUGIN extern _USBopen USBopen; extern _USBread8 USBread8; extern _USBread16 USBread16; @@ -828,12 +837,15 @@ extern _USBasync USBasync; extern _USBirqCallback USBirqCallback; extern _USBirqHandler USBirqHandler; extern _USBsetRAM USBsetRAM; +#endif // FW +#ifndef BUILTIN_FW_PLUGIN extern _FWopen FWopen; extern _FWread32 FWread32; extern _FWwrite32 FWwrite32; extern _FWirqCallback FWirqCallback; +#endif #endif diff --git a/pcsx2/PluginManager.cpp b/pcsx2/PluginManager.cpp index e2052e2faa..ec4e76ae45 100644 --- a/pcsx2/PluginManager.cpp +++ b/pcsx2/PluginManager.cpp @@ -153,6 +153,7 @@ static void CALLBACK fallback_configure() {} static void CALLBACK fallback_about() {} static s32 CALLBACK fallback_test() { return 0; } +#ifndef BUILTIN_GS_PLUGIN _GSvsync GSvsync; _GSopen GSopen; _GSopen2 GSopen2; @@ -179,6 +180,7 @@ _GSsetExclusive GSsetExclusive; _GSsetupRecording GSsetupRecording; _GSreset GSreset; _GSwriteCSR GSwriteCSR; +#endif static void CALLBACK GS_makeSnapshot(const char *path) {} static void CALLBACK GS_setGameCRC(u32 crc, int gameopts) {} @@ -269,6 +271,7 @@ static void CALLBACK GS_Legacy_GSreadFIFO2(u64* pMem, int qwc) { } // PAD +#ifndef BUILTIN_PAD_PLUGIN _PADinit PADinit; _PADopen PADopen; _PADstartPoll PADstartPoll; @@ -279,10 +282,12 @@ _PADkeyEvent PADkeyEvent; _PADsetSlot PADsetSlot; _PADqueryMtap PADqueryMtap; _PADWriteEvent PADWriteEvent; +#endif static void PAD_update( u32 padslot ) { } // SPU2 +#ifndef BUILTIN_SPU2_PLUGIN _SPU2open SPU2open; _SPU2write SPU2write; _SPU2reset SPU2reset; @@ -307,9 +312,11 @@ _SPU2irqCallback SPU2irqCallback; _SPU2setClockPtr SPU2setClockPtr; _SPU2async SPU2async; +#endif // DEV9 +#ifndef BUILTIN_DEV9_PLUGIN _DEV9open DEV9open; _DEV9read8 DEV9read8; _DEV9read16 DEV9read16; @@ -328,8 +335,10 @@ _DEV9writeDMA8Mem DEV9writeDMA8Mem; _DEV9irqCallback DEV9irqCallback; _DEV9irqHandler DEV9irqHandler; _DEV9async DEV9async; +#endif // USB +#ifndef BUILTIN_USB_PLUGIN _USBopen USBopen; _USBread8 USBread8; _USBread16 USBread16; @@ -342,12 +351,15 @@ _USBasync USBasync; _USBirqCallback USBirqCallback; _USBirqHandler USBirqHandler; _USBsetRAM USBsetRAM; +#endif // FW +#ifndef BUILTIN_FW_PLUGIN _FWopen FWopen; _FWread32 FWread32; _FWwrite32 FWwrite32; _FWirqCallback FWirqCallback; +#endif DEV9handler dev9Handler; USBhandler usbHandler; @@ -920,9 +932,38 @@ SysCorePlugins::PluginStatus_t::PluginStatus_t( PluginsEnum_t _pid, const wxStri IsInitialized = false; IsOpened = false; - IsStatic = false; - Lib = new DynamicLibrary(); + switch (_pid) { +#ifdef BUILTIN_GS_PLUGIN + case PluginId_GS: +#endif +#ifdef BUILTIN_PAD_PLUGIN + case PluginId_PAD: +#endif +#ifdef BUILTIN_SPU2_PLUGIN + case PluginId_SPU2: +#endif +#ifdef BUILTIN_CDVD_PLUGIN + case PluginId_CDVD: +#endif +#ifdef BUILTIN_DEV9_PLUGIN + case PluginId_DEV9: +#endif +#ifdef BUILTIN_USB_PLUGIN + case PluginId_USB: +#endif +#ifdef BUILTIN_FW_PLUGIN + case PluginId_FW: +#endif + case PluginId_Count: + IsStatic = true; + Lib = new StaticLibrary(_pid); + break; + default: + IsStatic = false; + Lib = new DynamicLibrary(); + break; + } if (IsStatic) { BindCommon( pid ); From 1bd8113f66bded96ead11a3ccf47b92fb1f4ee11 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Wed, 30 Mar 2016 10:19:54 +0200 Subject: [PATCH 3/3] cmake: add various option to disable plugin support --- cmake/BuildParameters.cmake | 36 ++++++++++++++++++++++++++++++- pcsx2/CMakeLists.txt | 22 +++++++++++++++++++ plugins/FWnull/CMakeLists.txt | 6 +++++- plugins/GSdx/CMakeLists.txt | 6 +++++- plugins/USBnull/CMakeLists.txt | 6 +++++- plugins/dev9null/CMakeLists.txt | 6 +++++- plugins/onepad/CMakeLists.txt | 6 +++++- plugins/spu2-x/src/CMakeLists.txt | 6 +++++- 8 files changed, 87 insertions(+), 7 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index fdec78b868..a62123fba7 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -82,6 +82,40 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") message(STATUS "Building with Clang/LLVM.") endif() +#------------------------------------------------------------------------------- +# Select the support of plugin +#------------------------------------------------------------------------------- +option(BUILTIN_GS "Disable support of GS plugin (developer option)") +option(BUILTIN_PAD "Disable support of PAD plugin (developer option)") +option(BUILTIN_SPU2 "Disable support of SPU2 plugin (developer option)") +option(BUILTIN_USB "Disable support of USB plugin (developer option)") +option(BUILTIN_FW "Disable support of FW plugin (developer option)") +option(BUILTIN_DEV9 "Disable support of DEV9 plugin (developer option)") +option(BUILTIN_CDVD "Disable support of CDVD plugin (developer option)") + +set(PLUGIN_SUPPORT "") +if(BUILTIN_GS) + set(PLUGIN_SUPPORT "${PLUGIN_SUPPORT} -DBUILTIN_GS_PLUGIN") +endif() +if(BUILTIN_PAD) + set(PLUGIN_SUPPORT "${PLUGIN_SUPPORT} -DBUILTIN_PAD_PLUGIN") +endif() +if(BUILTIN_SPU2) + set(PLUGIN_SUPPORT "${PLUGIN_SUPPORT} -DBUILTIN_SPU2_PLUGIN") +endif() +if(BUILTIN_USB) + set(PLUGIN_SUPPORT "${PLUGIN_SUPPORT} -DBUILTIN_USB_PLUGIN") +endif() +if(BUILTIN_FW) + set(PLUGIN_SUPPORT "${PLUGIN_SUPPORT} -DBUILTIN_FW_PLUGIN") +endif() +if(BUILTIN_DEV) + set(PLUGIN_SUPPORT "${PLUGIN_SUPPORT} -DBUILTIN_DEV_PLUGIN") +endif() +if(BUILTIN_CDVD) + set(PLUGIN_SUPPORT "${PLUGIN_SUPPORT} -DBUILTIN_CDVD_PLUGIN") +endif() + #------------------------------------------------------------------------------- # Select the architecture #------------------------------------------------------------------------------- @@ -312,7 +346,7 @@ else() endif() # Note: -DGTK_DISABLE_DEPRECATED can be used to test a build without gtk deprecated feature. It could be useful to port to a newer API -set(DEFAULT_GCC_FLAG "${ARCH_FLAG} ${COMMON_FLAG} ${DEFAULT_WARNINGS} ${AGGRESSIVE_WARNING} ${HARDENING_FLAG} ${DEBUG_FLAG} ${ASAN_FLAG} ${OPTIMIZATION_FLAG} ${LTO_FLAGS}") +set(DEFAULT_GCC_FLAG "${ARCH_FLAG} ${COMMON_FLAG} ${DEFAULT_WARNINGS} ${AGGRESSIVE_WARNING} ${HARDENING_FLAG} ${DEBUG_FLAG} ${ASAN_FLAG} ${OPTIMIZATION_FLAG} ${LTO_FLAGS} ${PLUGIN_SUPPORT}") # c++ only flags set(DEFAULT_CPP_FLAG "${DEFAULT_GCC_FLAG} -std=c++11 -Wno-invalid-offsetof") diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index 5aa6406ac0..40cf529f0b 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -630,6 +630,28 @@ set(pcsx2FinalLibs ${GCOV_LIBRARIES} ) +if(BUILTIN_GS) + set(pcsx2FinalLibs "${pcsx2FinalLibs} GSdx-1.0.0") +endif() +if(BUILTIN_PAD) + set(pcsx2FinalLibs "${pcsx2FinalLibs} onepad-1.2.0") +endif() +if(BUILTIN_SPU2) + set(pcsx2FinalLibs "${pcsx2FinalLibs} spu2x-2.0.0") +endif() +if(BUILTIN_USB) + set(pcsx2FinalLibs "${pcsx2FinalLibs} USBnull-0.7.0") +endif() +if(BUILTIN_FW) + set(pcsx2FinalLibs "${pcsx2FinalLibs} FWnull-0.7.0") +endif() +if(BUILTIN_DEV) + set(pcsx2FinalLibs "${pcsx2FinalLibs} dev9null-0.5.0") +endif() +if(BUILTIN_CDVD) + set(pcsx2FinalLibs "${pcsx2FinalLibs} CDVDnull") +endif() + # additonal include directories include_directories( gui diff --git a/plugins/FWnull/CMakeLists.txt b/plugins/FWnull/CMakeLists.txt index aaf9e4e3a8..ce2eb570ff 100644 --- a/plugins/FWnull/CMakeLists.txt +++ b/plugins/FWnull/CMakeLists.txt @@ -50,4 +50,8 @@ set(FWnullFinalLibs ${GTK2_LIBRARIES} ) -add_pcsx2_plugin(${Output} "${FWnullFinalSources}" "${FWnullFinalLibs}" "${FWnullFinalFlags}") +if(BUILTIN_FW) + add_pcsx2_lib(${Output} "${FWnullFinalSources}" "${FWnullFinalLibs}" "${FWnullFinalFlags}") +else() + add_pcsx2_plugin(${Output} "${FWnullFinalSources}" "${FWnullFinalLibs}" "${FWnullFinalFlags}") +endif() diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 7309ac7d9a..20cbd9e61b 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -211,7 +211,11 @@ if (REBUILD_SHADER) add_custom_command(OUTPUT res/glsl_source.h COMMAND perl ${CMAKE_SOURCE_DIR}/linux_various/glsl2h.pl) endif() -add_pcsx2_plugin(${Output} "${GSdxFinalSources}" "${GSdxFinalLibs}" "${GSdxFinalFlags}") +if(BUILTIN_GS) + add_pcsx2_lib(${Output} "${GSdxFinalSources}" "${GSdxFinalLibs}" "${GSdxFinalFlags}") +else() + add_pcsx2_plugin(${Output} "${GSdxFinalSources}" "${GSdxFinalLibs}" "${GSdxFinalFlags}") +endif() ################################### Replay Loader if(BUILD_REPLAY_LOADERS) diff --git a/plugins/USBnull/CMakeLists.txt b/plugins/USBnull/CMakeLists.txt index 7892d03ed8..fd6a6bb5e4 100644 --- a/plugins/USBnull/CMakeLists.txt +++ b/plugins/USBnull/CMakeLists.txt @@ -50,4 +50,8 @@ set(USBnullFinalLibs ${GTK2_LIBRARIES} ) -add_pcsx2_plugin(${Output} "${USBnullFinalSources}" "${USBnullFinalLibs}" "${USBnullFinalFlags}") +if(BUILTIN_USB) + add_pcsx2_lib(${Output} "${USBnullFinalSources}" "${USBnullFinalLibs}" "${USBnullFinalFlags}") +else() + add_pcsx2_plugin(${Output} "${USBnullFinalSources}" "${USBnullFinalLibs}" "${USBnullFinalFlags}") +endif() diff --git a/plugins/dev9null/CMakeLists.txt b/plugins/dev9null/CMakeLists.txt index b819985218..1fb0a3e7b5 100644 --- a/plugins/dev9null/CMakeLists.txt +++ b/plugins/dev9null/CMakeLists.txt @@ -47,4 +47,8 @@ set(dev9nullFinalLibs ${GTK2_LIBRARIES} ) -add_pcsx2_plugin(${Output} "${dev9nullFinalSources}" "${dev9nullFinalLibs}" "${dev9nullFinalFlags}") +if(BUILTIN_DEV9) + add_pcsx2_lib(${Output} "${dev9nullFinalSources}" "${dev9nullFinalLibs}" "${dev9nullFinalFlags}") +else() + add_pcsx2_plugin(${Output} "${dev9nullFinalSources}" "${dev9nullFinalLibs}" "${dev9nullFinalFlags}") +endif() diff --git a/plugins/onepad/CMakeLists.txt b/plugins/onepad/CMakeLists.txt index c7e40beafe..46ed79e2e2 100644 --- a/plugins/onepad/CMakeLists.txt +++ b/plugins/onepad/CMakeLists.txt @@ -126,4 +126,8 @@ foreach(result_file IN ITEMS COMMAND perl ${CMAKE_SOURCE_DIR}/linux_various/hex2h.pl "${image_sources}/${result_file}.png" "${compiled_images}/${result_file}" ) endforeach() -add_pcsx2_plugin(${Output} "${onepadFinalSources}" "${onepadFinalLibs}" "${onepadFinalFlags}") +if(BUILTIN_PAD) + add_pcsx2_lib(${Output} "${onepadFinalSources}" "${onepadFinalLibs}" "${onepadFinalFlags}") +else() + add_pcsx2_plugin(${Output} "${onepadFinalSources}" "${onepadFinalLibs}" "${onepadFinalFlags}") +endif() diff --git a/plugins/spu2-x/src/CMakeLists.txt b/plugins/spu2-x/src/CMakeLists.txt index 942dc6b363..cadb90f946 100644 --- a/plugins/spu2-x/src/CMakeLists.txt +++ b/plugins/spu2-x/src/CMakeLists.txt @@ -114,4 +114,8 @@ else() ) endif() -add_pcsx2_plugin(${Output} "${spu2xFinalSources}" "${spu2xFinalLibs}" "${spu2xFinalFlags}") +if(BUILTIN_SPU2) + add_pcsx2_lib(${Output} "${spu2xFinalSources}" "${spu2xFinalLibs}" "${spu2xFinalFlags}") +else() + add_pcsx2_plugin(${Output} "${spu2xFinalSources}" "${spu2xFinalLibs}" "${spu2xFinalFlags}") +endif()