Skip to content

Commit 0924051

Browse files
committed
Use new bazel profiler BUILD setup
Fixes: #309 Change-Id: Ice21e76197b5477b5da8f5253f785a59bbd027b5
1 parent 90ea560 commit 0924051

File tree

2 files changed

+67
-2
lines changed

2 files changed

+67
-2
lines changed

MODULE.bazel

+10-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ maven.install(
167167
"org.threeten:threeten-extra:1.5.0",
168168
"org.tukaani:xz:1.9",
169169
"org.yaml:snakeyaml:1.28",
170-
"tools.profiler:async-profiler:3.0",
171170
# The following jars are for testing.
172171
# junit is not test only due to //src/java_tools/junitrunner/java/com/google/testing/junit/junit4:runner,
173172
# and hamcrest is a dependency of junit.
@@ -189,4 +188,14 @@ maven.install(
189188
],
190189
strict_visibility = True,
191190
)
191+
192+
async_profiler_repos = use_extension("//:repositories.bzl", "async_profiler_repos")
193+
use_repo(
194+
async_profiler_repos,
195+
"async_profiler",
196+
"async_profiler_linux_arm64",
197+
"async_profiler_linux_x64",
198+
"async_profiler_macos",
199+
)
200+
192201
use_repo(maven, "maven")

repositories.bzl

+57-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
15+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
1616
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
1717
load("//third_party:bazel.bzl", "bazel_sha256", "bazel_version")
1818
load("//third_party:bazel_skylib.bzl", "skylib_sha256", "skylib_version")
@@ -175,3 +175,59 @@ def _non_module_deps(_):
175175
)
176176

177177
non_module_deps = module_extension(implementation = _non_module_deps)
178+
179+
def _async_profiler_repos(ctx):
180+
http_file(
181+
name = "async_profiler",
182+
downloaded_file_path = "async-profiler.jar",
183+
# At commit f0ceda6356f05b7ad0a6593670c8c113113bf0b3 (2024-12-09).
184+
sha256 = "da95a5292fb203966196ecb68a39a8c26ad7276aeef642ec1de872513be1d8b3",
185+
urls = ["https://mirror.bazel.build/github.com/async-profiler/async-profiler/releases/download/nightly/async-profiler.jar"],
186+
)
187+
188+
_ASYNC_PROFILER_BUILD_TEMPLATE = """
189+
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
190+
copy_file(
191+
name = "libasyncProfiler",
192+
src = "libasyncProfiler.{ext}",
193+
out = "{tag}/libasyncProfiler.so",
194+
visibility = ["//visibility:public"],
195+
)
196+
"""
197+
198+
http_archive(
199+
name = "async_profiler_linux_arm64",
200+
build_file_content = _ASYNC_PROFILER_BUILD_TEMPLATE.format(
201+
ext = "so",
202+
tag = "linux-arm64",
203+
),
204+
sha256 = "7c6243bb91272a2797acb8cc44acf3e406e0b658a94d90d9391ca375fc961857",
205+
strip_prefix = "async-profiler-3.0-f0ceda6-linux-arm64/lib",
206+
urls = ["https://mirror.bazel.build/github.com/async-profiler/async-profiler/releases/download/nightly/async-profiler-3.0-f0ceda6-linux-arm64.tar.gz"],
207+
)
208+
209+
http_archive(
210+
name = "async_profiler_linux_x64",
211+
build_file_content = _ASYNC_PROFILER_BUILD_TEMPLATE.format(
212+
ext = "so",
213+
tag = "linux-x64",
214+
),
215+
sha256 = "448a3dc681375860eba2264d6cae7a848bd3f07f81f547a9ce58b742a1541d25",
216+
strip_prefix = "async-profiler-3.0-f0ceda6-linux-x64/lib",
217+
urls = ["https://mirror.bazel.build/github.com/async-profiler/async-profiler/releases/download/nightly/async-profiler-3.0-f0ceda6-linux-x64.tar.gz"],
218+
)
219+
220+
http_archive(
221+
name = "async_profiler_macos",
222+
build_file_content = _ASYNC_PROFILER_BUILD_TEMPLATE.format(
223+
ext = "dylib",
224+
tag = "macos",
225+
),
226+
sha256 = "0651004c78d080f67763cddde6e1f58cd0d0c4cb0b57034beef80b450ff5adf2",
227+
strip_prefix = "async-profiler-3.0-f0ceda6-macos/lib",
228+
urls = ["https://mirror.bazel.build/github.com/async-profiler/async-profiler/releases/download/nightly/async-profiler-3.0-f0ceda6-macos.zip"],
229+
)
230+
231+
# This is an extension (instead of use_repo_rule usages) only to create a
232+
# lockfile entry for the distribution repo module extension.
233+
async_profiler_repos = module_extension(_async_profiler_repos)

0 commit comments

Comments
 (0)