44use File::Basename;
55use File::Path;
66use lib (' external/buildscripts' , " ../../Tools/perl_lib" ," perl_lib" , ' external/buildscripts/perl_lib' );
7+ use strict;
8+ use warnings;
79use Tools qw( InstallNameTool) ;
810
911print " >>> PATH in Build All = $ENV {PATH}\n\n " ;
1012
1113my $currentdir = getcwd();
1214
1315my $monoroot = File::Spec-> rel2abs(dirname(__FILE__ ) . " /../.." );
14- my $monoroot = abs_path($monoroot );
16+ $monoroot = abs_path($monoroot );
1517
1618my $buildscriptsdir = " $monoroot /external/buildscripts" ;
1719my $addtoresultsdistdir = " $buildscriptsdir /add_to_build_results/monodistribution" ;
5052my $existingMonoRootPath = ' ' ;
5153my $sdk = ' ' ;
5254my $arch32 = 0;
55+ my $targetArch = " " ;
5356my $winPerl = " " ;
5457my $winMonoRoot = " " ;
5558my $msBuildVersion = " 14.0" ;
9598 ' runtimetests=i' => \$runRuntimeTests ,
9699 ' classlibtests=i' => \$runClasslibTests ,
97100 ' arch32=i' => \$arch32 ,
101+ ' targetarch=s' => \$targetArch ,
98102 ' jobs=i' => \$jobs ,
99103 ' sdk=s' => \$sdk ,
100104 ' existingmono=s' => \$existingMonoRootPath ,
204208}
205209elsif ($^O eq ' darwin' )
206210{
207- $monoHostArch = $arch32 ? " i386 " : " x86_64" ;
211+ $monoHostArch = " x86_64" ;
208212 $existingExternalMono = " $existingExternalMonoRoot " ;
209213 $existingExternalMonoBinDir = " bin" ;
210214
215+ if ($targetArch eq " arm64" )
216+ {
217+ $disableMcs = 1;
218+ $test = 0;
219+ }
220+
211221 # From Massi: I was getting failures in install_name_tool about space
212222 # for the commands being too small, and adding here things like
213223 # $ENV{LDFLAGS} = '-headerpad_max_install_names' and
294304 }
295305 else
296306 {
297- if (not $checkoutonthefly )
307+ if (not $checkoutOnTheFly )
298308 {
299309 print (" >>> No external build deps found. Might as well try to check them out. If it fails, we'll continue and trust mono is in your PATH\n " );
300310 }
445455 }
446456
447457 my $macSdkPath = " " ;
448- my $macversion = ' 10.8 ' ;
458+ my $macversion = ' 10.12 ' ;
449459 my $darwinVersion = " 10" ;
450460 if ($^O eq ' darwin' )
451461 {
452- if ($sdk eq ' ' )
453- {
454- $sdk =' 10.11' ;
455- }
456-
457- my $macBuildEnvDir = " $externalBuildDeps /MacBuildEnvironment" ;
458- $macSdkPath = " $macBuildEnvDir /builds/MacOSX$sdk .sdk" ;
459- if (! -d $macSdkPath )
460- {
461- print (" >>> Unzipping mac build toolchain\n " );
462- system (" unzip" , ' -qd' , " $macBuildEnvDir " , " $macBuildEnvDir /builds.zip" ) eq 0 or die (" failed unzipping mac build toolchain\n " );
463- }
462+ $sdk =' 11.0' ;
463+ $macSdkPath = " $externalBuildDeps /mac-toolchain-11_0/MacOSX$sdk .sdk" ;
464464 }
465465
466466 if ($iphone || $iphoneSimulator )
681681 my $platformRootPostfix = " " ;
682682 my $useKraitPatch = 1;
683683 my $kraitPatchPath = " $monoroot /../../android_krait_signal_handler/build" ;
684- my $toolChainExtension = " " ;
685684
686685 $ENV {ANDROID_PLATFORM } = " android-$apiLevel " ;
687686
759758
760759 if ($runningOnWindows )
761760 {
762- $toolChainExtension = " .exe" ;
763-
764761 $androidPlatformRoot = ` cygpath -w $androidPlatformRoot ` ;
765762 # clean up trailing new lines that end up in the output from cygpath.
766763 $androidPlatformRoot =~ s /\n +$// ;
968965
969966 if ($runningOnWindows )
970967 {
971- $toolChainExtension = " .exe" ;
972-
973968 $tizenPlatformRoot = ` cygpath -w $tizenPlatformRoot ` ;
974969 # clean up trailing new lines that end up in the output from cygpath.
975970 $tizenPlatformRoot =~ s /\n +$// ;
11591154 $existingMonoRootPath = " $monoInstalls /$monoVersionToUse " ;
11601155 }
11611156
1157+ if ($targetArch eq " arm64" )
1158+ {
1159+ $macversion = " 11.0" ; # To build on ARM64, we need to specify min OS version as 11.0 as we need to use new APIs from 11.0
1160+ }
1161+
11621162 $mcs = " EXTERNAL_MCS=$existingMonoRootPath /bin/mcs" ;
11631163
11641164 $ENV {' CC' } = " $macSdkPath /../usr/bin/clang" ;
11651165 $ENV {' CXX' } = " $macSdkPath /../usr/bin/clang++" ;
1166- $ENV {' CFLAGS' } = $ENV {MACSDKOPTIONS } = " -D_XOPEN_SOURCE -I $macBuildEnvDir /builds/usr/include - mmacosx-version-min=$macversion -isysroot $macSdkPath " ;
1166+ $ENV {' CFLAGS' } = $ENV {MACSDKOPTIONS } = " -mmacosx-version-min=$macversion -isysroot $macSdkPath -g " ;
11671167
1168- $ENV {CFLAGS } = " $ENV {CFLAGS} -g - O0" if $debug ;
1168+ $ENV {CFLAGS } = " $ENV {CFLAGS} -O0" if $debug ;
11691169 $ENV {CFLAGS } = " $ENV {CFLAGS} -Os" if not $debug ; # optimize for size
11701170
1171- $ENV {CC } = " $ENV {CC} -arch $monoHostArch " ;
1172- $ENV {CXX } = " $ENV {CXX} -arch $monoHostArch " ;
1171+ $ENV {CC } = " $ENV {CC} -arch $targetArch " ;
1172+ $ENV {CXX } = " $ENV {CXX} -arch $targetArch " ;
11731173
11741174 # Add OSX specific autogen args
1175- push @configureparams , " --host=$monoHostArch -apple-darwin12.2.0" ;
1175+
1176+ if ($targetArch eq " x86_64" )
1177+ {
1178+ push @configureparams , " --host=x86_64-apple-darwin12.2.0" ;
1179+ }
1180+ elsif ($targetArch eq " arm64" )
1181+ {
1182+ push @configureparams , " --host=aarch64-apple-darwinmacos12.2.0" ;
1183+ }
1184+ else
1185+ {
1186+ die (" Unsupported macOS architecture: $targetArch " );
1187+ }
11761188
11771189 # Need to define because Apple's SIP gets in the way of us telling mono where to find this
11781190 push @configureparams , " --with-libgdiplus=$addtoresultsdistdir /lib/libgdiplus.dylib" ;
15101522 }
15111523 elsif ($^O eq ' darwin' )
15121524 {
1513- # Note these tmp directories will get merged into a single 'osx' directory later by a parent script
1514- $embedDirArchDestination = " $embedDirRoot /osx-tmp-$monoHostArch " ;
1515- $distDirArchBin = " $distdir /bin-osx-tmp-$monoHostArch " ;
1516- $versionsOutputFile = $arch32 ? " $buildsroot /versions-osx32.txt" : " $buildsroot /versions-osx64.txt" ;
1525+ $embedDirArchDestination = " $embedDirRoot /osx-tmp-$targetArch " ;
1526+ $distDirArchBin = " $distdir /bin-osx-tmp-$targetArch " ;
1527+ $versionsOutputFile = " $buildsroot /versions-macos-$targetArch .txt" ;
15171528 }
15181529 else
15191530 {
15981609 system (" ln" ," -f" , " $monoroot /mono/mini/.libs/libmonosgen-2.0.dylib" ," $embedDirArchDestination /libmonosgen-2.0.dylib" ) eq 0 or die (" failed symlinking libmonosgen-2.0.dylib\n " );
15991610
16001611 print " Hardlinking libMonoPosixHelper.dylib\n " ;
1601- system (" ln" ," -f" , " $monoroot /support/.libs/libMonoPosixHelper.dylib" ," $embedDirArchDestination /libMonoPosixHelper.dylib" ) eq 0 or die (" failed symlinking $libtarget /libMonoPosixHelper.dylib\n " );
1612+ system (" ln" ," -f" , " $monoroot /support/.libs/libMonoPosixHelper.dylib" ," $embedDirArchDestination /libMonoPosixHelper.dylib" ) eq 0 or die (" failed symlinking $embedDirArchDestination /libMonoPosixHelper.dylib\n " );
16021613
16031614 InstallNameTool(" $embedDirArchDestination /libmonobdwgc-2.0.dylib" , " \@ executable_path/../Frameworks/MonoEmbedRuntime/osx/libmonobdwgc-2.0.dylib" );
16041615 InstallNameTool(" $embedDirArchDestination /libmonosgen-2.0.dylib" , " \@ executable_path/../Frameworks/MonoEmbedRuntime/osx/libmonosgen-2.0.dylib" );
16911702
16921703if ($test )
16931704{
1705+ my $runtimeTestsDir = " $monoroot /mono/mini" ;
16941706 if ($runRuntimeTests )
16951707 {
1696- my $runtimeTestsDir = " $monoroot /mono/mini" ;
16971708 chdir (" $runtimeTestsDir " ) eq 1 or die (" failed to chdir" );
16981709 print (" \n >>> Calling make check in $runtimeTestsDir \n\n " );
16991710 system (" make" ," check" ) eq 0 or die (" runtime tests failed\n " );
17271738 print (" >>> Skipping unit tests\n " );
17281739}
17291740
1730- chdir ($currentdir );
1741+ chdir ($currentdir );
0 commit comments