Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,11 @@ endif()
string(TOLOWER "${DIST_ARCH}" DIST_ARCH)
string(REPLACE "amd64" "x86_64" DIST_ARCH "${DIST_ARCH}")
if (NOT DIST_DIR)
set(DIST_DIR "${DIST_ARCH}")
if(PLATFORM_NAME)
set(DIST_DIR "${DIST_ARCH}-${PLATFORM_NAME}")
else()
set(DIST_DIR "${DIST_ARCH}")
endif()
endif()

# ==================================================================================================
Expand Down
1 change: 1 addition & 0 deletions NEW_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).
## Release notes for next branch cut

- engine: Add experimental APIs `Engine::builder::paused()` and `Engine::setPaused()`
- ios: Add support for Apple Silicon (arm64) simulator
52 changes: 36 additions & 16 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,9 @@ function build_ios_target {
local platform=$3

echo "Building iOS ${lc_target} (${arch}) for ${platform}..."
mkdir -p "out/cmake-ios-${lc_target}-${arch}"
mkdir -p "out/cmake-ios-${lc_target}-${arch}-${platform}"

pushd "out/cmake-ios-${lc_target}-${arch}" > /dev/null
pushd "out/cmake-ios-${lc_target}-${arch}-${platform}" > /dev/null

if [[ ! -d "CMakeFiles" ]] || [[ "${ISSUE_CMAKE_ALWAYS}" == "true" ]]; then
cmake \
Expand All @@ -598,14 +598,14 @@ function build_ios_target {
${MATDBG_OPTION} \
${MATOPT_OPTION} \
../..
ln -sf "out/cmake-ios-${lc_target}-${arch}/compile_commands.json" \
ln -sf "out/cmake-ios-${lc_target}-${arch}-${platform}/compile_commands.json" \
../../compile_commands.json
fi

${BUILD_COMMAND}

if [[ "${INSTALL_COMMAND}" ]]; then
echo "Installing ${lc_target} in out/${lc_target}/filament..."
echo "Installing ${lc_target}-${arch}-${platform} in out/${lc_target}/filament..."
${BUILD_COMMAND} ${INSTALL_COMMAND}
fi

Expand Down Expand Up @@ -640,16 +640,26 @@ function build_ios {
if [[ "${ISSUE_DEBUG_BUILD}" == "true" ]]; then
build_ios_target "Debug" "arm64" "iphoneos"
if [[ "${IOS_BUILD_SIMULATOR}" == "true" ]]; then
build_ios_target "Debug" "arm64" "iphonesimulator"
build_ios_target "Debug" "x86_64" "iphonesimulator"
fi

if [[ "${BUILD_UNIVERSAL_LIBRARIES}" == "true" ]]; then
build/ios/create-universal-libs.sh \
-o out/ios-debug/filament/lib/universal \
out/ios-debug/filament/lib/arm64 \
out/ios-debug/filament/lib/x86_64
rm -rf out/ios-debug/filament/lib/arm64
rm -rf out/ios-debug/filament/lib/x86_64
-o ./out/ios-debug/filament/lib/universal \
./out/ios-debug/filament/lib/arm64-iphonesimulator \
./out/ios-debug/filament/lib/x86_64-iphonesimulator

rm -rf out/ios-debug/filament/lib/x86_64-iphonesimulator
rm -rf out/ios-debug/filament/lib/arm64-iphonesimulator

build/ios/create-xc-frameworks.sh \
-o out/ios-debug/filament/lib \
out/ios-debug/filament/lib/arm64-iphoneos \
out/ios-debug/filament/lib/universal

rm -rf out/ios-debug/filament/lib/universal
rm -rf out/ios-debug/filament/lib/arm64-iphoneos
fi

archive_ios "Debug"
Expand All @@ -658,16 +668,26 @@ function build_ios {
if [[ "${ISSUE_RELEASE_BUILD}" == "true" ]]; then
build_ios_target "Release" "arm64" "iphoneos"
if [[ "${IOS_BUILD_SIMULATOR}" == "true" ]]; then
build_ios_target "Release" "arm64" "iphonesimulator"
build_ios_target "Release" "x86_64" "iphonesimulator"
fi

if [[ "${BUILD_UNIVERSAL_LIBRARIES}" == "true" ]]; then
build/ios/create-universal-libs.sh \
-o out/ios-release/filament/lib/universal \
out/ios-release/filament/lib/arm64 \
out/ios-release/filament/lib/x86_64
rm -rf out/ios-release/filament/lib/arm64
rm -rf out/ios-release/filament/lib/x86_64
-o ./out/ios-release/filament/lib/universal \
./out/ios-release/filament/lib/arm64-iphonesimulator \
./out/ios-release/filament/lib/x86_64-iphonesimulator

rm -rf out/ios-release/filament/lib/x86_64-iphonesimulator
rm -rf out/ios-release/filament/lib/arm64-iphonesimulator

build/ios/create-xc-frameworks.sh \
-o out/ios-release/filament/lib \
out/ios-release/filament/lib/arm64-iphoneos \
out/ios-release/filament/lib/universal

rm -rf out/ios-release/filament/lib/universal
rm -rf out/ios-release/filament/lib/arm64-iphoneos
fi

archive_ios "Release"
Expand Down
107 changes: 107 additions & 0 deletions build/ios/create-xc-frameworks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#!/usr/bin/env bash

set -e

function print_help {
local SELF_NAME
SELF_NAME=$(basename "$0")
echo "$SELF_NAME. Combine multiple single-architecture or universal libraries into xc-frameworks."
echo ""
echo "Usage:"
echo " $SELF_NAME [options] <path>..."
echo ""
echo "Options:"
echo " -h"
echo " Print this help message."
echo " -o"
echo " Output directory to store the xcframeworks libraries."
echo ""
echo "Example:"
echo " Given the follow directories:"
echo " ├── universal/"
echo " │ └── libfoo.a <- universal library - ensure they share the same platform (iphone/simulator)"
echo " └── arm64-iphoneos/"
echo " └── libfoo.a <- arm64 iphoneos platform"
echo ""
echo " $SELF_NAME -o frameworks/ arm64-iphoneos/ universal/"
echo ""
echo " Each library is combined into an xc-framework:"
echo " └── frameworks/"
echo " └── libfoo.xcframework"
echo ""
echo "Each <path> should contain one or more single or universal-architecture static libraries."
echo "All <path>s should contain the same number of libraries, with the same names."
}

OUTPUT_DIR=""
while getopts "ho:" opt; do
case ${opt} in
h)
print_help
exit 1
;;
o)
OUTPUT_DIR="${OPTARG}"
;;
*)
print_help
exit 1
;;
esac
done

shift $((OPTIND - 1))

PATHS=("$@")

if [[ ! "${PATHS[*]}" ]]; then
echo "One or more paths required."
print_help
exit 1
fi

if [[ ! "${OUTPUT_DIR}" ]]; then
echo "Output directory required."
print_help
exit 1
fi

# Create the output directory, if it doesn't exist already.
mkdir -p "${OUTPUT_DIR}"

# Use the first path as the "leader" path. All paths should contain the same number of files with
# the same names, so it doesn't matter which we chose.
LEADER_PATH="${PATHS[0]}"

echo "Creating universal libraries from path: ${LEADER_PATH}..."

# Loop through each file in the leader path. For each library we find, we'll collect additional
# architectures in the other paths and combine them all into a universal library.
for FILE in "${LEADER_PATH}"/*.a; do
[ -f "${FILE}" ] || continue

# The static library file name, like "libfilament.a"
LIBRARY_NAME="${FILE##*/}"

