Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions modules/libgit2/1.9.1/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module(
name = "libgit2",
version = "1.9.1",
bazel_compatibility = [">=7.2.1"],
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "zlib", version = "1.3")
5 changes: 5 additions & 0 deletions modules/libgit2/1.9.1/overlay/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alias(
name = "libgit2",
actual = "//src/libgit2:git2",
visibility = ["//visibility:public"],
)
11 changes: 11 additions & 0 deletions modules/libgit2/1.9.1/overlay/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module(
name = "libgit2",
version = "1.9.1",
bazel_compatibility = [">=7.2.1"],
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "zlib", version = "1.3")
9 changes: 9 additions & 0 deletions modules/libgit2/1.9.1/overlay/deps/llhttp/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")

cc_library(
name = "llhttp",
srcs = glob(["*.c"]),
hdrs = ["llhttp.h"],
strip_include_prefix = "/deps/llhttp",
visibility = ["//:__subpackages__"],
)
49 changes: 49 additions & 0 deletions modules/libgit2/1.9.1/overlay/deps/pcre/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_cc//cc:cc_library.bzl", "cc_library")

_CONFIG_H = """
#define HAVE_MEMMOVE

#define NEWLINE 10
#define POSIX_MALLOC_THRESHOLD 10
#define LINK_SIZE 2
#define PARENS_NEST_LIMIT 250
#define MATCH_LIMIT 10000000
#define MATCH_LIMIT_RECURSION MATCH_LIMIT

#define MAX_NAME_SIZE 32
#define MAX_NAME_COUNT 10000
"""

write_file(
name = "pcre_config_h",
out = "config.h",
content = [_CONFIG_H],
newline = "unix",
)

cc_library(
name = "pcre_config",
hdrs = [":pcre_config_h"],
strip_include_prefix = "/deps/pcre",
)

cc_library(
name = "pcre_hdrs",
hdrs = ["pcre.h"],
strip_include_prefix = "/deps/pcre",
visibility = ["//:__subpackages__"],
)

cc_library(
name = "pcre",
srcs = glob(["*.c"]) + [
"pcre_internal.h",
"pcreposix.h",
"ucp.h",
],
implementation_deps = [":pcre_config"],
local_defines = ["HAVE_CONFIG_H"],
visibility = ["//:__subpackages__"],
deps = [":pcre_hdrs"],
)
16 changes: 16 additions & 0 deletions modules/libgit2/1.9.1/overlay/deps/xdiff/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")

cc_library(
name = "xdiff_hdrs",
hdrs = glob(["*.h"]),
strip_include_prefix = "/deps/xdiff",
visibility = ["//:__subpackages__"],
deps = ["//src/util:util_hdrs"],
)

cc_library(
name = "xdiff",
srcs = glob(["*.c"]),
visibility = ["//:__subpackages__"],
deps = [":xdiff_hdrs"],
)
12 changes: 12 additions & 0 deletions modules/libgit2/1.9.1/overlay/include/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")

cc_library(
name = "git2",
hdrs = [
"git2.h",
] + glob([
"git2/**/*.h",
]),
strip_include_prefix = "/include",
visibility = ["//:__subpackages__"],
)
34 changes: 34 additions & 0 deletions modules/libgit2/1.9.1/overlay/src/libgit2/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")

cc_library(
name = "libgit2_hdrs",
hdrs = glob(["**/*.h"]),
strip_include_prefix = "/src/libgit2",
deps = [
"//deps/xdiff:xdiff_hdrs",
"//include:git2",
"//src/util:util_hdrs",
],
)

cc_library(
name = "git2",
srcs = glob([
"**/*.c",
"**/*.h",
]),
implementation_deps = [
":libgit2_hdrs",
"//deps/llhttp",
"//deps/xdiff",
"//src/util",
],
conlyopts = select({
"@platforms//os:windows": [],
"//conditions:default": [
"-Wno-error",
],
}),
Comment on lines +26 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for? Left-over build debugging...?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcc and clang compile with warnings 1 2 and has some macros intended for user use which also produce warnings (see 1: GIT_REPOSITORY_INIT_OPTIONS_INIT) so compiling with --copts = ["-Werror"] breaks the build.

I based it on this precedence though happy to remove/change.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you revert this addition?

The @platforms//os:* conditions are for changing flags according to the target OS. If you want to set flags for specific compilers, use @bazel_tools//tools/cpp:compiler instead (see https://github.com/jmillikin/rules_bison/blob/v0.4/bison/rules/bison_repository.bzl#L56-L85 for an example).

The example you copied from is probably assuming that Windows builds always use MSVC and that non-Windows always uses either GCC or Clang, which is true for BCR CI but not generally true for actual users. For example lots of folks use Clang on Windows.

Also, looking at the links you posted, the warnings in question do seem to be legitimate -- they're warning about stuff like uninitialized variables.

If you're building your own code with -Werror that's fine, but I wouldn't recommend setting it with --copts because that'll apply it to every cc_library in your dependency tree. Many open-source projects have a ... relaxed ... approach to fixing compiler warnings, and there's always the possibility that a newer compiler will emit warnings for older code.

visibility = ["//:__subpackages__"],
deps = ["//include:git2"],
)
76 changes: 76 additions & 0 deletions modules/libgit2/1.9.1/overlay/src/util/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_cc//cc:cc_library.bzl", "cc_library")

