### Problem
J2Objc pruner would crash when encountering a target without an explicit target such as "//some/path/to/target" instead of "//some/path/to/target:target"
### Solution
Added support for importing dependencies that are the same name as the directory.
PiperOrigin-RevId: 521881825
Change-Id: I4384a2468b92c5964dc8665f49b28a5c816f6bda
diff --git a/tools/objc/j2objc_dead_code_pruner_binary.py b/tools/objc/j2objc_dead_code_pruner_binary.py
index 00524128..258d987 100755
--- a/tools/objc/j2objc_dead_code_pruner_binary.py
+++ b/tools/objc/j2objc_dead_code_pruner_binary.py
@@ -416,8 +416,14 @@
for filename in files.split(','):
with file_open(filename, 'r') as f:
for line in f:
- entry = line.strip().split(':')[0]
- dep = line.strip().split(':')[1]
+ split = line.strip().split(':')
+ entry = split[0]
+ if len(split) == 1:
+ # The build system allows for adding just the entry if the dependency
+ # is the same name
+ dep = split[0]
+ else:
+ dep = split[1]
if entry in tree:
tree[entry].append(dep)
else: