[Mac] Generate O3DE SDK app bundle that can be notarized and distributed (#4150)
* [Mac] Initial support for building with hardened runtime enabled and code signing the binaries and bundles generated by the CMake install process. Signed-off-by: amzn-sj <srikkant@amazon.com> * 1. Move call to ly_post_install_step 2. Entitlements should only be added for executables 3. Change use of CMake exec_program to newer execute_process 4. Remove broken symlinks from embedded Python frameworks 5. Run post install code signing only if hardened runtime is enabled Signed-off-by: amzn-sj <srikkant@amazon.com> * Remove unnecessary flag Signed-off-by: amzn-sj <srikkant@amazon.com> * Remove unnecessary additional call to condesign python inside a bundle Signed-off-by: amzn-sj <srikkant@amazon.com> * 1. Move commonly used install functions for codesigning, copying files, and fixing frameworks to a utility script 2. Remove unnecessary wait in the Editor/AP launchers I added earlier. 3. Codesign 3rd party libraries for distribution. Signed-off-by: amzn-sj <srikkant@amazon.com> * 1. Codesigning on 3rd party libs should only happen when hardened runtime is enabled. 2. Change the order of the if blocks in Editor's main_dummy.cpp. This was causing strange notarization issues because it wass too similar to AP's main executable. Signed-off-by: amzn-sj <srikkant@amazon.com> * Add new line to end of file Signed-off-by: amzn-sj <srikkant@amazon.com> * 1. Move architecture specification to PAL_mac cmake file. 2. Codesign failure should be fatal. Signed-off-by: amzn-sj <srikkant@amazon.com> * Address some PR feedback Signed-off-by: amzn-sj <srikkant@amazon.com> * Remove unnecessary comment. Change if to use IN_LIST. Signed-off-by: amzn-sj <srikkant@amazon.com> * HOME may not always be defined. Adding alternate POSIX way of determining HOME. Signed-off-by: amzn-sj <srikkant@amazon.com> * Checking in partial work to get O3DE SDK built as an app bundle. Has a bunch of debug code that needs to be cleaned up. Signed-off-by: amzn-sj <srikkant@amazon.com> * Remove this and add it back later with fixed casing. Signed-off-by: amzn-sj <srikkant@amazon.com> * Adding file back with fixed case Signed-off-by: amzn-sj <srikkant@amazon.com> * 1. Add entitlements sparingly(only when necessary) 2. Convert entitlements to plist files which we can directly pass to codesign 3. Install python site-packages in the o3de_sdk launcher and then launch the project manger. Signed-off-by: amzn-sj <srikkant@amazon.com> * 1. Move hardened runtime check to codesigning functions only. This way, non-hardened runtime install is identical to the former except for codesign. Makes it easy for QA to test internally. 2. Move cmake min version for install to the pre-install steps. Signed-off-by: amzn-sj <srikkant@amazon.com> * 1. Remove the dummy launchers for AssetProcessor and Editor 2. Add loader_path to the rpaths of binaries outside an app bundle so that the dynamic loader can load their dependencies if any. Signed-off-by: amzn-sj <srikkant@amazon.com> * Remove file named main_dummy.cpp Signed-off-by: amzn-sj <srikkant@amazon.com> * Add O3DE SDK launcher Signed-off-by: amzn-sj <srikkant@amazon.com> * Add missing runtime dependencies to gems Signed-off-by: amzn-sj <srikkant@amazon.com> * 1. Update the path to binaries when codesigning to the correct one. 2. Remove some debug messages. 3. Move installed binary path setreg generation to the target install function. This way, we get the correct path to the bundle accounting for different configs and subdirectories. Signed-off-by: amzn-sj <srikkant@amazon.com> * Add explanatory comments. Signed-off-by: amzn-sj <srikkant@amazon.com> * 1. ly_install_add_install_path_setreg cannot be called during install target because the runtime dependencies are already processed by then. 2. The SDK launcher now uses the ProjectManager's bundle setreg to find the path to the installed binaries Signed-off-by: amzn-sj <srikkant@amazon.com> * Update path to install relative binaries after merge from dev Signed-off-by: amzn-sj <srikkant@amazon.com> * Only one config of the SDK launcher needs to be installed. Preinstall steps should not be run per config, but only once. Signed-off-by: amzn-sj <srikkant@amazon.com> * 1. Install python dependencies using the get_python.sh script. 2. Replace any reference to hard-coded package name/version numbers with variables. 3. Add one more missing runtime dependency. 4. Misc. PR feedback. Signed-off-by: amzn-sj <srikkant@amazon.com> * 1. Remove the need for setreg files in all tool bundle. Project binary path can be used instead. 2. Move O3DE_SDK_Launcher to Code/Tools/BundleLauncher 3. Add ly_install_run_script() function for install(SCRIPT) functionality. 4. Address some other PR feedback. Signed-off-by: amzn-sj <srikkant@amazon.com> * Add source permission when installing O3DE_SDK executable. Signed-off-by: amzn-sj <srikkant@amazon.com> * Rename setreg file to add specialization tag. Signed-off-by: amzn-sj <srikkant@amazon.com> * Remove LY_BUILD_PERMUTATION that's not needed Signed-off-by: amzn-sj <srikkant@amazon.com> * 1. Add BinariesInstallPath.setreg to all our bundles like before. This is now only added during the install process though. 2. Fix path in Install_common.cmake Signed-off-by: amzn-sj <srikkant@amazon.com> * Fix comment Signed-off-by: amzn-sj <srikkant@amazon.com>monroegm-disable-blank-issue-2
parent
3812e60ab6
commit
1f542838bb
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.disable-library-validation</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Component/ComponentApplication.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzFramework/Process/ProcessWatcher.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// Create a ComponentApplication to initialize the AZ::SystemAllocator and initialize the SettingsRegistry
|
||||
AZ::ComponentApplication::Descriptor desc;
|
||||
AZ::ComponentApplication application;
|
||||
application.Create(desc);
|
||||
|
||||
AZStd::vector<AZStd::string> envVars;
|
||||
|
||||
const char* homePath = std::getenv("HOME");
|
||||
envVars.push_back(AZStd::string::format("HOME=%s", homePath));
|
||||
|
||||
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
|
||||
{
|
||||
const char* dyldLibPathOrig = std::getenv("DYLD_LIBRARY_PATH");
|
||||
AZStd::string dyldSearchPath = AZStd::string::format("DYLD_LIBRARY_PATH=%s", dyldLibPathOrig);
|
||||
if (AZ::IO::FixedMaxPath projectModulePath;
|
||||
settingsRegistry->Get(projectModulePath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectConfigurationBinPath))
|
||||
{
|
||||
dyldSearchPath.append(":");
|
||||
dyldSearchPath.append(projectModulePath.c_str());
|
||||
}
|
||||
|
||||
if (AZ::IO::FixedMaxPath installedBinariesFolder;
|
||||
settingsRegistry->Get(installedBinariesFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_InstalledBinaryFolder))
|
||||
{
|
||||
if (AZ::IO::FixedMaxPath engineRootFolder;
|
||||
settingsRegistry->Get(engineRootFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder))
|
||||
{
|
||||
installedBinariesFolder = engineRootFolder / installedBinariesFolder;
|
||||
dyldSearchPath.append(":");
|
||||
dyldSearchPath.append(installedBinariesFolder.c_str());
|
||||
}
|
||||
}
|
||||
envVars.push_back(dyldSearchPath);
|
||||
}
|
||||
|
||||
AZStd::string commandArgs;
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
commandArgs.append(argv[i]);
|
||||
commandArgs.append(" ");
|
||||
}
|
||||
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
AZ::IO::Path processPath{ AZ::IO::PathView(AZ::Utils::GetExecutableDirectory()) };
|
||||
processPath /= "Editor";
|
||||
processLaunchInfo.m_processExecutableString = AZStd::move(processPath.Native());
|
||||
processLaunchInfo.m_commandlineParameters = commandArgs;
|
||||
processLaunchInfo.m_environmentVariables = &envVars;
|
||||
processLaunchInfo.m_showWindow = true;
|
||||
|
||||
AzFramework::ProcessLauncher::LaunchUnwatchedProcess(processLaunchInfo);
|
||||
|
||||
application.Destroy();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.disable-library-validation</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Component/ComponentApplication.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzFramework/Process/ProcessWatcher.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// Create a ComponentApplication to initialize the AZ::SystemAllocator and initialize the SettingsRegistry
|
||||
AZ::ComponentApplication::Descriptor desc;
|
||||
AZ::ComponentApplication application;
|
||||
application.Create(desc);
|
||||
|
||||
AZStd::vector<AZStd::string> envVars;
|
||||
|
||||
const char* homePath = std::getenv("HOME");
|
||||
envVars.push_back(AZStd::string::format("HOME=%s", homePath));
|
||||
|
||||
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
|
||||
{
|
||||
const char* dyldLibPathOrig = std::getenv("DYLD_LIBRARY_PATH");
|
||||
AZStd::string dyldSearchPath = AZStd::string::format("DYLD_LIBRARY_PATH=%s", dyldLibPathOrig);
|
||||
if (AZ::IO::FixedMaxPath projectModulePath;
|
||||
settingsRegistry->Get(projectModulePath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectConfigurationBinPath))
|
||||
{
|
||||
dyldSearchPath.append(":");
|
||||
dyldSearchPath.append(projectModulePath.c_str());
|
||||
}
|
||||
|
||||
if (AZ::IO::FixedMaxPath installedBinariesFolder;
|
||||
settingsRegistry->Get(installedBinariesFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_InstalledBinaryFolder))
|
||||
{
|
||||
if (AZ::IO::FixedMaxPath engineRootFolder;
|
||||
settingsRegistry->Get(engineRootFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder))
|
||||
{
|
||||
installedBinariesFolder = engineRootFolder / installedBinariesFolder;
|
||||
dyldSearchPath.append(":");
|
||||
dyldSearchPath.append(installedBinariesFolder.c_str());
|
||||
}
|
||||
}
|
||||
envVars.push_back(dyldSearchPath);
|
||||
}
|
||||
|
||||
AZStd::string commandArgs;
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
commandArgs.append(argv[i]);
|
||||
commandArgs.append(" ");
|
||||
}
|
||||
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
AZ::IO::Path processPath{ AZ::IO::PathView(AZ::Utils::GetExecutableDirectory()) };
|
||||
processPath /= "AssetProcessor";
|
||||
processLaunchInfo.m_processExecutableString = AZStd::move(processPath.Native());
|
||||
processLaunchInfo.m_commandlineParameters = commandArgs;
|
||||
processLaunchInfo.m_environmentVariables = &envVars;
|
||||
processLaunchInfo.m_showWindow = true;
|
||||
|
||||
AzFramework::ProcessLauncher::LaunchUnwatchedProcess(processLaunchInfo);
|
||||
|
||||
application.Destroy();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#
|
||||
|
||||
# This is the launcher that will be used by the O3DE_SDK.app bundle
|
||||
# generated by the cmake install process for Mac.
|
||||
if(NOT ${PAL_PLATFORM_NAME} STREQUAL Mac)
|
||||
return()
|
||||
endif()
|
||||
|
||||
ly_add_target(
|
||||
NAME O3DE_SDK EXECUTABLE
|
||||
NAMESPACE AZ
|
||||
FILES_CMAKE
|
||||
O3DE_SDK_files.cmake
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
AZ::AzCore
|
||||
AZ::AzFramework
|
||||
)
|
||||
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/Component/ComponentApplication.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzFramework/Process/ProcessWatcher.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <mach-o/dyld.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// We need to pass in the engine path since we won't be able to find it by searching upwards.
|
||||
// We can't use any containers that use our custom allocator till after the call to ComponentApplication::Create()
|
||||
AZ::IO::FixedMaxPath processPath = AZ::Utils::GetExecutableDirectory();
|
||||
AZ::IO::FixedMaxPath enginePath = (processPath / "../Engine").LexicallyNormal();
|
||||
auto enginePathParam = AZ::SettingsRegistryInterface::FixedValueString::format(R"(--engine-path="%s")", enginePath.c_str());
|
||||
// Uses the fixed_vector deduction guide to determine the type is AZStd::fixed_vector<char*, 2>
|
||||
AZStd::fixed_vector commandLineParams{ processPath.Native().data(), enginePathParam.data() };
|
||||
|
||||
|
||||
// Create a ComponentApplication to initialize the AZ::SystemAllocator and initialize the SettingsRegistry
|
||||
AZ::ComponentApplication application(static_cast<int>(commandLineParams.size()), commandLineParams.data());
|
||||
application.Create(AZ::ComponentApplication::Descriptor());
|
||||
|
||||
AZ::IO::FixedMaxPath installedBinariesFolder;
|
||||
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
|
||||
{
|
||||
if (settingsRegistry->Get(installedBinariesFolder.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_InstalledBinaryFolder))
|
||||
{
|
||||
installedBinariesFolder = enginePath / installedBinariesFolder;
|
||||
}
|
||||
}
|
||||
|
||||
AZ::IO::FixedMaxPath shellPath = "/bin/sh";
|
||||
AZStd::string parameters = AZStd::string::format("-c \"export LY_CMAKE_PATH=/usr/local/bin && \"%s/python/get_python.sh\"\"", enginePath.c_str());
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo shellProcessLaunch;
|
||||
shellProcessLaunch.m_processExecutableString = AZStd::move(shellPath.Native());
|
||||
shellProcessLaunch.m_commandlineParameters = parameters;
|
||||
shellProcessLaunch.m_showWindow = true;
|
||||
shellProcessLaunch.m_workingDirectory = enginePath.String();
|
||||
AZStd::unique_ptr<AzFramework::ProcessWatcher> shellProcess(AzFramework::ProcessWatcher::LaunchProcess(shellProcessLaunch, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE));
|
||||
shellProcess->WaitForProcessToExit(120);
|
||||
shellProcess.reset();
|
||||
|
||||
AZ::IO::FixedMaxPath projectManagerPath = installedBinariesFolder/"o3de.app"/"Contents"/"MacOS"/"o3de";
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
processLaunchInfo.m_processExecutableString = AZStd::move(projectManagerPath.Native());
|
||||
processLaunchInfo.m_showWindow = true;
|
||||
AzFramework::ProcessLauncher::LaunchUnwatchedProcess(processLaunchInfo);
|
||||
|
||||
application.Destroy();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -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
|
||||
O3DE_SDK_Launcher.cpp
|
||||
)
|
||||
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>O3DE_SDK</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.O3DE.O3DE_SDK</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright (c) Contributors to the Open 3D Engine Project.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -0,0 +1,168 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#
|
||||
|
||||
function(fixup_qt_framework lib_name framework_path)
|
||||
|
||||
file(REMOVE_RECURSE
|
||||
${framework_path}/Headers
|
||||
${framework_path}/Resources
|
||||
${framework_path}/${lib_name}
|
||||
${framework_path}/Versions/Current
|
||||
${framework_path}/Versions/5/Headers
|
||||
)
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink 5 Current
|
||||
WORKING_DIRECTORY ${framework_path}/Versions
|
||||
)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/${lib_name} ${lib_name}
|
||||
WORKING_DIRECTORY ${framework_path}
|
||||
)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Resources Resources
|
||||
WORKING_DIRECTORY ${framework_path}
|
||||
)
|
||||
|
||||
endfunction()
|
||||
|
||||
function(fixup_python_framework framework_path)
|
||||
|
||||
file(REMOVE_RECURSE
|
||||
${framework_path}/Versions/Current
|
||||
${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/Headers
|
||||
${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/lib/Python
|
||||
${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/lib/python@LY_PYTHON_VERSION_MAJOR_MINOR@/test
|
||||
${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/lib/python@LY_PYTHON_VERSION_MAJOR_MINOR@/site-packages/scipy/io/tests
|
||||
${framework_path}/Python
|
||||
${framework_path}/Resources
|
||||
${framework_path}/Headers
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE exe_file_list "${framework_path}/**/*.exe")
|
||||
if(exe_file_list)
|
||||
file(REMOVE_RECURSE ${exe_file_list})
|
||||
endif()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink include/python@LY_PYTHON_VERSION_MAJOR_MINOR@m Headers
|
||||
WORKING_DIRECTORY ${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@
|
||||
)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink @LY_PYTHON_VERSION_MAJOR_MINOR@ Current
|
||||
WORKING_DIRECTORY ${framework_path}/Versions/
|
||||
)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Python Python
|
||||
WORKING_DIRECTORY ${framework_path}
|
||||
)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers Headers
|
||||
WORKING_DIRECTORY ${framework_path}
|
||||
)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Resources Resources
|
||||
WORKING_DIRECTORY ${framework_path}
|
||||
)
|
||||
file(CHMOD ${framework_path}/Versions/Current/Python
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||
)
|
||||
|
||||
endfunction()
|
||||
|
||||
function(codesign_file file entitlement_file)
|
||||
|
||||
if (NOT @LY_ENABLE_HARDENED_RUNTIME@)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(EXISTS ${entitlement_file})
|
||||
|
||||
execute_process(COMMAND "/usr/bin/codesign" "--force" "--sign" "@LY_CODE_SIGN_IDENTITY@" "--deep" "-o" "runtime" "--timestamp" "--entitlements" "${entitlement_file}" "${file}"
|
||||
TIMEOUT 300
|
||||
OUTPUT_VARIABLE codesign_out
|
||||
RESULT_VARIABLE codesign_ret
|
||||
)
|
||||
else()
|
||||
execute_process(COMMAND "/usr/bin/codesign" "--force" "--sign" "@LY_CODE_SIGN_IDENTITY@" "--deep" "-o" "runtime" "--timestamp" "${file}"
|
||||
TIMEOUT 300
|
||||
OUTPUT_VARIABLE codesign_out
|
||||
RESULT_VARIABLE codesign_ret
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT ${codesign_ret} EQUAL "0")
|
||||
message(FATAL_ERROR "Codesign operation for ${file_path} returned ${codesign_ret} with message ${codesign_out}")
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
function(codesign_python_framework_binaries framework_path)
|
||||
|
||||
if (NOT @LY_ENABLE_HARDENED_RUNTIME@)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# The codesign "--deep" flag will only codesign binaries in folders with specific names.
|
||||
# We need to codesign all the binaries that the "--deep" flag will miss.
|
||||
file(GLOB_RECURSE files
|
||||
LIST_DIRECTORIES false
|
||||
"${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/bin/**"
|
||||
"${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/lib/**"
|
||||
"${framework_path}/Versions/@LY_PYTHON_VERSION_MAJOR_MINOR@/Resources/**")
|
||||
|
||||
foreach(file ${files})
|
||||
if(NOT EXISTS ${file})
|
||||
file(REMOVE ${file})
|
||||
continue()
|
||||
endif()
|
||||
cmake_path(SET path_var "${file}")
|
||||
cmake_path(GET path_var EXTENSION LAST_ONLY extension)
|
||||
set(should_codesign FALSE)
|
||||
set(extension_skip_list ".dylib" ".so" ".7m")
|
||||
if (NOT extension)
|
||||
set(should_codesign TRUE)
|
||||
elseif(extension IN_LIST extension_skip_list)
|
||||
set(should_codesign TRUE)
|
||||
endif()
|
||||
if(${should_codesign})
|
||||
codesign_file("${file}" "@LY_ROOT_FOLDER@/python/Platform/Mac/PythonEntitlements.plist")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
endfunction()
|
||||
|
||||
function(ly_copy source_file target_directory)
|
||||
|
||||
if("${source_file}" MATCHES "\\.[Ff]ramework[^\\.]")
|
||||
|
||||
# fixup origin to copy the whole Framework folder
|
||||
string(REGEX REPLACE "(.*\\.[Ff]ramework).*" "\\1" source_file "${source_file}")
|
||||
|
||||
endif()
|
||||
get_filename_component(target_filename "${source_file}" NAME)
|
||||
file(COPY "${source_file}" DESTINATION "${target_directory}" FILE_PERMISSIONS @LY_COPY_PERMISSIONS@ FOLLOW_SYMLINK_CHAIN)
|
||||
|
||||
# Our Qt and Python frameworks aren't in the correct bundle format to be codesigned.
|
||||
if("${target_filename}" MATCHES "(Qt[^.]+)\\.[Ff]ramework")
|
||||
fixup_qt_framework(${CMAKE_MATCH_1} "${target_directory}/${target_filename}")
|
||||
# For some Qt frameworks(QtCore), signing the bundle doesn't work because of bundle
|
||||
# format issues(despite the fixes above). But once we've patched the framework above, there's
|
||||
# only one executable that we need to sign so we can do it directly.
|
||||
set(target_filename "${target_filename}/Versions/5/${CMAKE_MATCH_1}")
|
||||
elseif("${target_filename}" MATCHES "Python.framework")
|
||||
fixup_python_framework("${target_directory}/${target_filename}")
|
||||
codesign_python_framework_binaries("${target_directory}/${target_filename}")
|
||||
endif()
|
||||
codesign_file("${target_directory}/${target_filename}" "none")
|
||||
|
||||
endfunction()
|
||||
|
||||
function(ly_download_and_codesign_sdk_python)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -DPAL_PLATFORM_NAME=Mac -DLY_3RDPARTY_PATH=${CMAKE_INSTALL_PREFIX}/python -P ${CMAKE_INSTALL_PREFIX}/python/get_python.cmake)
|
||||
fixup_python_framework(${CMAKE_INSTALL_PREFIX}/python/runtime/@LY_PYTHON_PACKAGE_NAME@/Python.framework)
|
||||
codesign_python_framework_binaries(${CMAKE_INSTALL_PREFIX}/python/runtime/@LY_PYTHON_PACKAGE_NAME@/Python.framework)
|
||||
codesign_file(${CMAKE_INSTALL_PREFIX}/python/runtime/@LY_PYTHON_PACKAGE_NAME@/Python.framework @LY_ROOT_FOLDER@/python/Platform/Mac/PythonEntitlements.plist)
|
||||
endfunction()
|
||||
|
||||
function(ly_codesign_sdk)
|
||||
codesign_file(${LY_INSTALL_PATH_ORIGINAL}/O3DE_SDK.app "none")
|
||||
endfunction()
|
||||
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
# The O3DE SDK will be shipped as an app bundle. So we create an O3DE_SDK.app directory
|
||||
# and install SDK into the app's Contents/Engine directory.
|
||||
set(LY_INSTALL_PATH_ORIGINAL ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
file(INSTALL @LY_ROOT_FOLDER@/Code/Tools/BundleLauncher/info.plist
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/O3DE_SDK.app/Contents
|
||||
)
|
||||
|
||||
# This SDK launcher will install python site-packages and then launch the ProjectManager
|
||||
# when a user double clicks on the SDK from Finder. We're only going to need one version
|
||||
# of the SDK launcher regardless of what configs of the engine are installed.
|
||||
if (EXISTS @CMAKE_BINARY_DIR@/bin/profile/O3DE_SDK)
|
||||
set(sdk_launcher_config profile)
|
||||
elseif (EXISTS @CMAKE_BINARY_DIR@/bin/debug/O3DE_SDK)
|
||||
set(sdk_launcher_config debug)
|
||||
elseif (EXISTS @CMAKE_BINARY_DIR@/bin/release/O3DE_SDK)
|
||||
set(sdk_launcher_config release)
|
||||
endif()
|
||||
file(INSTALL @CMAKE_BINARY_DIR@/bin/${sdk_launcher_config}/O3DE_SDK
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/O3DE_SDK.app/Contents/MacOS
|
||||
USE_SOURCE_PERMISSIONS
|
||||
)
|
||||
file(INSTALL @CMAKE_BINARY_DIR@/runtime_install/${sdk_launcher_config}/BinariesInstallPath.setreg
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/O3DE_SDK.app/Contents/MacOS/Registry
|
||||
)
|
||||
|
||||
# We need to update the CMAKE_INSTALL_PREFIX so that the engine is installed inside the app bundle.
|
||||
file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/O3DE_SDK.app/Contents/Engine)
|
||||
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/O3DE_SDK.app/Contents/Engine)
|
||||
@ -0,0 +1,34 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#
|
||||
|
||||
cmake_path(SET file_path "${CMAKE_INSTALL_PREFIX}/@install_relative_binaries_path@/@runtime_output_filename@")
|
||||
cmake_path(GET file_path EXTENSION LAST_ONLY file_ext)
|
||||
|
||||
if(file_ext STREQUAL .app)
|
||||
|
||||
file(INSTALL @CMAKE_BINARY_DIR@/runtime_install/$<CONFIG>/BinariesInstallPath.setreg
|
||||
DESTINATION ${file_path}/Contents/MacOS/Registry
|
||||
)
|
||||
|
||||
if(EXISTS "${file_path}/Contents/Frameworks/Python.framework")
|
||||
codesign_python_framework_binaries("${file_path}/Contents/Frameworks/Python.framework")
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
find_program(LY_INSTALL_NAME_TOOL install_name_tool)
|
||||
if (NOT LY_INSTALL_NAME_TOOL)
|
||||
message(FATAL_ERROR "Unable to locate 'install_name_tool'")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND
|
||||
${LY_INSTALL_NAME_TOOL} -add_rpath @loader_path ${file_path})
|
||||
|
||||
endif()
|
||||
|
||||
codesign_file("${file_path}" "@entitlement_file@")
|
||||
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.disable-library-validation</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
Loading…
Reference in New Issue