Merge pull request #228 from UebelAndre/bazel

Add Bazel 9 support
This commit is contained in:
danilak-G
2026-03-03 16:49:56 +00:00
committed by GitHub
2 changed files with 29 additions and 18 deletions

View File

@@ -26,10 +26,20 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
licenses(["notice"]) licenses(["notice"])
exports_files([
"COPYING",
"COPYING.notestdata",
])
SNAPPY_VERSION = (1, 2, 2) SNAPPY_VERSION = (1, 2, 2)
config_setting( config_setting(
@@ -133,10 +143,10 @@ cc_test(
) )
# Generate a config.h similar to what cmake would produce. # Generate a config.h similar to what cmake would produce.
genrule( write_file(
name = "config_h", name = "config_h",
outs = ["config.h"], out = "config.h",
cmd = """cat <<EOF >$@ content = """\
#define HAVE_STDDEF_H 1 #define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1 #define HAVE_STDINT_H 1
#ifdef __has_builtin #ifdef __has_builtin
@@ -193,19 +203,17 @@ genrule(
# define SNAPPY_IS_BIG_ENDIAN 1 # define SNAPPY_IS_BIG_ENDIAN 1
# endif # endif
#endif #endif
EOF """.splitlines(),
""",
) )
genrule( expand_template(
name = "snappy_stubs_public_h", name = "snappy_stubs_public_h",
srcs = ["snappy-stubs-public.h.in"], out = "snappy-stubs-public.h",
outs = ["snappy-stubs-public.h"], substitutions = {
# Assume sys/uio.h is available on non-Windows. "${HAVE_SYS_UIO_H_01}": "!_WIN32",
# Set the version numbers. "${PROJECT_VERSION_MAJOR}": str(SNAPPY_VERSION[0]),
cmd = ("""sed -e 's/$${HAVE_SYS_UIO_H_01}/!_WIN32/g' \ "${PROJECT_VERSION_MINOR}": str(SNAPPY_VERSION[1]),
-e 's/$${PROJECT_VERSION_MAJOR}/%d/g' \ "${PROJECT_VERSION_PATCH}": str(SNAPPY_VERSION[2]),
-e 's/$${PROJECT_VERSION_MINOR}/%d/g' \ },
-e 's/$${PROJECT_VERSION_PATCH}/%d/g' \ template = "snappy-stubs-public.h.in",
$< >$@""" % SNAPPY_VERSION),
) )

View File

@@ -4,20 +4,23 @@ module(
compatibility_level = 1, compatibility_level = 1,
) )
bazel_dep(name = "rules_cc", version = "0.2.4")
bazel_dep(name = "bazel_skylib", version = "1.8.2")
bazel_dep( bazel_dep(
name = "googletest", name = "googletest",
version = "1.14.0.bcr.1", version = "1.17.0.bcr.2",
dev_dependency = True, dev_dependency = True,
repo_name = "com_google_googletest", repo_name = "com_google_googletest",
) )
bazel_dep( bazel_dep(
name = "google_benchmark", name = "google_benchmark",
version = "1.9.0", version = "1.9.5",
dev_dependency = True, dev_dependency = True,
repo_name = "com_google_benchmark", repo_name = "com_google_benchmark",
) )
bazel_dep( bazel_dep(
name = "platforms", name = "platforms",
version = "0.0.9", version = "1.0.0",
) )