@@ -77,6 +77,10 @@ function print_help {
7777 echo " meant for building the samples."
7878 echo " -P"
7979 echo " Enable perfetto traces on Android. Disabled by default on the Release build, enabled otherwise."
80+ echo " -y build_type"
81+ echo " Build the filament dependent tools (matc, resgen) separately from the project. This will set"
82+ echo " the tools as prebuilts that filament target will then use to build. The built_type option"
83+ echo " (debug|release) is meant to indicate the type of build of the resulting prebuilts."
8084 echo " "
8185 echo " Build types:"
8286 echo " release"
@@ -217,6 +221,11 @@ OSMESA_OPTION=""
217221IOS_BUILD_SIMULATOR=false
218222BUILD_UNIVERSAL_LIBRARIES=false
219223
224+ ISSUE_SPLIT_BUILD=false
225+ SPLIT_BUILD_TYPE=" "
226+ PREBUILT_TOOLS_DIR=" "
227+ IMPORT_EXECUTABLES_DIR_OPTION=" -DIMPORT_EXECUTABLES_DIR=out"
228+
220229BUILD_GENERATOR=Ninja
221230BUILD_COMMAND=ninja
222231BUILD_CUSTOM_TARGETS=
@@ -242,6 +251,37 @@ function build_clean_aggressive {
242251 git clean -qfX android
243252}
244253
254+ function build_tools_for_split_build {
255+ local build_type_arg=$1
256+ local lc_build_type=$( echo " ${build_type_arg} " | tr ' [:upper:]' ' [:lower:]' )
257+ PREBUILT_TOOLS_DIR=" out/prebuilt-tools-${lc_build_type} "
258+
259+ echo " Building tools for split build (${lc_build_type} ) in ${PREBUILT_TOOLS_DIR} ..."
260+ mkdir -p " ${PREBUILT_TOOLS_DIR} "
261+
262+ pushd " ${PREBUILT_TOOLS_DIR} " > /dev/null
263+
264+ local lc_name=$( echo " ${UNAME} " | tr ' [:upper:]' ' [:lower:]' )
265+ local architectures=" "
266+ if [[ " ${lc_name} " == " darwin" ]]; then
267+ if [[ " ${BUILD_UNIVERSAL_LIBRARIES} " == " true" ]]; then
268+ architectures=" -DCMAKE_OSX_ARCHITECTURES=arm64;x86_64"
269+ fi
270+ fi
271+
272+ cmake \
273+ -G " ${BUILD_GENERATOR} " \
274+ -DFILAMENT_EXPORT_PREBUILT_EXECUTABLES_DIR=${PREBUILT_TOOLS_DIR} \
275+ -DCMAKE_BUILD_TYPE=" ${build_type_arg} " \
276+ ${WEBGPU_OPTION} \
277+ ${architectures} \
278+ ../..
279+
280+ ${BUILD_COMMAND} ${WEB_HOST_TOOLS}
281+
282+ popd > /dev/null
283+ }
284+
245285function build_desktop_target {
246286 local lc_target=$( echo " $1 " | tr ' [:upper:]' ' [:lower:]' )
247287 local build_targets=$2
@@ -265,7 +305,7 @@ function build_desktop_target {
265305 if [[ ! -d " CMakeFiles" ]] || [[ " ${ISSUE_CMAKE_ALWAYS} " == " true" ]]; then
266306 cmake \
267307 -G " ${BUILD_GENERATOR} " \
268- -DIMPORT_EXECUTABLES_DIR=out \
308+ ${IMPORT_EXECUTABLES_DIR_OPTION} \
269309 -DCMAKE_BUILD_TYPE=" $1 " \
270310 -DCMAKE_INSTALL_PREFIX=" ../${lc_target} /filament" \
271311 ${EGL_ON_LINUX_OPTION} \
@@ -331,7 +371,7 @@ function build_webgl_with_target {
331371 source " ${EMSDK} /emsdk_env.sh"
332372 cmake \
333373 -G " ${BUILD_GENERATOR} " \
334- -DIMPORT_EXECUTABLES_DIR=out \
374+ ${IMPORT_EXECUTABLES_DIR_OPTION} \
335375 -DCMAKE_TOOLCHAIN_FILE=" ${EMSDK} /upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" \
336376 -DCMAKE_BUILD_TYPE=" $1 " \
337377 -DCMAKE_INSTALL_PREFIX=" ../webgl-${lc_target} /filament" \
@@ -404,7 +444,7 @@ function build_android_target {
404444 if [[ ! -d " CMakeFiles" ]] || [[ " ${ISSUE_CMAKE_ALWAYS} " == " true" ]]; then
405445 cmake \
406446 -G " ${BUILD_GENERATOR} " \
407- -DIMPORT_EXECUTABLES_DIR=out \
447+ ${IMPORT_EXECUTABLES_DIR_OPTION} \
408448 -DCMAKE_BUILD_TYPE=" $1 " \
409449 -DFILAMENT_NDK_VERSION=" ${FILAMENT_NDK_VERSION} " \
410450 -DCMAKE_INSTALL_PREFIX=" ../android-${lc_target} /filament" \
@@ -638,7 +678,7 @@ function build_ios_target {
638678 if [[ ! -d " CMakeFiles" ]] || [[ " ${ISSUE_CMAKE_ALWAYS} " == " true" ]]; then
639679 cmake \
640680 -G " ${BUILD_GENERATOR} " \
641- -DIMPORT_EXECUTABLES_DIR=out \
681+ ${IMPORT_EXECUTABLES_DIR_OPTION} \
642682 -DCMAKE_BUILD_TYPE=" $1 " \
643683 -DCMAKE_INSTALL_PREFIX=" ../ios-${lc_target} /filament" \
644684 -DIOS_ARCH=" ${arch} " \
@@ -810,7 +850,7 @@ function check_debug_release_build {
810850
811851pushd " $( dirname " $0 " ) " > /dev/null
812852
813- while getopts " :hacCfgimp:q:uvWslwedtk:bVx:S:X:P " opt; do
853+ while getopts " :hacCfgimp:q:uvWslwedtk:bVx:S:X:Py: " opt; do
814854 case ${opt} in
815855 h)
816856 print_help
@@ -979,6 +1019,20 @@ while getopts ":hacCfgimp:q:uvWslwedtk:bVx:S:X:P" opt; do
9791019 ;;
9801020 X) OSMESA_OPTION=" -DFILAMENT_OSMESA_PATH=${OPTARG} "
9811021 ;;
1022+ y)
1023+ ISSUE_SPLIT_BUILD=true
1024+ SPLIT_BUILD_TYPE=${OPTARG}
1025+ case $( echo " ${SPLIT_BUILD_TYPE} " | tr ' [:upper:]' ' [:lower:]' ) in
1026+ debug|release)
1027+ ;;
1028+ * )
1029+ echo " Unknown build type for -y: ${SPLIT_BUILD_TYPE} "
1030+ echo " Build type must be one of [debug|release]"
1031+ echo " "
1032+ exit 1
1033+ ;;
1034+ esac
1035+ ;;
9821036 \? )
9831037 echo " Invalid option: -${OPTARG} " >&2
9841038 echo " "
@@ -1013,6 +1067,13 @@ done
10131067
10141068validate_build_command
10151069
1070+ if [[ " ${ISSUE_SPLIT_BUILD} " == " true" ]]; then
1071+ # Capitalize first letter of SPLIT_BUILD_TYPE
1072+ SPLIT_BUILD_TYPE_CAPITALIZED=" $( echo ${SPLIT_BUILD_TYPE: 0: 1} | tr ' [:lower:]' ' [:upper:]' ) ${SPLIT_BUILD_TYPE: 1} "
1073+ build_tools_for_split_build " ${SPLIT_BUILD_TYPE_CAPITALIZED} "
1074+ IMPORT_EXECUTABLES_DIR_OPTION=" -DFILAMENT_IMPORT_PREBUILT_EXECUTABLES_DIR=${PREBUILT_TOOLS_DIR} "
1075+ fi
1076+
10161077if [[ " ${ISSUE_CLEAN} " == " true" ]]; then
10171078 build_clean
10181079fi
0 commit comments