Skip to content
Draft
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
3 changes: 3 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_shell", version = "0.6.1")
bazel_dep(name = "bazel_lib", version = "3.2.0")

cc_compatibility_proxy = use_extension("@rules_cc//cc:extensions.bzl", "compatibility_proxy")
use_repo(cc_compatibility_proxy, "cc_compatibility_proxy")

# Dev dependencies
bazel_dep(name = "gazelle", version = "0.41.0", dev_dependency = True, repo_name = "bazel_gazelle")
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.9.0", dev_dependency = True)
Expand Down
7 changes: 7 additions & 0 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ use_repo(
"bison",
"cares",
"curl",
"examples_libarchive",
"examples_zlib",
"expat",
"flex",
Expand Down Expand Up @@ -141,6 +142,12 @@ use_repo(
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "bazel_lib", version = "3.2.0")

bazel_lib_toolchains = use_extension("@bazel_lib//lib:extensions.bzl", "toolchains")
bazel_lib_toolchains.coreutils()
use_repo(bazel_lib_toolchains, "coreutils_toolchains")

register_toolchains("@coreutils_toolchains//:all")

# Support the integration tests

new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,342 @@
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake", "configure_make", "make")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

UNIX_ONLY = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"//conditions:default": ["@platforms//:incompatible"],
})

LEAF_SHARED_LIB = select({
"@platforms//os:macos": ["libleaf.dylib"],
"//conditions:default": ["libleaf.so"],
})

MIDDLE_SHARED_LIB = select({
"@platforms//os:macos": ["libmiddle.dylib"],
"//conditions:default": ["libmiddle.so"],
})

MAKE_SHARED_LIBRARY_ARGS = select({
"@platforms//os:macos": [
"SHARED_LIBRARY_SUFFIX=dylib",
"SHARED_LIBRARY_LINK_FLAG=-dynamiclib",
"LEAF_INSTALL_NAME=-Wl,-install_name,@rpath/libleaf.dylib",
"MIDDLE_INSTALL_NAME=-Wl,-install_name,@rpath/libmiddle.dylib",
],
"//conditions:default": [
"SHARED_LIBRARY_SUFFIX=so",
"SHARED_LIBRARY_LINK_FLAG=-shared",
],
})

filegroup(
name = "srcs",
srcs = glob(
["**"],
exclude = [
"BUILD.bazel",
"runtime_search_test.sh",
],
),
)

cmake(
name = "cmake_leaf",
cache_entries = {
"RUNTIME_CHAIN_COMPONENT": "leaf",
"RUNTIME_TEST_FAMILY": "cmake",
},
lib_source = ":srcs",
out_include_dir = "",
out_shared_libs = LEAF_SHARED_LIB,
runtime_library_search_directories = "enabled",
target_compatible_with = UNIX_ONLY,
)

cmake(
name = "cmake_middle",
cache_entries = {
"RUNTIME_CHAIN_COMPONENT": "middle",
"RUNTIME_TEST_FAMILY": "cmake",
},
lib_source = ":srcs",
out_include_dir = "",
out_shared_libs = MIDDLE_SHARED_LIB,
runtime_library_search_directories = "enabled",
target_compatible_with = UNIX_ONLY,
deps = [":cmake_leaf"],
)

cmake(
name = "cmake_app",
cache_entries = {
"RUNTIME_CHAIN_COMPONENT": "app",
"RUNTIME_TEST_FAMILY": "cmake",
},
lib_source = ":srcs",
out_binaries = ["runtime_app"],
out_include_dir = "",
runtime_library_search_directories = "enabled",
target_compatible_with = UNIX_ONLY,
deps = [":cmake_middle"],
)

cmake(
name = "cmake_self_bundle",
cache_entries = {
"RUNTIME_CHAIN_COMPONENT": "bundle",
"RUNTIME_TEST_FAMILY": "cmake_self",
},
include_self_runtime_library_search_directories = True,
lib_source = ":srcs",
out_binaries = ["runtime_app"],
out_include_dir = "",
out_shared_libs = LEAF_SHARED_LIB + MIDDLE_SHARED_LIB,
runtime_library_search_directories = "enabled",
target_compatible_with = UNIX_ONLY,
)

sh_test(
name = "cmake_test",
size = "small",
srcs = ["runtime_search_test.sh"],
args = [
"cmake",
"$(rlocationpath :cmake_app)",
],
data = [
":cmake_app",
"@bazel_tools//tools/bash/runfiles",
],
target_compatible_with = UNIX_ONLY,
)

sh_test(
name = "cmake_self_test",
size = "small",
srcs = ["runtime_search_test.sh"],
args = [
"cmake_self",
"$(rlocationpaths :cmake_self_bundle)",
],
data = [
":cmake_self_bundle",
"@bazel_tools//tools/bash/runfiles",
],
target_compatible_with = UNIX_ONLY,
)

make(
name = "make_leaf",
args = ["RUNTIME_TEST_FAMILY=make"] + MAKE_SHARED_LIBRARY_ARGS,
lib_source = ":srcs",
out_include_dir = "",
out_shared_libs = LEAF_SHARED_LIB,
runtime_library_search_directories = "enabled",
shared_ldflags_vars = ["LDFLAGS"],
target_compatible_with = UNIX_ONLY,
targets = [
"leaf",
"install-leaf",
],
)

