Skip to content

Commit

Permalink
Moved configure_use_malloc example to third party examples (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre authored May 21, 2021
1 parent 4e702ae commit 6202e29
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 49 deletions.
1 change: 0 additions & 1 deletion examples/.bazelignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
cmake_crosstool
configure_use_malloc
22 changes: 0 additions & 22 deletions examples/configure_use_malloc/BUILD.bazel

This file was deleted.

21 changes: 0 additions & 21 deletions examples/configure_use_malloc/WORKSPACE

This file was deleted.

7 changes: 5 additions & 2 deletions examples/third_party/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test_suite(
"//cares:test_c_ares",
"//curl:curl_build_test",
"//gn:gn_launch_test",
"//gperftools:test",
"//libgit2:libgit2_build_test",
"//libpng:test_libpng",
"//libssh2:libssh2_build_test",
Expand All @@ -21,11 +22,12 @@ test_suite(
tags = ["manual"],
tests = [
# Missing a new enough m4 to build
#"//bison:bison_build_test",
# "//bison:bison_build_test",
"//cares:test_c_ares",
"//curl:curl_build_test",
# Attempts to access git sha during configure of build so fails
#"//gn:gn_launch_test",
# "//gn:gn_launch_test",
"//gperftools:test",
"//libgit2:libgit2_build_test",
"//libpng:test_libpng",
"//libssh2:libssh2_build_test",
Expand All @@ -41,6 +43,7 @@ test_suite(
"//cares:test_c_ares",
"//curl:curl_build_test",
"//gn:gn_launch_test",
"//gperftools:test",
"//iconv:iconv_build_test",
"//libgit2:libgit2_build_test",
"//libpng:test_libpng",
Expand Down
34 changes: 34 additions & 0 deletions examples/third_party/gperftools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
# load("@rules_cc//cc:defs.bzl", "cc_test")

exports_files(
[
"BUILD.gperftools.bazel",
],
visibility = ["//visibility:public"],
)

# TODO(rules_foreign_cc#227) This currently gives an error:
# "ERROR: <...>/use_malloc/BUILD:17:14: in malloc attribute of cc_test rule //:test:
# configure_make rule '@gperftools//:gperftools_build' is misplaced here (expected cc_library)"
# cc_test(
# name = "malloc_test",
# srcs = ["malloc_test.cpp"],
# malloc = "@gperftools//:gperftools_build",
# )

build_test(
name = "build_test",
targets = [
"@gperftools//:gperftools_build",
],
)

test_suite(
name = "test",
tests = [
":build_test",
# ":malloc_test",
],
visibility = ["//:__pkg__"],
)
22 changes: 22 additions & 0 deletions examples/third_party/gperftools/BUILD.gperftools.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")

filegroup(
name = "all_srcs",
srcs = glob(["**"]),
)

configure_make(
name = "gperftools_build",
configure_env_vars = select({
"@platforms//os:macos": {"AR": ""},
"//conditions:default": {},
}),
configure_options = [
"--enable-shared=no",
"--enable-frame-pointers",
"--disable-libunwind",
],
lib_source = ":all_srcs",
out_static_libs = ["libtcmalloc_and_profiler.a"],
visibility = ["//visibility:public"],
)
14 changes: 14 additions & 0 deletions examples/third_party/gperftools/gperftools_repositories.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""A module defining the third party dependency gperftools"""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

def gperftools_repositories():
maybe(
http_archive,
name = "gperftools",
build_file = Label("//gperftools:BUILD.gperftools.bazel"),
sha256 = "1ee8c8699a0eff6b6a203e59b43330536b22bbcbe6448f54c7091e5efb0763c9",
strip_prefix = "gperftools-2.7",
urls = ["https://github.com/gperftools/gperftools/releases/download/gperftools-2.7/gperftools-2.7.tar.gz"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

int main(int argc, char* argv[])
{
std::cout << "Hi there!";
}
std::cout << "Hi there!";
}
5 changes: 4 additions & 1 deletion examples/third_party/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# buildifier: disable=module-docstring
"""A centralized module defining all repositories required for third party examples of rules_foreign_cc"""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//bison:bison_repositories.bzl", "bison_repositories")
load("//cares:cares_repositories.bzl", "cares_repositories")
load("//curl:curl_repositories.bzl", "curl_repositories")
load("//gn:gn_repositories.bzl", "gn_repositories")
load("//gperftools:gperftools_repositories.bzl", "gperftools_repositories")
load("//iconv:iconv_repositories.bzl", "iconv_repositories")
load("//libgit2:libgit2_repositories.bzl", "libgit2_repositories")
load("//libpng:libpng_repositories.bzl", "libpng_repositories")
Expand All @@ -20,6 +22,7 @@ def repositories():
cares_repositories()
curl_repositories()
gn_repositories()
gperftools_repositories()
iconv_repositories()
libgit2_repositories()
libpng_repositories()
Expand Down

0 comments on commit 6202e29

Please sign in to comment.