Search in sources :

Example 1 with AppleSdk

use of com.facebook.buck.apple.AppleSdk 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();
}
Also used : Path(java.nio.file.Path) AppleToolchain(com.facebook.buck.apple.AppleToolchain) ImmutableList(com.google.common.collect.ImmutableList) AppleSdk(com.facebook.buck.apple.AppleSdk) AppleSdkPaths(com.facebook.buck.apple.AppleSdkPaths) AppleCxxPlatform(com.facebook.buck.apple.AppleCxxPlatform) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap)

Aggregations

AppleCxxPlatform (com.facebook.buck.apple.AppleCxxPlatform)1 AppleSdk (com.facebook.buck.apple.AppleSdk)1 AppleSdkPaths (com.facebook.buck.apple.AppleSdkPaths)1 AppleToolchain (com.facebook.buck.apple.AppleToolchain)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1