-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into python_stubs
- Loading branch information
Showing
11 changed files
with
220 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/bin/zsh | ||
|
||
# Creates an Apple framework for the given platform type | ||
# documentation: https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle | ||
# https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html | ||
echo "⌛️ Creating MaterialX.framework ..." | ||
|
||
# Variables are substituted by CMake | ||
CMAKE_INSTALL_PREFIX="@CMAKE_INSTALL_PREFIX@" | ||
PROJECT_BINARY_DIR="@PROJECT_BINARY_DIR@" | ||
|
||
FRAMEWORK_NAME="MaterialX" | ||
FRAMEWORK_DIR="${CMAKE_INSTALL_PREFIX}/frameworks/${FRAMEWORK_NAME}.framework" | ||
FRAMEWORK_LIBRARIES_DIR="${FRAMEWORK_DIR}/Libraries" | ||
FRAMEWORK_ROOT_LIBRARY_NAME="libMaterialX.@MATERIALX_LIBRARY_VERSION@.dylib" | ||
EMBEDDED_BUILD=@__embedded_build@ | ||
FRAMEWORK_RESOURCES_DIR="${FRAMEWORK_DIR}" | ||
MATERIALX_SOURCE_LIBRARIES="${CMAKE_INSTALL_PREFIX}/libraries/" | ||
BUNDLE_IDENTIFIER="org.aswf.materialx" | ||
CODESIGN_ID="@CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY@" | ||
OLD_RC_PATH="${CMAKE_INSTALL_PREFIX}/lib" | ||
|
||
function fix_linkage() { | ||
readonly file=${1:?"A file path must be specified."} | ||
readonly prepend="${FRAMEWORK_NAME}.framework/Libraries" | ||
filename=$(basename ${file}) | ||
# First, change the install name. This corresponds to LC_ID_DYLIB. | ||
install_name_tool -id "@rpath/${prepend}/${filename}" ${file} | ||
|
||
parts=("${(@f)$(otool -l ${file})}") | ||
for line in ${parts}; do | ||
dylib_name="" | ||
[[ $line =~ ' *name @rpath/(.*\.dylib)' ]] && dylib_name=$match[1] | ||
if [ -n "${dylib_name}" ]; then | ||
install_name_tool -change "@rpath/${dylib_name}" "@rpath/${prepend}/${dylib_name}" "${file}" | ||
fi | ||
if [[ $line == *"${OLD_RC_PATH}"* ]]; then | ||
install_name_tool -delete_rpath ${OLD_RC_PATH} ${file} | ||
fi | ||
done | ||
|
||
codesign -f -s ${CODESIGN_ID} ${file} | ||
} | ||
|
||
# Remove the existing directory if it exists | ||
if [ -d ${FRAMEWORK_DIR} ]; then | ||
echo "Removing existing framework"; | ||
rm -Rf ${FRAMEWORK_DIR}; | ||
fi | ||
|
||
# Create the parent directory | ||
echo "Creating Framework Directory: ${FRAMEWORK_DIR}" | ||
mkdir -p ${FRAMEWORK_DIR} | ||
|
||
if [ "$EMBEDDED_BUILD" = true ];then | ||
FRAMEWORK_RESOURCES_DIR="${FRAMEWORK_DIR}/Resources" | ||
FRAMEWORK_PLIST_LOCATION="${FRAMEWORK_DIR}/Info.plist" | ||
FRAMEWORK_HEADERS_DIR="${FRAMEWORK_DIR}/Headers" | ||
FRAMEWORK_LIB_PATH=""${FRAMEWORK_DIR}/${FRAMEWORK_NAME}"" | ||
else | ||
FRAMEWORK_RESOURCES_DIR="${FRAMEWORK_DIR}/Versions/A/Resources/" | ||
FRAMEWORK_PLIST_LOCATION="${FRAMEWORK_DIR}/Versions/A/Resources/Info.plist" | ||
FRAMEWORK_HEADERS_DIR="${FRAMEWORK_DIR}/Versions/A/Headers" | ||
FRAMEWORK_LIB_PATH="${FRAMEWORK_DIR}/Versions/A/${FRAMEWORK_NAME}" | ||
fi | ||
|
||
echo "Creating Resources Root: ${FRAMEWORK_RESOURCES_DIR}" | ||
mkdir -p ${FRAMEWORK_RESOURCES_DIR} | ||
|
||
echo "Creating Headers Root: ${FRAMEWORK_HEADERS_DIR}" | ||
mkdir -p ${FRAMEWORK_HEADERS_DIR} | ||
|
||
# Copy the plist over | ||
echo "Copying files into ${FRAMEWORK_DIR}" | ||
ditto "${PROJECT_BINARY_DIR}/Info.plist" "${FRAMEWORK_PLIST_LOCATION}" | ||
|
||
# Copy the primary directories over | ||
ditto "${CMAKE_INSTALL_PREFIX}/include/" ${FRAMEWORK_HEADERS_DIR} | ||
ditto "${CMAKE_INSTALL_PREFIX}/libraries/" "${FRAMEWORK_RESOURCES_DIR}/libraries" | ||
ditto "${CMAKE_INSTALL_PREFIX}/resources" "${FRAMEWORK_RESOURCES_DIR}/render" | ||
|
||
cp "${CMAKE_INSTALL_PREFIX}/lib/${FRAMEWORK_ROOT_LIBRARY_NAME}" "${FRAMEWORK_LIB_PATH}" | ||
|
||
# Setup symlinks | ||
if [ "$EMBEDDED_BUILD" = false ];then | ||
(cd "${FRAMEWORK_DIR}/Versions" && ln -s "A" "Current") | ||
(cd ${FRAMEWORK_DIR} && ln -s "Versions/Current/Resources" "Resources") | ||
(cd ${FRAMEWORK_DIR} && ln -s "Versions/Current/Headers" "Headers") | ||
(cd ${FRAMEWORK_DIR} && ln -s "Versions/Current/${FRAMEWORK_NAME}" ${FRAMEWORK_NAME}) | ||
fi | ||
|
||
# Fix the linkage on the primary dylib | ||
fix_linkage "${FRAMEWORK_DIR}/${FRAMEWORK_NAME}" | ||
install_name_tool -id "@rpath/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "${FRAMEWORK_DIR}/${FRAMEWORK_NAME}" | ||
install_name_tool -change "@rpath/${FRAMEWORK_NAME}.framework/Libraries/${FRAMEWORK_NAME}" "@rpath/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "${FRAMEWORK_DIR}/${FRAMEWORK_NAME}" | ||
|
||
# Frameworks require all includes to use the framework name as the prefix for automatic discovery | ||
echo "Modifying headers..." | ||
HEADER_SET="" | ||
for i in $(cd $FRAMEWORK_HEADERS_DIR && ls -d */ | cut -f1 -d'/');do | ||
HEADER_SET+="${i}|" | ||
done; | ||
# Sed on macOS is POSIX compliant and so uses different args than GNU | ||
# Things to be aware of are [[:<:]] and [[:>:]] are for word boundaries and spaces are explicit literals | ||
INCLUDE_PATTERN="^# *include [\"|<]([[:<:]](${HEADER_SET::-1})[[:>:]].*)[\"|>].*$" | ||
find ${FRAMEWORK_HEADERS_DIR} -type f -name "*.h*" -print0 | xargs -0 sed -i "" -E "s,${INCLUDE_PATTERN},#include <${FRAMEWORK_NAME}/\1>,g" | ||
|
||
# Sign the final framework | ||
echo "Codesigning the framework..." | ||
set -e | ||
codesign --force --sign ${CODESIGN_ID} --generate-entitlement-der --identifier ${BUNDLE_IDENTIFIER} --verbose ${FRAMEWORK_DIR} | ||
|
||
echo "✅ Finished creating framework at ${FRAMEWORK_DIR}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?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>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>MaterialX</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>org.aswf.materialx</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>MaterialX</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>@MATERIALX_LIBRARY_VERSION@</string> | ||
<key>CFBundleVersion</key> | ||
<string>@CFBUNDLEVERSION@</string> | ||
<key>CSResourcesFileMapped</key> | ||
<true /> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters