forked from xamarin/GoogleApisForiOSComponents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoco.cake
143 lines (119 loc) · 4.45 KB
/
poco.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
enum ComponentGroup
{
Firebase,
Google
}
enum FrameworkSource
{
Targets,
Pods,
Custom
}
struct Platform
{
#region Properties
public string Arch { get; private set; }
public string Sdk { get; private set; }
public static Platform iOSSimulator { get; } = new Platform ("i386", "iphonesimulator");
public static Platform iOSSimulator64 { get; } = new Platform ("x86_64", "iphonesimulator");
public static Platform iOSArmV7 { get; } = new Platform ("armv7", "iphoneos");
public static Platform iOSArmV7s { get; } = new Platform ("armv7s", "iphoneos");
public static Platform iOSArm64 { get; } = new Platform ("arm64", "iphoneos");
#endregion
#region Constructors
Platform (string arch, string sdk) {
Arch = arch;
Sdk = sdk;
}
#endregion
#region Public Functionality
public static Platform Create (string arch, string sdk) => new Platform (arch, sdk);
public override string ToString () => $"{Arch} => {Sdk}";
#endregion
#region Operations
public static bool operator == (Platform first, Platform second) =>
string.Equals (first.ToString (), second.ToString ());
public static bool operator != (Platform first, Platform second) =>
!string.Equals (first.ToString (), second.ToString ());
public override bool Equals (object obj) =>
obj is Platform platform && this == platform;
public override int GetHashCode () =>
base.GetHashCode ();
#endregion
}
class PodSpec
{
// The podspec name
public string Name { get; set; }
// The podspec version if any, the component version otherwise.
public string Version { get; set; }
// Target used to build the Xcode Pods project.
// If null, Name property value will be used.
public string TargetName { get; set; }
// Overrides the default framework's name built with Pods project and Xcode.
// If null, Name property value will be used.
public string FrameworkName { get; set; }
// The desired subspec to be used.
// If null, default subspecs defined within the podspec will be used.
public string [] SubSpecs { get; set; }
// If true and when Subspecs property is not null, default subspecs
// defined within the podspec will added to the Podfile. Otherwise,
// only subSpecs specified in Subspecs will be used. False by default.
public bool UseDefaultSubspecs { get; set; }
// Specify the source where the framework will be gotten.
// From a .targets file by default.
public FrameworkSource FrameworkSource { get; set; }
// If true, the podspec can be built using Xcode. True by default.
public bool CanBeBuild { get; set; }
public PodSpec (string name, string version, string targetName = null, string frameworkName = null, FrameworkSource frameworkSource = FrameworkSource.Targets, string [] subSpecs = null, bool useDefaultSubspecs = false, bool canBeBuild = true)
{
Name = name;
Version = version;
TargetName = targetName ?? name;
FrameworkName = frameworkName ?? name;
FrameworkSource = frameworkSource;
SubSpecs = subSpecs;
UseDefaultSubspecs = useDefaultSubspecs;
CanBeBuild = canBeBuild;
}
}
class Artifact : IEquatable<Artifact>
{
// The id of the component.
public string Id { get; set; }
// The version to be published on NuGet.
public string NugetVersion { get; set; }
// The minimun iOS supported version of the component.
public string MinimunSupportedVersion { get; set; }
// If it's a Firebase or Google component.
public ComponentGroup ComponentGroup { get; set; }
// The C# project name. This will have the Id property value if not specified.
public string CsprojName { get; set; }
// Other Google/Firebase components that make this component work.
public Artifact [] Dependencies { get; set; }
// The component build order.
public int BuildOrder { get => Dependencies?.Length + 1 ?? 1; }
// The specs used in the Podfile.
public PodSpec [] PodSpecs { get; set; }
public Artifact (string id, string nugetVersion, string minimunSupportedVersion, ComponentGroup componentType, string csprojName = null, Artifact [] dependencies = null, PodSpec [] podSpecs = null)
{
Id = id;
NugetVersion = nugetVersion;
MinimunSupportedVersion = minimunSupportedVersion;
ComponentGroup = componentType;
CsprojName = csprojName ?? id;
Dependencies = dependencies;
PodSpecs = podSpecs;
}
public bool Equals (Artifact other)
{
if (Object.ReferenceEquals(other, null)) return false;
if (Object.ReferenceEquals(this, other)) return true;
return Id == other.Id;
}
public override int GetHashCode()
{
int hashCode = Id.GetHashCode();
return hashCode ^ hashCode;
}
}