Enably QtForPython for Linux (#5667)
- Fix PALification and include Linux for the QtForPython gem - Add Linux-only module loader for Pyside2 related modules - Remove (unnecessary) #if !defined(Q_OS_WIN) Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>
This commit is contained in:
@@ -21,7 +21,8 @@ ly_add_target(
|
||||
NAME QtForPython.Editor.Static STATIC
|
||||
NAMESPACE Gem
|
||||
FILES_CMAKE
|
||||
qtforpython_editor_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
|
||||
qtforpython_editor_files.cmake
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Source/Platform/${PAL_PLATFORM_NAME}/qtforpython_editor_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
|
||||
PLATFORM_INCLUDE_FILES
|
||||
${common_source_dir}/${PAL_TRAIT_COMPILER_ID}/qtforpython_${PAL_TRAIT_COMPILER_ID_LOWERCASE}.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
@@ -45,6 +46,9 @@ ly_add_target(
|
||||
NAMESPACE Gem
|
||||
FILES_CMAKE
|
||||
qtforpython_shared_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Source/Platform/${PAL_PLATFORM_NAME}
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
Gem::QtForPython.Editor.Static
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
namespace QtForPython
|
||||
{
|
||||
const char* s_libPythonLibraryFile = "libpython3.7m.so.1.0";
|
||||
const char* s_libPyside2LibraryFile = "libpyside2.abi3.so.5.14";
|
||||
const char* s_libShibokenLibraryFile = "libshiboken2.abi3.so.5.14";
|
||||
|
||||
class InitializeEmbeddedPyside2
|
||||
{
|
||||
public:
|
||||
InitializeEmbeddedPyside2()
|
||||
{
|
||||
m_libPythonLibraryFile = InitializeEmbeddedPyside2::LoadModule(s_libPythonLibraryFile);
|
||||
m_libPyside2LibraryFile = InitializeEmbeddedPyside2::LoadModule(s_libPyside2LibraryFile);
|
||||
m_libShibokenLibraryFile = InitializeEmbeddedPyside2::LoadModule(s_libShibokenLibraryFile);
|
||||
}
|
||||
virtual ~InitializeEmbeddedPyside2()
|
||||
{
|
||||
InitializeEmbeddedPyside2::UnloadModule(m_libShibokenLibraryFile);
|
||||
InitializeEmbeddedPyside2::UnloadModule(m_libPyside2LibraryFile);
|
||||
InitializeEmbeddedPyside2::UnloadModule(m_libPythonLibraryFile);
|
||||
}
|
||||
|
||||
private:
|
||||
static void* LoadModule(const char* moduleToLoad)
|
||||
{
|
||||
void* moduleHandle = dlopen(moduleToLoad, RTLD_NOW | RTLD_GLOBAL);
|
||||
if (!moduleHandle)
|
||||
{
|
||||
const char* loadError = dlerror();
|
||||
AZ_Error("QtForPython", false, "Unable to load python library %s for Pyside2: %s", moduleToLoad,
|
||||
loadError ? loadError : "Unknown Error");
|
||||
}
|
||||
return moduleHandle;
|
||||
}
|
||||
|
||||
static void UnloadModule(void* moduleHandle)
|
||||
{
|
||||
if (moduleHandle)
|
||||
{
|
||||
dlclose(moduleHandle);
|
||||
}
|
||||
}
|
||||
|
||||
void* m_libPythonLibraryFile;
|
||||
void* m_libPyside2LibraryFile;
|
||||
void* m_libShibokenLibraryFile;
|
||||
};
|
||||
} // namespace QtForPython
|
||||
@@ -6,4 +6,4 @@
|
||||
#
|
||||
#
|
||||
|
||||
set(PAL_TRAIT_BUILD_QTFORPYTHON_SUPPORTED FALSE)
|
||||
set(PAL_TRAIT_BUILD_QTFORPYTHON_SUPPORTED TRUE)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set(FILES
|
||||
InitializeEmbeddedPyside2.h
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace QtForPython
|
||||
{
|
||||
class InitializeEmbeddedPyside2
|
||||
{
|
||||
public:
|
||||
InitializeEmbeddedPyside2() = default;
|
||||
virtual ~InitializeEmbeddedPyside2() = default;
|
||||
};
|
||||
} // namespace QtForPython
|
||||
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set(FILES
|
||||
InitializeEmbeddedPyside2.h
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace QtForPython
|
||||
{
|
||||
class InitializeEmbeddedPyside2
|
||||
{
|
||||
public:
|
||||
InitializeEmbeddedPyside2() = default;
|
||||
virtual ~InitializeEmbeddedPyside2() = default;
|
||||
};
|
||||
} // namespace QtForPython
|
||||
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
#
|
||||
#
|
||||
|
||||
set(FILES
|
||||
InitializeEmbeddedPyside2.h
|
||||
)
|
||||
@@ -8,13 +8,17 @@
|
||||
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Module/Module.h>
|
||||
#include <AzCore/Debug/Trace.h>
|
||||
|
||||
#include <QtForPythonSystemComponent.h>
|
||||
|
||||
#include "InitializeEmbeddedPyside2.h"
|
||||
|
||||
namespace QtForPython
|
||||
{
|
||||
class QtForPythonModule
|
||||
: public AZ::Module
|
||||
, private InitializeEmbeddedPyside2
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(QtForPythonModule, "{81545CD5-79FA-47CE-96F2-1A9C5D59B4B9}", AZ::Module);
|
||||
@@ -22,11 +26,13 @@ namespace QtForPython
|
||||
|
||||
QtForPythonModule()
|
||||
: AZ::Module()
|
||||
, InitializeEmbeddedPyside2()
|
||||
{
|
||||
m_descriptors.insert(m_descriptors.end(), {
|
||||
QtForPythonSystemComponent::CreateDescriptor(),
|
||||
});
|
||||
}
|
||||
~QtForPythonModule() override = default;
|
||||
|
||||
/**
|
||||
* Add required SystemComponents to the SystemEntity.
|
||||
|
||||
@@ -203,10 +203,6 @@ namespace QtForPython
|
||||
{
|
||||
QtBootstrapParameters params;
|
||||
|
||||
#if !defined(Q_OS_WIN)
|
||||
#error Unsupported OS platform for this QtForPython gem
|
||||
#endif
|
||||
|
||||
params.m_mainWindowId = 0;
|
||||
using namespace AzToolsFramework;
|
||||
QWidget* activeWindow = nullptr;
|
||||
|
||||
@@ -45,3 +45,4 @@ ly_associate_package(PACKAGE_NAME squish-ccr-deb557d-rev1-linux
|
||||
ly_associate_package(PACKAGE_NAME astc-encoder-3.2-rev1-linux TARGETS astc-encoder PACKAGE_HASH 2ba97a06474d609945f0ab4419af1f6bbffdd294ca6b869f5fcebec75c573c0f)
|
||||
ly_associate_package(PACKAGE_NAME ISPCTexComp-36b80aa-rev1-linux TARGETS ISPCTexComp PACKAGE_HASH 065fd12abe4247dde247330313763cf816c3375c221da030bdec35024947f259)
|
||||
ly_associate_package(PACKAGE_NAME lz4-1.9.3-vcpkg-rev4-linux TARGETS lz4 PACKAGE_HASH 5de3dbd3e2a3537c6555d759b3c5bb98e5456cf85c74ff6d046f809b7087290d)
|
||||
ly_associate_package(PACKAGE_NAME pyside2-5.15.2-rev1-linux TARGETS pyside2 PACKAGE_HASH ec04291f3940e76ac817bc0c825f7a47f18d8760f0bdb8da4530732f2a69405e)
|
||||
|
||||
Reference in New Issue
Block a user