@@ -63,6 +63,9 @@ python_module_test () {
6363}
6464
6565check_env () {
66+ command -v brew > /dev/null 2>&1 || { echo >&2 " ${RED} Homebrew is required to be installed.${NC} " ; exit 1; }
67+ brew --prefix mesa > /dev/null 2>&1 || { echo >&2 " ${RED} You must install 'mesa' from Homebrew.${NC} " ; exit 1; }
68+ [ -x $( brew --prefix mesa) /bin/mesa_clc ] || { echo >&2 " ${RED} 'mesa_clc' not found in host Mesa installation.${NC} " ; exit 1; }
6669 command -v python3 > /dev/null 2>&1 || { echo >&2 " ${RED} You must install 'python3' on your host machine.${NC} " ; exit 1; }
6770 python_module_test six > /dev/null 2>&1 || { echo >&2 " ${RED} 'six' not found in your Python 3 installation.${NC} " ; exit 1; }
6871 python_module_test pyparsing > /dev/null 2>&1 || { echo >&2 " ${RED} 'pyparsing' not found in your Python 3 installation.${NC} " ; exit 1; }
@@ -170,6 +173,7 @@ download_all () {
170173 clone $VIRGLRENDERER_REPO $VIRGLRENDERER_COMMIT
171174 clone $HYPERVISOR_REPO $HYPERVISOR_COMMIT
172175 clone $LIBUCONTEXT_REPO $LIBUCONTEXT_COMMIT
176+ clone $MESA_REPO $MESA_COMMIT
173177}
174178
175179copy_private_headers () {
@@ -205,6 +209,7 @@ meson_quote() {
205209
206210generate_meson_cross () {
207211 cross=" $1 "
212+ system=" $2 "
208213 echo " # Automatically generated - do not modify" > $cross
209214 echo " [properties]" >> $cross
210215 echo " needs_exe_wrapper = true" >> $cross
@@ -227,15 +232,21 @@ generate_meson_cross() {
227232 echo " python = ['$( which python3) ']" >> $cross
228233 echo " glib-mkenums = ['$( which glib-mkenums) ']" >> $cross
229234 echo " glib-compile-resources = ['$( which glib-compile-resources) ']" >> $cross
235+ echo " mesa_clc = ['$( brew --prefix mesa) /bin/mesa_clc']" >> $cross
236+ echo " vtn_bindgen2 = ['$( brew --prefix mesa) /bin/vtn_bindgen2']" >> $cross
230237 echo " [host_machine]" >> $cross
231- case $PLATFORM in
232- ios* | visionos* )
233- echo " system = 'ios'" >> $cross
234- ;;
235- macos )
236- echo " system = 'darwin'" >> $cross
237- ;;
238- esac
238+ if [ " $system " == " auto" ]; then
239+ case $PLATFORM in
240+ ios* | visionos* )
241+ echo " system = 'ios'" >> $cross
242+ ;;
243+ macos )
244+ echo " system = 'darwin'" >> $cross
245+ ;;
246+ esac
247+ else
248+ echo " system = '$system '" >> $cross
249+ fi
239250 case " $ARCH " in
240251 armv7 | armv7s )
241252 echo " cpu_family = 'arm'" >> $cross
@@ -301,6 +312,7 @@ generate_cmake_toolchain() {
301312 #
302313 echo " set(CMAKE_SYSTEM_PROCESSOR \" $ARCH \" )" >> " $toolchain "
303314 echo " set(CMAKE_OSX_ARCHITECTURES \" $ARCH \" )" >> " $toolchain "
315+ echo " set(CMAKE_MACOSX_BUNDLE OFF CACHE BOOL \"\" )" >> " $toolchain "
304316 echo " " >> " $toolchain "
305317
306318 #
@@ -506,19 +518,20 @@ build () {
506518 cd " $pwd "
507519}
508520
509- meson_build () {
510- SRCDIR=" $1 "
511- shift 1
521+ meson_cross_build () {
522+ CROSS=" $1 "
523+ SRCDIR=" $2 "
524+ shift 2
512525 FILE=" $( basename $SRCDIR ) "
513526 NAME=" ${FILE% .tar.* } "
514527 case $SRCDIR in
515528 http* | ftp* )
516529 SRCDIR=" $BUILD_DIR /$NAME "
517530 ;;
518531 esac
519- MESON_CROSS=" $( realpath " $BUILD_DIR " ) /meson.cross"
532+ MESON_CROSS=" $( realpath " $BUILD_DIR " ) /meson- $CROSS .cross"
520533 if [ ! -f " $MESON_CROSS " ]; then
521- generate_meson_cross " $MESON_CROSS "
534+ generate_meson_cross " $MESON_CROSS " " $CROSS "
522535 fi
523536 pwd=" $( pwd) "
524537
@@ -535,6 +548,14 @@ meson_build () {
535548 cd " $pwd "
536549}
537550
551+ meson_build () {
552+ meson_cross_build auto $@
553+ }
554+
555+ meson_darwin_build () {
556+ meson_cross_build darwin $@
557+ }
558+
538559cmake_build () {
539560 SRCDIR=" $1 "
540561 shift 1
@@ -646,7 +667,7 @@ build_qemu_dependencies () {
646667 meson_build $GST_GOOD_SRC -Dtests=disabled -Ddefault_library=both
647668 meson_build $SPICE_PROTOCOL_SRC
648669 meson_build $SPICE_SERVER_SRC -Dlz4=false -Dsasl=false
649- meson_build $SLIRP_SRC
670+ meson_darwin_build $SLIRP_SRC
650671 # USB support
651672 if [ -z " $SKIP_USB_BUILD " ]; then
652673 build $USB_SRC
@@ -656,7 +677,7 @@ build_qemu_dependencies () {
656677 build_angle
657678 meson_build $EPOXY_REPO -Dtests=false -Dglx=no -Degl=yes
658679 cmake_build $VULKAN_LOADER_REPO -D UPDATE_DEPS=On
659- meson_build $VIRGLRENDERER_REPO -Dtests=false -Dcheck-gl-errors=false -Dvenus=true -Dvulkan-dload=false -Drender-server-worker=thread
680+ meson_darwin_build $VIRGLRENDERER_REPO -Dtests=false -Dcheck-gl-errors=false -Dvenus=true -Dvulkan-dload=false -Drender-server-worker=thread
660681 # Hypervisor for iOS
661682 if [ " $PLATFORM " == " ios" ] || [ " $PLATFORM " == " ios_simulator" ]; then
662683 build_hypervisor
@@ -672,6 +693,19 @@ build_spice_client () {
672693 meson_build $SPICE_CLIENT_SRC -Dcoroutine=libucontext
673694}
674695
696+ patch_vulkan_icd () {
697+ local icd_file=" $1 "
698+
699+ sed -i ' ' -E '
700+ s|("library_path"[[:space:]]*:[[:space:]]*")[^"]*/lib([^"/]+)\.dylib(")|\1\2.framework/Versions/Current/\2\3|
701+ ' " $icd_file "
702+ }
703+
704+ build_vulkan_drivers () {
705+ meson_darwin_build $MESA_REPO -Dmesa-clc=system -Dgallium-drivers= -Dvulkan-drivers=kosmickrisp -Dplatforms=macos
706+ patch_vulkan_icd " $PREFIX /share/vulkan/icd.d/kosmickrisp_mesa_icd.arm64.json"
707+ }
708+
675709fixup () {
676710 FILE=$1
677711 BASE=$( basename " $FILE " )
960994echo " ${GREEN} Deleting old sysroot!${NC} "
961995rm -rf " $PREFIX /" *
962996rm -f " $BUILD_DIR /BUILD_SUCCESS"
963- rm -f " $BUILD_DIR /meson.cross"
997+ rm -f " $BUILD_DIR /meson*.cross"
998+ rm -f " $BUILD_DIR /cross.cmake"
964999mkdir -p " $PREFIX /Frameworks"
9651000copy_private_headers
9661001build_pkg_config
9671002build_qemu_dependencies
9681003build $QEMU_DIR --cross-prefix=" " $QEMU_PLATFORM_BUILD_FLAGS
9691004build_spice_client
1005+ build_vulkan_drivers
9701006fixup_all
9711007remove_shared_gst_plugins # another hack...
9721008echo " ${GREEN} All done!${NC} "
0 commit comments