INPUT_FILES=("-library ${LEADER_PATH}/${LIBRARY_NAME}")
for ARCH_PATH in "${PATHS[@]:1}"; do
THIS_FILE="${ARCH_PATH}/${LIBRARY_NAME}"
if [[ -f "${THIS_FILE}" ]]; then
INPUT_FILES+=("-library ${THIS_FILE}")
else
echo "Error: ${THIS_FILE} does not exist."
exit 1
fi
done

# Remove the .a extension
LIBRARY_NAME="${LIBRARY_NAME%.a}"

OUTPUT="${OUTPUT_DIR}/${LIBRARY_NAME}.xcframework"
# Delete previous xcframework
rm -rf $OUTPUT

# Create the xcframework command and execute it
CMD="xcodebuild -create-xcframework ${INPUT_FILES[@]} -output ${OUTPUT}"
eval $CMD
done
70 changes: 32 additions & 38 deletions ios/CocoaPods/Filament.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ Pod::Spec.new do |spec|
spec.platform = :ios, "11.0"
spec.source = { :http => "https://github.com/google/filament/releases/download/v1.51.0/filament-v1.51.0-ios.tgz" }

# Fix linking error with Xcode 12; we do not yet support the simulator on Apple silicon.
spec.pod_target_xcconfig = {
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64'
}
spec.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }

