Skip to content

Commit

Permalink
Remove unused Java references.
Browse files Browse the repository at this point in the history
Part of a Bazel dead code cleanup.

PiperOrigin-RevId: 532258399
Change-Id: I22d8f74b0be90ae01771c559f7f3ef086ab7e5cb
  • Loading branch information
gregestren authored and fweikert committed May 25, 2023
1 parent 2fed556 commit 69d84f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import com.google.devtools.build.lib.util.CPU;
import com.google.devtools.build.lib.util.OS;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.common.options.Converter;
import com.google.devtools.common.options.OptionsParsingException;

Expand Down Expand Up @@ -83,51 +82,6 @@ public String convert(String input) throws OptionsParsingException {
return input;
}

/**
* Reverses the conversion performed by {@link Converter#convert} to return the matching OS, CPU
* pair.
*/
public static Pair<CPU, OS> reverse(String input) {
if (input == null || input.length() == 0 || "unknown".equals(input)) {
// Use the auto-detected values.
return Pair.of(CPU.getCurrent(), OS.getCurrent());
}

// Handle the easy cases.
if (input.startsWith("darwin")) {
return Pair.of(CPU.getCurrent(), OS.DARWIN);
} else if (input.startsWith("freebsd")) {
return Pair.of(CPU.getCurrent(), OS.FREEBSD);
} else if (input.startsWith("openbsd")) {
return Pair.of(CPU.getCurrent(), OS.OPENBSD);
} else if (input.startsWith("x64_windows")) {
return Pair.of(CPU.getCurrent(), OS.WINDOWS);
}

// Handle the Linux cases.
switch (input) {
case "piii":
return Pair.of(CPU.X86_32, OS.LINUX);
case "k8":
return Pair.of(CPU.X86_64, OS.LINUX);
case "ppc":
return Pair.of(CPU.PPC, OS.LINUX);
case "arm":
return Pair.of(CPU.ARM, OS.LINUX);
case "s390x":
return Pair.of(CPU.S390X, OS.LINUX);
case "mips64":
return Pair.of(CPU.MIPS64, OS.LINUX);
case "riscv64":
return Pair.of(CPU.RISCV64, OS.LINUX);
default:
// fall through
}

// Use the auto-detected values.
return Pair.of(CPU.getCurrent(), OS.getCurrent());
}

@Override
public String getTypeDescription() {
return "a string";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,6 @@ public abstract class PackageSpecification {
// TODO(b/77598306): Remove the parameter after switching all callers to pass true.
protected abstract String asString(boolean includeDoubleSlash);

/**
* Returns a string representation of this package spec without the repository, and which is
* round-trippable through {@link #fromString}.
*
* <p>For instance, {@code @somerepo//pkg/subpkg/...} turns into {@code "//pkg/subpkg/..."}.
*
* <p>Omitting the repository means that the returned strings are ambiguous in the absence of
* additional context. But, for instance, if interpreted with respect to a {@code package_group}'s
* {@code packages} attribute, the strings always have the same repository as the package group.
*/
// TODO(brandjon): This method's main benefit is that it's round-trippable. But we can already
// achieve the same thing with asString(), if the caller parses out the repo to pass to
// fromString() as a separate arg. It'd be nice to eliminate this method in favor of asString()
// and make a version of fromString() that can parse repo names in the label. We'd just have to
// mimic the Label parsing of repo (we can't reuse Label parsing directly since it won't like the
// `/...` syntax). Repo remapping shouldn't come up, since the names we get from stringification
// ought to already be canonical/absolute.
protected abstract String asStringWithoutRepository();

@Override
public String toString() {
return asString(/*includeDoubleSlash=*/ false);
Expand Down Expand Up @@ -300,12 +281,6 @@ protected String asString(boolean includeDoubleSlash) {
return PackageGroupContents.stringForSinglePackage(singlePackageName, includeDoubleSlash);
}

@Override
protected String asStringWithoutRepository() {
return PackageGroupContents.stringForSinglePackageWithDoubleSlashAndWithoutRepository(
singlePackageName);
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down Expand Up @@ -342,12 +317,6 @@ protected String asString(boolean includeDoubleSlash) {
return PackageGroupContents.stringForAllPackagesBeneath(prefix, includeDoubleSlash);
}

@Override
protected String asStringWithoutRepository() {
return PackageGroupContents.stringForAllPackagesBeneathWithDoubleSlashAndWithoutRepository(
prefix);
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down Expand Up @@ -384,11 +353,6 @@ protected String asString(boolean includeDoubleSlash) {
return "-" + delegate.asString(includeDoubleSlash);
}

@Override
protected String asStringWithoutRepository() {
return "-" + delegate.asStringWithoutRepository();
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
Expand Down Expand Up @@ -419,11 +383,6 @@ protected String asString(boolean includeDoubleSlash) {
return PackageGroupContents.stringForAllPackages(includeDoubleSlash);
}

@Override
protected String asStringWithoutRepository() {
return "public";
}

@Override
public boolean equals(Object o) {
return o instanceof AllPackages;
Expand All @@ -450,11 +409,6 @@ protected String asString(boolean includeDoubleSlash) {
return "private";
}

@Override
protected String asStringWithoutRepository() {
return "private";
}

@Override
public boolean equals(Object o) {
return o instanceof NoPackages;
Expand Down Expand Up @@ -692,8 +646,15 @@ private static String stringForAllPackagesBeneath(
}

/**
* Does the equivalent of mapping {@link PackageSpecification#asStringWithoutRepository} to the
* component package specs.
* /** Returns a string representation of this package spec without the repository, and which is
* round-trippable through {@link #fromString}.
*
* <p>For instance, {@code @somerepo//pkg/subpkg/...} turns into {@code "//pkg/subpkg/..."}.
*
* <p>Omitting the repository means that the returned strings are ambiguous in the absence of
* additional context. But, for instance, if interpreted with respect to a {@code
* package_group}'s {@code packages} attribute, the strings always have the same repository as
* the package group.
*
* <p>Note that this is ambiguous w.r.t. specs that reference other repositories.
*
Expand Down

0 comments on commit 69d84f2

Please sign in to comment.