Skip to content

Commit 8a0e781

Browse files
authored
Merge pull request #988 from Unity-Technologies/remove-32-bit-slice-embed-runtimes
Remove the 32-bit slice from the Mono runtime
2 parents 0347724 + 3767f74 commit 8a0e781

File tree

1 file changed

+163
-165
lines changed

1 file changed

+163
-165
lines changed
Lines changed: 163 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1,163 @@
1-
use Cwd;
2-
use Cwd 'abs_path';
3-
use Getopt::Long;
4-
use File::Basename;
5-
use File::Path;
6-
7-
my $currentdir = getcwd();
8-
9-
my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../..");
10-
my $monoroot = abs_path($monoroot);
11-
my $buildscriptsdir = "$monoroot/external/buildscripts";
12-
my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE};
13-
my $buildsroot = "$monoroot/builds";
14-
15-
my $artifact=0;
16-
my $artifactsCommon=0;
17-
my $buildUsAndBoo=0;
18-
19-
my @thisScriptArgs = ();
20-
my @passAlongArgs = ();
21-
foreach my $arg (@ARGV)
22-
{
23-
# Filter out --clean if someone uses it. We have to clean since we are doing two builds
24-
if (not $arg =~ /^--clean=/)
25-
{
26-
# We don't need common artifacts, us, and boo, from both, so filter out temporarily and we'll
27-
# only pass it to the second build
28-
if ($arg =~ /^--artifactscommon=/ || $arg =~ /^--buildusandboo=/)
29-
{
30-
push @thisScriptArgs, $arg;
31-
}
32-
else
33-
{
34-
push @passAlongArgs, $arg;
35-
}
36-
}
37-
38-
if ($arg =~ /^--artifact=/)
39-
{
40-
push @thisScriptArgs, $arg;
41-
}
42-
}
43-
44-
print(">>> This Script Args = @thisScriptArgs\n");
45-
print(">>> Pass Along Args = @passAlongArgs\n");
46-
47-
@ARGV = @thisScriptArgs;
48-
GetOptions(
49-
'artifact=i'=>\$artifact,
50-
'artifactscommon=i'=>\$artifactsCommon,
51-
'buildusandboo=i'=>\$buildUsAndBoo,
52-
);
53-
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-
59-
if ($artifactsCommon)
60-
{
61-
push @passAlongArgs, "--artifactscommon=1";
62-
}
63-
64-
if ($buildUsAndBoo)
65-
{
66-
push @passAlongArgs, "--buildusandboo=1";
67-
}
68-
69-
print(">>> Building x86_64\n");
70-
system("perl", "$buildscriptsdir/build.pl", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building x86_64');
71-
72-
if ($artifact)
73-
{
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";
120-
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))
124-
{
125-
system("mkdir -p $distDirDestinationBin");
126-
}
127-
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-
}
165-
}
1+
use Cwd;
2+
use Cwd 'abs_path';
3+
use Getopt::Long;
4+
use File::Basename;
5+
use File::Path;
6+
7+
my $currentdir = getcwd();
8+
9+
my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../..");
10+
my $monoroot = abs_path($monoroot);
11+
my $buildscriptsdir = "$monoroot/external/buildscripts";
12+
my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE};
13+
my $buildsroot = "$monoroot/builds";
14+
15+
my $artifact=0;
16+
my $artifactsCommon=0;
17+
my $buildUsAndBoo=0;
18+
19+
my @thisScriptArgs = ();
20+
my @passAlongArgs = ();
21+
foreach my $arg (@ARGV)
22+
{
23+
# Filter out --clean if someone uses it. We have to clean since we are doing two builds
24+
if (not $arg =~ /^--clean=/)
25+
{
26+
# We don't need common artifacts, us, and boo, from both, so filter out temporarily and we'll
27+
# only pass it to the second build
28+
if ($arg =~ /^--artifactscommon=/ || $arg =~ /^--buildusandboo=/)
29+
{
30+
push @thisScriptArgs, $arg;
31+
}
32+
else
33+
{
34+
push @passAlongArgs, $arg;
35+
}
36+
}
37+
38+
if ($arg =~ /^--artifact=/)
39+
{
40+
push @thisScriptArgs, $arg;
41+
}
42+
}
43+
44+
print(">>> This Script Args = @thisScriptArgs\n");
45+
print(">>> Pass Along Args = @passAlongArgs\n");
46+
47+
@ARGV = @thisScriptArgs;
48+
GetOptions(
49+
'artifact=i'=>\$artifact,
50+
'artifactscommon=i'=>\$artifactsCommon,
51+
'buildusandboo=i'=>\$buildUsAndBoo,
52+
);
53+
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+
59+
if ($artifactsCommon)
60+
{
61+
push @passAlongArgs, "--artifactscommon=1";
62+
}
63+
64+
if ($buildUsAndBoo)
65+
{
66+
push @passAlongArgs, "--buildusandboo=1";
67+
}
68+
69+
print(">>> Building x86_64\n");
70+
system("perl", "$buildscriptsdir/build.pl", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building x86_64');
71+
72+
if ($artifact)
73+
{
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+
for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib')
94+
{
95+
print(">>> cp $embedDirSource64/$file $embedDirDestination/$file\n\n");
96+
system ('cp', "$embedDirSource64/$file", "$embedDirDestination/$file");
97+
}
98+
99+
if (not $buildMachine)
100+
{
101+
print(">>> Doing non-build machine stuff...\n");
102+
for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib')
103+
{
104+
print(">>> Removing $embedDirDestination/$file.dSYM\n");
105+
rmtree ("$embedDirDestination/$file.dSYM");
106+
print(">>> 'dsymutil $embedDirDestination/$file\n");
107+
system ('dsymutil', "$embedDirDestination/$file") eq 0 or warn ("Failed creating $embedDirDestination/$file.dSYM");
108+
}
109+
110+
print(">>> Done with non-build machine stuff\n");
111+
}
112+
113+
# Merge stuff in the monodistribution directory
114+
my $distDirRoot = "$buildsroot/monodistribution";
115+
my $distDirDestinationBin = "$buildsroot/monodistribution/bin";
116+
my $distDirDestinationLib = "$buildsroot/monodistribution/lib";
117+
my $distDirSourceBin32 = "$distDirRoot/bin-osx-tmp-$monoArch32Target";
118+
my $distDirSourceBin64 = "$distDirRoot/bin-osx-tmp-x86_64";
119+
120+
# Should always exist because build_all would have put stuff in it, but in some situations
121+
# depending on the options it may not. So create it if it does not exist
122+
if (!(-d $distDirDestinationBin))
123+
{
124+
system("mkdir -p $distDirDestinationBin");
125+
}
126+
127+
if (!(-d $distDirDestinationLib))
128+
{
129+
system("mkdir -p $distDirDestinationLib");
130+
}
131+
132+
if (!(-d $distDirSourceBin32))
133+
{
134+
die("Expected source directory not found : $distDirSourceBin32\n");
135+
}
136+
137+
if (!(-d $distDirSourceBin64))
138+
{
139+
die("Expected source directory not found : $distDirSourceBin64\n");
140+
}
141+
142+
for my $file ('mono','pedump')
143+
{
144+
print(">>> lipo $distDirSourceBin32/$file $distDirSourceBin64/$file -create -output $distDirDestinationBin/$file\n\n");
145+
system ('lipo', "$distDirSourceBin32/$file", "$distDirSourceBin64/$file", '-create', '-output', "$distDirDestinationBin/$file");
146+
}
147+
148+
for my $file ('libMonoPosixHelper.dylib')
149+
{
150+
print(">>> cp $embedDirSource64/$file $distDirDestinationLib/$file\n\n");
151+
system ('cp', "$embedDirSource64/$file", "$distDirDestinationLib/$file");
152+
}
153+
154+
if ($buildMachine)
155+
{
156+
print(">>> Clean up temporary arch specific build directories\n");
157+
158+
rmtree("$distDirSourceBin32");
159+
rmtree("$distDirSourceBin64");
160+
rmtree("$embedDirSource32");
161+
rmtree("$embedDirSource64");
162+
}
163+
}

0 commit comments

Comments
 (0)