make(
name = "make_middle",
args = ["RUNTIME_TEST_FAMILY=make"] + MAKE_SHARED_LIBRARY_ARGS,
lib_source = ":srcs",
out_include_dir = "",
out_shared_libs = MIDDLE_SHARED_LIB,
runtime_library_search_directories = "enabled",
shared_ldflags_vars = ["LDFLAGS"],
target_compatible_with = UNIX_ONLY,
targets = [
"middle",
"install-middle",
],
deps = [":make_leaf"],
)

make(
name = "make_app",
args = ["RUNTIME_TEST_FAMILY=make"] + MAKE_SHARED_LIBRARY_ARGS,
executable_ldflags_vars = ["LDFLAGS"],
lib_source = ":srcs",
out_binaries = ["runtime_app"],
out_include_dir = "",
runtime_library_search_directories = "enabled",
target_compatible_with = UNIX_ONLY,
targets = [
"app",
"install-app",
],
deps = [":make_middle"],
)

make(
name = "make_self_bundle",
args = ["RUNTIME_TEST_FAMILY=make_self"] + MAKE_SHARED_LIBRARY_ARGS,
executable_ldflags_vars = ["EXECUTABLE_LDFLAGS"],
include_self_runtime_library_search_directories = True,
lib_source = ":srcs",
out_binaries = ["runtime_app"],
out_include_dir = "",
out_shared_libs = LEAF_SHARED_LIB + MIDDLE_SHARED_LIB,
runtime_library_search_directories = "enabled",
shared_ldflags_vars = ["SHARED_LDFLAGS"],
target_compatible_with = UNIX_ONLY,
targets = [
"app",
"install-leaf",
"install-middle",
"install-app",
],
)

sh_test(
name = "make_test",
size = "small",
srcs = ["runtime_search_test.sh"],
args = [
"make",
"$(rlocationpath :make_app)",
],
data = [
":make_app",
"@bazel_tools//tools/bash/runfiles",
],
target_compatible_with = UNIX_ONLY,
)

sh_test(
name = "make_self_test",
size = "small",
srcs = ["runtime_search_test.sh"],
args = [
"make_self",
"$(rlocationpaths :make_self_bundle)",
],
data = [
":make_self_bundle",
"@bazel_tools//tools/bash/runfiles",
],
target_compatible_with = UNIX_ONLY,
)

configure_make(
name = "configure_make_leaf",
args = MAKE_SHARED_LIBRARY_ARGS,
configure_options = ["--family=configure_make"],
configure_prefix = "bash",
lib_source = ":srcs",
out_include_dir = "",
out_shared_libs = LEAF_SHARED_LIB,
runtime_library_search_directories = "enabled",
shared_ldflags_vars = ["LDFLAGS"],
target_compatible_with = UNIX_ONLY,
targets = [
"leaf",
"install-leaf",
],
)

configure_make(
name = "configure_make_middle",
args = MAKE_SHARED_LIBRARY_ARGS,
configure_options = ["--family=configure_make"],
configure_prefix = "bash",
lib_source = ":srcs",
out_include_dir = "",
out_shared_libs = MIDDLE_SHARED_LIB,
runtime_library_search_directories = "enabled",
shared_ldflags_vars = ["LDFLAGS"],
target_compatible_with = UNIX_ONLY,
targets = [
"middle",
"install-middle",
],
deps = [":configure_make_leaf"],
)

configure_make(
name = "configure_make_app",
args = MAKE_SHARED_LIBRARY_ARGS,
configure_options = ["--family=configure_make"],
configure_prefix = "bash",
executable_ldflags_vars = ["LDFLAGS"],
lib_source = ":srcs",
out_binaries = ["runtime_app"],
out_include_dir = "",
runtime_library_search_directories = "enabled",
target_compatible_with = UNIX_ONLY,
targets = [
"app",
"install-app",
],
deps = [":configure_make_middle"],
)

configure_make(
name = "configure_make_self_bundle",
args = MAKE_SHARED_LIBRARY_ARGS,
configure_options = ["--family=configure_make_self"],
configure_prefix = "bash",
executable_ldflags_vars = ["EXECUTABLE_LDFLAGS"],
include_self_runtime_library_search_directories = True,
lib_source = ":srcs",
out_binaries = ["runtime_app"],
out_include_dir = "",
out_shared_libs = LEAF_SHARED_LIB + MIDDLE_SHARED_LIB,
runtime_library_search_directories = "enabled",
shared_ldflags_vars = ["SHARED_LDFLAGS"],
target_compatible_with = UNIX_ONLY,
targets = [
"app",
"install-leaf",
"install-middle",
"install-app",
],
)

sh_test(
name = "configure_make_test",
size = "small",
srcs = ["runtime_search_test.sh"],
args = [
"configure_make",
"$(rlocationpath :configure_make_app)",
],
data = [
":configure_make_app",
"@bazel_tools//tools/bash/runfiles",
],
target_compatible_with = UNIX_ONLY,
)

sh_test(
name = "configure_make_self_test",
size = "small",
srcs = ["runtime_search_test.sh"],
args = [
"configure_make_self",
"$(rlocationpaths :configure_make_self_bundle)",
],
data = [
":configure_make_self_bundle",
"@bazel_tools//tools/bash/runfiles",
],
target_compatible_with = UNIX_ONLY,
)

test_suite(
name = "tests",
tests = [
":cmake_self_test",
":cmake_test",
":configure_make_self_test",
":configure_make_test",
":make_self_test",
":make_test",
],
)
Loading
Loading