spec.subspec "filament" do |ss|
ss.source_files =
"include/filament/*.h",
Expand All @@ -23,13 +17,13 @@ Pod::Spec.new do |spec|
"include/ibl/*.h",
"include/geometry/*.h"
ss.header_mappings_dir = "include"
ss.vendored_libraries =
"lib/universal/libfilament.a",
"lib/universal/libbackend.a",
"lib/universal/libfilabridge.a",
"lib/universal/libfilaflat.a",
"lib/universal/libibl.a",
"lib/universal/libgeometry.a"
ss.vendored_frameworks =
"lib/libfilament.xcframework",
"lib/libbackend.xcframework",
"lib/libfilabridge.xcframework",
"lib/libfilaflat.xcframework",
"lib/libibl.xcframework",
"lib/libgeometry.xcframework"
ss.dependency "Filament/utils"
ss.dependency "Filament/math"
end
Expand All @@ -40,55 +34,55 @@ Pod::Spec.new do |spec|
"include/filament/MaterialChunkType.h",
"include/filament/MaterialEnums.h"
ss.header_mappings_dir = "include"
ss.vendored_libraries =
"lib/universal/libfilamat.a",
"lib/universal/libshaders.a",
"lib/universal/libsmol-v.a",
"lib/universal/libfilabridge.a"
ss.vendored_frameworks =
"lib/libfilamat.xcframework",
"lib/libshaders.xcframework",
"lib/libsmol-v.xcframework",
"lib/libfilabridge.xcframework"
ss.dependency "Filament/utils"
ss.dependency "Filament/math"
end

spec.subspec "gltfio_core" do |ss|
ss.source_files = "include/gltfio/**/*.h"
ss.header_mappings_dir = "include"
ss.vendored_libraries =
"lib/universal/libgltfio_core.a",
"lib/universal/libdracodec.a",
"lib/universal/libuberarchive.a",
"lib/universal/libstb.a"
ss.vendored_frameworks =
"lib/libgltfio_core.xcframework",
"lib/libdracodec.xcframework",
"lib/libuberarchive.xcframework",
"lib/libstb.xcframework"
ss.dependency "Filament/filament"
ss.dependency "Filament/ktxreader"
ss.dependency "Filament/uberz"
end

spec.subspec "camutils" do |ss|
ss.source_files = "include/camutils/*.h"
ss.vendored_libraries = "lib/universal/libcamutils.a"
ss.vendored_frameworks = "lib/libcamutils.xcframework"
ss.header_dir = "camutils"
ss.dependency "Filament/math"
end

spec.subspec "filameshio" do |ss|
ss.source_files = "include/filameshio/*.h"
ss.vendored_libraries =
"lib/universal/libfilameshio.a",
"lib/universal/libmeshoptimizer.a"
ss.vendored_frameworks =
"lib/libfilameshio.xcframework",
"lib/libmeshoptimizer.xcframework"
ss.header_dir = "filameshio"
ss.dependency "Filament/filament"
end

spec.subspec "image" do |ss|
ss.source_files = "include/image/*.h"
ss.vendored_libraries = "lib/universal/libimage.a"
ss.vendored_frameworks = "lib/libimage.xcframework"
ss.header_dir = "image"
ss.dependency "Filament/filament"
end

spec.subspec "utils" do |ss|
ss.source_files = "include/utils/**/*.h"
ss.header_mappings_dir = "include"
ss.vendored_libraries = "lib/universal/libutils.a"
ss.vendored_frameworks = "lib/libutils.xcframework"
ss.dependency "Filament/tsl"
end

Expand All @@ -105,29 +99,29 @@ Pod::Spec.new do |spec|
spec.subspec "ktxreader" do |ss|
ss.source_files = "include/ktxreader/*.h"
ss.header_mappings_dir = "include"
ss.vendored_libraries =
"lib/universal/libktxreader.a",
"lib/universal/libbasis_transcoder.a"
ss.vendored_frameworks =
"lib/libktxreader.xcframework",
"lib/libbasis_transcoder.xcframework"
ss.dependency "Filament/image"
ss.dependency "Filament/filament"
end

spec.subspec "viewer" do |ss|
ss.source_files = "include/viewer/*.h"
ss.header_mappings_dir = "include"
ss.vendored_libraries =
"lib/universal/libviewer.a",
"lib/universal/libcivetweb.a"
ss.vendored_frameworks =
"lib/libviewer.xcframework",
"lib/libcivetweb.xcframework"
ss.dependency "Filament/filament"
ss.dependency "Filament/gltfio_core"
end

spec.subspec "uberz" do |ss|
ss.source_files = "include/uberz/*.h"
ss.header_mappings_dir = "include"
ss.vendored_libraries =
"lib/universal/libuberzlib.a",
"lib/universal/libzstd.a"
ss.vendored_frameworks =
"lib/libuberzlib.xcframework",
"lib/libzstd.xcframework"
ss.header_dir = "uberz"
ss.dependency "Filament/filamat"
ss.dependency "Filament/tsl"
Expand Down
2 changes: 1 addition & 1 deletion ios/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ build Filament in Release mode, replace `debug` with `release` in the above `bui

If you also want to be able to run on the iOS simulator, add the `-s` flag to the `build.sh`
command. For example, the following command will build for both devices (ARM64) and the simulator
(x86_64) in Debug mode:
(x86_64/ARM64) in Debug mode:

```
$ ./build.sh -s -p ios -i debug
Expand Down
Loading