Java tutorial
/* * Copyright 2017-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ package com.facebook.buck.cxx; import com.facebook.buck.core.model.Flavor; import com.facebook.buck.core.model.FlavorDomain; import com.facebook.buck.core.model.Flavored; import com.facebook.buck.core.toolchain.ToolchainProvider; import com.facebook.buck.cxx.toolchain.CxxBuckConfig; import com.facebook.buck.cxx.toolchain.CxxPlatformsProvider; import com.facebook.buck.cxx.toolchain.LinkerMapMode; import com.facebook.buck.cxx.toolchain.StripStyle; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import java.util.Optional; public class CxxLibraryFlavored implements Flavored { private final ToolchainProvider toolchainProvider; private final CxxBuckConfig cxxBuckConfig; public CxxLibraryFlavored(ToolchainProvider toolchainProvider, CxxBuckConfig cxxBuckConfig) { this.toolchainProvider = toolchainProvider; this.cxxBuckConfig = cxxBuckConfig; } @Override public Optional<ImmutableSet<FlavorDomain<?>>> flavorDomains() { return Optional.of(ImmutableSet.of( // Missing: CXX Compilation Database // Missing: CXX Description Enhancer // Missing: CXX Infer Enhancer getCxxPlatformsProvider().getUnresolvedCxxPlatforms(), LinkerMapMode.FLAVOR_DOMAIN, StripStyle.FLAVOR_DOMAIN)); } @Override public boolean hasFlavors(ImmutableSet<Flavor> flavors) { return getCxxPlatformsProvider().getUnresolvedCxxPlatforms().containsAnyOf(flavors) || flavors.contains(CxxCompilationDatabase.COMPILATION_DATABASE) || flavors.contains(CxxCompilationDatabase.UBER_COMPILATION_DATABASE) || CxxInferEnhancer.INFER_FLAVOR_DOMAIN.containsAnyOf(flavors) || flavors.contains(CxxInferEnhancer.InferFlavors.INFER_ANALYZE.getFlavor()) || flavors.contains(CxxInferEnhancer.InferFlavors.INFER_CAPTURE_ALL.getFlavor()) || flavors.contains(CxxDescriptionEnhancer.EXPORTED_HEADER_SYMLINK_TREE_FLAVOR) || LinkerMapMode.FLAVOR_DOMAIN.containsAnyOf(flavors) || !Sets.intersection(cxxBuckConfig.getDeclaredPlatforms(), flavors).isEmpty(); } private CxxPlatformsProvider getCxxPlatformsProvider() { return toolchainProvider.getByName(CxxPlatformsProvider.DEFAULT_NAME, CxxPlatformsProvider.class); } }