Skip to content

Commit

Permalink
Fix bazel build
Browse files Browse the repository at this point in the history
Drive-by: simplify constraints
  • Loading branch information
eustas committed Dec 29, 2023
1 parent fef82ea commit 2cb6ad2
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 98 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ tests/testdata/* binary
BUILD.bazel !export-ignore
CHANGELOG.md !export-ignore
CMakeLists.txt !export-ignore
compiler_config_setting.bzl !export-ignore
CONTRIBUTING.md !export-ignore
LICENSE !export-ignore
MANIFEST.in !export-ignore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ jobs:
run: |
cd ${GITHUB_WORKSPACE}/${{ matrix.bazel_project }}
bazelisk query "tests(...)" --output=label > ${RUNNER_TEMP}/tests.lst
[ -s ${RUNNER_TEMP}/tests.lst ] && bazelisk test -c opt ...:all
[ -s ${RUNNER_TEMP}/tests.lst ] && bazelisk test -c opt ...:all --test_output=errors
bazelisk clean
- name: Build / Test with Maven
Expand Down
34 changes: 8 additions & 26 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Description:
# Brotli is a generic-purpose lossless compression algorithm.

load(":compiler_config_setting.bzl", "create_msvc_config")

package(
default_visibility = ["//visibility:public"],
)
Expand All @@ -12,37 +10,21 @@ licenses(["notice"]) # MIT
exports_files(["LICENSE"])

config_setting(
name = "darwin",
values = {"cpu": "darwin"},
visibility = ["//visibility:public"],
)

config_setting(
name = "darwin_x86_64",
values = {"cpu": "darwin_x86_64"},
visibility = ["//visibility:public"],
)

config_setting(
name = "windows",
values = {"cpu": "x64_windows"},
name = "clang-cl",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "clang-cl",
},
visibility = ["//visibility:public"],
)

config_setting(
name = "windows_msvc",
values = {"cpu": "x64_windows_msvc"},
name = "msvc",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "msvc-cl",
},
visibility = ["//visibility:public"],
)

config_setting(
name = "windows_msys",
values = {"cpu": "x64_windows_msys"},
visibility = ["//visibility:public"],
)

create_msvc_config()

STRICT_C_OPTIONS = select({
":msvc": [],
":clang-cl": [
Expand Down
40 changes: 0 additions & 40 deletions compiler_config_setting.bzl

This file was deleted.

14 changes: 7 additions & 7 deletions go/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_go",
sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f",
sha256 = "c8035e8ae248b56040a65ad3f0b7434712e2037e5dfdcebfe97576e620422709",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.44.0/rules_go-v0.44.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.44.0/rules_go-v0.44.0.zip",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.17.1")
go_register_toolchains(version = "1.21.5")

http_archive(
name = "bazel_gazelle",
sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
sha256 = "b7387f72efb59f876e4daae42f1d3912d0d45563eac7cb23d1de0b094ab588cf",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
],
)

Expand Down
40 changes: 35 additions & 5 deletions java/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@ package(
default_visibility = ["//visibility:public"],
)

config_setting(
name = "darwin",
values = {"cpu": "darwin"},
visibility = ["//visibility:public"],
)

config_setting(
name = "darwin_x86_64",
values = {"cpu": "darwin_x86_64"},
visibility = ["//visibility:public"],
)

config_setting(
name = "windows",
values = {"cpu": "x64_windows"},
visibility = ["//visibility:public"],
)

config_setting(
name = "windows_msvc",
values = {"cpu": "x64_windows_msvc"},
visibility = ["//visibility:public"],
)

config_setting(
name = "windows_msys",
values = {"cpu": "x64_windows_msys"},
visibility = ["//visibility:public"],
)

# >>> JNI headers

genrule(
Expand All @@ -14,11 +44,11 @@ genrule(
genrule(
name = "copy_link_jni_md_header",
srcs = select({
"@org_brotli//:darwin": ["@openjdk_macosx_jni_md_h//file"],
"@org_brotli//:darwin_x86_64": ["@openjdk_macosx_jni_md_h//file"],
"@org_brotli//:windows_msys": ["@openjdk_windows_jni_md_h//file"],
"@org_brotli//:windows_msvc": ["@openjdk_windows_jni_md_h//file"],
"@org_brotli//:windows": ["@openjdk_windows_jni_md_h//file"],
":darwin": ["@openjdk_macosx_jni_md_h//file"],
":darwin_x86_64": ["@openjdk_macosx_jni_md_h//file"],
":windows_msys": ["@openjdk_windows_jni_md_h//file"],
":windows_msvc": ["@openjdk_windows_jni_md_h//file"],
":windows": ["@openjdk_windows_jni_md_h//file"],
"//conditions:default": ["@openjdk_solaris_jni_md_h//file"],
}),
outs = ["jni/jni_md.h"],
Expand Down
21 changes: 11 additions & 10 deletions java/org/brotli/integration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ java_binary(

java_test(
name = "bundle_checker_data_test",
args = ["org/brotli/integration/test_data.zip"],
data = ["test_data.zip"],
args = ["$(location :test_data)"],
data = [":test_data"],
main_class = "org.brotli.integration.BundleChecker",
use_testrunner = 0,
runtime_deps = [":bundle_checker"],
Expand All @@ -48,26 +48,27 @@ java_test(
name = "bundle_checker_fuzz_test",
args = [
"-s",
"org/brotli/integration/fuzz_data.zip",
"$(location :fuzz_data)",
],
data = ["fuzz_data.zip"],
data = [":fuzz_data"],
main_class = "org.brotli.integration.BundleChecker",
use_testrunner = 0,
runtime_deps = [":bundle_checker"],
)

filegroup(
name = "fuzz_data",
srcs = ["fuzz_data.zip"],
visibility = ["//visibility:private"],
)
filegroup(
name = "test_data",
srcs = ["test_data.zip"],
visibility = [
"//org/brotli/wrapper/dec:__pkg__",
],
visibility = ["//org/brotli/wrapper/dec:__pkg__"],
)

filegroup(
name = "test_corpus",
srcs = ["test_corpus.zip"],
visibility = [
"//org/brotli/wrapper/enc:__pkg__",
],
visibility = ["//org/brotli/wrapper/enc:__pkg__"],
)
9 changes: 9 additions & 0 deletions java/org/brotli/integration/BrotliJniTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,13 @@ public class BrotliJniTestBase {
System.load(new java.io.File(jniLibrary).getAbsolutePath());
}
}

/**
* Makes sure this class is initialized.
*
* Invoking this is an alternative to extending this class.
*/
public static void init() {
// Do nothing, just force `<clinit>` execution, if necessary.
}
}
2 changes: 1 addition & 1 deletion java/org/brotli/wrapper/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ filegroup(

filegroup(
name = "brotli_jni_no_dictionary_data",
srcs = ["//:brotli_jni_no_dictionary_data.dll"],
srcs = ["@org_brotli_java//:brotli_jni_no_dictionary_data.dll"],
)

java_library(
Expand Down
2 changes: 1 addition & 1 deletion java/org/brotli/wrapper/dec/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ java_library(

filegroup(
name = "brotli_jni",
srcs = ["//:brotli_jni.dll"],
srcs = ["@org_brotli_java//:brotli_jni.dll"],
)

filegroup(
Expand Down
2 changes: 1 addition & 1 deletion java/org/brotli/wrapper/enc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ filegroup(

filegroup(
name = "brotli_jni",
srcs = ["//:brotli_jni.dll"],
srcs = ["@org_brotli_java//:brotli_jni.dll"],
)

java_library(
Expand Down
4 changes: 3 additions & 1 deletion java/org/brotli/wrapper/enc/EncoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.brotli.integration.BundleHelper;
import org.brotli.wrapper.dec.BrotliInputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -17,13 +18,14 @@

/** Tests for {@link org.brotli.wrapper.enc.Encoder}. */
@RunWith(AllTests.class)
public class EncoderTest extends BrotliJniTestBase {
public class EncoderTest extends TestCase {
static InputStream getBundle() throws IOException {
return new FileInputStream(System.getProperty("TEST_BUNDLE"));
}

/** Creates a test suite. */
public static TestSuite suite() throws IOException {
BrotliJniTestBase.init();
TestSuite suite = new TestSuite();
InputStream bundle = getBundle();
try {
Expand Down
8 changes: 4 additions & 4 deletions js/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_closure",
sha256 = "d66deed38a0bb20581c15664f0ab62270af5940786855c7adc3087b27168b529",
strip_prefix = "rules_closure-0.11.0",
sha256 = "9498e57368efb82b985db1ed426a767cbf1ba0398fd7aed632fc3908654e1b1e",
strip_prefix = "rules_closure-0.12.0",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/0.11.0.tar.gz",
"https://github.com/bazelbuild/rules_closure/archive/0.11.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/0.12.0.tar.gz",
"https://github.com/bazelbuild/rules_closure/archive/0.12.0.tar.gz",
],
)

Expand Down

0 comments on commit 2cb6ad2

Please sign in to comment.