6262}
6363
6464print (" >>> Building x86_64\n " );
65- system (" perl" , " $buildscriptsdir /build.pl" , " --clean=1" , " --classlibtests=0" , @passAlongArgs ) eq 0 or die (' failing building x86_64' );
65+ system (" perl" , " $buildscriptsdir /build.pl" , " --clean=1" , " --classlibtests=0" , " --targetarch=x86_64" , @passAlongArgs ) eq 0 or die (' failing building x86_64' );
66+
67+ print (" >>> Building ARM64\n " );
68+ system (" perl" , " $buildscriptsdir /build.pl" , " --clean=1" , " --classlibtests=0" , " --targetarch=arm64" , @passAlongArgs ) eq 0 or die (" failing building ARM64" );
6669
6770if ($artifact )
6871{
6972 print (" >>> Moving built binaries to final output directories\n " );
70- # Merge stuff in the embedruntimes directory
71- my $embedDirRoot = " $buildsroot /embedruntimes" ;
72- my $embedDirDestination = " $embedDirRoot /osx" ;
73- my $embedDirSource64 = " $embedDirRoot /osx-tmp-x86_64" ;
74-
75- system (" mkdir -p $embedDirDestination " );
76-
77- if (!(-d $embedDirSource64 ))
78- {
79- die (" Expected source directory not found : $embedDirSource64 \n " );
80- }
8173
82- for my $file (' libmonobdwgc-2.0.dylib' ,' libmonosgen-2.0.dylib' ,' libMonoPosixHelper.dylib' )
83- {
84- print (" >>> cp $embedDirSource64 /$file $embedDirDestination /$file \n\n " );
85- system (' cp' , " $embedDirSource64 /$file " , " $embedDirDestination /$file " );
86- }
87-
88- if (not $buildMachine )
89- {
90- print (" >>> Doing non-build machine stuff...\n " );
91- for my $file (' libmonobdwgc-2.0.dylib' ,' libmonosgen-2.0.dylib' ,' libMonoPosixHelper.dylib' )
92- {
93- print (" >>> Removing $embedDirDestination /$file .dSYM\n " );
94- rmtree (" $embedDirDestination /$file .dSYM" );
95- print (" >>> 'dsymutil $embedDirDestination /$file \n " );
96- system (' dsymutil' , " $embedDirDestination /$file " ) eq 0 or warn (" Failed creating $embedDirDestination /$file .dSYM" );
97- }
74+ # Copy stuff in the embedruntimes directory
75+ my $embedDirRoot = " $buildsroot /embedruntimes" ;
76+ my $embedDirSourceX64 = " $embedDirRoot /osx-tmp-x86_64" ;
77+ my $embedDirSourceARM64 = " $embedDirRoot /osx-tmp-arm64" ;
9878
99- print ( " >>> Done with non-build machine stuff \n " );
100- }
79+ CopyEmbedRuntimeBinaries( $embedDirSourceX64 , " $embedDirRoot /osx " );
80+ CopyEmbedRuntimeBinaries( $embedDirSourceARM64 , " $embedDirRoot /osx-arm64 " );
10181
10282 # Merge stuff in the monodistribution directory
10383 my $distDirRoot = " $buildsroot /monodistribution" ;
10484 my $distDirDestinationBin = " $buildsroot /monodistribution/bin" ;
10585 my $distDirDestinationLib = " $buildsroot /monodistribution/lib" ;
106- my $distDirSourceBin64 = " $distDirRoot /bin-osx-tmp-x86_64" ;
86+ my $distDirSourceBinX64 = " $distDirRoot /bin-osx-tmp-x86_64" ;
87+ my $distDirSourceBinARM64 = " $distDirRoot /bin-osx-tmp-arm64" ;
10788
10889 # Should always exist because build_all would have put stuff in it, but in some situations
10990 # depending on the options it may not. So create it if it does not exist
11798 system (" mkdir -p $distDirDestinationLib " );
11899 }
119100
120- if (!(-d $distDirSourceBin64 ))
101+ if (!(-d $distDirSourceBinX64 ))
102+ {
103+ die (" Expected source directory not found : $distDirSourceBinX64 \n " );
104+ }
105+
106+ if (!(-d $distDirSourceBinARM64 ))
107+ {
108+ die (" Expected source directory not found : $distDirSourceBinARM64 \n " );
109+ }
110+
111+ for my $file (' mono' )
121112 {
122- die ( " Expected source directory not found : $distDirSourceBin64 \n " );
113+ MergeIntoFatBinary( " $distDirSourceBinX64 / $file " , " $distDirSourceBinARM64 / $file " , " $distDirDestinationBin / $file " );
123114 }
124115
125- for my $file (' mono ' , ' pedump' )
116+ for my $file (' pedump' )
126117 {
127- system (' mv' , " $distDirSourceBin64 /$file " , " $distDirDestinationBin /$file " );
118+ # pedump doens't get cross-compiled
119+ system (' mv' , " $distDirSourceBinX64 /$file " , " $distDirDestinationBin /$file " ) eq 0 or die (" Failed to move '$distDirSourceBinX64 /$file ' to '$distDirDestinationBin /$file '." );
128120 }
129121
130122 for my $file (' libMonoPosixHelper.dylib' )
131123 {
132- print (" >>> cp $embedDirSource64 /$file $distDirDestinationLib /$file \n\n " );
133- system (' cp' , " $embedDirSource64 /$file " , " $distDirDestinationLib /$file " );
124+ MergeIntoFatBinary(" $embedDirSourceX64 /$file " , " $embedDirSourceARM64 /$file " , " $distDirDestinationLib /$file " );
134125 }
135126
136127 if ($buildMachine )
137128 {
138129 print (" >>> Clean up temporary arch specific build directories\n " );
139130
140- rmtree(" $distDirSourceBin64 " );
141- rmtree(" $embedDirSource64 " );
131+ rmtree(" $distDirSourceBinX64 " );
132+ rmtree(" $distDirSourceBinARM64 " );
133+ rmtree(" $embedDirSourceX64 " );
134+ rmtree(" $embedDirSourceARM64 " );
142135 }
143136}
137+
138+ sub CopyEmbedRuntimeBinaries
139+ {
140+ my ($embedDirSource , $embedDirDestination ) = @_ ;
141+
142+ system (" mkdir -p $embedDirDestination " );
143+
144+ if (!(-d $embedDirSource ))
145+ {
146+ die (" Expected source directory not found : $embedDirSource \n " );
147+ }
148+
149+ for my $file (' libmonobdwgc-2.0.dylib' ,' libmonosgen-2.0.dylib' ,' libMonoPosixHelper.dylib' )
150+ {
151+ print (" >>> cp $embedDirSource /$file $embedDirDestination /$file \n\n " );
152+ system (' cp' , " $embedDirSource /$file " , " $embedDirDestination /$file " ) eq 0 or die (" Failed to copy '$embedDirSource /$file ' to '$embedDirDestination /$file '." );
153+ }
154+
155+ if (not $buildMachine )
156+ {
157+ print (" >>> Doing non-build machine stuff...\n " );
158+ for my $file (' libmonobdwgc-2.0.dylib' ,' libmonosgen-2.0.dylib' ,' libMonoPosixHelper.dylib' )
159+ {
160+ print (" >>> Removing $embedDirDestination /$file .dSYM\n " );
161+ rmtree(" $embedDirDestination /$file .dSYM" );
162+ print (" >>> 'dsymutil $embedDirDestination /$file \n " );
163+ system (' dsymutil' , " $embedDirDestination /$file " ) eq 0 or warn (" Failed creating $embedDirDestination /$file .dSYM" );
164+ }
165+
166+ print (" >>> Done with non-build machine stuff\n " );
167+ }
168+ }
169+
170+ sub MergeIntoFatBinary
171+ {
172+ my ($binary1 , $binary2 , $binaryOutput ) = @_ ;
173+
174+ print (" >>> Merging '$binary1 ' and '$binary2 ' into '$binaryOutput '\n\n " );
175+ system (' lipo' , " $binary1 " , " $binary2 " , " -create" , " -output" , " $binaryOutput " ) eq 0 or die (" Failed to run lipo!" );
176+ }
0 commit comments