Creates the build toolchain for a given platform and architecture. The target platform. True if return null platform if it's missing, otherwise will invoke an exception. The platform.
(TargetPlatform targetPlatform, bool nullIfMissing = false)
| 224 | /// <param name="nullIfMissing">True if return null platform if it's missing, otherwise will invoke an exception.</param> |
| 225 | /// <returns>The platform.</returns> |
| 226 | public static Platform GetPlatform(TargetPlatform targetPlatform, bool nullIfMissing = false) |
| 227 | { |
| 228 | if (_platforms == null) |
| 229 | { |
| 230 | using (new ProfileEventScope("GetPlatforms")) |
| 231 | _platforms = Builder.BuildTypes.Where(x => x.IsClass && !x.IsAbstract && x.IsSubclassOf(typeof(Platform))).Select(Activator.CreateInstance).Cast<Platform>().ToArray(); |
| 232 | } |
| 233 | |
| 234 | foreach (var platform in _platforms) |
| 235 | { |
| 236 | if (platform.Target == targetPlatform) |
| 237 | { |
| 238 | return platform; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | if (nullIfMissing) |
| 243 | return null; |
| 244 | throw new Exception(string.Format("Platform {0} is not supported.", targetPlatform)); |
| 245 | } |
| 246 | |
| 247 | /// <summary> |
| 248 | /// Tries to create the build toolchain for a given architecture. Returns null if platform is not supported. |
no test coverage detected