Skip to content

Commit 8b2341a

Browse files
authored
Merge pull request #922 from Unity-Technologies/unity-master-restore-osx-32
Unity master restore osx 32
2 parents 757ac66 + ab25ce8 commit 8b2341a

File tree

2 files changed

+96
-8
lines changed

2 files changed

+96
-8
lines changed

external/buildscripts/build.pl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,9 +1563,10 @@
15631563
}
15641564
elsif($^O eq 'darwin')
15651565
{
1566-
$embedDirArchDestination = "$embedDirRoot/osx";
1567-
$distDirArchBin = "$distdir/bin";
1568-
$versionsOutputFile = "$buildsroot/versions-osx.txt";
1566+
# Note these tmp directories will get merged into a single 'osx' directory later by a parent script
1567+
$embedDirArchDestination = "$embedDirRoot/osx-tmp-$monoHostArch";
1568+
$distDirArchBin = "$distdir/bin-osx-tmp-$monoHostArch";
1569+
$versionsOutputFile = $arch32 ? "$buildsroot/versions-osx32.txt" : "$buildsroot/versions-osx64.txt";
15691570
}
15701571
else
15711572
{

external/buildscripts/build_all_osx.pl

Lines changed: 92 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
'buildusandboo=i'=>\$buildUsAndBoo,
5252
);
5353

54+
my $monoArch32Target = "i386";
55+
56+
print(">>> Building $monoArch32Target\n");
57+
system("perl", "$buildscriptsdir/build.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ("failing building $monoArch32Target");
58+
5459
if ($artifactsCommon)
5560
{
5661
push @passAlongArgs, "--artifactscommon=1";
@@ -66,13 +71,95 @@
6671

6772
if ($artifact)
6873
{
69-
print(">>> Copying libMonoPosixHelper.dylib to lib directory\n");
74+
print(">>> Creating universal binaries\n");
75+
# Merge stuff in the embedruntimes directory
76+
my $embedDirRoot = "$buildsroot/embedruntimes";
77+
my $embedDirDestination = "$embedDirRoot/osx";
78+
my $embedDirSource32 = "$embedDirRoot/osx-tmp-$monoArch32Target";
79+
my $embedDirSource64 = "$embedDirRoot/osx-tmp-x86_64";
80+
81+
system("mkdir -p $embedDirDestination");
82+
83+
if (!(-d $embedDirSource32))
84+
{
85+
die("Expected source directory not found : $embedDirSource32\n");
86+
}
87+
88+
if (!(-d $embedDirSource64))
89+
{
90+
die("Expected source directory not found : $embedDirSource64\n");
91+
}
92+
93+
# Create universal binaries
94+
for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib')
95+
{
96+
print(">>> lipo $embedDirSource32/$file $embedDirSource64/$file -create -output $embedDirDestination/$file\n\n");
97+
system ('lipo', "$embedDirSource32/$file", "$embedDirSource64/$file", '-create', '-output', "$embedDirDestination/$file");
98+
}
99+
100+
if (not $buildMachine)
101+
{
102+
print(">>> Doing non-build machine stuff...\n");
103+
for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib')
104+
{
105+
print(">>> Removing $embedDirDestination/$file.dSYM\n");
106+
rmtree ("$embedDirDestination/$file.dSYM");
107+
print(">>> 'dsymutil $embedDirDestination/$file\n");
108+
system ('dsymutil', "$embedDirDestination/$file") eq 0 or warn ("Failed creating $embedDirDestination/$file.dSYM");
109+
}
110+
111+
print(">>> Done with non-build machine stuff\n");
112+
}
113+
114+
# Merge stuff in the monodistribution directory
115+
my $distDirRoot = "$buildsroot/monodistribution";
116+
my $distDirDestinationBin = "$buildsroot/monodistribution/bin";
117+
my $distDirDestinationLib = "$buildsroot/monodistribution/lib";
118+
my $distDirSourceBin32 = "$distDirRoot/bin-osx-tmp-$monoArch32Target";
119+
my $distDirSourceBin64 = "$distDirRoot/bin-osx-tmp-x86_64";
70120

71-
my $libDir = "$buildsroot/monodistribution/lib";
72-
if (!(-d $libDir))
121+
# Should always exist because build_all would have put stuff in it, but in some situations
122+
# depending on the options it may not. So create it if it does not exist
123+
if (!(-d $distDirDestinationBin))
73124
{
74-
system("mkdir -p $libDir");
125+
system("mkdir -p $distDirDestinationBin");
75126
}
76127

77-
system("cp","$buildsroot/embedruntimes/osx/libMonoPosixHelper.dylib", "$libDir/")
128+
if (!(-d $distDirDestinationLib))
129+
{
130+
system("mkdir -p $distDirDestinationLib");
131+
}
132+
133+
if (!(-d $distDirSourceBin32))
134+
{
135+
die("Expected source directory not found : $distDirSourceBin32\n");
136+
}
137+
138+
if (!(-d $distDirSourceBin64))
139+
{
140+
die("Expected source directory not found : $distDirSourceBin64\n");
141+
}
142+
143+
for my $file ('mono','pedump')
144+
{
145+
print(">>> lipo $distDirSourceBin32/$file $distDirSourceBin64/$file -create -output $distDirDestinationBin/$file\n\n");
146+
system ('lipo', "$distDirSourceBin32/$file", "$distDirSourceBin64/$file", '-create', '-output', "$distDirDestinationBin/$file");
147+
}
148+
149+
#Create universal binaries for stuff is in the embed dir but will end up in the dist dir
150+
for my $file ('libMonoPosixHelper.dylib')
151+
{
152+
print(">>> lipo $embedDirSource32/$file $embedDirSource64/$file -create -output $distDirDestinationLib/$file\n\n");
153+
system ('lipo', "$embedDirSource32/$file", "$embedDirSource64/$file", '-create', '-output', "$distDirDestinationLib/$file");
154+
}
155+
156+
if ($buildMachine)
157+
{
158+
print(">>> Clean up temporary arch specific build directories\n");
159+
160+
rmtree("$distDirSourceBin32");
161+
rmtree("$distDirSourceBin64");
162+
rmtree("$embedDirSource32");
163+
rmtree("$embedDirSource64");
164+
}
78165
}

0 commit comments

Comments
 (0)