mirror of
https://github.com/google/brotli.git
synced 2024-11-08 05:10:06 +00:00
Fix/simplify/improve Bazel build
PiperOrigin-RevId: 595656443
This commit is contained in:
parent
082c9626a4
commit
1045ab52df
16
.github/workflows/build_test.yml
vendored
16
.github/workflows/build_test.yml
vendored
@ -86,17 +86,17 @@ jobs:
|
|||||||
cxx_compiler: g++
|
cxx_compiler: g++
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
|
|
||||||
- name: cmake-win64:msvc2019-rel
|
- name: cmake-win64:msvc-rel
|
||||||
build_system: cmake
|
build_system: cmake
|
||||||
cmake_generator: Visual Studio 16 2019
|
cmake_generator: Visual Studio 17 2022
|
||||||
cmake_config: Release
|
cmake_config: Release
|
||||||
os: windows-2019
|
os: windows-latest
|
||||||
|
|
||||||
- name: cmake-win64:msvc2019-dbg
|
- name: cmake-win64:msvc-dbg
|
||||||
build_system: cmake
|
build_system: cmake
|
||||||
cmake_generator: Visual Studio 16 2019
|
cmake_generator: Visual Studio 17 2022
|
||||||
cmake_config: Debug
|
cmake_config: Debug
|
||||||
os: windows-2019
|
os: windows-latest
|
||||||
|
|
||||||
- name: fuzz:clang15
|
- name: fuzz:clang15
|
||||||
build_system: fuzz
|
build_system: fuzz
|
||||||
@ -288,9 +288,9 @@ jobs:
|
|||||||
with open(match) as manifest:
|
with open(match) as manifest:
|
||||||
for entry in manifest:
|
for entry in manifest:
|
||||||
entry = entry.strip()
|
entry = entry.strip()
|
||||||
if not entry.startswith("org_brotli_java"):
|
if not entry.startswith("_main"):
|
||||||
continue
|
continue
|
||||||
if entry.startswith('org_brotli_java/external'):
|
if entry.startswith("_main/external"):
|
||||||
continue
|
continue
|
||||||
(alias, space, link) = entry.partition(' ')
|
(alias, space, link) = entry.partition(' ')
|
||||||
if alias.endswith('.jar') or alias.endswith('.exe'):
|
if alias.endswith('.jar') or alias.endswith('.exe'):
|
||||||
|
34
BUILD.bazel
34
BUILD.bazel
@ -1,8 +1,6 @@
|
|||||||
# Description:
|
# Description:
|
||||||
# Brotli is a generic-purpose lossless compression algorithm.
|
# Brotli is a generic-purpose lossless compression algorithm.
|
||||||
|
|
||||||
load(":compiler_config_setting.bzl", "create_msvc_config")
|
|
||||||
|
|
||||||
package(
|
package(
|
||||||
default_visibility = ["//visibility:public"],
|
default_visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
@ -12,37 +10,21 @@ licenses(["notice"]) # MIT
|
|||||||
exports_files(["LICENSE"])
|
exports_files(["LICENSE"])
|
||||||
|
|
||||||
config_setting(
|
config_setting(
|
||||||
name = "darwin",
|
name = "clang-cl",
|
||||||
values = {"cpu": "darwin"},
|
flag_values = {
|
||||||
|
"@bazel_tools//tools/cpp:compiler": "clang-cl",
|
||||||
|
},
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
config_setting(
|
config_setting(
|
||||||
name = "darwin_x86_64",
|
name = "msvc",
|
||||||
values = {"cpu": "darwin_x86_64"},
|
flag_values = {
|
||||||
|
"@bazel_tools//tools/cpp:compiler": "msvc-cl",
|
||||||
|
},
|
||||||
visibility = ["//visibility:public"],
|
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({
|
STRICT_C_OPTIONS = select({
|
||||||
":msvc": [],
|
":msvc": [],
|
||||||
":clang-cl": [
|
":clang-cl": [
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
# Copyright 2018 Google Inc. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Distributed under MIT license.
|
|
||||||
# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
"""Creates config_setting that allows selecting based on 'compiler' value."""
|
|
||||||
|
|
||||||
def create_msvc_config():
|
|
||||||
# The "do_not_use_tools_cpp_compiler_present" attribute exists to
|
|
||||||
# distinguish between older versions of Bazel that do not support
|
|
||||||
# "@bazel_tools//tools/cpp:compiler" flag_value, and newer ones that do.
|
|
||||||
# In the future, the only way to select on the compiler will be through
|
|
||||||
# flag_values{"@bazel_tools//tools/cpp:compiler"} and the else branch can
|
|
||||||
# be removed.
|
|
||||||
if hasattr(cc_common, "do_not_use_tools_cpp_compiler_present"):
|
|
||||||
native.config_setting(
|
|
||||||
name = "clang-cl",
|
|
||||||
flag_values = {
|
|
||||||
"@bazel_tools//tools/cpp:compiler": "clang-cl",
|
|
||||||
},
|
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
)
|
|
||||||
native.config_setting(
|
|
||||||
name = "msvc",
|
|
||||||
flag_values = {
|
|
||||||
"@bazel_tools//tools/cpp:compiler": "msvc-cl",
|
|
||||||
},
|
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
native.config_setting(
|
|
||||||
name = "clang-cl",
|
|
||||||
values = {"compiler": "clang-cl"},
|
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
)
|
|
||||||
native.config_setting(
|
|
||||||
name = "msvc",
|
|
||||||
values = {"compiler": "msvc-cl"},
|
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
)
|
|
@ -9,10 +9,10 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "io_bazel_rules_go",
|
name = "io_bazel_rules_go",
|
||||||
sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f",
|
sha256 = "c8035e8ae248b56040a65ad3f0b7434712e2037e5dfdcebfe97576e620422709",
|
||||||
urls = [
|
urls = [
|
||||||
"https://mirror.bazel.build/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.29.0/rules_go-v0.29.0.zip",
|
"https://github.com/bazelbuild/rules_go/releases/download/v0.44.0/rules_go-v0.44.0.zip",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,14 +20,14 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe
|
|||||||
|
|
||||||
go_rules_dependencies()
|
go_rules_dependencies()
|
||||||
|
|
||||||
go_register_toolchains(version = "1.17.1")
|
go_register_toolchains(version = "1.21.5")
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "bazel_gazelle",
|
name = "bazel_gazelle",
|
||||||
sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
|
sha256 = "b7387f72efb59f876e4daae42f1d3912d0d45563eac7cb23d1de0b094ab588cf",
|
||||||
urls = [
|
urls = [
|
||||||
"https://mirror.bazel.build/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.24.0/bazel-gazelle-v0.24.0.tar.gz",
|
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,6 +2,36 @@ package(
|
|||||||
default_visibility = ["//visibility:public"],
|
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
|
# >>> JNI headers
|
||||||
|
|
||||||
genrule(
|
genrule(
|
||||||
@ -14,11 +44,11 @@ genrule(
|
|||||||
genrule(
|
genrule(
|
||||||
name = "copy_link_jni_md_header",
|
name = "copy_link_jni_md_header",
|
||||||
srcs = select({
|
srcs = select({
|
||||||
"@org_brotli//:darwin": ["@openjdk_macosx_jni_md_h//file"],
|
":darwin": ["@openjdk_macosx_jni_md_h//file"],
|
||||||
"@org_brotli//:darwin_x86_64": ["@openjdk_macosx_jni_md_h//file"],
|
":darwin_x86_64": ["@openjdk_macosx_jni_md_h//file"],
|
||||||
"@org_brotli//:windows_msys": ["@openjdk_windows_jni_md_h//file"],
|
":windows_msys": ["@openjdk_windows_jni_md_h//file"],
|
||||||
"@org_brotli//:windows_msvc": ["@openjdk_windows_jni_md_h//file"],
|
":windows_msvc": ["@openjdk_windows_jni_md_h//file"],
|
||||||
"@org_brotli//:windows": ["@openjdk_windows_jni_md_h//file"],
|
":windows": ["@openjdk_windows_jni_md_h//file"],
|
||||||
"//conditions:default": ["@openjdk_solaris_jni_md_h//file"],
|
"//conditions:default": ["@openjdk_solaris_jni_md_h//file"],
|
||||||
}),
|
}),
|
||||||
outs = ["jni/jni_md.h"],
|
outs = ["jni/jni_md.h"],
|
||||||
|
@ -30,27 +30,27 @@ maven_install(
|
|||||||
http_file(
|
http_file(
|
||||||
name = "openjdk_jni_h",
|
name = "openjdk_jni_h",
|
||||||
downloaded_file_path = "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"],
|
urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk/src/share/javavm/export/jni.h"],
|
||||||
sha256 = "ed99792df48670072b78028faf704a8dcb6868fe140ccc7eced9b01dfa62fef4",
|
sha256 = "ed99792df48670072b78028faf704a8dcb6868fe140ccc7eced9b01dfa62fef4",
|
||||||
)
|
)
|
||||||
|
|
||||||
http_file(
|
http_file(
|
||||||
name = "openjdk_solaris_jni_md_h",
|
name = "openjdk_solaris_jni_md_h",
|
||||||
downloaded_file_path = "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"],
|
urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk/src/solaris/javavm/export/jni_md.h"],
|
||||||
sha256 = "ecbe6944fe1a4290644d5a6b3c8f68576798a53b9da12cd31c58c48569595ff7",
|
sha256 = "b6cf7b06e5bba38d2daa2ff0789f99d396b3cb3bcc37d0367c8360fdccdef294",
|
||||||
)
|
)
|
||||||
|
|
||||||
http_file(
|
http_file(
|
||||||
name = "openjdk_macosx_jni_md_h",
|
name = "openjdk_macosx_jni_md_h",
|
||||||
downloaded_file_path = "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"],
|
urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk/src/macosx/javavm/export/jni_md.h"],
|
||||||
sha256 = "8f718071022e7e7f2fc9a229984b7e83582db91ed83861b49ce1461436fe8dc4",
|
sha256 = "8f718071022e7e7f2fc9a229984b7e83582db91ed83861b49ce1461436fe8dc4",
|
||||||
)
|
)
|
||||||
|
|
||||||
http_file(
|
http_file(
|
||||||
name = "openjdk_windows_jni_md_h",
|
name = "openjdk_windows_jni_md_h",
|
||||||
downloaded_file_path = "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"],
|
urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk/src/windows/javavm/export/jni_md.h"],
|
||||||
sha256 = "5479fb385ea1e11619f5c0cdfd9ccb3ea3a3fea0f5bc6176fb3ce62be29d759b",
|
sha256 = "5479fb385ea1e11619f5c0cdfd9ccb3ea3a3fea0f5bc6176fb3ce62be29d759b",
|
||||||
)
|
)
|
||||||
|
@ -37,8 +37,8 @@ java_binary(
|
|||||||
|
|
||||||
java_test(
|
java_test(
|
||||||
name = "bundle_checker_data_test",
|
name = "bundle_checker_data_test",
|
||||||
args = ["org/brotli/integration/test_data.zip"],
|
args = ["$(location :test_data)"],
|
||||||
data = ["test_data.zip"],
|
data = [":test_data"],
|
||||||
main_class = "org.brotli.integration.BundleChecker",
|
main_class = "org.brotli.integration.BundleChecker",
|
||||||
use_testrunner = 0,
|
use_testrunner = 0,
|
||||||
runtime_deps = [":bundle_checker"],
|
runtime_deps = [":bundle_checker"],
|
||||||
@ -48,26 +48,28 @@ java_test(
|
|||||||
name = "bundle_checker_fuzz_test",
|
name = "bundle_checker_fuzz_test",
|
||||||
args = [
|
args = [
|
||||||
"-s",
|
"-s",
|
||||||
"org/brotli/integration/fuzz_data.zip",
|
"$(location :fuzz_data)",
|
||||||
],
|
],
|
||||||
data = ["fuzz_data.zip"],
|
data = [":fuzz_data"],
|
||||||
main_class = "org.brotli.integration.BundleChecker",
|
main_class = "org.brotli.integration.BundleChecker",
|
||||||
use_testrunner = 0,
|
use_testrunner = 0,
|
||||||
runtime_deps = [":bundle_checker"],
|
runtime_deps = [":bundle_checker"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
filegroup(
|
||||||
|
name = "fuzz_data",
|
||||||
|
srcs = ["fuzz_data.zip"],
|
||||||
|
visibility = ["//visibility:private"],
|
||||||
|
)
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
name = "test_data",
|
name = "test_data",
|
||||||
srcs = ["test_data.zip"],
|
srcs = ["test_data.zip"],
|
||||||
visibility = [
|
visibility = ["//org/brotli/wrapper/dec:__pkg__"],
|
||||||
"//org/brotli/wrapper/dec:__pkg__",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
name = "test_corpus",
|
name = "test_corpus",
|
||||||
srcs = ["test_corpus.zip"],
|
srcs = ["test_corpus.zip"],
|
||||||
visibility = [
|
visibility = ["//org/brotli/wrapper/enc:__pkg__"],
|
||||||
"//org/brotli/wrapper/enc:__pkg__",
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user