diff --git a/docs/concept/buckconfig.soy b/docs/concept/buckconfig.soy
index f29db9007af..dd46eacffa2 100644
--- a/docs/concept/buckconfig.soy
+++ b/docs/concept/buckconfig.soy
@@ -24,7 +24,7 @@ The root of your project must contain a configuration file
named .buckconfig
. If present, Buck will read this file
before executing its business logic so that any customizations specified
in .buckconfig
will take effect. This file uses the
-{sp}INI file format with
+{sp}INI file format with
a few extensions discussed below.
ANDROID_SDK=/Library/Android/sdk
.
+ be built against. This is equivalent to setting the environment variable ANDROID_SDK=/Library/Android/sdk
.
The environment variables ANDROID_SDK
and ANDROID_HOME
both supersede the buckconfig setting.
The default is empty.
{/param}
@@ -618,7 +618,7 @@ osx_toolchains_override = tools.stable,tools.swift40,tools.common
{param raw_example}
{literal}[apple] - # Use (my_clang|my_actool) executable which exists in one of the + # Use (my_clang|my_actool) executable which exists in one of the # imported SDKs and toolchains, instead of the defaults. clang_xcode_tool_name_override=my_clang actool_xcode_tool_name_override=my_actool @@ -837,7 +837,7 @@ osx_toolchains_override = tools.stable,tools.swift40,tools.common {param name: 'name' /} {param example_value: 'BUILD' /} {param description} - The name of {call buck.build_file /}s within a project. + The name of {call buck.build_file /}s within a project. This defaults toBUCK
. We recommend that you use the default name. However, you could specify a different name—such asBUILD
shown @@ -2629,7 +2629,7 @@ cxx_library( {param description} The maximum number of threads allowed to run the dexing steps with. Since the dexing steps can use a lot of memory, it might be useful to set this to a lower value to avoid out-of-memory - on systems that have a lot of CPU cores. This parameter is mostly useful + on systems that have a lot of CPU cores. This parameter is mostly useful when {call buckconfig.dx_threads /} is not specified and the number of threads is obtained based on hardware. {/param} @@ -2890,24 +2890,28 @@ your.buckjavaargs
file: {call buckconfig.entry} {param section: 'ndk' /} {param name: 'app_platform' /} + {param example_value: 'android-21' /} {param description} -The android platform libraries that the code is targeting. This is equivalent to the{sp}
APP_TARGET
in the NDK build system. The default isandroid-16
. + {/param} +{/call} + +{call buckconfig.entry} + {param section: 'ndk' /} + {param name: 'app_platform_per_cpu_abi' /} + {param example_value: 'arm64 => android-19, i386 => android-22' /} + {param description} ++ The android platform libraries that the code is targeting, set on a{sp} + per-CPU ABI basis. This is equivalent to the
APP_TARGET
in{sp} + the NDK build system.- This setting can also be set on a per-CPU ABI basis. Each key should begin with the{sp} - prefix
{/param} - {param raw_example} -{literal}app_platform-
, followed by the CPU ABI name. ABI-specific values{sp} - have higher precedence. + If no value is set for a particular CPU ABI, the value from{sp} +app_platform
is used as a fallback.-[ndk] - app_platform = android-19 - app_platform-arm64 = android-21 -{/literal} - {/param} {/call} {call buckconfig.entry} @@ -3918,19 +3922,19 @@ your.buckjavaargs
file:Specifies a comma-separated list of mappings from regular expressions - (regexes) to message strings. + (regexes) to message strings.
If the text of a Buck parser error matches one of the specified regexes, the corresponding message string is appended to the error. You can use the message string to provide - additional helpful information to the user. + additional helpful information to the user.
If the regex contains unescaped parentheses,
{/param} @@ -3979,7 +3983,7 @@ your()
, the text - that the parentheses enclose is captured. You can then insert this captured text - in the appended string by using$1
for the first captured text - string,$2
for the second, and so on. This works exactly like + that the parentheses enclose is captured. You can then insert this captured text + in the appended string by using$1
for the first captured text + string,$2
for the second, and so on. This works exactly like Java regex replacement strings..buckjavaargs
file: {param description} Whether the super console is enabled. If so, a more reactive UI will be shown. Valid values are ENABLED, DISABLED, and AUTO. By default, this is set to AUTO - which will take OS, terminal settings and other things into account. In most + which will take OS, terminal settings and other things into account. In most interactive cases, it will be enabled. {/param} {/call} diff --git a/src/com/facebook/buck/android/AndroidBuckConfig.java b/src/com/facebook/buck/android/AndroidBuckConfig.java index 6ee4dda3c43..00ade355049 100644 --- a/src/com/facebook/buck/android/AndroidBuckConfig.java +++ b/src/com/facebook/buck/android/AndroidBuckConfig.java @@ -25,13 +25,10 @@ import com.google.common.collect.ImmutableSet; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Map; import java.util.Optional; import java.util.Set; public class AndroidBuckConfig { - private static final String APP_PLATFORM_KEY_PREFIX = "app_platform-"; - private final BuckConfig delegate; private final Platform platform; @@ -68,10 +65,14 @@ public OptionalgetNdkRepositoryPath() { return delegate.getValue("ndk", "ndk_repository_path"); } - public Optional getNdkCpuAbiAgnosticAppPlatform() { + public Optional getNdkCpuAbiFallbackAppPlatform() { return delegate.getValue("ndk", "app_platform"); } + public ImmutableMap getNdkCpuAbiAppPlatformMap() { + return delegate.getMap("ndk", "app_platform_per_cpu_abi"); + } + public Optional > getNdkCpuAbis() { return delegate.getOptionalListWithoutComments("ndk", "cpu_abis").map(ImmutableSet::copyOf); } @@ -109,27 +110,16 @@ public boolean isGrayscaleImageProcessingEnabled() { } /** - * Returns the CPU specific app platform, or the agnostic one if set. If neither are set, returns + * Returns the CPU specific app platform, or the fallback one if set. If neither are set, returns * `Optional.empty` instead of a default value so callers can determine the difference between * user-set and buck defaults. */ public Optional getNdkAppPlatformForCpuAbi(String cpuAbi) { - ImmutableMap platformMap = getNdkAppPlatformMap(); + ImmutableMap platformMap = getNdkCpuAbiAppPlatformMap(); Optional specificAppPlatform = Optional.ofNullable(platformMap.get(cpuAbi)); return specificAppPlatform.isPresent() ? specificAppPlatform - : getNdkCpuAbiAgnosticAppPlatform(); - } - - private ImmutableMap getNdkAppPlatformMap() { - ImmutableMap allEntries = delegate.getEntriesForSection("ndk"); - ImmutableMap.Builder platforms = ImmutableMap.builder(); - for (Map.Entry entry : allEntries.entrySet()) { - if (entry.getKey().startsWith(APP_PLATFORM_KEY_PREFIX)) { - platforms.put(entry.getKey().substring(APP_PLATFORM_KEY_PREFIX.length()), entry.getValue()); - } - } - return platforms.build(); + : getNdkCpuAbiFallbackAppPlatform(); } /** diff --git a/test/com/facebook/buck/android/AndroidBuckConfigTest.java b/test/com/facebook/buck/android/AndroidBuckConfigTest.java index b497f2e6a16..d8d009c51f6 100644 --- a/test/com/facebook/buck/android/AndroidBuckConfigTest.java +++ b/test/com/facebook/buck/android/AndroidBuckConfigTest.java @@ -38,20 +38,19 @@ public AndroidBuckConfig makeAndroidBuckConfig(ImmutableMap ndkS public void testNdkAppPlatformForCpuAbi() throws IOException { ImmutableMap ndkSection = new ImmutableMap.Builder () - .put("app_platform-i386", "foo") - .put("app_platform-arm64", "bar") + .put("app_platform_per_cpu_abi", "i386 => foo, arm64 => bar") .build(); AndroidBuckConfig androidBuckConfig = makeAndroidBuckConfig(ndkSection); - // Make sure we don't have an agnostic value. - assertEquals(androidBuckConfig.getNdkCpuAbiAgnosticAppPlatform(), Optional.empty()); + // Make sure we don't have an fallback value. + assertEquals(androidBuckConfig.getNdkCpuAbiFallbackAppPlatform(), Optional.empty()); // Make sure we get our ABI values back. assertEquals(androidBuckConfig.getNdkAppPlatformForCpuAbi("i386"), Optional.of("foo")); assertEquals(androidBuckConfig.getNdkAppPlatformForCpuAbi("arm64"), Optional.of("bar")); // Make sure unset ABI values don't return anything, as - // we didn't set the agnostic value. + // we didn't set the fallback value. assertEquals(androidBuckConfig.getNdkAppPlatformForCpuAbi("fake"), Optional.empty()); } @@ -60,8 +59,8 @@ public void testNdkAppPlatformUnset() throws IOException { ImmutableMap ndkSection = new ImmutableMap.Builder ().build(); AndroidBuckConfig androidBuckConfig = makeAndroidBuckConfig(ndkSection); - // Make sure we don't have an agnostic value. - assertEquals(androidBuckConfig.getNdkCpuAbiAgnosticAppPlatform(), Optional.empty()); + // Make sure we don't have an fallback value. + assertEquals(androidBuckConfig.getNdkCpuAbiFallbackAppPlatform(), Optional.empty()); // Make sure we don't get anything ABI-specific. assertEquals(androidBuckConfig.getNdkAppPlatformForCpuAbi("i386"), Optional.empty()); @@ -71,18 +70,18 @@ public void testNdkAppPlatformUnset() throws IOException { public void testNdkAppPlatformPriority() throws IOException { ImmutableMap ndkSection = new ImmutableMap.Builder () - .put("app_platform", "agnostic") - .put("app_platform-arm64", "specific") + .put("app_platform", "fallback") + .put("app_platform_per_cpu_abi", "arm64 => specific") .build(); AndroidBuckConfig androidBuckConfig = makeAndroidBuckConfig(ndkSection); - // Make sure we have an agnostic value. - assertEquals(androidBuckConfig.getNdkCpuAbiAgnosticAppPlatform(), Optional.of("agnostic")); + // Make sure we have an fallback value. + assertEquals(androidBuckConfig.getNdkCpuAbiFallbackAppPlatform(), Optional.of("fallback")); - // Make sure ABI-specific values override the agnostic one. + // Make sure ABI-specific values override the fallback one. assertEquals(androidBuckConfig.getNdkAppPlatformForCpuAbi("arm64"), Optional.of("specific")); - // Make sure we default to agnostic. - assertEquals(androidBuckConfig.getNdkAppPlatformForCpuAbi("fake"), Optional.of("agnostic")); + // Make sure we default to fallback. + assertEquals(androidBuckConfig.getNdkAppPlatformForCpuAbi("fake"), Optional.of("fallback")); } } diff --git a/test/com/facebook/buck/android/NdkLibraryIntegrationTest.java b/test/com/facebook/buck/android/NdkLibraryIntegrationTest.java index 1ad5da4a5db..c6d325151bc 100644 --- a/test/com/facebook/buck/android/NdkLibraryIntegrationTest.java +++ b/test/com/facebook/buck/android/NdkLibraryIntegrationTest.java @@ -25,12 +25,12 @@ import com.facebook.buck.android.toolchain.ndk.impl.AndroidNdkHelper; import com.facebook.buck.android.toolchain.ndk.impl.AndroidNdkHelper.SymbolGetter; import com.facebook.buck.android.toolchain.ndk.impl.AndroidNdkHelper.SymbolsAndDtNeeded; -import com.facebook.buck.core.rules.resolver.impl.TestBuildRuleResolver; +import com.facebook.buck.core.rules.SourcePathRuleFinder; +import com.facebook.buck.core.rules.resolver.impl.TestActionGraphBuilder; import com.facebook.buck.core.sourcepath.resolver.SourcePathResolver; import com.facebook.buck.core.sourcepath.resolver.impl.DefaultSourcePathResolver; import com.facebook.buck.io.filesystem.ProjectFilesystem; import com.facebook.buck.io.filesystem.TestProjectFilesystems; -import com.facebook.buck.rules.SourcePathRuleFinder; import com.facebook.buck.testutil.ProcessResult; import com.facebook.buck.testutil.TemporaryPaths; import com.facebook.buck.testutil.TestConsole; @@ -127,7 +127,7 @@ public void ndkLibraryAppPlatformDefaultCpuAbi() throws InterruptedException, IO workspace.replaceFileContents( ".buckconfig", "#app_platform", - "app_platform = android-16\n app_platform-armv7 = android-19"); + "app_platform = android-16\n app_platform_per_cpu_abi = armv7 => android-19"); Path apkPath = workspace.buildAndReturnOutput("//apps/sample:app_cxx_lib_app_platform"); SymbolsAndDtNeeded info; @@ -157,7 +157,7 @@ public void ndkLibraryAppPlatformByCpuAbi() throws InterruptedException, IOExcep workspace.replaceFileContents( ".buckconfig", "#app_platform", - "app_platform-x86 = android-18\n app_platform-armv7 = android-19"); + "app_platform_per_cpu_abi = x86 => android-18, armv7 => android-19"); Path apkPath = workspace.buildAndReturnOutput("//apps/sample:app_cxx_lib_app_platform"); SymbolsAndDtNeeded info; @@ -182,7 +182,7 @@ private SymbolGetter getSymbolGetter(ProjectFilesystem filesystem, TemporaryPath throws IOException, InterruptedException { NdkCxxPlatform platform = AndroidNdkHelper.getNdkCxxPlatform(filesystem); SourcePathResolver pathResolver = - DefaultSourcePathResolver.from(new SourcePathRuleFinder(new TestBuildRuleResolver())); + DefaultSourcePathResolver.from(new SourcePathRuleFinder(new TestActionGraphBuilder())); Path tmpDir = tempLocation.newFolder("symbols_tmp"); return new SymbolGetter( new DefaultProcessExecutor(new TestConsole()), tmpDir, platform.getObjdump(), pathResolver);