aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar cparsons <cparsons@google.com>2017-07-18 02:24:21 +0200
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-07-18 09:49:19 +0200
commitc238b573aef850ecc4c2a7bdb49233de225d6b12 (patch)
tree5ea7f1e2e347c894705cd5db216079db939e373b /src/test
parent6e72f78e1c2e573787ec862e671f3b3b4c33dc96 (diff)
Add testing for builds which contain two targets with different minimum_os but same sources
RELNOTES: None. PiperOrigin-RevId: 162295421
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java7
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/AppleDynamicLibraryTest.java5
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java5
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java132
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/RuleType.java22
5 files changed, 129 insertions, 42 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java
index 65cb196269..89d3517442 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java
@@ -472,7 +472,7 @@ public class AppleBinaryTest extends ObjcRuleTestCase {
" srcs = ['a.m'],",
" deps = ['//protos:objc_protos_low_level',]",
")");
-
+
if (depBinaryType == BinaryType.DYLIB) {
scratchFrameworkSkylarkStub("frameworkstub/framework_stub.bzl");
scratch.file(
@@ -1418,4 +1418,9 @@ public class AppleBinaryTest extends ObjcRuleTestCase {
public void testCustomModuleMap() throws Exception {
checkCustomModuleMap(RULE_TYPE);
}
+
+ @Test
+ public void testMinimumOsDifferentTargets() throws Exception {
+ checkMinimumOsDifferentTargets(RULE_TYPE, "_lipobin", "_bin");
+ }
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleDynamicLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleDynamicLibraryTest.java
index f128dde240..82b875afc7 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleDynamicLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleDynamicLibraryTest.java
@@ -198,4 +198,9 @@ public class AppleDynamicLibraryTest extends ObjcRuleTestCase {
public void testAvoidDepsObjects() throws Exception {
checkAvoidDepsObjects(RULE_TYPE);
}
+
+ @Test
+ public void testMinimumOsDifferentTargets() throws Exception {
+ checkMinimumOsDifferentTargets(RULE_TYPE, "_lipobin", "_bin");
+ }
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java
index 01f8b08d99..887b941e40 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java
@@ -540,4 +540,9 @@ public class AppleStaticLibraryTest extends ObjcRuleTestCase {
Iterables.getOnlyElement(
provider.getDepsObjcProvider().get(ObjcProvider.MULTI_ARCH_LINKED_ARCHIVES)));
}
+
+ @Test
+ public void testMinimumOsDifferentTargets() throws Exception {
+ checkMinimumOsDifferentTargets(RULE_TYPE, "_lipo.a", "-fl.a");
+ }
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
index 875258689d..2c82883104 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java
@@ -159,7 +159,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
* Returns the bin dir for artifacts built for a given Apple architecture and minimum OS
* version (as set by a configuration transition) and configuration distinguisher but the global
* default for {@code --cpu}.
- *
+ *
* @param arch the given Apple architecture which artifacts are built under this configuration.
* Note this will likely be different than the value of {@code --cpu}.
* @param configurationDistinguisher the configuration distinguisher used to describe the
@@ -214,7 +214,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
* Returns the bin dir for artifacts built for a given Apple architecture (as set by a
* configuration transition) and configuration distinguisher but the global default for
* {@code --cpu} and the platform default for minimum OS.
- *
+ *
* @param arch the given Apple architecture which artifacts are built under this configuration.
* Note this will likely be different than the value of {@code --cpu}
* @param configurationDistinguisher the configuration distinguisher used to describe the
@@ -294,14 +294,14 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
platform.getNameInPlist()) + AppleToolchain.DEVELOPER_FRAMEWORK_PATH;
}
- /**
- * Creates an {@code objc_library} target writer for the label indicated by the given String.
+ /**
+ * Creates an {@code objc_library} target writer for the label indicated by the given String.
*/
protected ScratchAttributeWriter createLibraryTargetWriter(String labelString) {
return ScratchAttributeWriter.fromLabelString(this, "objc_library", labelString);
}
- /**
+ /**
* Creates an {@code objc_binary} target writer for the label indicated by the given String.
*/
protected ScratchAttributeWriter createBinaryTargetWriter(String labelString) {
@@ -448,12 +448,12 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
protected List<BuildConfiguration> getSplitConfigurations(BuildConfiguration configuration,
SplitTransition<BuildOptions> splitTransition) throws InterruptedException {
ImmutableList.Builder<BuildConfiguration> splitConfigs = ImmutableList.builder();
-
+
for (BuildOptions splitOptions : splitTransition.split(configuration.getOptions())) {
splitConfigs.add(getSkyframeExecutor().getConfigurationForTesting(
reporter, configuration.fragmentClasses(), splitOptions));
}
-
+
return splitConfigs.build();
}
@@ -483,7 +483,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
assertThat(Artifact.toRootRelativePaths(action.getOutputs()))
.containsExactly("x/x_bin");
- verifyLinkAction(Iterables.getOnlyElement(action.getOutputs()),
+ verifyLinkAction(Iterables.getOnlyElement(action.getOutputs()),
getBinArtifact("x-linker.objlist", "//x:x"), "i386",
ImmutableList.of("libx.a", "liblib1.a", "liblib2.a"), ImmutableList.<PathFragment>of(),
extraLinkArgs);
@@ -555,7 +555,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
* @param filelistArtifact the input filelist artifact
* @param arch the architecture (for example, "i386") which the binary is to be created for
* @param inputArchives the suffixes (basenames or relative paths with basenames) of the input
- * archive files for the link action
+ * archive files for the link action
* @param importedFrameworks custom framework path fragments
* @param extraLinkArgs extra link arguments expected on the link action
*/
@@ -606,7 +606,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
protected void checkLinkActionWithTransitiveCppDependency(
RuleType ruleType, ExtraLinkArgs extraLinkArgs) throws Exception {
-
+
createLibraryTargetWriter("//lib1:lib1").setAndCreateFiles("srcs", "a.mm").write();
createLibraryTargetWriter("//lib2:lib2")
.setAndCreateFiles("srcs", "a.m", "b.m", "private.h")
@@ -652,7 +652,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
protected void assertAppleSdkVersionEnv(Map<String, String> env) throws Exception {
assertAppleSdkVersionEnv(env, DEFAULT_IOS_SDK_VERSION);
}
-
+
protected void assertAppleSdkVersionEnv(Map<String, String> env, DottedVersion versionNumber)
throws Exception {
assertThat(env).containsEntry("APPLE_SDK_VERSION_OVERRIDE", versionNumber.toString());
@@ -666,7 +666,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
protected void assertAppleSdkVersionEnv(CommandAction action) throws Exception {
assertAppleSdkVersionEnv(action, DEFAULT_IOS_SDK_VERSION.toString());
}
-
+
protected void assertAppleSdkVersionEnv(CommandAction action, String versionString)
throws Exception {
assertThat(action.getEnvironment())
@@ -677,7 +677,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
throws Exception {
assertThat(action.getEnvironment()).containsEntry("APPLE_SDK_PLATFORM", platformName);
}
-
+
protected void assertXcodeVersionEnv(CommandAction action, String versionNumber)
throws Exception {
assertThat(action.getEnvironment()).containsEntry("XCODE_VERSION_OVERRIDE", versionNumber);
@@ -1088,7 +1088,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
protected void assertRequiresDarwin(ExecutionInfoSpecifier action) {
assertThat(action.getExecutionInfo()).containsKey(ExecutionRequirements.REQUIRES_DARWIN);
}
-
+
/**
* Asserts that the given action can specify execution requirements, but does not require
* execution on darwin.
@@ -1186,7 +1186,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
ruleType.scratchTarget(scratch, "srcs", "['a.m', 'b.o']");
assertThat(Artifact.toRootRelativePaths(archiveAction("//x:x").getInputs())).contains("x/b.o");
}
-
+
protected void checkPopulatesBundling(RuleType ruleType) throws Exception {
scratch.file("x/a.m");
scratch.file("x/info.plist");
@@ -2001,7 +2001,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
String familyAttribute) throws Exception {
checkReportsErrorsForInvalidFamiliesAttribute(ruleType, "a", familyAttribute, "['foo']");
checkReportsErrorsForInvalidFamiliesAttribute(ruleType, "b", familyAttribute, "[]");
- checkReportsErrorsForInvalidFamiliesAttribute(ruleType, "c", familyAttribute,
+ checkReportsErrorsForInvalidFamiliesAttribute(ruleType, "c", familyAttribute,
"['iphone', 'ipad', 'iphone']");
checkReportsErrorsForInvalidFamiliesAttribute(ruleType, "d", familyAttribute,
"['iphone', 'bar']");
@@ -2019,7 +2019,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
String... extraAttributes)
throws Exception {
scratch.file("lib/" + libFile);
-
+
createLibraryTargetWriter("//lib:lib")
.setAndCreateFiles("srcs", "a.m", "b.m", "private.h")
.set(attributeName, "['" + libFile + "']")
@@ -2066,7 +2066,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
protected BinaryFileWriteAction bundleMergeControlAction(String binaryLabelString)
throws Exception {
Label binaryLabel = Label.parseAbsolute(binaryLabelString);
- ConfiguredTarget binary = getConfiguredTarget(binaryLabelString);
+ ConfiguredTarget binary = getConfiguredTarget(binaryLabelString);
return (BinaryFileWriteAction) getGeneratingAction(
getBinArtifact(binaryLabel.getName() + artifactName(".ipa-control"), binary));
}
@@ -2593,18 +2593,18 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
assertThat(compileActionA.getArguments())
.containsAllIn(allExpectedCoptsBuilder.build()).inOrder();
-
+
}
-
+
protected void checkLinkopts(RuleType ruleType) throws Exception {
ruleType.scratchTarget(scratch, "linkopts", "['foo', 'bar']");
-
+
CommandAction linkAction = linkAction("//x:x");
String linkArgs = Joiner.on(" ").join(linkAction.getArguments());
assertThat(linkArgs).contains("-Wl,foo");
assertThat(linkArgs).contains("-Wl,bar");
}
-
+
protected void checkMergesPartialInfoplists(RuleType ruleType) throws Exception {
scratch.file("x/primary-Info.plist");
ruleType.scratchTarget(scratch,
@@ -2695,12 +2695,12 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
.setList("srcs", "a.cc")
.setList("defines", "foo", "bar")
.write();
-
+
ScratchAttributeWriter.fromLabelString(this, ruleType.getRuleTypeName(), "//objc:x")
.setList("srcs", "a.m")
.setList("deps", "//dep:lib")
.write();
-
+
CommandAction compileAction = compileAction("//objc:x", "a.o");
assertThat(compileAction.getArguments()).containsAllOf("-Dfoo", "-Dbar");
}
@@ -3574,7 +3574,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
verifyObjlist(
binBinAction, String.format("%s-linker.objlist", targetName),
"lib/libcclib.a", String.format("x/lib%s.a", targetName));
-
+
assertThat(Artifact.toExecPaths(binBinAction.getInputs()))
.containsAllOf(
iosConfigurationCcDepsBin("i386", configurationDistinguisher) + "lib/libcclib.a",
@@ -3744,7 +3744,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
CommandAction binBinAction = (CommandAction) getGeneratingAction(
getFirstArtifactEndingWith(appLipoAction.getInputs(), "bin_bin"));
-
+
String i386Prefix = iosConfigurationCcDepsBin("i386", configurationDistinguisher);
ImmutableList<String> archiveFilenames = ImmutableList.of(
i386Prefix + "lib/libcclib.a",
@@ -4141,7 +4141,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
/**
* Verifies that the given rule supports the minimum_os attribute, and adds compile and link
* args to set the minimum os appropriately, including compile args for dependencies.
- *
+ *
* @param ruleType the rule to test
*/
protected void checkMinimumOsLinkAndCompileArg(RuleType ruleType) throws Exception {
@@ -4168,7 +4168,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
* Verifies that the given rule supports the minimum_os attribute under the watchOS platform
* type, and adds compile and link args to set the minimum os appropriately for watchos,
* including compile args for dependencies.
- *
+ *
* @param ruleType the rule to test
*/
protected void checkMinimumOsLinkAndCompileArg_watchos(RuleType ruleType) throws Exception {
@@ -4203,7 +4203,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
"foobar"),
ruleType.target(scratch, "x", "x", "minimum_os_version", "'foobar'"));
}
-
+
/**
* Verifies that the given rule throws a sensible error if the minimum_os attribute has a bad
* value.
@@ -4215,7 +4215,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
"4.3alpha"),
ruleType.target(scratch, "x", "x", "minimum_os_version", "'4.3alpha'"));
}
-
+
/**
* Verifies that the given rule throws a sensible error if the minimum_os attribute has a bad
* value.
@@ -4233,7 +4233,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
ruleType.scratchTarget(scratch,
"srcs", "['a.m']",
"dylibs", "['//fx:framework_import']");
-
+
scratch.file("fx/MyFramework.framework/MyFramework");
scratch.file("fx/BUILD",
"objc_framework(",
@@ -4319,7 +4319,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
CommandAction i386BinAction = (CommandAction) getGeneratingAction(
getFirstArtifactEndingWith(appLipoAction.getInputs(), i386Prefix + "x/x_bin"));
-
+
CommandAction x8664BinAction = (CommandAction) getGeneratingAction(
getFirstArtifactEndingWith(appLipoAction.getInputs(), x8664Prefix + "x/x_bin"));
@@ -4329,7 +4329,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
verifyObjlist(
x8664BinAction, "x/x-linker.objlist",
"x/libx.a", "package/libcclib.a");
-
+
assertThat(Artifact.toExecPaths(i386BinAction.getInputs()))
.containsAllOf(
i386Prefix + "x/libx.a",
@@ -4409,7 +4409,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
" srcs = ['ccdep.c'],",
" linkopts = ['-somelinkopt'],",
")");
-
+
ruleType.scratchTarget(scratch,
"srcs", "['main.m']",
"deps", "['//bin:objclib']");
@@ -4442,7 +4442,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
" linkopts = ['-one-more-opt', '-framework UIKit'],",
" deps = ['cclib1'],",
")");
-
+
ruleType.scratchTarget(scratch,
"srcs", "['main.m']",
"deps", "['//bin:cclib2', '//bin:cclib3']");
@@ -4588,7 +4588,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
"platform_type", "'watchos'");
scratch.file("package/BUILD",
"objc_library(name = 'objcLib', srcs = [ 'b.m' ])");
-
+
Action lipoAction = actionProducingArtifact("//x:x", "_lipobin");
String i386Bin = configurationBin("i386", ConfigurationDistinguisher.APPLEBIN_WATCHOS)
@@ -4667,7 +4667,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
scratch.file("package/BUILD",
"objc_library(name = 'objcLib', srcs = [ 'b.m' ])");
useConfiguration("--xcode_version=5.8");
-
+
CommandAction action = linkAction("//x:x");
assertThat(Artifact.toRootRelativePaths(action.getInputs())).containsAllOf(
"x/libx.a", "package/libobjcLib.a", "x/x-linker.objlist");
@@ -4754,7 +4754,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
* \ /
* ( avoidLibDepTwo )
*
- * All libraries prefixed with "avoid" shouldn't be statically linked in the top level target.
+ * All libraries prefixed with "avoid" shouldn't be statically linked in the top level target.
*/
ruleType.scratchTarget(scratch,
"deps", "['//package:objcLib']",
@@ -4841,7 +4841,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
assertThat(getFirstArtifactEndingWith(linkAction.getInputs(),
"package/libDylib2Lib.a")).isNull();
- // Sanity check that the identical binary without dylibs would be fully linked.
+ // Sanity check that the identical binary without dylibs would be fully linked.
Action alternateLipobinAction = lipoBinAction("//package:alternate");
Artifact alternateBinArtifact = getFirstArtifactEndingWith(alternateLipobinAction.getInputs(),
"package/alternate_bin");
@@ -4925,4 +4925,58 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase {
provider = providerForTarget("//x:x");
assertThat(Artifact.toExecPaths(provider.get(MODULE_MAP))).contains("y/module.modulemap");
}
+
+ /**
+ * Verifies that the given rule supports different minimum_os attribute values for two targets
+ * in the same build, and adds compile args to set the minimum os appropriately for
+ * dependencies of each.
+ *
+ * @param ruleType the rule to test
+ * @param multiArchArtifactSuffix the suffix of the artifact that the rule-under-test produces
+ * @param singleArchArtifactSuffix the suffix of the single-architecture artifact that is an
+ * input to the rule-under-test's generating action
+ */
+ protected void checkMinimumOsDifferentTargets(RuleType ruleType, String multiArchArtifactSuffix,
+ String singleArchArtifactSuffix) throws Exception {
+ ruleType.scratchTarget("nine", "nine", scratch,
+ "deps", "['//package:objcLib']",
+ "minimum_os_version", "'9.0'");
+ ruleType.scratchTarget("eight", "eight", scratch,
+ "deps", "['//package:objcLib']",
+ "minimum_os_version", "'8.0'");
+ scratch.file("package/BUILD",
+ "genrule(name = 'root', srcs = ['//nine:nine', '//eight:eight'], outs = ['genout'],",
+ " cmd = 'touch genout')",
+ "objc_library(name = 'objcLib', srcs = [ 'b.m' ])");
+
+ ConfiguredTarget rootTarget = getConfiguredTarget("//package:root");
+ Artifact rootArtifact = getGenfilesArtifact("genout", rootTarget);
+
+ Action genruleAction = getGeneratingAction(rootArtifact);
+ Action eightLipoAction = getGeneratingAction(
+ getFirstArtifactEndingWith(genruleAction.getInputs(), "eight" + multiArchArtifactSuffix));
+ Action nineLipoAction = getGeneratingAction(
+ getFirstArtifactEndingWith(genruleAction.getInputs(), "nine" + multiArchArtifactSuffix));
+ Artifact eightBin =
+ getFirstArtifactEndingWith(eightLipoAction.getInputs(), singleArchArtifactSuffix);
+ Artifact nineBin =
+ getFirstArtifactEndingWith(nineLipoAction.getInputs(), singleArchArtifactSuffix);
+
+ CommandAction eightLinkAction = (CommandAction) getGeneratingAction(eightBin);
+ CommandAction nineLinkAction = (CommandAction) getGeneratingAction(nineBin);
+
+ CommandAction eightObjcLibArchiveAction = (CommandAction) getGeneratingAction(
+ getFirstArtifactEndingWith(eightLinkAction.getInputs(), "libobjcLib.a"));
+ CommandAction eightObjcLibCompileAction = (CommandAction) getGeneratingAction(
+ getFirstArtifactEndingWith(eightObjcLibArchiveAction.getInputs(), "b.o"));
+ CommandAction nineObjcLibArchiveAction = (CommandAction) getGeneratingAction(
+ getFirstArtifactEndingWith(nineLinkAction.getInputs(), "libobjcLib.a"));
+ CommandAction nineObjcLibCompileAction = (CommandAction) getGeneratingAction(
+ getFirstArtifactEndingWith(nineObjcLibArchiveAction.getInputs(), "b.o"));
+
+ assertThat(Joiner.on(" ").join(eightObjcLibCompileAction.getArguments()))
+ .contains("-mios-simulator-version-min=8.0");
+ assertThat(Joiner.on(" ").join(nineObjcLibCompileAction.getArguments()))
+ .contains("-mios-simulator-version-min=9.0");
+ }
}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/RuleType.java b/src/test/java/com/google/devtools/build/lib/rules/objc/RuleType.java
index 18875c680d..44c24e8308 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/RuleType.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/RuleType.java
@@ -138,8 +138,26 @@ public abstract class RuleType {
*/
public final String scratchTarget(Scratch scratch, String... checkSpecificAttrs)
throws IOException {
- String target = target(scratch, "x", "x", checkSpecificAttrs);
- scratch.file("x/BUILD", target);
+ return scratchTarget("x", "x", scratch, checkSpecificAttrs);
+ }
+
+ /**
+ * Creates a target at a given package which is the only target in the BUILD file. Returns the
+ * string that is written to the scratch file as it is often useful for debugging purposes.
+ *
+ * @param packageDir the package of the target, for example "foo" in //foo:bar
+ * @param targetName the name of the target, for example "bar" in //foo:bar
+ * @param scratch the scratch object to use to create the build file
+ * @param checkSpecificAttrs alternating name/values of attributes to add to the rule that are
+ * required for the check being performed to be defined a certain way. Pass
+ * {@link #OMIT_REQUIRED_ATTR} for a value to prevent an attribute from being automatically
+ * defined.
+ */
+ public final String scratchTarget(String packageDir, String targetName,
+ Scratch scratch, String... checkSpecificAttrs)
+ throws IOException {
+ String target = target(scratch, packageDir, targetName, checkSpecificAttrs);
+ scratch.file(packageDir + "/BUILD", target);
return target;
}
}