зеркало из https://github.com/github/codeql.git
Bazel: code reorganization
This commit is contained in:
Родитель
664d5ba0a9
Коммит
13b2442fed
|
@ -27,6 +27,6 @@ http_archive(
|
|||
],
|
||||
)
|
||||
|
||||
load("@ql//:defs.bzl", "ql_utils")
|
||||
load("@ql//misc/bazel:workspace.bzl", "ql_workspace")
|
||||
|
||||
ql_utils(name = "utils")
|
||||
ql_workspace()
|
||||
|
|
14
defs.bzl
14
defs.bzl
|
@ -3,17 +3,3 @@ codeql_platform = select({
|
|||
"@platforms//os:macos": "osx64",
|
||||
"@platforms//os:windows": "win64",
|
||||
})
|
||||
|
||||
_paths_bzl = """
|
||||
def source_dir():
|
||||
return '%s/' + native.package_name()
|
||||
"""
|
||||
|
||||
def _ql_utils_impl(repository_ctx):
|
||||
root = repository_ctx.path(Label("@ql//:WORKSPACE.bazel")).realpath.dirname
|
||||
repository_ctx.file("BUILD.bazel")
|
||||
repository_ctx.file("paths.bzl", content = _paths_bzl % root)
|
||||
|
||||
ql_utils = repository_rule(
|
||||
implementation = _ql_utils_impl,
|
||||
)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
def root_source_dir():
|
||||
""" get absolute path to the root source directory
|
||||
|
||||
This can break hermeticity if used in a build step"""
|
||||
return '{root}'
|
||||
|
||||
def current_source_dir():
|
||||
""" get absolute path to the source directory of this bazel package
|
||||
|
||||
This can break hermeticity if used in a build step"""
|
||||
return root_source_dir() + '/' + native.package_name()
|
|
@ -0,0 +1,15 @@
|
|||
def _ql_utils_impl(repository_ctx):
|
||||
root = repository_ctx.path(Label("//:WORKSPACE.bazel")).realpath.dirname
|
||||
repository_ctx.file("BUILD.bazel")
|
||||
repository_ctx.template(
|
||||
"source_dir.bzl",
|
||||
Label("@ql//misc/bazel:source_dir.bzl.tpl"),
|
||||
substitutions = {"{root}": str(root)},
|
||||
)
|
||||
|
||||
_ql_utils = repository_rule(
|
||||
implementation = _ql_utils_impl,
|
||||
)
|
||||
|
||||
def ql_workspace():
|
||||
_ql_utils(name = "utils")
|
|
@ -1,4 +1,4 @@
|
|||
load("@utils//:paths.bzl", "source_dir")
|
||||
load("@utils//:source_dir.bzl", "current_source_dir")
|
||||
load("@rules_pkg//:install.bzl", "pkg_install")
|
||||
|
||||
pkg_install(
|
||||
|
@ -6,6 +6,6 @@ pkg_install(
|
|||
srcs = ["//swift:extractor-pack"],
|
||||
args = [
|
||||
"--destdir",
|
||||
source_dir() + "/../extractor_pack",
|
||||
current_source_dir() + "/../extractor_pack",
|
||||
],
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче