From 70e7b1ae4a3f3cd0009cbcc81e66330780c16653 Mon Sep 17 00:00:00 2001 From: Evgenii Kliuchnikov Date: Thu, 6 Jul 2023 11:56:38 +0000 Subject: simplify building of fuzzer PiperOrigin-RevId: 545950923 --- .github/workflows/build_test.yml | 15 ++- .github/workflows/codeql.yml | 4 + .github/workflows/fuzz.yml | 5 + .github/workflows/release.yaml | 4 + .github/workflows/scorecard.yml | 4 + BUILD | 159 ----------------------------- BUILD.bazel | 159 +++++++++++++++++++++++++++++ WORKSPACE | 21 ---- WORKSPACE.bazel | 26 +++++ c/fuzz/.bazelrc | 18 ++++ c/fuzz/BUILD.bazel | 12 +++ c/fuzz/WORKSPACE.bazel | 0 go/BUILD | 2 - go/BUILD.bazel | 2 + go/WORKSPACE | 36 ------- go/WORKSPACE.bazel | 36 +++++++ go/cbrotli/BUILD | 26 ----- go/cbrotli/BUILD.bazel | 26 +++++ java/BUILD | 93 ----------------- java/BUILD.bazel | 93 +++++++++++++++++ java/WORKSPACE | 56 ---------- java/WORKSPACE.bazel | 56 ++++++++++ java/org/brotli/common/BUILD | 11 -- java/org/brotli/common/BUILD.bazel | 11 ++ java/org/brotli/dec/BUILD | 62 ----------- java/org/brotli/dec/BUILD.bazel | 62 +++++++++++ java/org/brotli/enc/BUILD | 14 --- java/org/brotli/enc/BUILD.bazel | 14 +++ java/org/brotli/integration/BUILD | 73 ------------- java/org/brotli/integration/BUILD.bazel | 73 +++++++++++++ java/org/brotli/wrapper/common/BUILD | 61 ----------- java/org/brotli/wrapper/common/BUILD.bazel | 61 +++++++++++ java/org/brotli/wrapper/dec/BUILD | 103 ------------------- java/org/brotli/wrapper/dec/BUILD.bazel | 103 +++++++++++++++++++ java/org/brotli/wrapper/enc/BUILD | 95 ----------------- java/org/brotli/wrapper/enc/BUILD.bazel | 95 +++++++++++++++++ js/BUILD | 84 --------------- js/BUILD.bazel | 84 +++++++++++++++ js/WORKSPACE | 17 --- js/WORKSPACE.bazel | 17 +++ research/BUILD | 42 -------- research/BUILD.bazel | 42 ++++++++ research/WORKSPACE | 32 ------ research/WORKSPACE.bazel | 32 ++++++ 44 files changed, 1052 insertions(+), 989 deletions(-) delete mode 100644 BUILD create mode 100644 BUILD.bazel delete mode 100644 WORKSPACE create mode 100644 WORKSPACE.bazel create mode 100644 c/fuzz/.bazelrc create mode 100644 c/fuzz/BUILD.bazel create mode 100644 c/fuzz/WORKSPACE.bazel delete mode 100644 go/BUILD create mode 100644 go/BUILD.bazel delete mode 100644 go/WORKSPACE create mode 100644 go/WORKSPACE.bazel delete mode 100644 go/cbrotli/BUILD create mode 100644 go/cbrotli/BUILD.bazel delete mode 100644 java/BUILD create mode 100644 java/BUILD.bazel delete mode 100644 java/WORKSPACE create mode 100644 java/WORKSPACE.bazel delete mode 100644 java/org/brotli/common/BUILD create mode 100644 java/org/brotli/common/BUILD.bazel delete mode 100644 java/org/brotli/dec/BUILD create mode 100644 java/org/brotli/dec/BUILD.bazel delete mode 100644 java/org/brotli/enc/BUILD create mode 100644 java/org/brotli/enc/BUILD.bazel delete mode 100644 java/org/brotli/integration/BUILD create mode 100644 java/org/brotli/integration/BUILD.bazel delete mode 100644 java/org/brotli/wrapper/common/BUILD create mode 100644 java/org/brotli/wrapper/common/BUILD.bazel delete mode 100644 java/org/brotli/wrapper/dec/BUILD create mode 100644 java/org/brotli/wrapper/dec/BUILD.bazel delete mode 100644 java/org/brotli/wrapper/enc/BUILD create mode 100644 java/org/brotli/wrapper/enc/BUILD.bazel delete mode 100644 js/BUILD create mode 100644 js/BUILD.bazel delete mode 100644 js/WORKSPACE create mode 100644 js/WORKSPACE.bazel delete mode 100644 research/BUILD create mode 100644 research/BUILD.bazel delete mode 100644 research/WORKSPACE create mode 100644 research/WORKSPACE.bazel diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 31bcd64..590a54a 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -13,6 +13,10 @@ on: pull_request: types: [opened, reopened, labeled, synchronize] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: ubuntu_build: name: Build and test ${{ matrix.name }} @@ -288,8 +292,15 @@ jobs: - name: Quick Fuzz if: ${{ matrix.build_system == 'fuzz' }} run: | - export ASAN_OPTIONS=detect_leaks=0 - ./c/fuzz/test_fuzzer.sh + mkdir ${RUNNER_TEMP}/decode_corpora + unzip java/org/brotli/integration/fuzz_data.zip -d ${RUNNER_TEMP}/decode_corpora + cd ${GITHUB_WORKSPACE}/c/fuzz + bazelisk build --config=asan-libfuzzer :decode_fuzzer + for f in `ls ${RUNNER_TEMP}/decode_corpora` + do + echo "Testing $f" + ./bazel-bin/decode_fuzzer_bin ${RUNNER_TEMP}/decode_corpora/$f + done - name: Build with Bazel if: ${{ matrix.build_system == 'bazel' }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1df6419..fad20e2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,6 +9,10 @@ on: schedule: - cron: '18 15 * * 0' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: analyze: name: Analyze diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 77188ab..78e71e3 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -7,6 +7,11 @@ name: CIFuzz on: [pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: Fuzzing: runs-on: ubuntu-latest diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 967d5f6..0f2be31 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,6 +14,10 @@ on: release: types: [ published ] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: windows_build: name: Windows Build (vcpkg / ${{ matrix.triplet }}) diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index a71f9f8..9b544e6 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -14,6 +14,10 @@ on: push: branches: [ "master" ] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + # Declare default permissions as read only. permissions: read-all diff --git a/BUILD b/BUILD deleted file mode 100644 index 34e4a54..0000000 --- a/BUILD +++ /dev/null @@ -1,159 +0,0 @@ -# Description: -# Brotli is a generic-purpose lossless compression algorithm. - -load(":compiler_config_setting.bzl", "create_msvc_config") - -package( - default_visibility = ["//visibility:public"], -) - -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"}, - 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"], -) - -create_msvc_config() - -STRICT_C_OPTIONS = select({ - ":msvc": [], - ":clang-cl": [ - "/W4", - "-Wconversion", - "-Wlong-long", - "-Wmissing-declarations", - "-Wmissing-prototypes", - "-Wno-strict-aliasing", - "-Wshadow", - "-Wsign-compare", - "-Wno-sign-conversion", - ], - "//conditions:default": [ - "--pedantic-errors", - "-Wall", - "-Wconversion", - "-Werror", - "-Wextra", - "-Wlong-long", - "-Wmissing-declarations", - "-Wmissing-prototypes", - "-Wno-strict-aliasing", - "-Wshadow", - "-Wsign-compare", - ], -}) - -filegroup( - name = "public_headers", - srcs = glob(["c/include/brotli/*.h"]), -) - -filegroup( - name = "common_headers", - srcs = glob(["c/common/*.h"]), -) - -filegroup( - name = "common_sources", - srcs = glob(["c/common/*.c"]), -) - -filegroup( - name = "dec_headers", - srcs = glob(["c/dec/*.h"]), -) - -filegroup( - name = "dec_sources", - srcs = glob(["c/dec/*.c"]), -) - -filegroup( - name = "enc_headers", - srcs = glob(["c/enc/*.h"]), -) - -filegroup( - name = "enc_sources", - srcs = glob(["c/enc/*.c"]), -) - -cc_library( - name = "brotli_inc", - hdrs = [":public_headers"], - copts = STRICT_C_OPTIONS, - strip_include_prefix = "c/include", -) - -cc_library( - name = "brotlicommon", - srcs = [":common_sources"], - hdrs = [":common_headers"], - copts = STRICT_C_OPTIONS, - deps = [":brotli_inc"], -) - -cc_library( - name = "brotlidec", - srcs = [":dec_sources"], - hdrs = [":dec_headers"], - copts = STRICT_C_OPTIONS, - deps = [":brotlicommon"], -) - -cc_library( - name = "brotlienc", - srcs = [":enc_sources"], - hdrs = [":enc_headers"], - copts = STRICT_C_OPTIONS, - linkopts = select({ - ":clang-cl": [], - ":msvc": [], - "//conditions:default": ["-lm"], - }), - deps = [":brotlicommon"], -) - -cc_binary( - name = "brotli", - srcs = ["c/tools/brotli.c"], - copts = STRICT_C_OPTIONS, - linkstatic = 1, - deps = [ - ":brotlidec", - ":brotlienc", - ], -) - -filegroup( - name = "dictionary", - srcs = ["c/common/dictionary.bin"], -) diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..34e4a54 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,159 @@ +# Description: +# Brotli is a generic-purpose lossless compression algorithm. + +load(":compiler_config_setting.bzl", "create_msvc_config") + +package( + default_visibility = ["//visibility:public"], +) + +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"}, + 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"], +) + +create_msvc_config() + +STRICT_C_OPTIONS = select({ + ":msvc": [], + ":clang-cl": [ + "/W4", + "-Wconversion", + "-Wlong-long", + "-Wmissing-declarations", + "-Wmissing-prototypes", + "-Wno-strict-aliasing", + "-Wshadow", + "-Wsign-compare", + "-Wno-sign-conversion", + ], + "//conditions:default": [ + "--pedantic-errors", + "-Wall", + "-Wconversion", + "-Werror", + "-Wextra", + "-Wlong-long", + "-Wmissing-declarations", + "-Wmissing-prototypes", + "-Wno-strict-aliasing", + "-Wshadow", + "-Wsign-compare", + ], +}) + +filegroup( + name = "public_headers", + srcs = glob(["c/include/brotli/*.h"]), +) + +filegroup( + name = "common_headers", + srcs = glob(["c/common/*.h"]), +) + +filegroup( + name = "common_sources", + srcs = glob(["c/common/*.c"]), +) + +filegroup( + name = "dec_headers", + srcs = glob(["c/dec/*.h"]), +) + +filegroup( + name = "dec_sources", + srcs = glob(["c/dec/*.c"]), +) + +filegroup( + name = "enc_headers", + srcs = glob(["c/enc/*.h"]), +) + +filegroup( + name = "enc_sources", + srcs = glob(["c/enc/*.c"]), +) + +cc_library( + name = "brotli_inc", + hdrs = [":public_headers"], + copts = STRICT_C_OPTIONS, + strip_include_prefix = "c/include", +) + +cc_library( + name = "brotlicommon", + srcs = [":common_sources"], + hdrs = [":common_headers"], + copts = STRICT_C_OPTIONS, + deps = [":brotli_inc"], +) + +cc_library( + name = "brotlidec", + srcs = [":dec_sources"], + hdrs = [":dec_headers"], + copts = STRICT_C_OPTIONS, + deps = [":brotlicommon"], +) + +cc_library( + name = "brotlienc", + srcs = [":enc_sources"], + hdrs = [":enc_headers"], + copts = STRICT_C_OPTIONS, + linkopts = select({ + ":clang-cl": [], + ":msvc": [], + "//conditions:default": ["-lm"], + }), + deps = [":brotlicommon"], +) + +cc_binary( + name = "brotli", + srcs = ["c/tools/brotli.c"], + copts = STRICT_C_OPTIONS, + linkstatic = 1, + deps = [ + ":brotlidec", + ":brotlienc", + ], +) + +filegroup( + name = "dictionary", + srcs = ["c/common/dictionary.bin"], +) diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index 75f3768..0000000 --- a/WORKSPACE +++ /dev/null @@ -1,21 +0,0 @@ -workspace(name = "org_brotli") - -local_repository( - name = "ignore_org_brotli_go", - path = "go", -) - -local_repository( - name = "ignore_org_brotli_java", - path = "java", -) - -local_repository( - name = "ignore_org_brotli_js", - path = "js", -) - -local_repository( - name = "ignore_org_brotli_research", - path = "research", -) diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel new file mode 100644 index 0000000..c26ddf8 --- /dev/null +++ b/WORKSPACE.bazel @@ -0,0 +1,26 @@ +workspace(name = "org_brotli") + +local_repository( + name = "ignore_org_brotli_fuzz", + path = "c/fuzz", +) + +local_repository( + name = "ignore_org_brotli_go", + path = "go", +) + +local_repository( + name = "ignore_org_brotli_java", + path = "java", +) + +local_repository( + name = "ignore_org_brotli_js", + path = "js", +) + +local_repository( + name = "ignore_org_brotli_research", + path = "research", +) diff --git a/c/fuzz/.bazelrc b/c/fuzz/.bazelrc new file mode 100644 index 0000000..243942a --- /dev/null +++ b/c/fuzz/.bazelrc @@ -0,0 +1,18 @@ +# Force the use of Clang for C++ builds. +build --action_env=CC=clang +build --action_env=CXX=clang++ + +# Define the --config=asan-libfuzzer configuration. +build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer +build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer +build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan + +# Define the --config=msan-libfuzzer configuration. +build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer +build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer +build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=msan + +# Define the --config=ubsan-libfuzzer configuration. +build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer +build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer +build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=ubsan diff --git a/c/fuzz/BUILD.bazel b/c/fuzz/BUILD.bazel new file mode 100644 index 0000000..7f56d96 --- /dev/null +++ b/c/fuzz/BUILD.bazel @@ -0,0 +1,12 @@ +load("@rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzz_test") + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # MIT + +# To start fuzzing run: bazel run --config=asan-libfuzzer //:fuzz_config_run +cc_fuzz_test( + name = "decode_fuzzer", + srcs = ["decode_fuzzer.c"], + deps = ["@org_brotli//:brotlidec"], +) diff --git a/c/fuzz/WORKSPACE.bazel b/c/fuzz/WORKSPACE.bazel new file mode 100644 index 0000000..e69de29 diff --git a/go/BUILD b/go/BUILD deleted file mode 100644 index 72a5317..0000000 --- a/go/BUILD +++ /dev/null @@ -1,2 +0,0 @@ -# Description: -# cbrotli is a CGo wrapper for Brotli, a generic-purpose lossless compression algorithm. diff --git a/go/BUILD.bazel b/go/BUILD.bazel new file mode 100644 index 0000000..72a5317 --- /dev/null +++ b/go/BUILD.bazel @@ -0,0 +1,2 @@ +# Description: +# cbrotli is a CGo wrapper for Brotli, a generic-purpose lossless compression algorithm. diff --git a/go/WORKSPACE b/go/WORKSPACE deleted file mode 100644 index 570e250..0000000 --- a/go/WORKSPACE +++ /dev/null @@ -1,36 +0,0 @@ -workspace(name = "org_brotli_go") - -local_repository( - name = "org_brotli", - path = "..", -) - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "io_bazel_rules_go", - sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f", - 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", - ], -) - -load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") - -go_rules_dependencies() - -go_register_toolchains(version = "1.17.1") - -http_archive( - name = "bazel_gazelle", - sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb", - 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", - ], -) - -load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") - -gazelle_dependencies() diff --git a/go/WORKSPACE.bazel b/go/WORKSPACE.bazel new file mode 100644 index 0000000..570e250 --- /dev/null +++ b/go/WORKSPACE.bazel @@ -0,0 +1,36 @@ +workspace(name = "org_brotli_go") + +local_repository( + name = "org_brotli", + path = "..", +) + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "io_bazel_rules_go", + sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f", + 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", + ], +) + +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") + +go_rules_dependencies() + +go_register_toolchains(version = "1.17.1") + +http_archive( + name = "bazel_gazelle", + sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb", + 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", + ], +) + +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") + +gazelle_dependencies() diff --git a/go/cbrotli/BUILD b/go/cbrotli/BUILD deleted file mode 100644 index 78ad36c..0000000 --- a/go/cbrotli/BUILD +++ /dev/null @@ -1,26 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # MIT - -go_library( - name = "cbrotli", - srcs = [ - "reader.go", - "writer.go", - ], - cdeps = [ - "@org_brotli//:brotlidec", - "@org_brotli//:brotlienc", - ], - cgo = True, - importpath = "github.com/google/brotli/go/cbrotli", -) - -go_test( - name = "cbrotli_test", - size = "small", - srcs = ["cbrotli_test.go"], - embed = [":cbrotli"], -) diff --git a/go/cbrotli/BUILD.bazel b/go/cbrotli/BUILD.bazel new file mode 100644 index 0000000..78ad36c --- /dev/null +++ b/go/cbrotli/BUILD.bazel @@ -0,0 +1,26 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # MIT + +go_library( + name = "cbrotli", + srcs = [ + "reader.go", + "writer.go", + ], + cdeps = [ + "@org_brotli//:brotlidec", + "@org_brotli//:brotlienc", + ], + cgo = True, + importpath = "github.com/google/brotli/go/cbrotli", +) + +go_test( + name = "cbrotli_test", + size = "small", + srcs = ["cbrotli_test.go"], + embed = [":cbrotli"], +) diff --git a/java/BUILD b/java/BUILD deleted file mode 100644 index 0ae6c15..0000000 --- a/java/BUILD +++ /dev/null @@ -1,93 +0,0 @@ -package( - default_visibility = ["//visibility:public"], -) - -# >>> JNI headers - -genrule( - name = "copy_link_jni_header", - srcs = ["@openjdk_jni_h//file"], - outs = ["jni/jni.h"], - cmd = "cp -f $< $@", -) - -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"], - "//conditions:default": ["@openjdk_solaris_jni_md_h//file"], - }), - outs = ["jni/jni_md.h"], - cmd = "cp -f $< $@", -) - -cc_library( - name = "jni_inc", - hdrs = [ - ":jni/jni.h", - ":jni/jni_md.h", - ], - includes = ["jni"], -) - -# <<< JNI headers - -genrule( - name = "license", - srcs = ["@org_brotli//:LICENSE"], - outs = ["META-INF/LICENSE"], - cmd = "cp -f $< $@", -) - -######################################################## -# WARNING: do not (transitively) depend on this target! -######################################################## -cc_binary( - name = "brotli_jni.dll", - srcs = [ - "//org/brotli/wrapper/common:jni_src", - "//org/brotli/wrapper/dec:jni_src", - "//org/brotli/wrapper/enc:jni_src", - "@org_brotli//:common_headers", - "@org_brotli//:common_sources", - "@org_brotli//:dec_headers", - "@org_brotli//:dec_sources", - "@org_brotli//:enc_headers", - "@org_brotli//:enc_sources", - ], - linkshared = 1, - deps = [ - ":jni_inc", - "@org_brotli//:brotli_inc", - ], -) - -######################################################## -# WARNING: do not (transitively) depend on this target! -######################################################## -cc_binary( - name = "brotli_jni_no_dictionary_data.dll", - srcs = [ - "//org/brotli/wrapper/common:jni_src", - "//org/brotli/wrapper/dec:jni_src", - "//org/brotli/wrapper/enc:jni_src", - "@org_brotli//:common_headers", - "@org_brotli//:common_sources", - "@org_brotli//:dec_headers", - "@org_brotli//:dec_sources", - "@org_brotli//:enc_headers", - "@org_brotli//:enc_sources", - ], - defines = [ - "BROTLI_EXTERNAL_DICTIONARY_DATA=", - ], - linkshared = 1, - deps = [ - ":jni_inc", - "@org_brotli//:brotli_inc", - ], -) diff --git a/java/BUILD.bazel b/java/BUILD.bazel new file mode 100644 index 0000000..0ae6c15 --- /dev/null +++ b/java/BUILD.bazel @@ -0,0 +1,93 @@ +package( + default_visibility = ["//visibility:public"], +) + +# >>> JNI headers + +genrule( + name = "copy_link_jni_header", + srcs = ["@openjdk_jni_h//file"], + outs = ["jni/jni.h"], + cmd = "cp -f $< $@", +) + +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"], + "//conditions:default": ["@openjdk_solaris_jni_md_h//file"], + }), + outs = ["jni/jni_md.h"], + cmd = "cp -f $< $@", +) + +cc_library( + name = "jni_inc", + hdrs = [ + ":jni/jni.h", + ":jni/jni_md.h", + ], + includes = ["jni"], +) + +# <<< JNI headers + +genrule( + name = "license", + srcs = ["@org_brotli//:LICENSE"], + outs = ["META-INF/LICENSE"], + cmd = "cp -f $< $@", +) + +######################################################## +# WARNING: do not (transitively) depend on this target! +######################################################## +cc_binary( + name = "brotli_jni.dll", + srcs = [ + "//org/brotli/wrapper/common:jni_src", + "//org/brotli/wrapper/dec:jni_src", + "//org/brotli/wrapper/enc:jni_src", + "@org_brotli//:common_headers", + "@org_brotli//:common_sources", + "@org_brotli//:dec_headers", + "@org_brotli//:dec_sources", + "@org_brotli//:enc_headers", + "@org_brotli//:enc_sources", + ], + linkshared = 1, + deps = [ + ":jni_inc", + "@org_brotli//:brotli_inc", + ], +) + +######################################################## +# WARNING: do not (transitively) depend on this target! +######################################################## +cc_binary( + name = "brotli_jni_no_dictionary_data.dll", + srcs = [ + "//org/brotli/wrapper/common:jni_src", + "//org/brotli/wrapper/dec:jni_src", + "//org/brotli/wrapper/enc:jni_src", + "@org_brotli//:common_headers", + "@org_brotli//:common_sources", + "@org_brotli//:dec_headers", + "@org_brotli//:dec_sources", + "@org_brotli//:enc_headers", + "@org_brotli//:enc_sources", + ], + defines = [ + "BROTLI_EXTERNAL_DICTIONARY_DATA=", + ], + linkshared = 1, + deps = [ + ":jni_inc", + "@org_brotli//:brotli_inc", + ], +) diff --git a/java/WORKSPACE b/java/WORKSPACE deleted file mode 100644 index 3ac9d4b..0000000 --- a/java/WORKSPACE +++ /dev/null @@ -1,56 +0,0 @@ -workspace(name = "org_brotli_java") - -local_repository( - name = "org_brotli", - path = "..", -) - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") - -RULES_JVM_EXTERNAL_TAG = "4.0" -RULES_JVM_EXTERNAL_SHA = "31701ad93dbfe544d597dbe62c9a1fdd76d81d8a9150c2bf1ecf928ecdf97169" - -http_archive( - name = "rules_jvm_external", - strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, - sha256 = RULES_JVM_EXTERNAL_SHA, - url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, -) - -load("@rules_jvm_external//:defs.bzl", "maven_install") - -maven_install( - artifacts = ["junit:junit:4.12"], - repositories = [ - "https://maven.google.com", - "https://repo1.maven.org/maven2", - ], -) - -http_file( - name = "openjdk_jni_h", - downloaded_file_path = "jni.h", - urls = ["https://hg.openjdk.java.net/jdk8/jdk8/jdk/raw-file/687fd7c7986d/src/share/javavm/export/jni.h"], - sha256 = "ed99792df48670072b78028faf704a8dcb6868fe140ccc7eced9b01dfa62fef4", -) - -http_file( - name = "openjdk_solaris_jni_md_h", - downloaded_file_path = "jni_md.h", - urls = ["https://hg.openjdk.java.net/jdk8/jdk8/jdk/raw-file/687fd7c7986d/src/solaris/javavm/export/jni_md.h"], - sha256 = "ecbe6944fe1a4290644d5a6b3c8f68576798a53b9da12cd31c58c48569595ff7", -) - -http_file( - name = "openjdk_macosx_jni_md_h", - downloaded_file_path = "jni_md.h", - urls = ["https://hg.openjdk.java.net/jdk8/jdk8/jdk/raw-file/687fd7c7986d/src/macosx/javavm/export/jni_md.h"], - sha256 = "8f718071022e7e7f2fc9a229984b7e83582db91ed83861b49ce1461436fe8dc4", -) - -http_file( - name = "openjdk_windows_jni_md_h", - downloaded_file_path = "jni_md.h", - urls = ["https://hg.openjdk.java.net/jdk8/jdk8/jdk/raw-file/687fd7c7986d/src/windows/javavm/export/jni_md.h"], - sha256 = "5479fb385ea1e11619f5c0cdfd9ccb3ea3a3fea0f5bc6176fb3ce62be29d759b", -) diff --git a/java/WORKSPACE.bazel b/java/WORKSPACE.bazel new file mode 100644 index 0000000..3ac9d4b --- /dev/null +++ b/java/WORKSPACE.bazel @@ -0,0 +1,56 @@ +workspace(name = "org_brotli_java") + +local_repository( + name = "org_brotli", + path = "..", +) + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") + +RULES_JVM_EXTERNAL_TAG = "4.0" +RULES_JVM_EXTERNAL_SHA = "31701ad93dbfe544d597dbe62c9a1fdd76d81d8a9150c2bf1ecf928ecdf97169" + +http_archive( + name = "rules_jvm_external", + strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, + sha256 = RULES_JVM_EXTERNAL_SHA, + url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, +) + +load("@rules_jvm_external//:defs.bzl", "maven_install") + +maven_install( + artifacts = ["junit:junit:4.12"], + repositories = [ + "https://maven.google.com", + "https://repo1.maven.org/maven2", + ], +) + +http_file( + name = "openjdk_jni_h", + downloaded_file_path = "jni.h", + urls = ["https://hg.openjdk.java.net/jdk8/jdk8/jdk/raw-file/687fd7c7986d/src/share/javavm/export/jni.h"], + sha256 = "ed99792df48670072b78028faf704a8dcb6868fe140ccc7eced9b01dfa62fef4", +) + +http_file( + name = "openjdk_solaris_jni_md_h", + downloaded_file_path = "jni_md.h", + urls = ["https://hg.openjdk.java.net/jdk8/jdk8/jdk/raw-file/687fd7c7986d/src/solaris/javavm/export/jni_md.h"], + sha256 = "ecbe6944fe1a4290644d5a6b3c8f68576798a53b9da12cd31c58c48569595ff7", +) + +http_file( + name = "openjdk_macosx_jni_md_h", + downloaded_file_path = "jni_md.h", + urls = ["https://hg.openjdk.java.net/jdk8/jdk8/jdk/raw-file/687fd7c7986d/src/macosx/javavm/export/jni_md.h"], + sha256 = "8f718071022e7e7f2fc9a229984b7e83582db91ed83861b49ce1461436fe8dc4", +) + +http_file( + name = "openjdk_windows_jni_md_h", + downloaded_file_path = "jni_md.h", + urls = ["https://hg.openjdk.java.net/jdk8/jdk8/jdk/raw-file/687fd7c7986d/src/windows/javavm/export/jni_md.h"], + sha256 = "5479fb385ea1e11619f5c0cdfd9ccb3ea3a3fea0f5bc6176fb3ce62be29d759b", +) diff --git a/java/org/brotli/common/BUILD b/java/org/brotli/common/BUILD deleted file mode 100644 index 771b1e3..0000000 --- a/java/org/brotli/common/BUILD +++ /dev/null @@ -1,11 +0,0 @@ -# Description: -# Java port of Brotli. - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # MIT - -java_library( - name = "shared_dictionary", - srcs = ["SharedDictionaryType.java"], -) diff --git a/java/org/brotli/common/BUILD.bazel b/java/org/brotli/common/BUILD.bazel new file mode 100644 index 0000000..771b1e3 --- /dev/null +++ b/java/org/brotli/common/BUILD.bazel @@ -0,0 +1,11 @@ +# Description: +# Java port of Brotli. + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # MIT + +java_library( + name = "shared_dictionary", + srcs = ["SharedDictionaryType.java"], +) diff --git a/java/org/brotli/dec/BUILD b/java/org/brotli/dec/BUILD deleted file mode 100644 index 17286e0..0000000 --- a/java/org/brotli/dec/BUILD +++ /dev/null @@ -1,62 +0,0 @@ -# Description: -# Java port of Brotli decoder. - -load(":build_defs.bzl", "brotli_java_test") - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # MIT - -TEST_DEPS = [ - ":dec", - "@maven//:junit_junit", -] - -java_library( - name = "dec", - srcs = glob( - ["*.java"], - exclude = [ - "Decoder.java", - "*Test*.java", - ], - ), - proguard_specs = ["proguard.pgcfg"], - resources = ["//:license"], -) - -brotli_java_test( - name = "BitReaderTest", - srcs = ["BitReaderTest.java"], - deps = TEST_DEPS, -) - -brotli_java_test( - name = "DecodeTest", - srcs = ["DecodeTest.java"], - deps = TEST_DEPS, -) - -brotli_java_test( - name = "DictionaryTest", - srcs = ["DictionaryTest.java"], - deps = TEST_DEPS, -) - -brotli_java_test( - name = "EagerStreamTest", - srcs = ["EagerStreamTest.java"], - deps = TEST_DEPS, -) - -brotli_java_test( - name = "SynthTest", - srcs = ["SynthTest.java"], - deps = TEST_DEPS, -) - -brotli_java_test( - name = "TransformTest", - srcs = ["TransformTest.java"], - deps = TEST_DEPS, -) diff --git a/java/org/brotli/dec/BUILD.bazel b/java/org/brotli/dec/BUILD.bazel new file mode 100644 index 0000000..17286e0 --- /dev/null +++ b/java/org/brotli/dec/BUILD.bazel @@ -0,0 +1,62 @@ +# Description: +# Java port of Brotli decoder. + +load(":build_defs.bzl", "brotli_java_test") + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # MIT + +TEST_DEPS = [ + ":dec", + "@maven//:junit_junit", +] + +java_library( + name = "dec", + srcs = glob( + ["*.java"], + exclude = [ + "Decoder.java", + "*Test*.java", + ], + ), + proguard_specs = ["proguard.pgcfg"], + resources = ["//:license"], +) + +brotli_java_test( + name = "BitReaderTest", + srcs = ["BitReaderTest.java"], + deps = TEST_DEPS, +) + +brotli_java_test( + name = "DecodeTest", + srcs = ["DecodeTest.java"], + deps = TEST_DEPS, +) + +brotli_java_test( + name = "DictionaryTest", + srcs = ["DictionaryTest.java"], + deps = TEST_DEPS, +) + +brotli_java_test( + name = "EagerStreamTest", + srcs = ["EagerStreamTest.java"], + deps = TEST_DEPS, +) + +brotli_java_test( + name = "SynthTest", + srcs = ["SynthTest.java"], + deps = TEST_DEPS, +) + +brotli_java_test( + name = "TransformTest", + srcs = ["TransformTest.java"], + deps = TEST_DEPS, +) diff --git a/java/org/brotli/enc/BUILD b/java/org/brotli/enc/BUILD deleted file mode 100644 index 66905b9..0000000 --- a/java/org/brotli/enc/BUILD +++ /dev/null @@ -1,14 +0,0 @@ -# Description: -# Java port of Brotli decoder. - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # MIT - -java_library( - name = "prepared_dictionary", - srcs = [ - "PreparedDictionary.java", - "PreparedDictionaryGenerator.java", - ], -) diff --git a/java/org/brotli/enc/BUILD.bazel b/java/org/brotli/enc/BUILD.bazel new file mode 100644 index 0000000..66905b9 --- /dev/null +++ b/java/org/brotli/enc/BUILD.bazel @@ -0,0 +1,14 @@ +# Description: +# Java port of Brotli decoder. + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # MIT + +java_library( + name = "prepared_dictionary", + srcs = [ + "PreparedDictionary.java", + "PreparedDictionaryGenerator.java", + ], +) diff --git a/java/org/brotli/integration/BUILD b/java/org/brotli/integration/BUILD deleted file mode 100644 index 5b77325..0000000 --- a/java/org/brotli/integration/BUILD +++ /dev/null @@ -1,73 +0,0 @@ -# Description: -# Integration test runner + corpus for Java port of Brotli decoder. - -java_library( - name = "brotli_jni_test_base", - srcs = ["BrotliJniTestBase.java"], - visibility = [ - "//org/brotli/wrapper/common:__pkg__", - "//org/brotli/wrapper/dec:__pkg__", - "//org/brotli/wrapper/enc:__pkg__", - ], -) - -java_library( - name = "bundle_helper", - srcs = ["BundleHelper.java"], - visibility = [ - "//org/brotli/wrapper/dec:__pkg__", - "//org/brotli/wrapper/enc:__pkg__", - ], -) - -java_library( - name = "bundle_checker", - srcs = ["BundleChecker.java"], - deps = [ - ":bundle_helper", - "//org/brotli/dec", - ], -) - -java_binary( - name = "bundle_checker_bin", - main_class = "org.brotli.integration.BundleChecker", - runtime_deps = [":bundle_checker"], -) - -java_test( - name = "bundle_checker_data_test", - args = ["org/brotli/integration/test_data.zip"], - data = ["test_data.zip"], - main_class = "org.brotli.integration.BundleChecker", - use_testrunner = 0, - runtime_deps = [":bundle_checker"], -) - -java_test( - name = "bundle_checker_fuzz_test", - args = [ - "-s", - "org/brotli/integration/fuzz_data.zip", - ], - data = ["fuzz_data.zip"], - main_class = "org.brotli.integration.BundleChecker", - use_testrunner = 0, - runtime_deps = [":bundle_checker"], -) - -filegroup( - name = "test_data", - srcs = ["test_data.zip"], - visibility = [ - "//org/brotli/wrapper/dec:__pkg__", - ], -) - -filegroup( - name = "test_corpus", - srcs = ["test_corpus.zip"], - visibility = [ - "//org/brotli/wrapper/enc:__pkg__", - ], -) diff --git a/java/org/brotli/integration/BUILD.bazel b/java/org/brotli/integration/BUILD.bazel new file mode 100644 index 0000000..5b77325 --- /dev/null +++ b/java/org/brotli/integration/BUILD.bazel @@ -0,0 +1,73 @@ +# Description: +# Integration test runner + corpus for Java port of Brotli decoder. + +java_library( + name = "brotli_jni_test_base", + srcs = ["BrotliJniTestBase.java"], + visibility = [ + "//org/brotli/wrapper/common:__pkg__", + "//org/brotli/wrapper/dec:__pkg__", + "//org/brotli/wrapper/enc:__pkg__", + ], +) + +java_library( + name = "bundle_helper", + srcs = ["BundleHelper.java"], + visibility = [ + "//org/brotli/wrapper/dec:__pkg__", + "//org/brotli/wrapper/enc:__pkg__", + ], +) + +java_library( + name = "bundle_checker", + srcs = ["BundleChecker.java"], + deps = [ + ":bundle_helper", + "//org/brotli/dec", + ], +) + +java_binary( + name = "bundle_checker_bin", + main_class = "org.brotli.integration.BundleChecker", + runtime_deps = [":bundle_checker"], +) + +java_test( + name = "bundle_checker_data_test", + args = ["org/brotli/integration/test_data.zip"], + data = ["test_data.zip"], + main_class = "org.brotli.integration.BundleChecker", + use_testrunner = 0, + runtime_deps = [":bundle_checker"], +) + +java_test( + name = "bundle_checker_fuzz_test", + args = [ + "-s", + "org/brotli/integration/fuzz_data.zip", + ], + data = ["fuzz_data.zip"], + main_class = "org.brotli.integration.BundleChecker", + use_testrunner = 0, + runtime_deps = [":bundle_checker"], +) + +filegroup( + name = "test_data", + srcs = ["test_data.zip"], + visibility = [ + "//org/brotli/wrapper/dec:__pkg__", + ], +) + +filegroup( + name = "test_corpus", + srcs = ["test_corpus.zip"], + visibility = [ + "//org/brotli/wrapper/enc:__pkg__", + ], +) diff --git a/java/org/brotli/wrapper/common/BUILD b/java/org/brotli/wrapper/common/BUILD deleted file mode 100644 index eeaa474..0000000 --- a/java/org/brotli/wrapper/common/BUILD +++ /dev/null @@ -1,61 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # MIT - -filegroup( - name = "jni_src", - srcs = ["common_jni.cc"], -) - -filegroup( - name = "brotli_jni_no_dictionary_data", - srcs = ["//:brotli_jni_no_dictionary_data.dll"], -) - -java_library( - name = "common", - srcs = glob( - ["*.java"], - exclude = ["*Test*.java"], - ), - resources = ["//:license"], -) - -java_library( - name = "test_lib", - testonly = 1, - srcs = glob(["*Test*.java"]), - deps = [ - ":common", - "//org/brotli/dec", - "//org/brotli/integration:brotli_jni_test_base", - "//org/brotli/wrapper/dec", - "@maven//:junit_junit", - ], -) - -java_test( - name = "SetZeroDictionaryTest", - size = "small", - data = [ - ":brotli_jni_no_dictionary_data", # Bazel JNI workaround - ], - jvm_flags = [ - "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni_no_dictionary_data)", - ], - test_class = "org.brotli.wrapper.common.SetZeroDictionaryTest", - runtime_deps = [":test_lib"], -) - -java_test( - name = "SetRfcDictionaryTest", - size = "small", - data = [ - ":brotli_jni_no_dictionary_data", # Bazel JNI workaround - ], - jvm_flags = [ - "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni_no_dictionary_data)", - ], - test_class = "org.brotli.wrapper.common.SetRfcDictionaryTest", - runtime_deps = [":test_lib"], -) diff --git a/java/org/brotli/wrapper/common/BUILD.bazel b/java/org/brotli/wrapper/common/BUILD.bazel new file mode 100644 index 0000000..eeaa474 --- /dev/null +++ b/java/org/brotli/wrapper/common/BUILD.bazel @@ -0,0 +1,61 @@ +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # MIT + +filegroup( + name = "jni_src", + srcs = ["common_jni.cc"], +) + +filegroup( + name = "brotli_jni_no_dictionary_data", + srcs = ["//:brotli_jni_no_dictionary_data.dll"], +) + +java_library( + name = "common", + srcs = glob( + ["*.java"], + exclude = ["*Test*.java"], + ), + resources = ["//:license"], +) + +java_library( + name = "test_lib", + testonly = 1, + srcs = glob(["*Test*.java"]), + deps = [ + ":common", + "//org/brotli/dec", + "//org/brotli/integration:brotli_jni_test_base", + "//org/brotli/wrapper/dec", + "@maven//:junit_junit", + ], +) + +java_test( + name = "SetZeroDictionaryTest", + size = "small", + data = [ + ":brotli_jni_no_dictionary_data", # Bazel JNI workaround + ], + jvm_flags = [ + "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni_no_dictionary_data)", + ], + test_class = "org.brotli.wrapper.common.SetZeroDictionaryTest", + runtime_deps = [":test_lib"], +) + +java_test( + name = "SetRfcDictionaryTest", + size = "small", + data = [ + ":brotli_jni_no_dictionary_data", # Bazel JNI workaround + ], + jvm_flags = [ + "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni_no_dictionary_data)", + ], + test_class = "org.brotli.wrapper.common.SetRfcDictionaryTest", + runtime_deps = [":test_lib"], +) diff --git a/java/org/brotli/wrapper/dec/BUILD b/java/org/brotli/wrapper/dec/BUILD deleted file mode 100644 index ca902f7..0000000 --- a/java/org/brotli/wrapper/dec/BUILD +++ /dev/null @@ -1,103 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # MIT - -filegroup( - name = "jni_src", - srcs = [ - "decoder_jni.cc", - "decoder_jni.h", - # TODO(eustas): investigate, why this prevents JNI library loading. - #"decoder_jni_onload.cc", - ], -) - -java_library( - name = "dec", - srcs = glob( - ["*.java"], - exclude = ["*Test*.java"], - ), - resources = ["//:license"], -) - -java_library( - name = "test_lib", - testonly = 1, - srcs = glob(["*Test*.java"]), - deps = [ - ":dec", - "//org/brotli/integration:brotli_jni_test_base", - "//org/brotli/integration:bundle_helper", - "//org/brotli/wrapper/enc", - "@maven//:junit_junit", - ], -) - -filegroup( - name = "brotli_jni", - srcs = ["//:brotli_jni.dll"], -) - -filegroup( - name = "test_bundle", - srcs = ["//org/brotli/integration:test_data"], -) - -java_test( - name = "BrotliDecoderChannelTest", - size = "large", - data = [ - ":brotli_jni", # Bazel JNI workaround - ":test_bundle", - ], - jvm_flags = [ - "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", - "-DTEST_BUNDLE=$(location :test_bundle)", - ], - test_class = "org.brotli.wrapper.dec.BrotliDecoderChannelTest", - runtime_deps = [":test_lib"], -) - -java_test( - name = "BrotliInputStreamTest", - size = "large", - data = [ - ":brotli_jni", # Bazel JNI workaround - ":test_bundle", - ], - jvm_flags = [ - "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", - "-DTEST_BUNDLE=$(location :test_bundle)", - ], - test_class = "org.brotli.wrapper.dec.BrotliInputStreamTest", - runtime_deps = [":test_lib"], -) - -java_test( - name = "DecoderTest", - size = "large", - data = [ - ":brotli_jni", # Bazel JNI workaround - ":test_bundle", - ], - jvm_flags = [ - "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", - "-DTEST_BUNDLE=$(location :test_bundle)", - ], - test_class = "org.brotli.wrapper.dec.DecoderTest", - runtime_deps = [":test_lib"], -) - -java_test( - name = "CornerCasesTest", - size = "large", - data = [ - ":brotli_jni", # Bazel JNI workaround - ], - jvm_flags = [ - "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", - ], - test_class = "org.brotli.wrapper.dec.CornerCasesTest", - runtime_deps = [":test_lib"], -) diff --git a/java/org/brotli/wrapper/dec/BUILD.bazel b/java/org/brotli/wrapper/dec/BUILD.bazel new file mode 100644 index 0000000..ca902f7 --- /dev/null +++ b/java/org/brotli/wrapper/dec/BUILD.bazel @@ -0,0 +1,103 @@ +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # MIT + +filegroup( + name = "jni_src", + srcs = [ + "decoder_jni.cc", + "decoder_jni.h", + # TODO(eustas): investigate, why this prevents JNI library loading. + #"decoder_jni_onload.cc", + ], +) + +java_library( + name = "dec", + srcs = glob( + ["*.java"], + exclude = ["*Test*.java"], + ), + resources = ["//:license"], +) + +java_library( + name = "test_lib", + testonly = 1, + srcs = glob(["*Test*.java"]), + deps = [ + ":dec", + "//org/brotli/integration:brotli_jni_test_base", + "//org/brotli/integration:bundle_helper", + "//org/brotli/wrapper/enc", + "@maven//:junit_junit", + ], +) + +filegroup( + name = "brotli_jni", + srcs = ["//:brotli_jni.dll"], +) + +filegroup( + name = "test_bundle", + srcs = ["//org/brotli/integration:test_data"], +) + +java_test( + name = "BrotliDecoderChannelTest", + size = "large", + data = [ + ":brotli_jni", # Bazel JNI workaround + ":test_bundle", + ], + jvm_flags = [ + "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", + "-DTEST_BUNDLE=$(location :test_bundle)", + ], + test_class = "org.brotli.wrapper.dec.BrotliDecoderChannelTest", + runtime_deps = [":test_lib"], +) + +java_test( + name = "BrotliInputStreamTest", + size = "large", + data = [ + ":brotli_jni", # Bazel JNI workaround + ":test_bundle", + ], + jvm_flags = [ + "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", + "-DTEST_BUNDLE=$(location :test_bundle)", + ], + test_class = "org.brotli.wrapper.dec.BrotliInputStreamTest", + runtime_deps = [":test_lib"], +) + +java_test( + name = "DecoderTest", + size = "large", + data = [ + ":brotli_jni", # Bazel JNI workaround + ":test_bundle", + ], + jvm_flags = [ + "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", + "-DTEST_BUNDLE=$(location :test_bundle)", + ], + test_class = "org.brotli.wrapper.dec.DecoderTest", + runtime_deps = [":test_lib"], +) + +java_test( + name = "CornerCasesTest", + size = "large", + data = [ + ":brotli_jni", # Bazel JNI workaround + ], + jvm_flags = [ + "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", + ], + test_class = "org.brotli.wrapper.dec.CornerCasesTest", + runtime_deps = [":test_lib"], +) diff --git a/java/org/brotli/wrapper/enc/BUILD b/java/org/brotli/wrapper/enc/BUILD deleted file mode 100644 index b8500c7..0000000 --- a/java/org/brotli/wrapper/enc/BUILD +++ /dev/null @@ -1,95 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # MIT - -filegroup( - name = "jni_src", - srcs = ["encoder_jni.cc"], -) - -filegroup( - name = "brotli_jni", - srcs = ["//:brotli_jni.dll"], -) - -java_library( - name = "enc", - srcs = glob( - ["*.java"], - exclude = ["*Test*.java"], - ), - deps = [ - "//org/brotli/common:shared_dictionary", - "//org/brotli/enc:prepared_dictionary", - ], - resources = ["//:license"], -) - -java_library( - name = "test_lib", - testonly = 1, - srcs = glob(["*Test*.java"]), - deps = [ - ":enc", - "//org/brotli/common:shared_dictionary", - "//org/brotli/enc:prepared_dictionary", - "//org/brotli/integration:brotli_jni_test_base", - "//org/brotli/integration:bundle_helper", - "//org/brotli/wrapper/common", - "//org/brotli/wrapper/dec", - "@maven//:junit_junit", - ], -) - -filegroup( - name = "test_bundle", - srcs = ["//org/brotli/integration:test_corpus"], -) - -java_test( - name = "BrotliEncoderChannelTest", - size = "large", - data = [ - ":brotli_jni", # Bazel JNI workaround - ":test_bundle", - ], - jvm_flags = [ - "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", - "-DTEST_BUNDLE=$(location :test_bundle)", - ], - shard_count = 15, - test_class = "org.brotli.wrapper.enc.BrotliEncoderChannelTest", - runtime_deps = [":test_lib"], -) - -java_test( - name = "BrotliOutputStreamTest", - size = "large", - data = [ - ":brotli_jni", # Bazel JNI workaround - ":test_bundle", - ], - jvm_flags = [ - "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", - "-DTEST_BUNDLE=$(location :test_bundle)", - ], - shard_count = 15, - test_class = "org.brotli.wrapper.enc.BrotliOutputStreamTest", - runtime_deps = [":test_lib"], -) - -java_test( - name = "EncoderTest", - size = "large", - data = [ - ":brotli_jni", # Bazel JNI workaround - ":test_bundle", - ], - jvm_flags = [ - "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", - "-DTEST_BUNDLE=$(location :test_bundle)", - ], - shard_count = 15, - test_class = "org.brotli.wrapper.enc.EncoderTest", - runtime_deps = [":test_lib"], -) diff --git a/java/org/brotli/wrapper/enc/BUILD.bazel b/java/org/brotli/wrapper/enc/BUILD.bazel new file mode 100644 index 0000000..b8500c7 --- /dev/null +++ b/java/org/brotli/wrapper/enc/BUILD.bazel @@ -0,0 +1,95 @@ +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # MIT + +filegroup( + name = "jni_src", + srcs = ["encoder_jni.cc"], +) + +filegroup( + name = "brotli_jni", + srcs = ["//:brotli_jni.dll"], +) + +java_library( + name = "enc", + srcs = glob( + ["*.java"], + exclude = ["*Test*.java"], + ), + deps = [ + "//org/brotli/common:shared_dictionary", + "//org/brotli/enc:prepared_dictionary", + ], + resources = ["//:license"], +) + +java_library( + name = "test_lib", + testonly = 1, + srcs = glob(["*Test*.java"]), + deps = [ + ":enc", + "//org/brotli/common:shared_dictionary", + "//org/brotli/enc:prepared_dictionary", + "//org/brotli/integration:brotli_jni_test_base", + "//org/brotli/integration:bundle_helper", + "//org/brotli/wrapper/common", + "//org/brotli/wrapper/dec", + "@maven//:junit_junit", + ], +) + +filegroup( + name = "test_bundle", + srcs = ["//org/brotli/integration:test_corpus"], +) + +java_test( + name = "BrotliEncoderChannelTest", + size = "large", + data = [ + ":brotli_jni", # Bazel JNI workaround + ":test_bundle", + ], + jvm_flags = [ + "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", + "-DTEST_BUNDLE=$(location :test_bundle)", + ], + shard_count = 15, + test_class = "org.brotli.wrapper.enc.BrotliEncoderChannelTest", + runtime_deps = [":test_lib"], +) + +java_test( + name = "BrotliOutputStreamTest", + size = "large", + data = [ + ":brotli_jni", # Bazel JNI workaround + ":test_bundle", + ], + jvm_flags = [ + "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", + "-DTEST_BUNDLE=$(location :test_bundle)", + ], + shard_count = 15, + test_class = "org.brotli.wrapper.enc.BrotliOutputStreamTest", + runtime_deps = [":test_lib"], +) + +java_test( + name = "EncoderTest", + size = "large", + data = [ + ":brotli_jni", # Bazel JNI workaround + ":test_bundle", + ], + jvm_flags = [ + "-DBROTLI_JNI_LIBRARY=$(location :brotli_jni)", + "-DTEST_BUNDLE=$(location :test_bundle)", + ], + shard_count = 15, + test_class = "org.brotli.wrapper.enc.EncoderTest", + runtime_deps = [":test_lib"], +) diff --git a/js/BUILD b/js/BUILD deleted file mode 100644 index d74e42c..0000000 --- a/js/BUILD +++ /dev/null @@ -1,84 +0,0 @@ -load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library", "closure_js_test") - -package( - default_visibility = ["//visibility:public"], -) - -licenses(["notice"]) # MIT - -# Not a real polyfill. Do NOT use for anything, but tests. -closure_js_library( - name = "polyfill", - srcs = ["polyfill.js"], - suppress = [ - "JSC_INVALID_OPERAND_TYPE", - "JSC_MISSING_JSDOC", - "JSC_STRICT_INEXISTENT_PROPERTY", - "JSC_TYPE_MISMATCH", - "JSC_UNKNOWN_EXPR_TYPE", - ], -) - -closure_js_library( - name = "jasmine-polyfill", - srcs = ["jasmine-polyfill.js"], - suppress = [ - "JSC_MISSING_JSDOC", - "JSC_UNKNOWN_EXPR_TYPE", - "JSC_MISSING_PROVIDE", - ], - deps = ["@io_bazel_rules_closure//closure/library:testing"], - testonly = True, -) - -# Do NOT use this artifact; it is for test purposes only. -closure_js_library( - name = "decode", - srcs = ["decode.js"], - suppress = ["JSC_USELESS_BLOCK"], - deps = [":polyfill"], -) - -closure_js_test( - name = "decode_test", - srcs = ["decode_test.js"], - entry_points = ["decode_test.js"], - suppress = ["moduleLoad"], - deps = [ - ":decode", - ":jasmine-polyfill", - ":polyfill", - ], -) - -closure_js_test( - name = "decode_synth_test", - srcs = ["decode_synth_test.js"], - entry_points = ["decode_synth_test.js"], - suppress = ["moduleLoad"], - deps = [ - ":decode", - ":jasmine-polyfill", - ":polyfill", - ], -) - -closure_js_library( - name = "test_data_js", - testonly = True, - srcs = ["test_data.js"], - suppress = ["lintChecks"], -) - -closure_js_test( - name = "bundle_test", - srcs = ["bundle_test.js"], - entry_points = ["bundle_test.js"], - suppress = ["moduleLoad"], - deps = [ - ":decode", - ":jasmine-polyfill", - ":polyfill", - ":test_data_js", - ], -) diff --git a/js/BUILD.bazel b/js/BUILD.bazel new file mode 100644 index 0000000..d74e42c --- /dev/null +++ b/js/BUILD.bazel @@ -0,0 +1,84 @@ +load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library", "closure_js_test") + +package( + default_visibility = ["//visibility:public"], +) + +licenses(["notice"]) # MIT + +# Not a real polyfill. Do NOT use for anything, but tests. +closure_js_library( + name = "polyfill", + srcs = ["polyfill.js"], + suppress = [ + "JSC_INVALID_OPERAND_TYPE", + "JSC_MISSING_JSDOC", + "JSC_STRICT_INEXISTENT_PROPERTY", + "JSC_TYPE_MISMATCH", + "JSC_UNKNOWN_EXPR_TYPE", + ], +) + +closure_js_library( + name = "jasmine-polyfill", + srcs = ["jasmine-polyfill.js"], + suppress = [ + "JSC_MISSING_JSDOC", + "JSC_UNKNOWN_EXPR_TYPE", + "JSC_MISSING_PROVIDE", + ], + deps = ["@io_bazel_rules_closure//closure/library:testing"], + testonly = True, +) + +# Do NOT use this artifact; it is for test purposes only. +closure_js_library( + name = "decode", + srcs = ["decode.js"], + suppress = ["JSC_USELESS_BLOCK"], + deps = [":polyfill"], +) + +closure_js_test( + name = "decode_test", + srcs = ["decode_test.js"], + entry_points = ["decode_test.js"], + suppress = ["moduleLoad"], + deps = [ + ":decode", + ":jasmine-polyfill", + ":polyfill", + ], +) + +closure_js_test( + name = "decode_synth_test", + srcs = ["decode_synth_test.js"], + entry_points = ["decode_synth_test.js"], + suppress = ["moduleLoad"], + deps = [ + ":decode", + ":jasmine-polyfill", + ":polyfill", + ], +) + +closure_js_library( + name = "test_data_js", + testonly = True, + srcs = ["test_data.js"], + suppress = ["lintChecks"], +) + +closure_js_test( + name = "bundle_test", + srcs = ["bundle_test.js"], + entry_points = ["bundle_test.js"], + suppress = ["moduleLoad"], + deps = [ + ":decode", + ":jasmine-polyfill", + ":polyfill", + ":test_data_js", + ], +) diff --git a/js/WORKSPACE b/js/WORKSPACE deleted file mode 100644 index 8e3b2af..0000000 --- a/js/WORKSPACE +++ /dev/null @@ -1,17 +0,0 @@ -workspace(name = "org_brotli_js") - -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", - 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", - ], -) - -load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains") -rules_closure_dependencies() -rules_closure_toolchains() diff --git a/js/WORKSPACE.bazel b/js/WORKSPACE.bazel new file mode 100644 index 0000000..8e3b2af --- /dev/null +++ b/js/WORKSPACE.bazel @@ -0,0 +1,17 @@ +workspace(name = "org_brotli_js") + +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", + 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", + ], +) + +load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains") +rules_closure_dependencies() +rules_closure_toolchains() diff --git a/research/BUILD b/research/BUILD deleted file mode 100644 index ef6967e..0000000 --- a/research/BUILD +++ /dev/null @@ -1,42 +0,0 @@ -# Description: brotli research tools. - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # MIT - -cc_library( - name = "dm", - srcs = ["deorummolae.cc"], - deps = ["@esaxx//:sais"], - hdrs = ["deorummolae.h"], -) - -cc_library( - name = "durchschlag", - srcs = ["durchschlag.cc"], - hdrs = ["durchschlag.h"], - deps = ["@divsufsort//:libdivsufsort"], -) - -cc_library( - name = "sieve", - srcs = ["sieve.cc"], - hdrs = ["sieve.h"], -) - -cc_binary( - name = "dictionary_generator", - srcs = ["dictionary_generator.cc"], - deps = [ - ":dm", - ":durchschlag", - ":sieve", - ], -) - -cc_binary( - name = "brotli_decoder", - srcs = ["brotli_decoder.c"], - linkstatic = 1, - deps = ["@org_brotli//:brotlidec"], -) diff --git a/research/BUILD.bazel b/research/BUILD.bazel new file mode 100644 index 0000000..ef6967e --- /dev/null +++ b/research/BUILD.bazel @@ -0,0 +1,42 @@ +# Description: brotli research tools. + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # MIT + +cc_library( + name = "dm", + srcs = ["deorummolae.cc"], + deps = ["@esaxx//:sais"], + hdrs = ["deorummolae.h"], +) + +cc_library( + name = "durchschlag", + srcs = ["durchschlag.cc"], + hdrs = ["durchschlag.h"], + deps = ["@divsufsort//:libdivsufsort"], +) + +cc_library( + name = "sieve", + srcs = ["sieve.cc"], + hdrs = ["sieve.h"], +) + +cc_binary( + name = "dictionary_generator", + srcs = ["dictionary_generator.cc"], + deps = [ + ":dm", + ":durchschlag", + ":sieve", + ], +) + +cc_binary( + name = "brotli_decoder", + srcs = ["brotli_decoder.c"], + linkstatic = 1, + deps = ["@org_brotli//:brotlidec"], +) diff --git a/research/WORKSPACE b/research/WORKSPACE deleted file mode 100644 index 343c3bb..0000000 --- a/research/WORKSPACE +++ /dev/null @@ -1,32 +0,0 @@ -workspace(name = "org_brotli_research") - -load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") - -local_repository( - name = "org_brotli", - path = "..", -) - -new_git_repository( - name = "divsufsort", - build_file = "@//:BUILD.libdivsufsort", - commit = "5f60d6f026c30fb4ac296f696b3c8b0eb71bd428", - remote = "https://github.com/y-256/libdivsufsort", - shallow_since = "1445958113 +0900", -) - -new_git_repository( - name = "esaxx", - build_file_content = """ -package(default_visibility = ["//visibility:public"]) -cc_library( - name = "sais", - hdrs = ["sais.hxx"], - includes = ["."], - include_prefix = "third_party/esaxx", -) -""", - commit = "ca7cb332011ec37a8436487f210f396b84bd8273", - remote = "https://github.com/hillbig/esaxx", - shallow_since = "1391400691 +0900", -) diff --git a/research/WORKSPACE.bazel b/research/WORKSPACE.bazel new file mode 100644 index 0000000..343c3bb --- /dev/null +++ b/research/WORKSPACE.bazel @@ -0,0 +1,32 @@ +workspace(name = "org_brotli_research") + +load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") + +local_repository( + name = "org_brotli", + path = "..", +) + +new_git_repository( + name = "divsufsort", + build_file = "@//:BUILD.libdivsufsort", + commit = "5f60d6f026c30fb4ac296f696b3c8b0eb71bd428", + remote = "https://github.com/y-256/libdivsufsort", + shallow_since = "1445958113 +0900", +) + +new_git_repository( + name = "esaxx", + build_file_content = """ +package(default_visibility = ["//visibility:public"]) +cc_library( + name = "sais", + hdrs = ["sais.hxx"], + includes = ["."], + include_prefix = "third_party/esaxx", +) +""", + commit = "ca7cb332011ec37a8436487f210f396b84bd8273", + remote = "https://github.com/hillbig/esaxx", + shallow_since = "1391400691 +0900", +) -- cgit v1.1