Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow building the Bazel server for OpenBSD. #10386

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class ShellConfiguration extends BuildConfiguration.Fragment {
ImmutableMap.<OS, PathFragment>builder()
.put(OS.WINDOWS, PathFragment.create("c:/tools/msys64/usr/bin/bash.exe"))
.put(OS.FREEBSD, PathFragment.create("/usr/local/bin/bash"))
.put(OS.OPENBSD, PathFragment.create("/usr/local/bin/bash"))
.build();

private final PathFragment shellExecutable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public String convert(String input) throws OptionsParsingException {
return "darwin";
case FREEBSD:
return "freebsd";
case OPENBSD:
return "openbsd";
case WINDOWS:
switch (CPU.getCurrent()) {
case X86_64:
Expand Down Expand Up @@ -81,6 +83,8 @@ public static Pair<CPU, OS> reverse(String input) {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ static String osToConstraint(OS os) {
return "@platforms//os:osx";
case FREEBSD:
return "@platforms//os:freebsd";
case OPENBSD:
return "@platforms//os:openbsd";
case LINUX:
return "@platforms//os:linux";
case WINDOWS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class JniLoader {
switch (OS.getCurrent()) {
case LINUX:
case FREEBSD:
case OPENBSD:
case UNKNOWN:
case DARWIN:
UnixJniLoader.loadJni();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ public static ImmutableList<CToolchain.Feature> getFeaturesToAppearLastInFeature
}

private static String ifLinux(CppPlatform platform, String... lines) {
// Platform `LINUX` also includes FreeBSD.
// Platform `LINUX` also includes FreeBSD and OpenBSD.
return ifTrue(platform == CppPlatform.LINUX, lines);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ private static String getPlatformName() {
return "windows";
case FREEBSD:
return "freebsd";
case OPENBSD:
return "openbsd";
default:
return OS.getCurrent().getCanonicalName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public class CommonCommandOptions extends OptionsBase {
help =
"If true, Bazel picks up host-OS-specific config lines from bazelrc files. For example, "
+ "if the host OS is Linux and you run bazel build, Bazel picks up lines starting "
+ "with build:linux. Supported OS identifiers are linux, macos, windows, and "
+ "freebsd. Enabling this flag is equivalent to using --config=linux on Linux, "
+ "with build:linux. Supported OS identifiers are linux, macos, windows, freebsd, "
+ "and openbsd. Enabling this flag is equivalent to using --config=linux on Linux, "
+ "--config=windows on Windows, etc.")
public boolean enablePlatformSpecificConfig;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/google/devtools/build/lib/util/OS.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
public enum OS {
DARWIN("osx", "Mac OS X"),
FREEBSD("freebsd", "FreeBSD"),
OPENBSD("openbsd", "OpenBSD"),
LINUX("linux", "Linux"),
WINDOWS("windows", "Windows"),
UNKNOWN("unknown", "");

private static final EnumSet<OS> POSIX_COMPATIBLE = EnumSet.of(DARWIN, FREEBSD, LINUX);
private static final EnumSet<OS> POSIX_COMPATIBLE = EnumSet.of(DARWIN, FREEBSD, OPENBSD, LINUX);

private final String canonicalName;
private final String detectionName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ static OsPathPolicy getFilePathOs() {
switch (OS.getCurrent()) {
case LINUX:
case FREEBSD:
case OPENBSD:
case UNKNOWN:
return UnixOsPathPolicy.INSTANCE;
case DARWIN:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public void getShellExecutableUnset() {
.isEqualTo(PathFragment.create("/bin/bash"));
assertThat(determineShellExecutable(OS.FREEBSD, null))
.isEqualTo(PathFragment.create("/usr/local/bin/bash"));
assertThat(determineShellExecutable(OS.OPENBSD, null))
.isEqualTo(PathFragment.create("/usr/local/bin/bash"));
assertThat(determineShellExecutable(OS.WINDOWS, null))
.isEqualTo(PathFragment.create("c:/tools/msys64/usr/bin/bash.exe"));
}
Expand All @@ -45,6 +47,8 @@ public void getShellExecutableIfSet() {
.isEqualTo(PathFragment.create("/bin/bash"));
assertThat(determineShellExecutable(OS.FREEBSD, binBash))
.isEqualTo(PathFragment.create("/bin/bash"));
assertThat(determineShellExecutable(OS.OPENBSD, binBash))
.isEqualTo(PathFragment.create("/bin/bash"));
assertThat(determineShellExecutable(OS.WINDOWS, binBash))
.isEqualTo(PathFragment.create("/bin/bash"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public static Collection createInputValues() {
new Object[] {OS.LINUX, "@platforms//os:linux"},
new Object[] {OS.DARWIN, "@platforms//os:osx"},
new Object[] {OS.FREEBSD, "@platforms//os:freebsd"},
new Object[] {OS.OPENBSD, "@platforms//os:openbsd"},
new Object[] {OS.WINDOWS, "@platforms//os:windows"});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public static void setup(MockToolsConfig mockToolsConfig) throws IOException {
"constraint_value(",
" name = 'freebsd',",
" constraint_setting = ':os',",
")",
"constraint_value(",
" name = 'openbsd',",
" constraint_setting = ':os',",
")");
String basePlatform;
if (TestConstants.LOCAL_CONFIG_PLATFORM_PATH != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ private static ListMultimap<String, RcChunkOfArgs> structuredArgsForDifferentPla
structuredArgs.put("c0:windows", new RcChunkOfArgs("rc1", ImmutableList.of("command_windows")));
structuredArgs.put("c0:macos", new RcChunkOfArgs("rc1", ImmutableList.of("command_macos")));
structuredArgs.put("c0:freebsd", new RcChunkOfArgs("rc1", ImmutableList.of("command_freebsd")));
structuredArgs.put("c0:openbsd", new RcChunkOfArgs("rc1", ImmutableList.of("command_openbsd")));
structuredArgs.put(
"c0:platform_config",
new RcChunkOfArgs("rc1", ImmutableList.of("--enable_platform_specific_config")));
Expand Down Expand Up @@ -328,6 +329,9 @@ public void testExpandConfigOptions_withPlatformSpecificConfigEnabled() throws E
case FREEBSD:
assertThat(parser.getResidue()).containsExactly("command_freebsd");
break;
case OPENBSD:
assertThat(parser.getResidue()).containsExactly("command_openbsd");
break;
default:
assertThat(parser.getResidue()).isEmpty();
}
Expand All @@ -353,6 +357,9 @@ public void testExpandConfigOptions_withPlatformSpecificConfigEnabledInConfig()
case FREEBSD:
assertThat(parser.getResidue()).containsExactly("command_freebsd");
break;
case OPENBSD:
assertThat(parser.getResidue()).containsExactly("command_openbsd");
break;
default:
assertThat(parser.getResidue()).isEmpty();
}
Expand Down
5 changes: 5 additions & 0 deletions tools/jdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ java_runtime_files(
srcs = ["include/freebsd/jni_md.h"],
)

java_runtime_files(
name = "jni_md_header-openbsd",
srcs = ["include/openbsd/jni_md.h"],
)

alias(
name = "java",
actual = "@local_jdk//:java",
Expand Down