_GIT2_FEATURES_H = """
#define GIT_REGEX_BUILTIN
#define GIT_SHA1_COLLISIONDETECT
#define GIT_SHA256_BUILTIN
#define GIT_HTTPPARSER_BUILTIN
#define GIT_THREADS
"""

write_file(
name = "git2_features_h",
out = "git2_features.h",
content = [_GIT2_FEATURES_H] +
select({
"@platforms//os:windows": ["#define GIT_IO_WSAPOLL 1"],
"//conditions:default": ["#define GIT_IO_POLL"],
}),
newline = "unix",
)

cc_library(
name = "git2_features",
hdrs = [":git2_features_h"],
strip_include_prefix = "/src/util",
)

cc_library(
name = "util_hdrs",
hdrs = glob(["**/*.h"]),
strip_include_prefix = "/src/util",
visibility = ["//:__subpackages__"],
deps = [
":git2_features",
"//deps/pcre:pcre_hdrs",
"//include:git2",
"@zlib",
],
)

GIT2_UTIL_WINDOWS_SRCS = glob([
"win32/*",
]) + ["hash/win32.c"]

GIT2_UTIL_UNIX_SRCS = glob(["unix/*"])

GIT2_UTIL_SRCS = glob(
include = ["**/*.c"],
exclude = [
"hash/common_crypto.c",
"hash/openssl.c",
] + GIT2_UTIL_WINDOWS_SRCS + GIT2_UTIL_UNIX_SRCS,
)

cc_library(
name = "util",
srcs = GIT2_UTIL_SRCS + select({
"@platforms//os:windows": GIT2_UTIL_WINDOWS_SRCS,
"//conditions:default": GIT2_UTIL_UNIX_SRCS,
}),
implementation_deps = [
"//deps/pcre",
"//deps/xdiff",
],
linkopts = select({
"@platforms//os:windows": [
"secur32.lib",
"ws2_32.lib",
"advapi32.lib",
],
"//conditions:default": [],
}),
visibility = ["//:__subpackages__"],
deps = [":util_hdrs"],
)
19 changes: 19 additions & 0 deletions modules/libgit2/1.9.1/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
matrix:
platform:
- debian10
- debian11
- ubuntu2004
- ubuntu2204
- macos
- macos_arm64
- windows
bazel:
- 7.x
- 8.x
tasks:
verify_targets:
name: Verify build targets
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets:
- '@libgit2//...'
16 changes: 16 additions & 0 deletions modules/libgit2/1.9.1/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"url": "https://github.com/libgit2/libgit2/archive/refs/tags/v1.9.1.tar.gz",
"integrity": "sha256-FMqzAUsretdZcP9FSOg2FfdNcZr+AKpHm0qInB4T/AA=",
"strip_prefix": "libgit2-1.9.1",
"patch_strip": 0,
"overlay": {
"BUILD.bazel": "sha256-fdg9xWPYD2n+6KA/6CpD3jduFkZ7tl9rMeh83e+Q+Ak=",
"MODULE.bazel": "sha256-xKjJdIvY/DT5Zhaz+NPbHPeG4v0iX/VvdiuLRwuMhes=",
"deps/llhttp/BUILD.bazel": "sha256-XLmlczQX4YDVuIz+pon+dosGRRlO08VAL/Zm4dvmrM8=",
"deps/pcre/BUILD.bazel": "sha256-LE92UDy/qqpzR/AL3YAJ5vIghMm+h4Mhgw8t4ryqByA=",
"deps/xdiff/BUILD.bazel": "sha256-kWOJfhwdeEIbw3SQ1mt+DUvidUfhxVO6nREpiZ5LWHM=",
"include/BUILD.bazel": "sha256-Rpi8QCJUzSiLYz7GoIo4aY7fCpQgYJ5I8mdWZLiQV8Y=",
"src/libgit2/BUILD.bazel": "sha256-BpsrseiJWPYlaXStaOZE9ku3dF0/Vy6dcpWGGx5CZwI=",
"src/util/BUILD.bazel": "sha256-Z6xhcmlpSh9aJUBzEISmP42Om3UvvArpZbi2T1EGaMg="
}
}
3 changes: 2 additions & 1 deletion modules/libgit2/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"versions": [
"1.8.1",
"1.8.1.bcr.1",
"1.9.0"
"1.9.0",
"1.9.1"
],
"yanked_versions": {}
}