use of com.facebook.buck.apple.AppleSdkPaths in project buck by facebook.
the class KnownBuildRuleTypes method buildAppleCxxPlatforms.
private static ImmutableList<AppleCxxPlatform> buildAppleCxxPlatforms(ProjectFilesystem filesystem, Supplier<Optional<Path>> appleDeveloperDirectorySupplier, ImmutableList<Path> extraToolchainPaths, ImmutableList<Path> extraPlatformPaths, BuckConfig buckConfig, AppleConfig appleConfig, SwiftBuckConfig swiftBuckConfig, ProcessExecutor processExecutor) throws IOException {
Optional<Path> appleDeveloperDirectory = appleDeveloperDirectorySupplier.get();
if (appleDeveloperDirectory.isPresent() && !Files.isDirectory(appleDeveloperDirectory.get())) {
LOG.error("Developer directory is set to %s, but is not a directory", appleDeveloperDirectory.get());
return ImmutableList.of();
}
ImmutableList.Builder<AppleCxxPlatform> appleCxxPlatformsBuilder = ImmutableList.builder();
ImmutableMap<String, AppleToolchain> toolchains = AppleToolchainDiscovery.discoverAppleToolchains(appleDeveloperDirectory, extraToolchainPaths);
ImmutableMap<AppleSdk, AppleSdkPaths> sdkPaths = AppleSdkDiscovery.discoverAppleSdkPaths(appleDeveloperDirectory, extraPlatformPaths, toolchains, appleConfig);
Optional<String> swiftVersion = swiftBuckConfig.getVersion();
Optional<AppleToolchain> swiftToolChain = Optional.empty();
if (swiftVersion.isPresent()) {
Optional<String> swiftToolChainName = swiftVersion.map(AppleCxxPlatform.SWIFT_VERSION_TO_TOOLCHAIN_IDENTIFIER);
swiftToolChain = toolchains.values().stream().filter(input -> input.getIdentifier().equals(swiftToolChainName.get())).findFirst();
}
for (Map.Entry<AppleSdk, AppleSdkPaths> entry : sdkPaths.entrySet()) {
AppleSdk sdk = entry.getKey();
AppleSdkPaths appleSdkPaths = entry.getValue();
String targetSdkVersion = appleConfig.getTargetSdkVersion(sdk.getApplePlatform()).orElse(sdk.getVersion());
LOG.debug("SDK %s using default version %s", sdk, targetSdkVersion);
for (String architecture : sdk.getArchitectures()) {
AppleCxxPlatform appleCxxPlatform = AppleCxxPlatforms.build(filesystem, sdk, targetSdkVersion, architecture, appleSdkPaths, buckConfig, appleConfig, Optional.of(processExecutor), swiftToolChain);
appleCxxPlatformsBuilder.add(appleCxxPlatform);
}
}
return appleCxxPlatformsBuilder.build();
}
Aggregations