Skip to content

Commit

Permalink
Support consuming sign-here via bzlmod
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkerber committed Apr 8, 2024
1 parent 0e7b148 commit e1c5fc1
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 46 deletions.
13 changes: 11 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
bazel_dep(name = "rules_apple", version = "3.2.1", repo_name = "build_bazel_rules_apple")
module(name = "sign-here")

bazel_dep(name = "rules_apple", version = "3.5.0", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "rules_swift", version = "1.18.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "swift-syntax", version = "509.0.2", repo_name = "SwiftSyntax")
bazel_dep(name = "swift_argument_parser", version = "1.3.0", repo_name = "com_github_apple_swift_argument_parser")

non_module_dependencies = use_extension("//:extensions.bzl", "non_module_dependencies")
use_repo(non_module_dependencies, "data_file")
use_repo(
non_module_dependencies,
"com_github_kitura_blueecc",
"com_github_kylef_pathkit",
)
2 changes: 1 addition & 1 deletion extensions.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//:repositories.bzl", "sign_here_dependencies")

def _non_module_dependencies_impl(_ctx):
sign_here_dependencies()
sign_here_dependencies(bzlmod = True)

non_module_dependencies = module_extension(
implementation = _non_module_dependencies_impl,
Expand Down
90 changes: 47 additions & 43 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,9 @@ def _maybe(repo_rule, name, **kwargs):
if not native.existing_rule(name):
repo_rule(name = name, **kwargs)

def sign_here_dependencies():
def sign_here_dependencies(bzlmod = False):
"""Sets up all necessary transitive dependencies."""

_maybe(
http_archive,
name = "com_github_apple_swift_argument_parser",
url = "https://github.com/apple/swift-argument-parser/archive/refs/tags/1.2.2.tar.gz",
strip_prefix = "swift-argument-parser-1.2.2",
sha256 = "44782ba7180f924f72661b8f457c268929ccd20441eac17301f18eff3b91ce0c",
build_file_content = """
load(
"@build_bazel_rules_swift//swift:swift.bzl",
"swift_library",
)
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "ArgumentParserToolInfo",
module_name = "ArgumentParserToolInfo",
srcs = glob([
"Sources/ArgumentParserToolInfo/**/*.swift"
], allow_empty = False),
)
swift_library(
name = "ArgumentParser",
module_name = "ArgumentParser",
srcs = glob([
"Sources/ArgumentParser/**/*.swift"
], allow_empty = False),
copts = [
"-suppress-warnings",
],
features = [
"-swift.treat_warnings_as_errors",
],
visibility = ["//visibility:public"],
deps = [
":ArgumentParserToolInfo"
]
)
""",
)

PATHKIT_GIT_SHA = "2fcd4618d52869b342e208324d455131a48f9e9b"
_maybe(
http_archive,
Expand Down Expand Up @@ -340,3 +298,49 @@ swift_library(
strip_prefix = "swift-syntax-%s" % SWIFT_SYNTAX_VERSION,
url = "https://github.com/apple/swift-syntax/archive/refs/tags/%s.tar.gz" % SWIFT_SYNTAX_VERSION,
)

# End non-bzlmod deps
if bzlmod:
return

_maybe(
http_archive,
name = "com_github_apple_swift_argument_parser",
url = "https://github.com/apple/swift-argument-parser/archive/refs/tags/1.2.2.tar.gz",
strip_prefix = "swift-argument-parser-1.2.2",
sha256 = "44782ba7180f924f72661b8f457c268929ccd20441eac17301f18eff3b91ce0c",
build_file_content = """
load(
"@build_bazel_rules_swift//swift:swift.bzl",
"swift_library",
)
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "ArgumentParserToolInfo",
module_name = "ArgumentParserToolInfo",
srcs = glob([
"Sources/ArgumentParserToolInfo/**/*.swift"
], allow_empty = False),
)
swift_library(
name = "ArgumentParser",
module_name = "ArgumentParser",
srcs = glob([
"Sources/ArgumentParser/**/*.swift"
], allow_empty = False),
copts = [
"-suppress-warnings",
],
features = [
"-swift.treat_warnings_as_errors",
],
visibility = ["//visibility:public"],
deps = [
":ArgumentParserToolInfo"
]
)
""",
)

0 comments on commit e1c5fc1

Please sign in to comment.