forked from xamarin/XamarinComponents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.cake
147 lines (122 loc) · 5.51 KB
/
common.cake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#tool nuget:?package=XamarinComponent&version=1.1.0.42
#addin nuget:?package=Cake.XCode&version=2.0.13
#addin nuget:?package=Cake.Xamarin.Build&version=2.0.18
#addin nuget:?package=Cake.Xamarin&version=1.3.0.15
#addin nuget:?package=Cake.FileHelpers&version=1.0.4
void BuildXCodeFatLibrary(FilePath xcodeProject, string target, string libraryTitle = null, FilePath fatLibrary = null, DirectoryPath workingDirectory = null, string targetFolderName = null)
{
BuildXCodeFatLibrary_iOS(xcodeProject, target, libraryTitle, fatLibrary, workingDirectory, targetFolderName);
}
void BuildXCodeFatLibrary_iOS(FilePath xcodeProject, string target, string libraryTitle = null, FilePath fatLibrary = null, DirectoryPath workingDirectory = null, string targetFolderName = null)
{
if (!IsRunningOnUnix())
{
Warning("{0} is not available on the current platform.", "xcodebuild");
return;
}
libraryTitle = libraryTitle ?? target;
fatLibrary = fatLibrary ?? string.Format("lib{0}.a", libraryTitle);
workingDirectory = workingDirectory ?? Directory("./externals/");
var output = string.Format("lib{0}.a", libraryTitle);
var i386 = string.Format("lib{0}-i386.a", libraryTitle);
var x86_64 = string.Format("lib{0}-x86_64.a", libraryTitle);
var armv7 = string.Format("lib{0}-armv7.a", libraryTitle);
var armv7s = string.Format("lib{0}-armv7s.a", libraryTitle);
var arm64 = string.Format("lib{0}-arm64.a", libraryTitle);
var buildArch = new Action<string, string, FilePath>((sdk, arch, dest) => {
if (!FileExists(dest))
{
XCodeBuild(new XCodeBuildSettings
{
Project = workingDirectory.CombineWithFilePath(xcodeProject).ToString(),
Target = target,
Sdk = sdk,
Arch = arch,
Configuration = "Release",
});
var tmpOutputPath = workingDirectory.Combine("build").Combine("Release-" + sdk);
if (!string.IsNullOrEmpty (targetFolderName))
tmpOutputPath = tmpOutputPath.Combine (targetFolderName);
var outputPath = tmpOutputPath.CombineWithFilePath(output);
CopyFile(outputPath, dest);
}
});
buildArch("iphonesimulator", "i386", workingDirectory.CombineWithFilePath(i386));
buildArch("iphonesimulator", "x86_64", workingDirectory.CombineWithFilePath(x86_64));
buildArch("iphoneos", "armv7", workingDirectory.CombineWithFilePath(armv7));
buildArch("iphoneos", "armv7s", workingDirectory.CombineWithFilePath(armv7s));
buildArch("iphoneos", "arm64", workingDirectory.CombineWithFilePath(arm64));
RunLipoCreate(workingDirectory, fatLibrary, i386, x86_64, armv7, armv7s, arm64);
}
void BuildXCodeFatLibrary_tvOS(FilePath xcodeProject, string target, string libraryTitle = null, FilePath fatLibrary = null, DirectoryPath workingDirectory = null, string targetFolderName = null)
{
if (!IsRunningOnUnix())
{
Warning("{0} is not available on the current platform.", "xcodebuild");
return;
}
libraryTitle = libraryTitle ?? target;
fatLibrary = fatLibrary ?? string.Format("lib{0}.a", libraryTitle);
workingDirectory = workingDirectory ?? Directory("./externals/");
var output = string.Format("lib{0}.a", libraryTitle);
var x86_64 = string.Format("lib{0}-x86_64.a", libraryTitle);
var arm64 = string.Format("lib{0}-arm64.a", libraryTitle);
var buildArch = new Action<string, string, FilePath>((sdk, arch, dest) => {
if (!FileExists(dest))
{
XCodeBuild(new XCodeBuildSettings
{
Project = workingDirectory.CombineWithFilePath(xcodeProject).ToString(),
Target = target,
Sdk = sdk,
Arch = arch,
Configuration = "Release",
});
var tmpOutputPath = workingDirectory.Combine("build").Combine("Release-" + sdk);
if (!string.IsNullOrEmpty (targetFolderName))
tmpOutputPath = tmpOutputPath.Combine (targetFolderName);
var outputPath = tmpOutputPath.CombineWithFilePath(output);
CopyFile(outputPath, dest);
}
});
buildArch("appletvsimulator", "x86_64", workingDirectory.CombineWithFilePath(x86_64));
buildArch("appletvos", "arm64", workingDirectory.CombineWithFilePath(arm64));
RunLipoCreate(workingDirectory, fatLibrary, x86_64, arm64);
}
void BuildXCodeFatLibrary_macOS(FilePath xcodeProject, string target, string libraryTitle = null, FilePath fatLibrary = null, DirectoryPath workingDirectory = null, string targetFolderName = null)
{
if (!IsRunningOnUnix())
{
Warning("{0} is not available on the current platform.", "xcodebuild");
return;
}
// NOTE: 'i386' is no longer supported
libraryTitle = libraryTitle ?? target;
fatLibrary = fatLibrary ?? string.Format("lib{0}.a", libraryTitle);
workingDirectory = workingDirectory ?? Directory("./externals/");
var output = string.Format("lib{0}.a", libraryTitle);
// var i386 = string.Format("lib{0}-i386.a", libraryTitle);
var x86_64 = string.Format("lib{0}-x86_64.a", libraryTitle);
var buildArch = new Action<string, string, FilePath>((sdk, arch, dest) => {
if (!FileExists(dest))
{
XCodeBuild(new XCodeBuildSettings
{
Project = workingDirectory.CombineWithFilePath(xcodeProject).ToString(),
Target = target,
Sdk = sdk,
Arch = arch,
Configuration = "Release",
});
var tmpOutputPath = workingDirectory.Combine("build").Combine("Release");
if (!string.IsNullOrEmpty (targetFolderName))
tmpOutputPath = tmpOutputPath.Combine (targetFolderName);
var outputPath = tmpOutputPath.CombineWithFilePath(output);
CopyFile(outputPath, dest);
}
});
buildArch("macosx", "x86_64", workingDirectory.CombineWithFilePath(x86_64));
// buildArch("macosx", "i386", workingDirectory.CombineWithFilePath(i386));
RunLipoCreate(workingDirectory, fatLibrary, x86_64);
// RunLipoCreate(workingDirectory, fatLibrary, x86_64, i386);
}