Skip to content

Commit 61bf2e5

Browse files
googlewaltcopybara-github
authored andcommitted
Automated rollback of commit 34c7146.
*** Reason for rollback *** broke stuff *** Original change description *** Do location expansion in copts of objc_library Fixes bazelbuild#13862 RELNOTES:none PiperOrigin-RevId: 409910075
1 parent 7333aa6 commit 61bf2e5

File tree

3 files changed

+2
-36
lines changed

3 files changed

+2
-36
lines changed

src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkRuleContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ private static void checkDeprecated(String newApi, String oldApi, StarlarkSemant
11031103
* @param knownLabels List of known labels
11041104
* @return Immutable map with immutable collections as values
11051105
*/
1106-
public static ImmutableMap<Label, ImmutableCollection<Artifact>> makeLabelMap(
1106+
private static ImmutableMap<Label, ImmutableCollection<Artifact>> makeLabelMap(
11071107
Iterable<TransitiveInfoCollection> knownLabels) {
11081108
ImmutableMap.Builder<Label, ImmutableCollection<Artifact>> builder = ImmutableMap.builder();
11091109

src/main/java/com/google/devtools/build/lib/rules/objc/ObjcStarlarkInternal.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818

1919
import com.google.common.collect.ImmutableList;
2020
import com.google.common.collect.ImmutableMap;
21-
import com.google.common.collect.Iterables;
2221
import com.google.devtools.build.docgen.annot.DocCategory;
2322
import com.google.devtools.build.lib.actions.Artifact;
24-
import com.google.devtools.build.lib.analysis.LocationExpander;
2523
import com.google.devtools.build.lib.analysis.TemplateVariableInfo;
2624
import com.google.devtools.build.lib.analysis.starlark.StarlarkRuleContext;
2725
import com.google.devtools.build.lib.analysis.test.InstrumentedFilesInfo;
@@ -118,18 +116,7 @@ public Sequence<String> expandToolchainAndRuleContextVariables(
118116
ImmutableMap.<String, String>builder().putAll(starlarkRuleContext.var()).build();
119117
List<String> expandedFlags = new ArrayList<>();
120118
for (String flag : Sequence.cast(flags, String.class, "flags")) {
121-
@SuppressWarnings("unchecked")
122-
String expandedFlag =
123-
LocationExpander.withExecPaths(
124-
starlarkRuleContext.getRuleContext(),
125-
StarlarkRuleContext.makeLabelMap(
126-
Iterables.concat(
127-
starlarkRuleContext.getRuleContext().getPrerequisites("srcs"),
128-
starlarkRuleContext.getRuleContext().getPrerequisites("non_arc_srcs"),
129-
starlarkRuleContext.getRuleContext().getPrerequisites("hdrs"),
130-
starlarkRuleContext.getRuleContext().getPrerequisites("data"))))
131-
.expand(flag);
132-
expandedFlag = expandFlag(expandedFlag, toolchainMap, starlarkRuleContextMap);
119+
String expandedFlag = expandFlag(flag, toolchainMap, starlarkRuleContextMap);
133120
try {
134121
ShellUtils.tokenize(expandedFlags, expandedFlag);
135122
} catch (TokenizationException e) {

src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,25 +2380,4 @@ public void testCompilationPrerequisitesHasHeaders() throws Exception {
23802380
.getOutputGroup(OutputGroupInfo.COMPILATION_PREREQUISITES)))
23812381
.contains("src bin/cc.h");
23822382
}
2383-
2384-
@Test
2385-
public void testCoptsLocationIsExpanded() throws Exception {
2386-
scratch.file(
2387-
"bin/BUILD",
2388-
"objc_library(",
2389-
" name = 'lib',",
2390-
" copts = ['$(rootpath lib1.m) $(location lib2.m) $(location data.data) $(execpath"
2391-
+ " header.h)'],",
2392-
" srcs = ['lib1.m'],",
2393-
" non_arc_srcs = ['lib2.m'],",
2394-
" data = ['data.data'],",
2395-
" hdrs = ['header.h'],",
2396-
")");
2397-
2398-
useConfiguration("--apple_platform_type=ios", "--cpu=ios_x86_64");
2399-
2400-
CppCompileAction compileA = (CppCompileAction) compileAction("//bin:lib", "lib1.o");
2401-
assertThat(compileA.compileCommandLine.getCopts())
2402-
.containsAtLeast("bin/lib1.m", "bin/lib2.m", "bin/data.data", "bin/header.h");
2403-
}
24042383
}

0 commit comments

Comments
 (0)