Skip to content

Commit

Permalink
Update CI workflow / Bazel build files
Browse files Browse the repository at this point in the history
  • Loading branch information
eustas committed Dec 31, 2023
1 parent fef82ea commit 3ea8c52
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 101 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
14 changes: 7 additions & 7 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ jobs:
cxx_compiler: g++
os: macos-latest

- name: cmake-win64:msvc2019-rel
- name: cmake-win64:msvc-rel
build_system: cmake
cmake_generator: Visual Studio 16 2019
cmake_generator: Visual Studio 17 2022
cmake_config: Release
os: windows-2019
os: windows-latest

- name: cmake-win64:msvc2019-dbg
- name: cmake-win64:msvc-dbg
build_system: cmake
cmake_generator: Visual Studio 16 2019
cmake_generator: Visual Studio 17 2022
cmake_config: Debug
os: windows-2019
os: windows-latest

- name: fuzz:clang15
build_system: fuzz
Expand Down 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_java//org/brotli/wrapper/dec:__pkg__"],
)

filegroup(
name = "test_corpus",
srcs = ["test_corpus.zip"],
visibility = [
"//org/brotli/wrapper/enc:__pkg__",
],
visibility = ["@org_brotli_java//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.
}
}
4 changes: 3 additions & 1 deletion java/org/brotli/integration/BundleChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ public static void main(String[] args) throws FileNotFoundException {
throw new RuntimeException("Usage: BundleChecker [-s] <fileX.zip> ...");
}
for (int i = argsOffset; i < args.length; ++i) {
new BundleChecker(new FileInputStream(args[i]), new AtomicInteger(0), sanityCheck).run();
String bundleArg = args[i];
String bundlePath = new java.io.File(bundleArg).getAbsolutePath();
new BundleChecker(new FileInputStream(bundlePath), new AtomicInteger(0), sanityCheck).run();
}
}
}
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

0 comments on commit 3ea8c52

Please sign in to comment.