diff --git a/MODULE.bazel b/MODULE.bazel index df156ebb5..10be24d5e 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -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) diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 6d6dbd586..48b053b1f 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -94,6 +94,7 @@ use_repo( "bison", "cares", "curl", + "examples_libarchive", "examples_zlib", "expat", "flex", @@ -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") diff --git a/examples/integration_tests/runtime_library_search_directories/BUILD.bazel b/examples/integration_tests/runtime_library_search_directories/BUILD.bazel new file mode 100644 index 000000000..81aef38fe --- /dev/null +++ b/examples/integration_tests/runtime_library_search_directories/BUILD.bazel @@ -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", + ], +) diff --git a/examples/integration_tests/runtime_library_search_directories/CMakeLists.txt b/examples/integration_tests/runtime_library_search_directories/CMakeLists.txt new file mode 100644 index 000000000..828d4b18e --- /dev/null +++ b/examples/integration_tests/runtime_library_search_directories/CMakeLists.txt @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 3.15) + +project(runtime_search C) + +set(RUNTIME_CHAIN_COMPONENT "" CACHE STRING "Component to build: leaf, middle, or app") +set(RUNTIME_TEST_FAMILY "cmake" CACHE STRING "Rule family marker for the runtime test") + +if(APPLE) + set(CMAKE_INSTALL_NAME_DIR "@rpath") + set(CMAKE_MACOSX_RPATH ON) +endif() + +function(runtime_chain_compile_definitions target) + target_compile_definitions( + ${target} + PRIVATE + RUNTIME_TEST_FAMILY="${RUNTIME_TEST_FAMILY}" + ) + target_include_directories(${target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") +endfunction() + +if(RUNTIME_CHAIN_COMPONENT STREQUAL "leaf") + add_library(leaf SHARED src/leaf.c) + runtime_chain_compile_definitions(leaf) + install(TARGETS leaf LIBRARY DESTINATION lib) +elseif(RUNTIME_CHAIN_COMPONENT STREQUAL "middle") + find_library(RUNTIME_CHAIN_LEAF_LIBRARY NAMES leaf REQUIRED) + add_library(middle SHARED src/middle.c) + runtime_chain_compile_definitions(middle) + target_link_libraries(middle PRIVATE "${RUNTIME_CHAIN_LEAF_LIBRARY}") + install(TARGETS middle LIBRARY DESTINATION lib) +elseif(RUNTIME_CHAIN_COMPONENT STREQUAL "app") + find_library(RUNTIME_CHAIN_MIDDLE_LIBRARY NAMES middle REQUIRED) + add_executable(runtime_app src/app.c) + runtime_chain_compile_definitions(runtime_app) + target_link_libraries(runtime_app PRIVATE "${RUNTIME_CHAIN_MIDDLE_LIBRARY}") + install(TARGETS runtime_app RUNTIME DESTINATION bin) +elseif(RUNTIME_CHAIN_COMPONENT STREQUAL "bundle") + add_library(leaf SHARED src/leaf.c) + runtime_chain_compile_definitions(leaf) + add_library(middle SHARED src/middle.c) + runtime_chain_compile_definitions(middle) + target_link_libraries(middle PRIVATE leaf) + add_executable(runtime_app src/app.c) + runtime_chain_compile_definitions(runtime_app) + target_link_libraries(runtime_app PRIVATE middle) + install(TARGETS leaf middle runtime_app LIBRARY DESTINATION lib RUNTIME DESTINATION bin) +else() + message(FATAL_ERROR "RUNTIME_CHAIN_COMPONENT must be one of: leaf, middle, app, bundle") +endif() diff --git a/examples/integration_tests/runtime_library_search_directories/Makefile b/examples/integration_tests/runtime_library_search_directories/Makefile new file mode 100644 index 000000000..080a196b3 --- /dev/null +++ b/examples/integration_tests/runtime_library_search_directories/Makefile @@ -0,0 +1,14 @@ +PREFIX ?= $(INSTALL_PREFIX) +PREFIX ?= install +RUNTIME_TEST_FAMILY ?= make +SRC_DIR ?= src + +.PHONY: all clean test + +all: app + +clean: + +test: all + +include runtime_chain_rules.mk diff --git a/examples/integration_tests/runtime_library_search_directories/Makefile.in b/examples/integration_tests/runtime_library_search_directories/Makefile.in new file mode 100644 index 000000000..eafe5c449 --- /dev/null +++ b/examples/integration_tests/runtime_library_search_directories/Makefile.in @@ -0,0 +1,17 @@ +PREFIX := @prefix@ +RUNTIME_TEST_FAMILY := @family@ +SRC_DIR := @srcdir@/src +CC := @cc@ +CFLAGS := @cflags@ +CPPFLAGS := @cppflags@ +LDFLAGS := @ldflags@ + +.PHONY: all clean test + +all: app + +clean: + +test: all + +include @srcdir@/runtime_chain_rules.mk diff --git a/examples/integration_tests/runtime_library_search_directories/README.md b/examples/integration_tests/runtime_library_search_directories/README.md new file mode 100644 index 000000000..97a2395a2 --- /dev/null +++ b/examples/integration_tests/runtime_library_search_directories/README.md @@ -0,0 +1,116 @@ +# Runtime library search directories + +This package tests that foreign_cc can add runtime loader search paths for +libraries produced by other foreign_cc targets and for libraries produced by the +same foreign_cc target. + +The tests are intentionally small. They do not try to cover every possible +native or foreign_cc provider shape; that broader matrix lives in +`examples/integration_tests/transitive_matrix`. This package focuses on whether +the exported `cmake`, `make`, and `configure_make` rules pass the right linker +flags to the upstream build system when +`runtime_library_search_directories = "enabled"` is set. + +On Linux, the resulting binary and shared libraries use ELF `RUNPATH` or +`RPATH`. On macOS, they use rpath install names. + +## Runtime chain + +All rule families build the same small C dependency chain: + +```text +runtime_app -> libmiddle -> libleaf +``` + +`libleaf` returns a fixed marker string. `libmiddle` calls `libleaf` and prefixes +the marker with the rule family. `runtime_app` calls `libmiddle`, prints the +result, and fails if the result does not match the expected value. + +For example, the CMake dependency-chain test expects: + +```text +cmake: expected libmiddle loaded through rpath -> expected libleaf loaded through rpath +``` + +The test runner also clears `LD_LIBRARY_PATH` and `DYLD_LIBRARY_PATH` before +running the binary. That keeps the assertion focused on runtime search paths +recorded in the binary and shared libraries, rather than ambient shell state. + +## Test shapes + +Each supported rule family has two test shapes. + +| Test shape | Example target | What it proves | +| ---------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Dependency chain | `cmake_test` | A foreign_cc binary target can find a shared library from its direct dependency, and that shared library can find a shared library from its own dependency. | +| Self bundle | `cmake_self_test` | A single foreign_cc target that produces both `bin/runtime_app` and libraries under `lib/` can make those outputs find each other when `include_self_runtime_library_search_directories = True`. | + +The same shapes are repeated for: + +| Rule family | Dependency-chain test | Self-bundle test | +| ---------------- | ----------------------- | ---------------------------- | +| `cmake` | `cmake_test` | `cmake_self_test` | +| `make` | `make_test` | `make_self_test` | +| `configure_make` | `configure_make_test` | `configure_make_self_test` | + +## Dependency-chain tests + +The dependency-chain tests build each component as a separate foreign_cc target: + +```text +_leaf -> installs libleaf under lib/ +_middle -> installs libmiddle under lib/, depends on _leaf +_app -> installs runtime_app under bin/, depends on _middle +``` + +The important behavior is that runtime search directories are derived from the +foreign_cc dependency graph: + +- `runtime_app` needs a runtime search path to find `libmiddle`. +- `libmiddle` needs a runtime search path to find `libleaf`. +- The test binary must run without `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH`. + +## Self-bundle tests + +The self-bundle tests build `runtime_app`, `libmiddle`, and `libleaf` from one +foreign_cc target: + +```text +_self_bundle -> installs runtime_app under bin/ + -> installs libmiddle and libleaf under lib/ +``` + +These tests enable: + +```python +include_self_runtime_library_search_directories = True +``` + +That verifies the companion "self" behavior: + +- a binary installed under `bin/` can find libraries installed under `lib/` +- a shared library installed under `lib/` can find sibling libraries in `lib/` + +This is useful for upstream projects that produce an executable and companion +shared libraries in the same install tree, but do not set their own relative +runtime search paths. + +## Fixture files + +| File | Purpose | +| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | +| `CMakeLists.txt` | Builds the chain for the `cmake` rule. | +| `Makefile` | Builds the chain directly for the `make` rule. | +| `configure` and `Makefile.in` | Provide a minimal configure-style wrapper for the `configure_make` rule. | +| `runtime_chain_rules.mk` | Shared Makefile logic used by `make` and `configure_make`. | +| `src/` | C sources for `runtime_app`, `libmiddle`, and `libleaf`. | +| `runtime_search_test.sh` | Shared shell test runner that resolves the Bazel runfile binary, clears ambient library search variables, and checks the printed marker. | + +## Run + +Run this package from the examples module: + +```bash +cd examples +bazel test //integration_tests/runtime_library_search_directories:tests --test_output=errors +``` diff --git a/examples/integration_tests/runtime_library_search_directories/configure b/examples/integration_tests/runtime_library_search_directories/configure new file mode 100755 index 000000000..4bf285076 --- /dev/null +++ b/examples/integration_tests/runtime_library_search_directories/configure @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -euo pipefail + +prefix="" +family="configure_make" + +for arg in "$@"; do + case "$arg" in + --prefix=*) + prefix="${arg#--prefix=}" + ;; + --family=*) + family="${arg#--family=}" + ;; + esac +done + +if [[ -z "$prefix" ]]; then + echo "missing required --prefix option" >&2 + exit 1 +fi + +srcdir="$(cd "$(dirname "$0")" && pwd)" + +escape_sed_replacement() { + printf '%s' "$1" | sed 's/[&|\\]/\\&/g' +} + +sed \ + -e "s|@prefix@|$prefix|g" \ + -e "s|@family@|$family|g" \ + -e "s|@srcdir@|$srcdir|g" \ + -e "s|@cc@|$(escape_sed_replacement "${CC:-cc}")|g" \ + -e "s|@cflags@|$(escape_sed_replacement "${CFLAGS:-}")|g" \ + -e "s|@cppflags@|$(escape_sed_replacement "${CPPFLAGS:-}")|g" \ + -e "s|@ldflags@|$(escape_sed_replacement "${LDFLAGS:-}")|g" \ + "$srcdir/Makefile.in" > Makefile diff --git a/examples/integration_tests/runtime_library_search_directories/runtime_chain_rules.mk b/examples/integration_tests/runtime_library_search_directories/runtime_chain_rules.mk new file mode 100644 index 000000000..e5fb05090 --- /dev/null +++ b/examples/integration_tests/runtime_library_search_directories/runtime_chain_rules.mk @@ -0,0 +1,56 @@ +BUILD_DIR ?= build +CC ?= cc +CFLAGS ?= +CPPFLAGS ?= +LDFLAGS ?= +EXECUTABLE_LDFLAGS ?= $(LDFLAGS) +SHARED_LDFLAGS ?= $(LDFLAGS) +SHARED_LIBRARY_SUFFIX ?= so +SHARED_LIBRARY_LINK_FLAG ?= -shared +LEAF_INSTALL_NAME ?= +MIDDLE_INSTALL_NAME ?= + +RUNTIME_CHAIN_CPPFLAGS = $(CPPFLAGS) -I$(SRC_DIR) -DRUNTIME_TEST_FAMILY=\"$(RUNTIME_TEST_FAMILY)\" +LEAF_SHARED_LIBRARY = libleaf.$(SHARED_LIBRARY_SUFFIX) +MIDDLE_SHARED_LIBRARY = libmiddle.$(SHARED_LIBRARY_SUFFIX) +LEAF_SHARED_LIBRARY_PATH = $(BUILD_DIR)/lib/$(LEAF_SHARED_LIBRARY) +MIDDLE_SHARED_LIBRARY_PATH = $(BUILD_DIR)/lib/$(MIDDLE_SHARED_LIBRARY) + +.PHONY: all leaf middle app install-leaf install-middle install-app clean test + +all: app + +test: all + +leaf: $(LEAF_SHARED_LIBRARY_PATH) + +middle: leaf $(MIDDLE_SHARED_LIBRARY_PATH) + +app: middle $(BUILD_DIR)/bin/runtime_app + +$(LEAF_SHARED_LIBRARY_PATH): $(SRC_DIR)/leaf.c $(SRC_DIR)/runtime_chain.h + mkdir -p $(BUILD_DIR)/lib + $(CC) $(CFLAGS) $(RUNTIME_CHAIN_CPPFLAGS) -fPIC $(SHARED_LIBRARY_LINK_FLAG) $(SRC_DIR)/leaf.c -o $@ $(LEAF_INSTALL_NAME) $(SHARED_LDFLAGS) + +$(MIDDLE_SHARED_LIBRARY_PATH): $(SRC_DIR)/middle.c $(SRC_DIR)/runtime_chain.h $(LEAF_SHARED_LIBRARY_PATH) + mkdir -p $(BUILD_DIR)/lib + $(CC) $(CFLAGS) $(RUNTIME_CHAIN_CPPFLAGS) -fPIC $(SHARED_LIBRARY_LINK_FLAG) $(SRC_DIR)/middle.c -o $@ $(MIDDLE_INSTALL_NAME) -L$(BUILD_DIR)/lib $(SHARED_LDFLAGS) -lleaf + +$(BUILD_DIR)/bin/runtime_app: $(SRC_DIR)/app.c $(SRC_DIR)/runtime_chain.h $(MIDDLE_SHARED_LIBRARY_PATH) + mkdir -p $(BUILD_DIR)/bin + $(CC) $(CFLAGS) $(RUNTIME_CHAIN_CPPFLAGS) $(SRC_DIR)/app.c -o $@ -L$(BUILD_DIR)/lib $(EXECUTABLE_LDFLAGS) -lmiddle + +install-leaf: leaf + mkdir -p $(PREFIX)/lib + cp -p $(LEAF_SHARED_LIBRARY_PATH) $(PREFIX)/lib/ + +install-middle: middle + mkdir -p $(PREFIX)/lib + cp -p $(MIDDLE_SHARED_LIBRARY_PATH) $(PREFIX)/lib/ + +install-app: app + mkdir -p $(PREFIX)/bin + cp -p $(BUILD_DIR)/bin/runtime_app $(PREFIX)/bin/ + +clean: + rm -rf $(BUILD_DIR) diff --git a/examples/integration_tests/runtime_library_search_directories/runtime_search_test.sh b/examples/integration_tests/runtime_library_search_directories/runtime_search_test.sh new file mode 100755 index 000000000..3a6f434f9 --- /dev/null +++ b/examples/integration_tests/runtime_library_search_directories/runtime_search_test.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +set -euo pipefail + +set +u +f=bazel_tools/tools/bash/runfiles/runfiles.bash +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -d ' ' -f 2-)" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -d ' ' -f 2-)" 2>/dev/null || { + echo >&2 "cannot find $f" + exit 1 + } +set -u + +if [[ "$#" -lt 2 ]]; then + echo "usage: $0 [runfile-path ...]" >&2 + exit 1 +fi + +family="$1" +shift + +binary_runfile_path="" +for arg in "$@"; do + read -r -a candidates <<< "$arg" + for candidate in "${candidates[@]}"; do + case "$candidate" in + */runtime_app) + binary_runfile_path="$candidate" + break 2 + ;; + esac + done +done + +if [[ -z "$binary_runfile_path" ]]; then + echo "runtime test binary runfile path not found in: $*" >&2 + exit 1 +fi + +binary="$(rlocation "$binary_runfile_path")" +if [[ -z "$binary" || ! -x "$binary" ]]; then + echo "runtime test binary is not executable: $binary_runfile_path" >&2 + exit 1 +fi + +stdout_file="$TEST_TMPDIR/runtime-search-stdout.txt" +stderr_file="$TEST_TMPDIR/runtime-search-stderr.txt" + +set +e +env -u LD_LIBRARY_PATH -u DYLD_LIBRARY_PATH "$binary" >"$stdout_file" 2>"$stderr_file" +status="$?" +set -e + +if [[ "$status" -ne 0 ]]; then + echo "runtime test binary failed with exit code $status" >&2 + cat "$stderr_file" >&2 + exit "$status" +fi + +expected="$family: expected libmiddle loaded through rpath -> expected libleaf loaded through rpath" +actual="$(cat "$stdout_file")" + +if [[ "$actual" != "$expected" ]]; then + echo "unexpected runtime marker" >&2 + echo "expected: $expected" >&2 + echo "actual: $actual" >&2 + cat "$stderr_file" >&2 + exit 1 +fi diff --git a/examples/integration_tests/runtime_library_search_directories/src/app.c b/examples/integration_tests/runtime_library_search_directories/src/app.c new file mode 100644 index 000000000..868408fdf --- /dev/null +++ b/examples/integration_tests/runtime_library_search_directories/src/app.c @@ -0,0 +1,23 @@ +#include +#include + +#include "runtime_chain.h" + +#ifndef RUNTIME_TEST_FAMILY +#define RUNTIME_TEST_FAMILY "unknown" +#endif + +int main(void) { + const char* actual = middle_marker(); + const char* expected = RUNTIME_TEST_FAMILY + ": expected libmiddle loaded through rpath -> expected libleaf loaded " + "through rpath"; + + puts(actual); + if (strcmp(actual, expected) != 0) { + fprintf(stderr, "expected: %s\n", expected); + fprintf(stderr, "actual: %s\n", actual); + return 1; + } + return 0; +} diff --git a/examples/integration_tests/runtime_library_search_directories/src/leaf.c b/examples/integration_tests/runtime_library_search_directories/src/leaf.c new file mode 100644 index 000000000..3a50e26a0 --- /dev/null +++ b/examples/integration_tests/runtime_library_search_directories/src/leaf.c @@ -0,0 +1,5 @@ +#include "runtime_chain.h" + +const char* leaf_marker(void) { + return "expected libleaf loaded through rpath"; +} diff --git a/examples/integration_tests/runtime_library_search_directories/src/middle.c b/examples/integration_tests/runtime_library_search_directories/src/middle.c new file mode 100644 index 000000000..2ced6a308 --- /dev/null +++ b/examples/integration_tests/runtime_library_search_directories/src/middle.c @@ -0,0 +1,16 @@ +#include + +#include "runtime_chain.h" + +#ifndef RUNTIME_TEST_FAMILY +#define RUNTIME_TEST_FAMILY "unknown" +#endif + +const char* middle_marker(void) { + static char marker[256]; + + snprintf(marker, sizeof(marker), + "%s: expected libmiddle loaded through rpath -> %s", + RUNTIME_TEST_FAMILY, leaf_marker()); + return marker; +} diff --git a/examples/integration_tests/runtime_library_search_directories/src/runtime_chain.h b/examples/integration_tests/runtime_library_search_directories/src/runtime_chain.h new file mode 100644 index 000000000..921ab315f --- /dev/null +++ b/examples/integration_tests/runtime_library_search_directories/src/runtime_chain.h @@ -0,0 +1,7 @@ +#ifndef RUNTIME_CHAIN_H_ +#define RUNTIME_CHAIN_H_ + +const char* leaf_marker(void); +const char* middle_marker(void); + +#endif diff --git a/examples/integration_tests/transitive_matrix/BUILD.bazel b/examples/integration_tests/transitive_matrix/BUILD.bazel new file mode 100644 index 000000000..c6da5d796 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/BUILD.bazel @@ -0,0 +1,112 @@ +exports_files( + [ + "app.c", + "linkage_test.sh", + "runtime_test.sh", + ], + visibility = ["//visibility:public"], +) + +filegroup( + name = "foreign_app_srcs", + srcs = [ + "CMakeLists.txt", + "app.c", + ], + visibility = ["//visibility:public"], +) + +test_suite( + name = "runtime_tests", + tests = [ + ":cc_binary_runtime_tests", + ":cmake_runtime_tests", + ], +) + +test_suite( + name = "linkage_tests", + tests = [ + ":cc_binary_linkage_tests", + ":cmake_linkage_tests", + ], +) + +test_suite( + name = "cc_binary_tests", + tests = [ + ":cc_binary_linkage_tests", + ":cc_binary_runtime_tests", + ], +) + +test_suite( + name = "cmake_tests", + tests = [ + ":cmake_linkage_tests", + ":cmake_runtime_tests", + ], +) + +test_suite( + name = "provider_parity_tests", + tests = [ + "//integration_tests/transitive_matrix/provider_parity:tests", + ], +) + +test_suite( + name = "known_gap_tests", + tests = [ + "//integration_tests/transitive_matrix/known_gap:tests", + ], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":provider_parity_tests", + ":runtime_tests", + ], +) + +test_suite( + name = "cc_binary_runtime_tests", + tests = [ + "//integration_tests/transitive_matrix/cc_direct:runtime_tests", + "//integration_tests/transitive_matrix/cc_dynamic:runtime_tests", + "//integration_tests/transitive_matrix/cc_static:runtime_tests", + "//integration_tests/transitive_matrix/cc_wrap:runtime_tests", + ], +) + +test_suite( + name = "cc_binary_linkage_tests", + tests = [ + "//integration_tests/transitive_matrix/cc_direct:linkage_tests", + "//integration_tests/transitive_matrix/cc_dynamic:linkage_tests", + "//integration_tests/transitive_matrix/cc_static:linkage_tests", + "//integration_tests/transitive_matrix/cc_wrap:linkage_tests", + ], +) + +test_suite( + name = "cmake_runtime_tests", + tests = [ + "//integration_tests/transitive_matrix/cmake_direct:runtime_tests", + "//integration_tests/transitive_matrix/cmake_dynamic:runtime_tests", + "//integration_tests/transitive_matrix/cmake_static:runtime_tests", + "//integration_tests/transitive_matrix/cmake_wrap:runtime_tests", + ], +) + +test_suite( + name = "cmake_linkage_tests", + tests = [ + "//integration_tests/transitive_matrix/cmake_direct:linkage_tests", + "//integration_tests/transitive_matrix/cmake_dynamic:linkage_tests", + "//integration_tests/transitive_matrix/cmake_static:linkage_tests", + "//integration_tests/transitive_matrix/cmake_wrap:linkage_tests", + ], +) diff --git a/examples/integration_tests/transitive_matrix/CMakeLists.txt b/examples/integration_tests/transitive_matrix/CMakeLists.txt new file mode 100644 index 000000000..97d887d90 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/CMakeLists.txt @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 3.15) + +project(transitive_cc_foreign_libarchive_matrix C) + +set(LIBARCHIVE_LIBRARY_NAME "archive" CACHE STRING "Library name to find for libarchive") +set(ZLIB_LIBRARY_NAME "" CACHE STRING "Optional library name to find for zlib") + +if(APPLE) + set(CMAKE_INSTALL_NAME_DIR "@rpath") + set(CMAKE_MACOSX_RPATH ON) +endif() + +function(matrix_add_dependency target library_name header_name) + find_library( + APP_FOUND_LIBRARY + NAMES ${library_name} + REQUIRED + ) + find_path( + APP_FOUND_INCLUDE_DIR + NAMES ${header_name} + REQUIRED + ) + target_link_libraries(${target} PRIVATE "${APP_FOUND_LIBRARY}") + target_include_directories(${target} PRIVATE "${APP_FOUND_INCLUDE_DIR}") + unset(APP_FOUND_LIBRARY CACHE) + unset(APP_FOUND_INCLUDE_DIR CACHE) +endfunction() + +function(matrix_add_optional_dependency target library_name header_name) + if(NOT library_name) + return() + endif() + find_library(APP_FOUND_LIBRARY NAMES ${library_name}) + find_path(APP_FOUND_INCLUDE_DIR NAMES ${header_name}) + if(APP_FOUND_LIBRARY AND APP_FOUND_INCLUDE_DIR) + target_link_libraries(${target} PRIVATE "${APP_FOUND_LIBRARY}") + target_include_directories(${target} PRIVATE "${APP_FOUND_INCLUDE_DIR}") + endif() + unset(APP_FOUND_LIBRARY CACHE) + unset(APP_FOUND_INCLUDE_DIR CACHE) +endfunction() + +add_executable(app app.c) +matrix_add_dependency(app "${LIBARCHIVE_LIBRARY_NAME}" archive.h) +matrix_add_optional_dependency(app "${ZLIB_LIBRARY_NAME}" zlib.h) +if(CMAKE_DL_LIBS) + target_link_libraries(app PRIVATE "${CMAKE_DL_LIBS}") +endif() +install(TARGETS app RUNTIME DESTINATION bin) diff --git a/examples/integration_tests/transitive_matrix/README.md b/examples/integration_tests/transitive_matrix/README.md new file mode 100644 index 000000000..9f3c9492a --- /dev/null +++ b/examples/integration_tests/transitive_matrix/README.md @@ -0,0 +1,242 @@ +# Transitive zlib/libarchive native/foreign matrix + +This directory tests a real upstream C dependency graph: + +```text +app binary -> libarchive -> zlib +``` + +Both zlib and libarchive are built from source. zlib targets are modeled after +`examples/third_party/zlib/BUILD.zlib.bazel`; libarchive has matching source +targets in `examples/third_party/libarchive/BUILD.libarchive.bazel`. + +## Goals + +- Confirm source-built zlib and libarchive can be substituted across native + `cc_*` and foreign_cc producers. +- Confirm final binaries link and run correctly through the transitive + `app -> libarchive -> zlib` path. +- Confirm produced binaries and shared libraries record the expected + static-versus-shared dependency shape. +- Confirm shared-library runtime loading works without ambient + `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` on Unix, and with only the expected + Bazel output DLL directories on Windows. +- Confirm foreign_cc-produced `CcInfo` has semantic parity with comparable + native `cc_*` provider targets after normalizing implementation-specific + filenames and symlink shapes. + +## Matrix and layout + +The layout is divided into three sections: + +1. `cc_*` and `cmake_*` directories contain the matrix runtime and linkage + tests for every scenario involving the transitive path from `app` to `zlib`. + There are 48 scenarios in total. +2. `provider_parity` contains `CcInfo` provider parity tests for zlib and + libarchive producers. +3. `known_gap` contains tests for known gaps in foreign_cc that have not been + remediated yet. + +For the matrix tests, the package prefix identifies the app consumer: + +| Package prefix | Role | +| -------------- | -------------------- | +| `cc_*` | `cc_binary` consumer | +| `cmake_*` | `cmake` consumer | + +The package suffix identifies how the app consumes libarchive: + +| Package suffix | Role | +| -------------- | -------------------------------------------------------------------------- | +| `*_static` | app consuming a static libarchive producer through `deps` | +| `*_direct` | app consuming a foreign shared libarchive producer directly through `deps` | +| `*_wrap` | app consuming native shared libarchive through a `cc_library` wrapper | +| `*_dynamic` | app consuming native shared libarchive through `dynamic_deps` | + +Because Windows has long-path limits, leaf packages and targets use short IDs. +The context for each scenario is described in the individual `BUILD.bazel` +file. The leaf packages also prevent different targets in the same package from +producing conflicting DLLs, such as multiple differently linked `archive.dll` +files in one package output directory. + +## Scenarios + +The matrix suite implements 48 app build scenarios, with one runtime test and +one linkage test per scenario. The scenarios are enumerated from four zlib +producer shapes, four libarchive producer shapes, and the valid app link modes +for each libarchive output shape. Each libarchive producer shape is crossed +with the four zlib producer shapes, giving 16 libarchive producer targets. + +### Producers + +| Producer | Shape | Target family | +| ---------- | --------------- | --------------------------------------------------------- | +| zlib | static | `@examples_zlib//:zlib_static` | +| zlib | foreign static | `@examples_zlib//:zlib_foreign_static` | +| zlib | dynamic wrapper | `@examples_zlib//:zlib_dynamic` | +| zlib | foreign shared | `@examples_zlib//:zlib_foreign_shared` | +| libarchive | static | `@examples_libarchive//:libarchive_static_zlib_*` | +| libarchive | foreign static | `@examples_libarchive//:libarchive_foreign_static_zlib_*` | +| libarchive | dynamic wrapper | `@examples_libarchive//:libarchive_dynamic_zlib_*` | +| libarchive | foreign shared | `@examples_libarchive//:libarchive_foreign_shared_zlib_*` | + +See [BUILD.zlib.bazel](../../third_party/zlib/BUILD.zlib.bazel) and +[BUILD.libarchive.bazel](../../third_party/libarchive/BUILD.libarchive.bazel). + +### Consumers + +Each leaf package lists one explicit scenario-level macro call. The call site +shows the app producer, app link mode, `deps`, `dynamic_deps` where applicable, +`linkstatic` where applicable, and expected runtime-loaded libraries. + +Except for `cmake_static`, the app-level consumer only links libarchive as a +direct dep; zlib enters transitively through the selected libarchive target. +`cmake_static` is the exception: those CMake app targets list zlib directly as +well, because CMake owns the final static link command. In the native +`cc_binary` static cases, Bazel traverses `CcInfo` from libarchive and adds the +required zlib archive to the final link line. A foreign_cc CMake app instead +receives staged libraries and link flags, then the upstream CMake project +decides what to pass to its `target_link_libraries`. A raw static libarchive +path does not carry a CMake transitive link interface for zlib, so these cases +name zlib explicitly to model a complete upstream static link. + +| App package | ID | Consumer | linkstatic | Link mode (libarchive) | Link mode (zlib) | BUILD file | +| --------------- | -------- | ----------- | ---------- | ------------------------ | --------------------- | -------------------------------------------------------- | +| `cc_static` | `s001` | `cc_binary` | `True` | native static | native static | [cc_static/s001](cc_static/s001/BUILD.bazel) | +| `cc_static` | `s002` | `cc_binary` | `False` | native static | native static | [cc_static/s002](cc_static/s002/BUILD.bazel) | +| `cc_static` | `s003` | `cc_binary` | `True` | native static | foreign_cc static | [cc_static/s003](cc_static/s003/BUILD.bazel) | +| `cc_static` | `s004` | `cc_binary` | `False` | native static | foreign_cc static | [cc_static/s004](cc_static/s004/BUILD.bazel) | +| `cc_static` | `s005` | `cc_binary` | `True` | native static | native shared wrapper | [cc_static/s005](cc_static/s005/BUILD.bazel) | +| `cc_static` | `s006` | `cc_binary` | `False` | native static | native shared wrapper | [cc_static/s006](cc_static/s006/BUILD.bazel) | +| `cc_static` | `s007` | `cc_binary` | `True` | native static | foreign_cc shared | [cc_static/s007](cc_static/s007/BUILD.bazel) | +| `cc_static` | `s008` | `cc_binary` | `False` | native static | foreign_cc shared | [cc_static/s008](cc_static/s008/BUILD.bazel) | +| `cc_static` | `s009` | `cc_binary` | `True` | foreign_cc static | native static | [cc_static/s009](cc_static/s009/BUILD.bazel) | +| `cc_static` | `s010` | `cc_binary` | `False` | foreign_cc static | native static | [cc_static/s010](cc_static/s010/BUILD.bazel) | +| `cc_static` | `s011` | `cc_binary` | `True` | foreign_cc static | foreign_cc static | [cc_static/s011](cc_static/s011/BUILD.bazel) | +| `cc_static` | `s012` | `cc_binary` | `False` | foreign_cc static | foreign_cc static | [cc_static/s012](cc_static/s012/BUILD.bazel) | +| `cc_static` | `s013` | `cc_binary` | `True` | foreign_cc static | native shared wrapper | [cc_static/s013](cc_static/s013/BUILD.bazel) | +| `cc_static` | `s014` | `cc_binary` | `False` | foreign_cc static | native shared wrapper | [cc_static/s014](cc_static/s014/BUILD.bazel) | +| `cc_static` | `s015` | `cc_binary` | `True` | foreign_cc static | foreign_cc shared | [cc_static/s015](cc_static/s015/BUILD.bazel) | +| `cc_static` | `s016` | `cc_binary` | `False` | foreign_cc static | foreign_cc shared | [cc_static/s016](cc_static/s016/BUILD.bazel) | +| `cc_direct` | `d001` | `cc_binary` | `False` | foreign_cc shared | native static | [cc_direct/d001](cc_direct/d001/BUILD.bazel) | +| `cc_direct` | `d002` | `cc_binary` | `False` | foreign_cc shared | foreign_cc static | [cc_direct/d002](cc_direct/d002/BUILD.bazel) | +| `cc_direct` | `d003` | `cc_binary` | `False` | foreign_cc shared | native shared wrapper | [cc_direct/d003](cc_direct/d003/BUILD.bazel) | +| `cc_direct` | `d004` | `cc_binary` | `False` | foreign_cc shared | foreign_cc shared | [cc_direct/d004](cc_direct/d004/BUILD.bazel) | +| `cc_dynamic` | `dyn001` | `cc_binary` | `False` | native cc_shared_library | native static | [cc_dynamic/dyn001](cc_dynamic/dyn001/BUILD.bazel) | +| `cc_dynamic` | `dyn002` | `cc_binary` | `False` | native cc_shared_library | foreign_cc static | [cc_dynamic/dyn002](cc_dynamic/dyn002/BUILD.bazel) | +| `cc_dynamic` | `dyn003` | `cc_binary` | `False` | native cc_shared_library | native shared wrapper | [cc_dynamic/dyn003](cc_dynamic/dyn003/BUILD.bazel) | +| `cc_dynamic` | `dyn004` | `cc_binary` | `False` | native cc_shared_library | foreign_cc shared | [cc_dynamic/dyn004](cc_dynamic/dyn004/BUILD.bazel) | +| `cc_wrap` | `w001` | `cc_binary` | `False` | native dynamic wrapper | native static | [cc_wrap/w001](cc_wrap/w001/BUILD.bazel) | +| `cc_wrap` | `w002` | `cc_binary` | `False` | native dynamic wrapper | foreign_cc static | [cc_wrap/w002](cc_wrap/w002/BUILD.bazel) | +| `cc_wrap` | `w003` | `cc_binary` | `False` | native dynamic wrapper | native shared wrapper | [cc_wrap/w003](cc_wrap/w003/BUILD.bazel) | +| `cc_wrap` | `w004` | `cc_binary` | `False` | native dynamic wrapper | foreign_cc shared | [cc_wrap/w004](cc_wrap/w004/BUILD.bazel) | +| `cmake_static` | `s001` | `cmake` | `-` | native static | native static | [cmake_static/s001](cmake_static/s001/BUILD.bazel) | +| `cmake_static` | `s002` | `cmake` | `-` | native static | foreign_cc static | [cmake_static/s002](cmake_static/s002/BUILD.bazel) | +| `cmake_static` | `s003` | `cmake` | `-` | native static | native shared wrapper | [cmake_static/s003](cmake_static/s003/BUILD.bazel) | +| `cmake_static` | `s004` | `cmake` | `-` | native static | foreign_cc shared | [cmake_static/s004](cmake_static/s004/BUILD.bazel) | +| `cmake_static` | `s005` | `cmake` | `-` | foreign_cc static | native static | [cmake_static/s005](cmake_static/s005/BUILD.bazel) | +| `cmake_static` | `s006` | `cmake` | `-` | foreign_cc static | foreign_cc static | [cmake_static/s006](cmake_static/s006/BUILD.bazel) | +| `cmake_static` | `s007` | `cmake` | `-` | foreign_cc static | native shared wrapper | [cmake_static/s007](cmake_static/s007/BUILD.bazel) | +| `cmake_static` | `s008` | `cmake` | `-` | foreign_cc static | foreign_cc shared | [cmake_static/s008](cmake_static/s008/BUILD.bazel) | +| `cmake_direct` | `d001` | `cmake` | `-` | foreign_cc shared | native static | [cmake_direct/d001](cmake_direct/d001/BUILD.bazel) | +| `cmake_direct` | `d002` | `cmake` | `-` | foreign_cc shared | foreign_cc static | [cmake_direct/d002](cmake_direct/d002/BUILD.bazel) | +| `cmake_direct` | `d003` | `cmake` | `-` | foreign_cc shared | native shared wrapper | [cmake_direct/d003](cmake_direct/d003/BUILD.bazel) | +| `cmake_direct` | `d004` | `cmake` | `-` | foreign_cc shared | foreign_cc shared | [cmake_direct/d004](cmake_direct/d004/BUILD.bazel) | +| `cmake_dynamic` | `dyn001` | `cmake` | `-` | native cc_shared_library | native static | [cmake_dynamic/dyn001](cmake_dynamic/dyn001/BUILD.bazel) | +| `cmake_dynamic` | `dyn002` | `cmake` | `-` | native cc_shared_library | foreign_cc static | [cmake_dynamic/dyn002](cmake_dynamic/dyn002/BUILD.bazel) | +| `cmake_dynamic` | `dyn003` | `cmake` | `-` | native cc_shared_library | native shared wrapper | [cmake_dynamic/dyn003](cmake_dynamic/dyn003/BUILD.bazel) | +| `cmake_dynamic` | `dyn004` | `cmake` | `-` | native cc_shared_library | foreign_cc shared | [cmake_dynamic/dyn004](cmake_dynamic/dyn004/BUILD.bazel) | +| `cmake_wrap` | `w001` | `cmake` | `-` | native dynamic wrapper | native static | [cmake_wrap/w001](cmake_wrap/w001/BUILD.bazel) | +| `cmake_wrap` | `w002` | `cmake` | `-` | native dynamic wrapper | foreign_cc static | [cmake_wrap/w002](cmake_wrap/w002/BUILD.bazel) | +| `cmake_wrap` | `w003` | `cmake` | `-` | native dynamic wrapper | native shared wrapper | [cmake_wrap/w003](cmake_wrap/w003/BUILD.bazel) | +| `cmake_wrap` | `w004` | `cmake` | `-` | native dynamic wrapper | foreign_cc shared | [cmake_wrap/w004](cmake_wrap/w004/BUILD.bazel) | + +## Tests + +### Runtime assertion + +Each `cc_*` and `cmake_*` consumer goes through a runtime test to make sure it +loads the expected libraries. + +The consuming app uses libarchive's gzip filter to write a tar archive to +memory, then reads it back through libarchive. That forces libarchive to use +zlib rather than only linking it. Successful runs print exactly: + +```text +expected libarchive+zlib loaded: payload=rules_foreign_cc_transitive_test +``` + +For shared-library cases, the app also reports the runtime loader path for +libarchive and zlib. The test compares those paths against the exact Bazel +runfiles for the expected shared-library targets, so a system library fallback +fails. + +### Linkage assertion + +Each scenario also runs a linkage test against the produced app and, when +libarchive is shared, the produced libarchive shared library. The test inspects +loader-visible dependency metadata and checks the expected link shape: + +| Link shape | Expected metadata assertion | +| ------------------------------ | ------------------------------------------- | +| static libarchive, static zlib | app has no dynamic libarchive or zlib dep | +| static libarchive, shared zlib | app has a dynamic zlib dep only | +| shared libarchive, static zlib | app has libarchive; libarchive lacks zlib | +| shared libarchive, shared zlib | app has libarchive; libarchive has zlib | + +On Linux this uses `readelf -d`, on macOS it uses `otool -L`, and on Windows it +uses `objdump -p`. + +### Provider parity + +The provider tests compare `CcInfo` from a foreign_cc target against a native +`cc_*` target that is intended to expose the same contract: + +zlib targets are under `@examples_zlib//`: + +| Foreign target | Native comparison target | Platform | +| ---------------------- | ------------------------ | --------------------- | +| `:zlib_foreign_static` | `:zlib_static` | Linux, macOS, Windows | +| `:zlib_foreign_shared` | `:zlib_dynamic` | Linux, macOS, Windows | + +libarchive targets are under `@examples_libarchive//`: + +| Foreign target | Native comparison target | Platform | +| ------------------------------------------------ | ----------------------------------------- | --------------------- | +| `:libarchive_foreign_static_zlib_static` | `:libarchive_static_zlib_static` | Linux, macOS, Windows | +| `:libarchive_foreign_static_zlib_foreign_static` | `:libarchive_static_zlib_foreign_static` | Linux, macOS, Windows | +| `:libarchive_foreign_static_zlib_dynamic` | `:libarchive_static_zlib_dynamic` | Linux, macOS, Windows | +| `:libarchive_foreign_static_zlib_foreign_shared` | `:libarchive_static_zlib_foreign_shared` | Linux, macOS, Windows | +| `:libarchive_foreign_shared_zlib_dynamic` | `:libarchive_dynamic_zlib_dynamic` | Linux, macOS, Windows | +| `:libarchive_foreign_shared_zlib_foreign_shared` | `:libarchive_dynamic_zlib_foreign_shared` | Linux, macOS, Windows | + +The comparison projects `CcInfo` down to the parts that should be semantically +equivalent: + +- compilation context: defines, local defines, whether headers are present, and + whether include paths are present +- linking context: static, dynamic, and interface library names; user link + flags; and whether dynamic/interface libraries use Bazel solib symlinks with + non-solib resolved files + +Version suffixes, import-library spelling differences, and solib path prefixes +are normalized because they are representation details rather than provider +contract differences. + +## Additional scenarios + +`known_gap_tests` keeps stricter cases that are expected to fail today. They are +tagged `manual`, disabled by default, and documented in `known_gap/README.md`. +Pass `--define=transitive_cc_foreign_known_gap=true` to reproduce them. + +## Run + +From `examples/`: + +```bash +bazel test //integration_tests/transitive_matrix:tests --test_output=errors +bazel test //integration_tests/transitive_matrix/... --test_output=errors +bazel test //integration_tests/transitive_matrix:known_gap_tests \ + --define=transitive_cc_foreign_known_gap=true \ + --test_output=errors +``` diff --git a/examples/integration_tests/transitive_matrix/app.c b/examples/integration_tests/transitive_matrix/app.c new file mode 100644 index 000000000..0078ba60e --- /dev/null +++ b/examples/integration_tests/transitive_matrix/app.c @@ -0,0 +1,295 @@ +#define _GNU_SOURCE + +#include +#include + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#elif defined(__APPLE__) +#include +#include +#else +#include +#endif + +#include +#include +#include + +static const char* kPayload = "rules_foreign_cc_transitive_test"; +static const char* kExpected = + "expected libarchive+zlib loaded: payload=rules_foreign_cc_transitive_test"; + +static void fail_archive(const char* operation, struct archive* archive) { + const char* error = archive_error_string(archive); + fprintf(stderr, "%s failed: %s\n", operation, + error ? error : "unknown error"); + exit(1); +} + +static void fail_message(const char* message) { + fprintf(stderr, "%s\n", message); + exit(1); +} + +#ifdef _WIN32 +static const char* kLibarchiveModuleNames[] = { + "archive.dll", + "libarchive.dll", + NULL, +}; + +static const char* kZlibModuleNames[] = { + "zlib1.dll", + "libz.dll", + "z.dll", + NULL, +}; + +static const void* find_loaded_symbol(const char* const* module_names, + const char* symbol_name) { + const char* const* module_name; + + for (module_name = module_names; *module_name != NULL; ++module_name) { + HMODULE module = GetModuleHandleA(*module_name); + FARPROC symbol; + + if (module == NULL) { + continue; + } + + symbol = GetProcAddress(module, symbol_name); + if (symbol != NULL) { + return (const void*)symbol; + } + } + return NULL; +} +#endif + +static void print_loaded_path(const char* name, const void* symbol) { +#ifdef _WIN32 + HMODULE module = NULL; + char path[MAX_PATH]; + DWORD length; + + if (symbol != NULL && + GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (LPCSTR)symbol, &module)) { + length = GetModuleFileNameA(module, path, sizeof(path)); + if (length > 0 && length < sizeof(path)) { + printf("loaded %s: %s\n", name, path); + return; + } + } + printf("loaded %s: \n", name); +#else + Dl_info info; + + if (symbol != NULL && dladdr(symbol, &info) != 0 && + info.dli_fname != NULL) { + printf("loaded %s: %s\n", name, info.dli_fname); + return; + } + printf("loaded %s: \n", name); +#endif +} + +#ifdef __APPLE__ +static int starts_with(const char* text, const char* prefix) { + return strncmp(text, prefix, strlen(prefix)) == 0; +} + +static int ends_with(const char* text, const char* suffix) { + size_t text_length = strlen(text); + size_t suffix_length = strlen(suffix); + + return text_length >= suffix_length && + strcmp(text + text_length - suffix_length, suffix) == 0; +} + +static int is_system_library_path(const char* path) { + return starts_with(path, "/usr/lib/") || + starts_with(path, "/System/Library/"); +} + +static int is_zlib_image_path(const char* path) { + const char* basename = strrchr(path, '/'); + + basename = basename != NULL ? basename + 1 : path; + return strcmp(basename, "libz.dylib") == 0 || + (starts_with(basename, "libz.") && ends_with(basename, ".dylib")); +} + +static const char* find_loaded_zlib_image_path(int prefer_non_system) { + uint32_t image_count = _dyld_image_count(); + uint32_t index; + + for (index = 0; index < image_count; ++index) { + const char* path = _dyld_get_image_name(index); + + if (path == NULL || !is_zlib_image_path(path)) { + continue; + } + if (prefer_non_system && is_system_library_path(path)) { + continue; + } + return path; + } + return NULL; +} + +static void print_loaded_zlib_path(void) { + const char* path = find_loaded_zlib_image_path(1); + + if (path == NULL) { + path = find_loaded_zlib_image_path(0); + } + if (path != NULL) { + printf("loaded zlib: %s\n", path); + return; + } + print_loaded_path("zlib", NULL); +} +#endif + +static void print_loaded_symbol_path(const char* name, + const void* fallback_symbol, + const char* symbol_name +#ifdef _WIN32 + , + const char* const* module_names +#endif +) { +#ifdef _WIN32 + const void* symbol = find_loaded_symbol(module_names, symbol_name); + print_loaded_path(name, symbol != NULL ? symbol : fallback_symbol); +#else + (void)symbol_name; + print_loaded_path(name, fallback_symbol); +#endif +} + +static void print_optional_loaded_symbol_path(const char* name, + const char* symbol_name) { +#ifdef _WIN32 + const void* symbol; + + if (strcmp(name, "zlib") == 0) { + symbol = find_loaded_symbol(kZlibModuleNames, symbol_name); + print_loaded_path(name, symbol); + return; + } + print_loaded_path(name, NULL); +#elif defined(__APPLE__) + if (strcmp(name, "zlib") == 0) { + (void)symbol_name; + print_loaded_zlib_path(); + return; + } + print_loaded_path(name, NULL); +#else + print_loaded_path(name, dlsym(RTLD_DEFAULT, symbol_name)); +#endif +} + +static size_t write_archive(char* buffer, size_t buffer_size) { + struct archive* archive = archive_write_new(); + struct archive_entry* entry = archive_entry_new(); + size_t used = 0; + + if (archive == NULL || entry == NULL) { + fail_message("failed to allocate libarchive writer"); + } + if (archive_write_add_filter_gzip(archive) != ARCHIVE_OK) { + fail_archive("archive_write_add_filter_gzip", archive); + } + if (archive_write_set_format_pax_restricted(archive) != ARCHIVE_OK) { + fail_archive("archive_write_set_format_pax_restricted", archive); + } + if (archive_write_open_memory(archive, buffer, buffer_size, &used) != + ARCHIVE_OK) { + fail_archive("archive_write_open_memory", archive); + } + + archive_entry_set_pathname(entry, "payload.txt"); + archive_entry_set_size(entry, (la_int64_t)strlen(kPayload)); + archive_entry_set_filetype(entry, AE_IFREG); + archive_entry_set_perm(entry, 0644); + + if (archive_write_header(archive, entry) != ARCHIVE_OK) { + fail_archive("archive_write_header", archive); + } + if (archive_write_data(archive, kPayload, strlen(kPayload)) < 0) { + fail_archive("archive_write_data", archive); + } + archive_entry_free(entry); + + if (archive_write_close(archive) != ARCHIVE_OK) { + fail_archive("archive_write_close", archive); + } + if (archive_write_free(archive) != ARCHIVE_OK) { + fail_message("archive_write_free failed"); + } + return used; +} + +static void read_archive(const char* buffer, size_t used) { + struct archive* archive = archive_read_new(); + struct archive_entry* entry = NULL; + char payload[128] = {0}; + la_ssize_t read_bytes; + + if (archive == NULL) { + fail_message("failed to allocate libarchive reader"); + } + if (archive_read_support_filter_gzip(archive) != ARCHIVE_OK) { + fail_archive("archive_read_support_filter_gzip", archive); + } + if (archive_read_support_format_tar(archive) != ARCHIVE_OK) { + fail_archive("archive_read_support_format_tar", archive); + } + if (archive_read_open_memory(archive, buffer, used) != ARCHIVE_OK) { + fail_archive("archive_read_open_memory", archive); + } + if (archive_read_next_header(archive, &entry) != ARCHIVE_OK) { + fail_archive("archive_read_next_header", archive); + } + if (strcmp(archive_entry_pathname(entry), "payload.txt") != 0) { + fail_message("unexpected archive entry path"); + } + + read_bytes = archive_read_data(archive, payload, sizeof(payload) - 1); + if (read_bytes < 0) { + fail_archive("archive_read_data", archive); + } + payload[read_bytes] = '\0'; + if (strcmp(payload, kPayload) != 0) { + fail_message("unexpected archive payload"); + } + + if (archive_read_close(archive) != ARCHIVE_OK) { + fail_archive("archive_read_close", archive); + } + if (archive_read_free(archive) != ARCHIVE_OK) { + fail_message("archive_read_free failed"); + } +} + +int main(void) { + char buffer[8192]; + size_t used = write_archive(buffer, sizeof(buffer)); + read_archive(buffer, used); + puts(kExpected); + print_loaded_symbol_path("libarchive", (const void*)&archive_read_new, + "archive_read_new" +#ifdef _WIN32 + , + kLibarchiveModuleNames +#endif + ); + print_optional_loaded_symbol_path("zlib", "zlibVersion"); + return 0; +} diff --git a/examples/integration_tests/transitive_matrix/cc_direct/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_direct/BUILD.bazel new file mode 100644 index 000000000..380dd1590 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_direct/BUILD.bazel @@ -0,0 +1,30 @@ +test_suite( + name = "runtime_tests", + tests = [ + "//integration_tests/transitive_matrix/cc_direct/d001:runtime_tests", + "//integration_tests/transitive_matrix/cc_direct/d002:runtime_tests", + "//integration_tests/transitive_matrix/cc_direct/d003:runtime_tests", + "//integration_tests/transitive_matrix/cc_direct/d004:runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [ + "//integration_tests/transitive_matrix/cc_direct/d001:linkage_tests", + "//integration_tests/transitive_matrix/cc_direct/d002:linkage_tests", + "//integration_tests/transitive_matrix/cc_direct/d003:linkage_tests", + "//integration_tests/transitive_matrix/cc_direct/d004:linkage_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_direct/d001/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_direct/d001/BUILD.bazel new file mode 100644 index 000000000..73e3b7570 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_direct/d001/BUILD.bazel @@ -0,0 +1,45 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary direct deps +# app: cc_binary(linkstatic = False) +# libarchive: foreign_cc shared +# zlib: native static +# runtime: libarchive must load from @examples_libarchive//:libarchive_foreign_shared_zlib_static +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_static_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_foreign_shared_zlib_static", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_foreign_shared_zlib_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_direct:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_direct:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_direct:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_direct/d002/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_direct/d002/BUILD.bazel new file mode 100644 index 000000000..cb6e7a450 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_direct/d002/BUILD.bazel @@ -0,0 +1,45 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary direct deps +# app: cc_binary(linkstatic = False) +# libarchive: foreign_cc shared +# zlib: foreign_cc static +# runtime: libarchive must load from @examples_libarchive//:libarchive_foreign_shared_zlib_foreign_static +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_static_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_foreign_shared_zlib_foreign_static", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_foreign_shared_zlib_foreign_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_direct:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_direct:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_direct:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_direct/d003/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_direct/d003/BUILD.bazel new file mode 100644 index 000000000..4fb435bf0 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_direct/d003/BUILD.bazel @@ -0,0 +1,47 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary direct deps +# app: cc_binary(linkstatic = False) +# libarchive: foreign_cc shared +# zlib: native shared wrapper +# runtime: libarchive must load from @examples_libarchive//:libarchive_foreign_shared_zlib_dynamic +# runtime: zlib must load from @examples_zlib//:zlib_shared +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_shared_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_foreign_shared_zlib_dynamic", + zlib = "@examples_zlib//:zlib_shared", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_foreign_shared_zlib_dynamic"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_direct:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_direct:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_direct:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_direct/d004/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_direct/d004/BUILD.bazel new file mode 100644 index 000000000..c664db1ae --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_direct/d004/BUILD.bazel @@ -0,0 +1,47 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary direct deps +# app: cc_binary(linkstatic = False) +# libarchive: foreign_cc shared +# zlib: foreign_cc shared +# runtime: libarchive must load from @examples_libarchive//:libarchive_foreign_shared_zlib_foreign_shared +# runtime: zlib must load from @examples_zlib//:zlib_foreign_shared +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_shared_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_foreign_shared_zlib_foreign_shared", + zlib = "@examples_zlib//:zlib_foreign_shared", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_foreign_shared_zlib_foreign_shared"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_direct:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_direct:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_direct:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_dynamic/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_dynamic/BUILD.bazel new file mode 100644 index 000000000..4f1795049 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_dynamic/BUILD.bazel @@ -0,0 +1,30 @@ +test_suite( + name = "runtime_tests", + tests = [ + "//integration_tests/transitive_matrix/cc_dynamic/dyn001:runtime_tests", + "//integration_tests/transitive_matrix/cc_dynamic/dyn002:runtime_tests", + "//integration_tests/transitive_matrix/cc_dynamic/dyn003:runtime_tests", + "//integration_tests/transitive_matrix/cc_dynamic/dyn004:runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [ + "//integration_tests/transitive_matrix/cc_dynamic/dyn001:linkage_tests", + "//integration_tests/transitive_matrix/cc_dynamic/dyn002:linkage_tests", + "//integration_tests/transitive_matrix/cc_dynamic/dyn003:linkage_tests", + "//integration_tests/transitive_matrix/cc_dynamic/dyn004:linkage_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_dynamic/dyn001/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_dynamic/dyn001/BUILD.bazel new file mode 100644 index 000000000..eb85ffe29 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_dynamic/dyn001/BUILD.bazel @@ -0,0 +1,46 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary dynamic_deps +# app: cc_binary(linkstatic = False) +# libarchive: native cc_shared_library +# zlib: native static +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_static +cc_binary_consumer_test( + name = "t", + dynamic_deps = ["@examples_libarchive//:libarchive_shared_zlib_static"], + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_static_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_static", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_headers"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_dynamic:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_dynamic:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_dynamic:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_dynamic/dyn002/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_dynamic/dyn002/BUILD.bazel new file mode 100644 index 000000000..f811e0330 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_dynamic/dyn002/BUILD.bazel @@ -0,0 +1,46 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary dynamic_deps +# app: cc_binary(linkstatic = False) +# libarchive: native cc_shared_library +# zlib: foreign_cc static +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_foreign_static +cc_binary_consumer_test( + name = "t", + dynamic_deps = ["@examples_libarchive//:libarchive_shared_zlib_foreign_static"], + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_static_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_foreign_static", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_headers"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_dynamic:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_dynamic:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_dynamic:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_dynamic/dyn003/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_dynamic/dyn003/BUILD.bazel new file mode 100644 index 000000000..ab8800ec2 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_dynamic/dyn003/BUILD.bazel @@ -0,0 +1,48 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary dynamic_deps +# app: cc_binary(linkstatic = False) +# libarchive: native cc_shared_library +# zlib: native shared wrapper +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_dynamic +# runtime: zlib must load from @examples_zlib//:zlib_shared +cc_binary_consumer_test( + name = "t", + dynamic_deps = ["@examples_libarchive//:libarchive_shared_zlib_dynamic"], + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_shared_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_dynamic", + zlib = "@examples_zlib//:zlib_shared", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_headers"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_dynamic:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_dynamic:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_dynamic:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_dynamic/dyn004/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_dynamic/dyn004/BUILD.bazel new file mode 100644 index 000000000..efb177584 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_dynamic/dyn004/BUILD.bazel @@ -0,0 +1,48 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary dynamic_deps +# app: cc_binary(linkstatic = False) +# libarchive: native cc_shared_library +# zlib: foreign_cc shared +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_foreign_shared +# runtime: zlib must load from @examples_zlib//:zlib_foreign_shared +cc_binary_consumer_test( + name = "t", + dynamic_deps = ["@examples_libarchive//:libarchive_shared_zlib_foreign_shared"], + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_shared_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_foreign_shared", + zlib = "@examples_zlib//:zlib_foreign_shared", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_headers"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_dynamic:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_dynamic:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_dynamic:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/BUILD.bazel new file mode 100644 index 000000000..7ad2b97e6 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/BUILD.bazel @@ -0,0 +1,54 @@ +test_suite( + name = "runtime_tests", + tests = [ + "//integration_tests/transitive_matrix/cc_static/s001:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s002:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s003:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s004:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s005:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s006:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s007:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s008:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s009:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s010:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s011:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s012:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s013:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s014:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s015:runtime_tests", + "//integration_tests/transitive_matrix/cc_static/s016:runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [ + "//integration_tests/transitive_matrix/cc_static/s001:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s002:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s003:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s004:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s005:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s006:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s007:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s008:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s009:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s010:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s011:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s012:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s013:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s014:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s015:linkage_tests", + "//integration_tests/transitive_matrix/cc_static/s016:linkage_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s001/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s001/BUILD.bazel new file mode 100644 index 000000000..1640efa0b --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s001/BUILD.bazel @@ -0,0 +1,44 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = True) +# libarchive: native static +# zlib: native static +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_static_deps = [ + "libarchive", + "zlib", + ], + ), + expected_loaded_libraries = expected_loaded_libraries(), + linkstatic = True, + deps = ["@examples_libarchive//:libarchive_static_zlib_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s002/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s002/BUILD.bazel new file mode 100644 index 000000000..2d6e63e30 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s002/BUILD.bazel @@ -0,0 +1,44 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = False) +# libarchive: native static +# zlib: native static +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_static_deps = [ + "libarchive", + "zlib", + ], + ), + expected_loaded_libraries = expected_loaded_libraries(), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_static_zlib_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s003/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s003/BUILD.bazel new file mode 100644 index 000000000..012b34b72 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s003/BUILD.bazel @@ -0,0 +1,44 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = True) +# libarchive: native static +# zlib: foreign_cc static +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_static_deps = [ + "libarchive", + "zlib", + ], + ), + expected_loaded_libraries = expected_loaded_libraries(), + linkstatic = True, + deps = ["@examples_libarchive//:libarchive_static_zlib_foreign_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s004/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s004/BUILD.bazel new file mode 100644 index 000000000..83d06152a --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s004/BUILD.bazel @@ -0,0 +1,44 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = False) +# libarchive: native static +# zlib: foreign_cc static +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_static_deps = [ + "libarchive", + "zlib", + ], + ), + expected_loaded_libraries = expected_loaded_libraries(), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_static_zlib_foreign_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s005/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s005/BUILD.bazel new file mode 100644 index 000000000..43fee145b --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s005/BUILD.bazel @@ -0,0 +1,45 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = True) +# libarchive: native static +# zlib: native shared wrapper +# runtime: zlib must load from @examples_zlib//:zlib_shared +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["zlib"], + app_static_deps = ["libarchive"], + ), + expected_loaded_libraries = expected_loaded_libraries( + zlib = "@examples_zlib//:zlib_shared", + ), + linkstatic = True, + deps = ["@examples_libarchive//:libarchive_static_zlib_dynamic"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s006/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s006/BUILD.bazel new file mode 100644 index 000000000..e837672b6 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s006/BUILD.bazel @@ -0,0 +1,45 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = False) +# libarchive: native static +# zlib: native shared wrapper +# runtime: zlib must load from @examples_zlib//:zlib_shared +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["zlib"], + app_static_deps = ["libarchive"], + ), + expected_loaded_libraries = expected_loaded_libraries( + zlib = "@examples_zlib//:zlib_shared", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_static_zlib_dynamic"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s007/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s007/BUILD.bazel new file mode 100644 index 000000000..11edc7cf0 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s007/BUILD.bazel @@ -0,0 +1,45 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = True) +# libarchive: native static +# zlib: foreign_cc shared +# runtime: zlib must load from @examples_zlib//:zlib_foreign_shared +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["zlib"], + app_static_deps = ["libarchive"], + ), + expected_loaded_libraries = expected_loaded_libraries( + zlib = "@examples_zlib//:zlib_foreign_shared", + ), + linkstatic = True, + deps = ["@examples_libarchive//:libarchive_static_zlib_foreign_shared"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s008/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s008/BUILD.bazel new file mode 100644 index 000000000..3ecac161a --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s008/BUILD.bazel @@ -0,0 +1,45 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = False) +# libarchive: native static +# zlib: foreign_cc shared +# runtime: zlib must load from @examples_zlib//:zlib_foreign_shared +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["zlib"], + app_static_deps = ["libarchive"], + ), + expected_loaded_libraries = expected_loaded_libraries( + zlib = "@examples_zlib//:zlib_foreign_shared", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_static_zlib_foreign_shared"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s009/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s009/BUILD.bazel new file mode 100644 index 000000000..ef3c125cd --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s009/BUILD.bazel @@ -0,0 +1,44 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = True) +# libarchive: foreign_cc static +# zlib: native static +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_static_deps = [ + "libarchive", + "zlib", + ], + ), + expected_loaded_libraries = expected_loaded_libraries(), + linkstatic = True, + deps = ["@examples_libarchive//:libarchive_foreign_static_zlib_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s010/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s010/BUILD.bazel new file mode 100644 index 000000000..53760ffb2 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s010/BUILD.bazel @@ -0,0 +1,44 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = False) +# libarchive: foreign_cc static +# zlib: native static +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_static_deps = [ + "libarchive", + "zlib", + ], + ), + expected_loaded_libraries = expected_loaded_libraries(), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_foreign_static_zlib_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s011/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s011/BUILD.bazel new file mode 100644 index 000000000..9c677697a --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s011/BUILD.bazel @@ -0,0 +1,44 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = True) +# libarchive: foreign_cc static +# zlib: foreign_cc static +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_static_deps = [ + "libarchive", + "zlib", + ], + ), + expected_loaded_libraries = expected_loaded_libraries(), + linkstatic = True, + deps = ["@examples_libarchive//:libarchive_foreign_static_zlib_foreign_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s012/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s012/BUILD.bazel new file mode 100644 index 000000000..07d5210e0 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s012/BUILD.bazel @@ -0,0 +1,44 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = False) +# libarchive: foreign_cc static +# zlib: foreign_cc static +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_static_deps = [ + "libarchive", + "zlib", + ], + ), + expected_loaded_libraries = expected_loaded_libraries(), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_foreign_static_zlib_foreign_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s013/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s013/BUILD.bazel new file mode 100644 index 000000000..881e0597d --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s013/BUILD.bazel @@ -0,0 +1,45 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = True) +# libarchive: foreign_cc static +# zlib: native shared wrapper +# runtime: zlib must load from @examples_zlib//:zlib_shared +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["zlib"], + app_static_deps = ["libarchive"], + ), + expected_loaded_libraries = expected_loaded_libraries( + zlib = "@examples_zlib//:zlib_shared", + ), + linkstatic = True, + deps = ["@examples_libarchive//:libarchive_foreign_static_zlib_dynamic"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s014/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s014/BUILD.bazel new file mode 100644 index 000000000..2ed49f187 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s014/BUILD.bazel @@ -0,0 +1,45 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = False) +# libarchive: foreign_cc static +# zlib: native shared wrapper +# runtime: zlib must load from @examples_zlib//:zlib_shared +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["zlib"], + app_static_deps = ["libarchive"], + ), + expected_loaded_libraries = expected_loaded_libraries( + zlib = "@examples_zlib//:zlib_shared", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_foreign_static_zlib_dynamic"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s015/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s015/BUILD.bazel new file mode 100644 index 000000000..74976659a --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s015/BUILD.bazel @@ -0,0 +1,45 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = True) +# libarchive: foreign_cc static +# zlib: foreign_cc shared +# runtime: zlib must load from @examples_zlib//:zlib_foreign_shared +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["zlib"], + app_static_deps = ["libarchive"], + ), + expected_loaded_libraries = expected_loaded_libraries( + zlib = "@examples_zlib//:zlib_foreign_shared", + ), + linkstatic = True, + deps = ["@examples_libarchive//:libarchive_foreign_static_zlib_foreign_shared"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_static/s016/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_static/s016/BUILD.bazel new file mode 100644 index 000000000..8cb86c53b --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_static/s016/BUILD.bazel @@ -0,0 +1,45 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary static deps +# app: cc_binary(linkstatic = False) +# libarchive: foreign_cc static +# zlib: foreign_cc shared +# runtime: zlib must load from @examples_zlib//:zlib_foreign_shared +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["zlib"], + app_static_deps = ["libarchive"], + ), + expected_loaded_libraries = expected_loaded_libraries( + zlib = "@examples_zlib//:zlib_foreign_shared", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_foreign_static_zlib_foreign_shared"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_wrap/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_wrap/BUILD.bazel new file mode 100644 index 000000000..f211824d8 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_wrap/BUILD.bazel @@ -0,0 +1,30 @@ +test_suite( + name = "runtime_tests", + tests = [ + "//integration_tests/transitive_matrix/cc_wrap/w001:runtime_tests", + "//integration_tests/transitive_matrix/cc_wrap/w002:runtime_tests", + "//integration_tests/transitive_matrix/cc_wrap/w003:runtime_tests", + "//integration_tests/transitive_matrix/cc_wrap/w004:runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [ + "//integration_tests/transitive_matrix/cc_wrap/w001:linkage_tests", + "//integration_tests/transitive_matrix/cc_wrap/w002:linkage_tests", + "//integration_tests/transitive_matrix/cc_wrap/w003:linkage_tests", + "//integration_tests/transitive_matrix/cc_wrap/w004:linkage_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_wrap/w001/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_wrap/w001/BUILD.bazel new file mode 100644 index 000000000..2adf36ff8 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_wrap/w001/BUILD.bazel @@ -0,0 +1,45 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary native dynamic wrapper +# app: cc_binary(linkstatic = False) +# libarchive: native dynamic wrapper +# zlib: native static +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_static +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_static_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_static", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_dynamic_zlib_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_wrap:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_wrap:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_wrap:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_wrap/w002/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_wrap/w002/BUILD.bazel new file mode 100644 index 000000000..eb9238f9b --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_wrap/w002/BUILD.bazel @@ -0,0 +1,45 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary native dynamic wrapper +# app: cc_binary(linkstatic = False) +# libarchive: native dynamic wrapper +# zlib: foreign_cc static +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_foreign_static +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_static_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_foreign_static", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_dynamic_zlib_foreign_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_wrap:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_wrap:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_wrap:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_wrap/w003/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_wrap/w003/BUILD.bazel new file mode 100644 index 000000000..d84192919 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_wrap/w003/BUILD.bazel @@ -0,0 +1,47 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary native dynamic wrapper +# app: cc_binary(linkstatic = False) +# libarchive: native dynamic wrapper +# zlib: native shared wrapper +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_dynamic +# runtime: zlib must load from @examples_zlib//:zlib_shared +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_shared_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_dynamic", + zlib = "@examples_zlib//:zlib_shared", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_dynamic_zlib_dynamic"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_wrap:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_wrap:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_wrap:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cc_wrap/w004/BUILD.bazel b/examples/integration_tests/transitive_matrix/cc_wrap/w004/BUILD.bazel new file mode 100644 index 000000000..5938e9afa --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cc_wrap/w004/BUILD.bazel @@ -0,0 +1,47 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cc_binary_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# cc_binary native dynamic wrapper +# app: cc_binary(linkstatic = False) +# libarchive: native dynamic wrapper +# zlib: foreign_cc shared +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_foreign_shared +# runtime: zlib must load from @examples_zlib//:zlib_foreign_shared +cc_binary_consumer_test( + name = "t", + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_shared_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_foreign_shared", + zlib = "@examples_zlib//:zlib_foreign_shared", + ), + linkstatic = False, + deps = ["@examples_libarchive//:libarchive_dynamic_zlib_foreign_shared"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cc_wrap:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cc_wrap:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cc_wrap:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_direct/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_direct/BUILD.bazel new file mode 100644 index 000000000..15a0f09fc --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_direct/BUILD.bazel @@ -0,0 +1,30 @@ +test_suite( + name = "runtime_tests", + tests = [ + "//integration_tests/transitive_matrix/cmake_direct/d001:runtime_tests", + "//integration_tests/transitive_matrix/cmake_direct/d002:runtime_tests", + "//integration_tests/transitive_matrix/cmake_direct/d003:runtime_tests", + "//integration_tests/transitive_matrix/cmake_direct/d004:runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [ + "//integration_tests/transitive_matrix/cmake_direct/d001:linkage_tests", + "//integration_tests/transitive_matrix/cmake_direct/d002:linkage_tests", + "//integration_tests/transitive_matrix/cmake_direct/d003:linkage_tests", + "//integration_tests/transitive_matrix/cmake_direct/d004:linkage_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_direct/d001/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_direct/d001/BUILD.bazel new file mode 100644 index 000000000..b442129be --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_direct/d001/BUILD.bazel @@ -0,0 +1,46 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake direct deps +# app: cmake() +# libarchive: foreign_cc shared +# zlib: native static +# runtime: libarchive must load from @examples_libarchive//:libarchive_foreign_shared_zlib_static +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries(libarchive = "archive"), + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_static_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_foreign_shared_zlib_static", + ), + deps = ["@examples_libarchive//:libarchive_foreign_shared_zlib_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_direct:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_direct:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_direct:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_direct/d002/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_direct/d002/BUILD.bazel new file mode 100644 index 000000000..7da40ff36 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_direct/d002/BUILD.bazel @@ -0,0 +1,46 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake direct deps +# app: cmake() +# libarchive: foreign_cc shared +# zlib: foreign_cc static +# runtime: libarchive must load from @examples_libarchive//:libarchive_foreign_shared_zlib_foreign_static +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries(libarchive = "archive"), + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_static_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_foreign_shared_zlib_foreign_static", + ), + deps = ["@examples_libarchive//:libarchive_foreign_shared_zlib_foreign_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_direct:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_direct:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_direct:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_direct/d003/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_direct/d003/BUILD.bazel new file mode 100644 index 000000000..22117e2fc --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_direct/d003/BUILD.bazel @@ -0,0 +1,48 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake direct deps +# app: cmake() +# libarchive: foreign_cc shared +# zlib: native shared wrapper +# runtime: libarchive must load from @examples_libarchive//:libarchive_foreign_shared_zlib_dynamic +# runtime: zlib must load from @examples_zlib//:zlib_shared +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries(libarchive = "archive"), + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_shared_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_foreign_shared_zlib_dynamic", + zlib = "@examples_zlib//:zlib_shared", + ), + deps = ["@examples_libarchive//:libarchive_foreign_shared_zlib_dynamic"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_direct:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_direct:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_direct:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_direct/d004/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_direct/d004/BUILD.bazel new file mode 100644 index 000000000..35e9dc094 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_direct/d004/BUILD.bazel @@ -0,0 +1,48 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake direct deps +# app: cmake() +# libarchive: foreign_cc shared +# zlib: foreign_cc shared +# runtime: libarchive must load from @examples_libarchive//:libarchive_foreign_shared_zlib_foreign_shared +# runtime: zlib must load from @examples_zlib//:zlib_foreign_shared +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries(libarchive = "archive"), + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_shared_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_foreign_shared_zlib_foreign_shared", + zlib = "@examples_zlib//:zlib_foreign_shared", + ), + deps = ["@examples_libarchive//:libarchive_foreign_shared_zlib_foreign_shared"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_direct:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_direct:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_direct:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_dynamic/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_dynamic/BUILD.bazel new file mode 100644 index 000000000..50705cf83 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_dynamic/BUILD.bazel @@ -0,0 +1,30 @@ +test_suite( + name = "runtime_tests", + tests = [ + "//integration_tests/transitive_matrix/cmake_dynamic/dyn001:runtime_tests", + "//integration_tests/transitive_matrix/cmake_dynamic/dyn002:runtime_tests", + "//integration_tests/transitive_matrix/cmake_dynamic/dyn003:runtime_tests", + "//integration_tests/transitive_matrix/cmake_dynamic/dyn004:runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [ + "//integration_tests/transitive_matrix/cmake_dynamic/dyn001:linkage_tests", + "//integration_tests/transitive_matrix/cmake_dynamic/dyn002:linkage_tests", + "//integration_tests/transitive_matrix/cmake_dynamic/dyn003:linkage_tests", + "//integration_tests/transitive_matrix/cmake_dynamic/dyn004:linkage_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_dynamic/dyn001/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_dynamic/dyn001/BUILD.bazel new file mode 100644 index 000000000..2614e0f26 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_dynamic/dyn001/BUILD.bazel @@ -0,0 +1,50 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake dynamic_deps +# app: cmake() +# libarchive: native cc_shared_library +# zlib: native static +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_static +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "archive_zlib_static", + libarchive_windows = "libarchive_shared_zlib_static.if", + ), + dynamic_deps = ["@examples_libarchive//:libarchive_shared_zlib_static"], + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_static_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_static", + ), + deps = ["@examples_libarchive//:libarchive_headers"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_dynamic:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_dynamic:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_dynamic:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_dynamic/dyn002/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_dynamic/dyn002/BUILD.bazel new file mode 100644 index 000000000..7c278eff0 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_dynamic/dyn002/BUILD.bazel @@ -0,0 +1,50 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake dynamic_deps +# app: cmake() +# libarchive: native cc_shared_library +# zlib: foreign_cc static +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_foreign_static +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "archive_zlib_foreign_static", + libarchive_windows = "libarchive_shared_zlib_foreign_static.if", + ), + dynamic_deps = ["@examples_libarchive//:libarchive_shared_zlib_foreign_static"], + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_static_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_foreign_static", + ), + deps = ["@examples_libarchive//:libarchive_headers"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_dynamic:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_dynamic:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_dynamic:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_dynamic/dyn003/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_dynamic/dyn003/BUILD.bazel new file mode 100644 index 000000000..8fa68e464 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_dynamic/dyn003/BUILD.bazel @@ -0,0 +1,52 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake dynamic_deps +# app: cmake() +# libarchive: native cc_shared_library +# zlib: native shared wrapper +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_dynamic +# runtime: zlib must load from @examples_zlib//:zlib_shared +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "archive_zlib_dynamic", + libarchive_windows = "libarchive_shared_zlib_dynamic.if", + ), + dynamic_deps = ["@examples_libarchive//:libarchive_shared_zlib_dynamic"], + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_shared_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_dynamic", + zlib = "@examples_zlib//:zlib_shared", + ), + deps = ["@examples_libarchive//:libarchive_headers"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_dynamic:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_dynamic:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_dynamic:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_dynamic/dyn004/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_dynamic/dyn004/BUILD.bazel new file mode 100644 index 000000000..9d97342fe --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_dynamic/dyn004/BUILD.bazel @@ -0,0 +1,52 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake dynamic_deps +# app: cmake() +# libarchive: native cc_shared_library +# zlib: foreign_cc shared +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_foreign_shared +# runtime: zlib must load from @examples_zlib//:zlib_foreign_shared +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "archive_zlib_foreign_shared", + libarchive_windows = "libarchive_shared_zlib_foreign_shared.if", + ), + dynamic_deps = ["@examples_libarchive//:libarchive_shared_zlib_foreign_shared"], + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_shared_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_foreign_shared", + zlib = "@examples_zlib//:zlib_foreign_shared", + ), + deps = ["@examples_libarchive//:libarchive_headers"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_dynamic:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_dynamic:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_dynamic:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_static/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_static/BUILD.bazel new file mode 100644 index 000000000..cdada47d7 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_static/BUILD.bazel @@ -0,0 +1,38 @@ +test_suite( + name = "runtime_tests", + tests = [ + "//integration_tests/transitive_matrix/cmake_static/s001:runtime_tests", + "//integration_tests/transitive_matrix/cmake_static/s002:runtime_tests", + "//integration_tests/transitive_matrix/cmake_static/s003:runtime_tests", + "//integration_tests/transitive_matrix/cmake_static/s004:runtime_tests", + "//integration_tests/transitive_matrix/cmake_static/s005:runtime_tests", + "//integration_tests/transitive_matrix/cmake_static/s006:runtime_tests", + "//integration_tests/transitive_matrix/cmake_static/s007:runtime_tests", + "//integration_tests/transitive_matrix/cmake_static/s008:runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [ + "//integration_tests/transitive_matrix/cmake_static/s001:linkage_tests", + "//integration_tests/transitive_matrix/cmake_static/s002:linkage_tests", + "//integration_tests/transitive_matrix/cmake_static/s003:linkage_tests", + "//integration_tests/transitive_matrix/cmake_static/s004:linkage_tests", + "//integration_tests/transitive_matrix/cmake_static/s005:linkage_tests", + "//integration_tests/transitive_matrix/cmake_static/s006:linkage_tests", + "//integration_tests/transitive_matrix/cmake_static/s007:linkage_tests", + "//integration_tests/transitive_matrix/cmake_static/s008:linkage_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_static/s001/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_static/s001/BUILD.bazel new file mode 100644 index 000000000..4b07a8362 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_static/s001/BUILD.bazel @@ -0,0 +1,51 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake static deps +# app: cmake() +# libarchive: native static +# zlib: native static +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "libarchive_static_zlib_static", + zlib = "z", + ), + expected_linkage = expected_linkage( + app_static_deps = [ + "libarchive", + "zlib", + ], + ), + expected_loaded_libraries = expected_loaded_libraries(), + deps = [ + "@examples_libarchive//:libarchive_static_zlib_static", + "@examples_zlib//:zlib_static", + ], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_static/s002/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_static/s002/BUILD.bazel new file mode 100644 index 000000000..21bbffa7f --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_static/s002/BUILD.bazel @@ -0,0 +1,52 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake static deps +# app: cmake() +# libarchive: native static +# zlib: foreign_cc static +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "libarchive_static_zlib_foreign_static", + zlib = "z", + zlib_windows = "zlib", + ), + expected_linkage = expected_linkage( + app_static_deps = [ + "libarchive", + "zlib", + ], + ), + expected_loaded_libraries = expected_loaded_libraries(), + deps = [ + "@examples_libarchive//:libarchive_static_zlib_foreign_static", + "@examples_zlib//:zlib_foreign_static", + ], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_static/s003/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_static/s003/BUILD.bazel new file mode 100644 index 000000000..889ee4f68 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_static/s003/BUILD.bazel @@ -0,0 +1,53 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake static deps +# app: cmake() +# libarchive: native static +# zlib: native shared wrapper +# runtime: zlib must load from @examples_zlib//:zlib_shared +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "libarchive_static_zlib_dynamic", + zlib = "z", + zlib_windows = "zlib_shared.if", + ), + expected_linkage = expected_linkage( + app_shared_deps = ["zlib"], + app_static_deps = ["libarchive"], + ), + expected_loaded_libraries = expected_loaded_libraries( + zlib = "@examples_zlib//:zlib_shared", + ), + deps = [ + "@examples_libarchive//:libarchive_static_zlib_dynamic", + "@examples_zlib//:zlib_dynamic", + ], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_static/s004/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_static/s004/BUILD.bazel new file mode 100644 index 000000000..7e2f4c86e --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_static/s004/BUILD.bazel @@ -0,0 +1,53 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake static deps +# app: cmake() +# libarchive: native static +# zlib: foreign_cc shared +# runtime: zlib must load from @examples_zlib//:zlib_foreign_shared +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "libarchive_static_zlib_foreign_shared", + zlib = "z", + zlib_windows = "zlib1", + ), + expected_linkage = expected_linkage( + app_shared_deps = ["zlib"], + app_static_deps = ["libarchive"], + ), + expected_loaded_libraries = expected_loaded_libraries( + zlib = "@examples_zlib//:zlib_foreign_shared", + ), + deps = [ + "@examples_libarchive//:libarchive_static_zlib_foreign_shared", + "@examples_zlib//:zlib_foreign_shared", + ], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_static/s005/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_static/s005/BUILD.bazel new file mode 100644 index 000000000..52d5f37af --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_static/s005/BUILD.bazel @@ -0,0 +1,51 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake static deps +# app: cmake() +# libarchive: foreign_cc static +# zlib: native static +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "archive", + zlib = "z", + ), + expected_linkage = expected_linkage( + app_static_deps = [ + "libarchive", + "zlib", + ], + ), + expected_loaded_libraries = expected_loaded_libraries(), + deps = [ + "@examples_libarchive//:libarchive_foreign_static_zlib_static", + "@examples_zlib//:zlib_static", + ], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_static/s006/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_static/s006/BUILD.bazel new file mode 100644 index 000000000..d7cd4d141 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_static/s006/BUILD.bazel @@ -0,0 +1,52 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake static deps +# app: cmake() +# libarchive: foreign_cc static +# zlib: foreign_cc static +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "archive", + zlib = "z", + zlib_windows = "zlib", + ), + expected_linkage = expected_linkage( + app_static_deps = [ + "libarchive", + "zlib", + ], + ), + expected_loaded_libraries = expected_loaded_libraries(), + deps = [ + "@examples_libarchive//:libarchive_foreign_static_zlib_foreign_static", + "@examples_zlib//:zlib_foreign_static", + ], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_static/s007/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_static/s007/BUILD.bazel new file mode 100644 index 000000000..a5b951e9f --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_static/s007/BUILD.bazel @@ -0,0 +1,53 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake static deps +# app: cmake() +# libarchive: foreign_cc static +# zlib: native shared wrapper +# runtime: zlib must load from @examples_zlib//:zlib_shared +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "archive", + zlib = "z", + zlib_windows = "zlib_shared.if", + ), + expected_linkage = expected_linkage( + app_shared_deps = ["zlib"], + app_static_deps = ["libarchive"], + ), + expected_loaded_libraries = expected_loaded_libraries( + zlib = "@examples_zlib//:zlib_shared", + ), + deps = [ + "@examples_libarchive//:libarchive_foreign_static_zlib_dynamic", + "@examples_zlib//:zlib_dynamic", + ], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_static/s008/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_static/s008/BUILD.bazel new file mode 100644 index 000000000..e8893bd6e --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_static/s008/BUILD.bazel @@ -0,0 +1,53 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake static deps +# app: cmake() +# libarchive: foreign_cc static +# zlib: foreign_cc shared +# runtime: zlib must load from @examples_zlib//:zlib_foreign_shared +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "archive", + zlib = "z", + zlib_windows = "zlib1", + ), + expected_linkage = expected_linkage( + app_shared_deps = ["zlib"], + app_static_deps = ["libarchive"], + ), + expected_loaded_libraries = expected_loaded_libraries( + zlib = "@examples_zlib//:zlib_foreign_shared", + ), + deps = [ + "@examples_libarchive//:libarchive_foreign_static_zlib_foreign_shared", + "@examples_zlib//:zlib_foreign_shared", + ], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_static:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_wrap/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_wrap/BUILD.bazel new file mode 100644 index 000000000..c31dc942c --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_wrap/BUILD.bazel @@ -0,0 +1,30 @@ +test_suite( + name = "runtime_tests", + tests = [ + "//integration_tests/transitive_matrix/cmake_wrap/w001:runtime_tests", + "//integration_tests/transitive_matrix/cmake_wrap/w002:runtime_tests", + "//integration_tests/transitive_matrix/cmake_wrap/w003:runtime_tests", + "//integration_tests/transitive_matrix/cmake_wrap/w004:runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [ + "//integration_tests/transitive_matrix/cmake_wrap/w001:linkage_tests", + "//integration_tests/transitive_matrix/cmake_wrap/w002:linkage_tests", + "//integration_tests/transitive_matrix/cmake_wrap/w003:linkage_tests", + "//integration_tests/transitive_matrix/cmake_wrap/w004:linkage_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_wrap/w001/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_wrap/w001/BUILD.bazel new file mode 100644 index 000000000..aa831f444 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_wrap/w001/BUILD.bazel @@ -0,0 +1,49 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake native dynamic wrapper +# app: cmake() +# libarchive: native dynamic wrapper +# zlib: native static +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_static +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "archive_zlib_static", + libarchive_windows = "libarchive_shared_zlib_static.if", + ), + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_static_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_static", + ), + deps = ["@examples_libarchive//:libarchive_dynamic_zlib_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_wrap:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_wrap:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_wrap:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_wrap/w002/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_wrap/w002/BUILD.bazel new file mode 100644 index 000000000..eba0a60c0 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_wrap/w002/BUILD.bazel @@ -0,0 +1,49 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake native dynamic wrapper +# app: cmake() +# libarchive: native dynamic wrapper +# zlib: foreign_cc static +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_foreign_static +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "archive_zlib_foreign_static", + libarchive_windows = "libarchive_shared_zlib_foreign_static.if", + ), + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_static_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_foreign_static", + ), + deps = ["@examples_libarchive//:libarchive_dynamic_zlib_foreign_static"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_wrap:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_wrap:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_wrap:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_wrap/w003/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_wrap/w003/BUILD.bazel new file mode 100644 index 000000000..fea6711f8 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_wrap/w003/BUILD.bazel @@ -0,0 +1,51 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake native dynamic wrapper +# app: cmake() +# libarchive: native dynamic wrapper +# zlib: native shared wrapper +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_dynamic +# runtime: zlib must load from @examples_zlib//:zlib_shared +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "archive_zlib_dynamic", + libarchive_windows = "libarchive_shared_zlib_dynamic.if", + ), + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_shared_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_dynamic", + zlib = "@examples_zlib//:zlib_shared", + ), + deps = ["@examples_libarchive//:libarchive_dynamic_zlib_dynamic"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_wrap:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_wrap:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_wrap:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/cmake_wrap/w004/BUILD.bazel b/examples/integration_tests/transitive_matrix/cmake_wrap/w004/BUILD.bazel new file mode 100644 index 000000000..ac7aedef6 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/cmake_wrap/w004/BUILD.bazel @@ -0,0 +1,51 @@ +load( + "//integration_tests/transitive_matrix:consumer_tests.bzl", + "cmake_cache_entries", + "cmake_consumer_test", + "expected_linkage", + "expected_loaded_libraries", +) + +# foreign_cc cmake native dynamic wrapper +# app: cmake() +# libarchive: native dynamic wrapper +# zlib: foreign_cc shared +# runtime: libarchive must load from @examples_libarchive//:libarchive_shared_zlib_foreign_shared +# runtime: zlib must load from @examples_zlib//:zlib_foreign_shared +cmake_consumer_test( + name = "t", + cache_entries = cmake_cache_entries( + libarchive = "archive_zlib_foreign_shared", + libarchive_windows = "libarchive_shared_zlib_foreign_shared.if", + ), + expected_linkage = expected_linkage( + app_shared_deps = ["libarchive"], + libarchive_shared_deps = ["zlib"], + ), + expected_loaded_libraries = expected_loaded_libraries( + libarchive = "@examples_libarchive//:libarchive_shared_zlib_foreign_shared", + zlib = "@examples_zlib//:zlib_foreign_shared", + ), + deps = ["@examples_libarchive//:libarchive_dynamic_zlib_foreign_shared"], +) + +test_suite( + name = "runtime_tests", + tests = [":t_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_wrap:__pkg__"], +) + +test_suite( + name = "linkage_tests", + tests = [":t_linkage_test"], + visibility = ["//integration_tests/transitive_matrix/cmake_wrap:__pkg__"], +) + +test_suite( + name = "tests", + tests = [ + ":linkage_tests", + ":runtime_tests", + ], + visibility = ["//integration_tests/transitive_matrix/cmake_wrap:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/consumer_tests.bzl b/examples/integration_tests/transitive_matrix/consumer_tests.bzl new file mode 100644 index 000000000..9eea37ac8 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/consumer_tests.bzl @@ -0,0 +1,308 @@ +"""Consumer app/runtime test macros for the transitive native/foreign matrix.""" + +load("@rules_cc//cc:defs.bzl", "cc_binary") +load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") +load("@rules_shell//shell:sh_test.bzl", "sh_test") + +_ALL_SUPPORTED_PLATFORMS = select({ + "@platforms//os:linux": [], + "@platforms//os:macos": [], + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], +}) + +_APP_LINKOPTS = select({ + "@platforms//os:linux": ["-ldl"], + "//conditions:default": [], +}) + +_APP_SRC = "//integration_tests/transitive_matrix:app.c" +_CONSUMER_BINARY = select({ + "@platforms//os:windows": ["app.exe"], + "//conditions:default": ["app"], +}) +_FOREIGN_APP_SRCS = "//integration_tests/transitive_matrix:foreign_app_srcs" + +def expected_loaded_libraries(libarchive = None, zlib = None): + """Returns the runtime libraries a consumer test expects to load. + + Args: + libarchive: Optional libarchive target label expected at runtime. + zlib: Optional zlib target label expected at runtime. + + Returns: + A dict keyed by logical library name with target labels as values. + """ + expected = {} + if libarchive: + expected["libarchive"] = libarchive + if zlib: + expected["zlib"] = zlib + return expected + +def expected_linkage( + app_shared_deps = [], + app_static_deps = [], + libarchive_shared_deps = [], + libarchive_static_deps = []): + """Returns linkage expectations for a consumer test. + + Args: + app_shared_deps: Logical libraries expected as app dynamic deps. + app_static_deps: Logical libraries not expected as app dynamic deps. + libarchive_shared_deps: Logical libraries expected as libarchive dynamic deps. + libarchive_static_deps: Logical libraries not expected as libarchive dynamic deps. + + Returns: + A struct containing linkage expectations for the app and libarchive. + """ + return struct( + app_shared_deps = app_shared_deps, + app_static_deps = app_static_deps, + libarchive_shared_deps = libarchive_shared_deps, + libarchive_static_deps = libarchive_static_deps, + ) + +def cmake_cache_entries( + libarchive, + libarchive_windows = None, + zlib = None, + zlib_windows = None): + """Returns CMake cache entries for platform-specific dependency names. + + Args: + libarchive: Default libarchive library name. + libarchive_windows: Optional Windows libarchive import library name. + zlib: Optional default zlib library name. + zlib_windows: Optional Windows zlib import library name. + + Returns: + A select() expression for the CMake cache entries. + """ + default_entries = { + "LIBARCHIVE_LIBRARY_NAME": libarchive, + } + windows_entries = { + "LIBARCHIVE_LIBRARY_NAME": libarchive_windows or libarchive, + } + + if zlib: + default_entries["ZLIB_LIBRARY_NAME"] = zlib + windows_entries["ZLIB_LIBRARY_NAME"] = zlib_windows or zlib + + return select({ + "@platforms//os:windows": windows_entries, + "//conditions:default": default_entries, + }) + +def runtime_test( + name, + binary, + binary_name, + target_compatible_with, + expected_loaded_libraries = {}, + tags = []): + manifest_name = name + "_manifest" + + # Example output: + # binary_name app + # binary integration_tests/.../case/app + # expect libarchive external/.../examples_libarchive/.../libarchive.so + # expect zlib external/.../examples_zlib/.../libz.so + native.genrule( + name = manifest_name, + srcs = [binary] + expected_loaded_libraries.values(), + outs = [name + ".runtime_manifest"], + cmd = "\n".join( + [ + "printf 'binary_name\\t%s\\n' '{}' > \"$@\"".format(binary_name), + "printf 'binary\\t%s\\n' '$(rlocationpaths {})' >> \"$@\"".format(binary), + ] + [ + "printf 'expect\\t%s\\t%s\\n' '{}' '$(rlocationpaths {})' >> \"$@\"".format( + library_name, + library, + ) + for library_name, library in expected_loaded_libraries.items() + ], + ), + target_compatible_with = target_compatible_with, + ) + + sh_test( + name = name, + size = "small", + srcs = ["//integration_tests/transitive_matrix:runtime_test.sh"], + args = [ + "$(rlocationpath :{})".format(manifest_name), + ], + data = [ + ":" + manifest_name, + binary, + "@coreutils_toolchains//:resolved_toolchain", + "@bazel_tools//tools/bash/runfiles", + ] + expected_loaded_libraries.values(), + env = { + "COREUTILS_RLOCATION_PATH": "$(rlocationpath @coreutils_toolchains//:resolved_toolchain)", + }, + tags = tags + ["manual"], + target_compatible_with = target_compatible_with, + ) + +def linkage_test( + name, + binary, + expected_loaded_libraries, + expected_linkage, + target_compatible_with, + tags = []): + """Creates a shell test that validates expected binary linkage. + + Args: + name: Name of the generated sh_test target. + binary: Label of the binary to inspect. + expected_loaded_libraries: Libraries that are expected to be loaded by the binary. Should be returned by expected_loaded_libraries(). + expected_linkage: Linkage expectations returned by expected_linkage(). + target_compatible_with: Platform compatibility for generated targets. + tags: Additional tags to apply to the generated sh_test target. + """ + manifest_name = name + "_manifest" + libarchive = expected_loaded_libraries.get("libarchive") + checks = [] + + for library in expected_linkage.app_shared_deps: + checks.append(("app", "dynamic", library, binary)) + for library in expected_linkage.app_static_deps: + checks.append(("app", "static", library, binary)) + + if expected_linkage.libarchive_shared_deps or expected_linkage.libarchive_static_deps: + if not libarchive: + fail("libarchive linkage checks require expected_loaded_libraries.libarchive") + + for library in expected_linkage.libarchive_shared_deps: + checks.append(("libarchive", "dynamic", library, libarchive)) + for library in expected_linkage.libarchive_static_deps: + checks.append(("libarchive", "static", library, libarchive)) + + # Linkage manifest rows are tab-separated: + # + # check + # + # Examples: + # + # check app dynamic libarchive + # check libarchive dynamic zlib + # check app static zlib + # + # `dynamic` means the inspected file must have a loader-visible dependency + # on the library. `static` means it must not. The paired runtime test proves + # the program still works. + native.genrule( + name = manifest_name, + srcs = [binary] + ([libarchive] if libarchive else []), + outs = [name + ".linkage_manifest"], + cmd = "\n".join( + ["rm -f \"$@\""] + [ + "printf 'check\\t%s\\t%s\\t%s\\t%s\\n' '{}' '{}' '{}' '$(rlocationpaths {})' >> \"$@\"".format( + inspect_name, + expected, + library, + inspect_label, + ) + for inspect_name, expected, library, inspect_label in checks + ], + ), + target_compatible_with = target_compatible_with, + ) + + sh_test( + name = name, + size = "small", + srcs = ["//integration_tests/transitive_matrix:linkage_test.sh"], + args = [ + "$(rlocationpath :{})".format(manifest_name), + ], + data = [ + ":" + manifest_name, + binary, + "@bazel_tools//tools/bash/runfiles", + ] + ([libarchive] if libarchive else []), + tags = tags + ["manual"], + target_compatible_with = target_compatible_with, + ) + +def cc_binary_consumer_test( + name, + deps, + expected_loaded_libraries, + expected_linkage, + dynamic_deps = [], + linkstatic = False, + linkopts = _APP_LINKOPTS, + target_compatible_with = _ALL_SUPPORTED_PLATFORMS, + tags = []): + cc_binary( + name = name, + srcs = [_APP_SRC], + dynamic_deps = dynamic_deps, + linkopts = linkopts, + linkstatic = linkstatic, + target_compatible_with = target_compatible_with, + deps = deps, + ) + + runtime_test( + name = name + "_test", + binary = ":" + name, + binary_name = name, + expected_loaded_libraries = expected_loaded_libraries, + tags = tags, + target_compatible_with = target_compatible_with, + ) + + linkage_test( + name = name + "_linkage_test", + binary = ":" + name, + expected_loaded_libraries = expected_loaded_libraries, + expected_linkage = expected_linkage, + tags = tags, + target_compatible_with = target_compatible_with, + ) + +def cmake_consumer_test( + name, + deps, + cache_entries, + expected_loaded_libraries, + expected_linkage, + dynamic_deps = [], + target_compatible_with = _ALL_SUPPORTED_PLATFORMS, + tags = []): + cmake( + name = name, + cache_entries = cache_entries, + dynamic_deps = dynamic_deps, + lib_source = _FOREIGN_APP_SRCS, + out_binaries = _CONSUMER_BINARY, + runtime_library_search_directories = "enabled", + runtime_library_search_mode = "executable", + target_compatible_with = target_compatible_with, + deps = deps, + ) + + runtime_test( + name = name + "_test", + binary = ":" + name, + binary_name = "app", + expected_loaded_libraries = expected_loaded_libraries, + tags = tags, + target_compatible_with = target_compatible_with, + ) + + linkage_test( + name = name + "_linkage_test", + binary = ":" + name, + expected_loaded_libraries = expected_loaded_libraries, + expected_linkage = expected_linkage, + tags = tags, + target_compatible_with = target_compatible_with, + ) diff --git a/examples/integration_tests/transitive_matrix/known_gap/BUILD.bazel b/examples/integration_tests/transitive_matrix/known_gap/BUILD.bazel new file mode 100644 index 000000000..f919795a5 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/known_gap/BUILD.bazel @@ -0,0 +1,69 @@ +load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") +load("//integration_tests/transitive_matrix:consumer_tests.bzl", "runtime_test") +load("//integration_tests/transitive_matrix:provider_semantic_parity_tests.bzl", "provider_semantic_parity_test") + +config_setting( + name = "enabled_linux", + constraint_values = ["@platforms//os:linux"], + values = {"define": "transitive_cc_foreign_known_gap=true"}, +) + +config_setting( + name = "enabled_macos", + constraint_values = ["@platforms//os:macos"], + values = {"define": "transitive_cc_foreign_known_gap=true"}, +) + +KNOWN_GAP_COMPATIBLE = select({ + ":enabled_linux": [], + ":enabled_macos": [], + "//conditions:default": ["@platforms//:incompatible"], +}) + +cmake( + name = "app", + lib_source = "//integration_tests/transitive_matrix:foreign_app_srcs", + out_binaries = ["app"], + runtime_library_search_directories = "enabled", + runtime_library_search_mode = "executable", + tags = ["manual"], + target_compatible_with = KNOWN_GAP_COMPATIBLE, + deps = ["@examples_libarchive//:libarchive_foreign_static_zlib_static"], +) + +runtime_test( + name = "t", + binary = ":app", + binary_name = "app", + tags = ["manual"], + target_compatible_with = KNOWN_GAP_COMPATIBLE, +) + +provider_semantic_parity_test( + name = "p001", + size = "small", + actual = "@examples_libarchive//:libarchive_foreign_shared_zlib_static", + expected = "@examples_libarchive//:libarchive_dynamic_zlib_static", + tags = ["manual"], + target_compatible_with = KNOWN_GAP_COMPATIBLE, +) + +provider_semantic_parity_test( + name = "p002", + size = "small", + actual = "@examples_libarchive//:libarchive_foreign_shared_zlib_foreign_static", + expected = "@examples_libarchive//:libarchive_dynamic_zlib_foreign_static", + tags = ["manual"], + target_compatible_with = KNOWN_GAP_COMPATIBLE, +) + +test_suite( + name = "tests", + tags = ["manual"], + target_compatible_with = KNOWN_GAP_COMPATIBLE, + tests = [ + ":p001", + ":p002", + ":t", + ], +) diff --git a/examples/integration_tests/transitive_matrix/known_gap/README.md b/examples/integration_tests/transitive_matrix/known_gap/README.md new file mode 100644 index 000000000..eebe16cdd --- /dev/null +++ b/examples/integration_tests/transitive_matrix/known_gap/README.md @@ -0,0 +1,58 @@ +# Known Gaps + +This package contains stricter cases that document current differences between +foreign_cc targets and comparable native `cc_*` targets. They are not part of +the default matrix because they are expected to fail today. + +The package is disabled unless the caller opts in: + +```bash +bazel test //integration_tests/transitive_matrix:known_gap_tests \ + --define=transitive_cc_foreign_known_gap=true \ + --test_output=errors +``` + +## Cases + +`:t` + +Scenario: foreign_cc CMake app -> foreign_cc static libarchive -> native static +zlib. + +Gap: the app declares only libarchive. The native static zlib input is present +in provider/action inputs, but is not staged as a foreign-build dependency +prefix that CMake can discover. + +`:p001` + +Scenario: foreign_cc shared libarchive built with native static zlib compared +to the native dynamic wrapper. + +Gap: foreign_cc exposes the static zlib library through the shared libarchive +target's `CcInfo`, while the comparable native dynamic wrapper does not expose +that static library in the same way. + +`:p002` + +Scenario: foreign_cc shared libarchive built with foreign_cc static zlib +compared to the native dynamic wrapper. + +Gap: this is the same provider-shape mismatch as above, but with the static +zlib producer coming from foreign_cc. + +## Relationship To The Default Matrix + +The default `cmake_static` matrix avoids the first gap by declaring both +libarchive and zlib as direct app dependencies. That verifies the app can link +and run when the final foreign build is given the complete static dependency +set. + +The known-gap runtime test asks for stricter transitive behavior: a downstream +foreign_cc app should be able to depend only on static libarchive and still have +zlib staged in a way the foreign build system can link. That propagation is not +currently available. + +The provider parity cases ask whether foreign shared libarchive targets expose +the same `CcInfo` shape as the native dynamic wrappers. Today they do not, so +the targets remain manual and opt-in until the intended provider contract is +clarified or changed. diff --git a/examples/integration_tests/transitive_matrix/linkage_test.sh b/examples/integration_tests/transitive_matrix/linkage_test.sh new file mode 100755 index 000000000..c162c48f6 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/linkage_test.sh @@ -0,0 +1,229 @@ +#!/usr/bin/env bash + +set -euo pipefail + +set +u +f=bazel_tools/tools/bash/runfiles/runfiles.bash +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -d ' ' -f 2-)" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -d ' ' -f 2-)" 2>/dev/null || { + echo >&2 "cannot find $f" + exit 1 + } +set -u + +if [[ "$#" -ne 1 ]]; then + echo >&2 "usage: linkage_test.sh " + exit 1 +fi + +manifest="$(rlocation "$1")" +if [[ -z "$manifest" || ! -f "$manifest" ]]; then + echo >&2 "linkage manifest not found: $1" + exit 1 +fi + +is_shared_candidate() { + case "$(basename "$1")" in + *.so|*.so.*|*.dylib|*.dll) + return 0 + ;; + esac + return 1 +} + +resolve_inspect_file() { + local inspect_name="$1" + local candidate_blob="$2" + local candidate + local resolved + + for candidate in $candidate_blob; do + case "$inspect_name" in + app) + is_shared_candidate "$candidate" && continue + ;; + libarchive) + is_shared_candidate "$candidate" || continue + ;; + *) + echo >&2 "unknown inspect target: $inspect_name" + exit 1 + ;; + esac + + resolved="$(rlocation "$candidate")" + if [[ -n "$resolved" && -f "$resolved" ]]; then + printf '%s\n' "$resolved" + return + fi + done + + echo >&2 "could not resolve inspect file for $inspect_name" + echo >&2 "candidates: $candidate_blob" + exit 1 +} + +inspect_dynamic_deps() { + local inspect_file="$1" + local output_file="$2" + local objdump_path + + case "$OSTYPE" in + darwin*) + otool -L "$inspect_file" >"$output_file" + ;; + msys*|cygwin*) + inspect_file="$(objdump_input_path "$inspect_file")" + objdump_path="$(find_objdump)" + "$objdump_path" -p "$inspect_file" >"$output_file" || true + ;; + *) + readelf -d "$inspect_file" >"$output_file" + ;; + esac +} + +objdump_input_path() { + local inspect_file="$1" + local resolved + + if command -v cygpath >/dev/null; then + inspect_file="$(cygpath -u "$inspect_file" 2>/dev/null || printf '%s\n' "$inspect_file")" + fi + + if command -v readlink >/dev/null; then + resolved="$(readlink -f "$inspect_file" 2>/dev/null || true)" + if [[ -n "$resolved" ]]; then + inspect_file="$resolved" + fi + fi + + printf '%s\n' "$inspect_file" +} + +find_objdump() { + local path + local paths=() + + for path in objdump x86_64-w64-mingw32-objdump; do + if command -v "$path" >/dev/null; then + command -v "$path" + return + fi + done + + paths+=( + "/usr/bin/objdump.exe" + "/mingw64/bin/objdump.exe" + "/ucrt64/bin/objdump.exe" + "/clang64/bin/objdump.exe" + "/c/msys64/usr/bin/objdump.exe" + "/c/msys64/mingw64/bin/objdump.exe" + "/c/msys64/ucrt64/bin/objdump.exe" + "/c/msys64/clang64/bin/objdump.exe" + "/c/cygwin64/bin/objdump.exe" + "/c/tools/StrawberryPerl/c/bin/objdump.exe" + "/c/tools/StrawberryPerl/c/x86_64-w64-mingw32/bin/objdump.exe" + "/cygdrive/c/msys64/usr/bin/objdump.exe" + "/cygdrive/c/msys64/mingw64/bin/objdump.exe" + "/cygdrive/c/msys64/ucrt64/bin/objdump.exe" + "/cygdrive/c/msys64/clang64/bin/objdump.exe" + "/cygdrive/c/cygwin64/bin/objdump.exe" + "/cygdrive/c/tools/StrawberryPerl/c/bin/objdump.exe" + "/cygdrive/c/tools/StrawberryPerl/c/x86_64-w64-mingw32/bin/objdump.exe" + ) + + for path in "${paths[@]}"; do + if [[ -x "$path" ]]; then + printf '%s\n' "$path" + return + fi + done + + echo >&2 "objdump not found; install MSYS/Cygwin binutils or add objdump.exe to PATH" + exit 1 +} + +shared_pattern_for() { + local library="$1" + + case "$OSTYPE:$library" in + darwin*:libarchive) + echo 'libarchive.*\.dylib' + ;; + darwin*:zlib) + echo 'libz.*\.dylib' + ;; + msys*:libarchive|cygwin*:libarchive) + echo 'archive.*\.dll|libarchive.*\.dll' + ;; + msys*:zlib|cygwin*:zlib) + echo 'zlib1?\.dll' + ;; + *:libarchive) + echo 'Shared library: \[.*libarchive.*\.so' + ;; + *:zlib) + echo 'Shared library: \[.*libz\.so' + ;; + *) + echo >&2 "unknown logical library: $library" + exit 1 + ;; + esac +} + +verify_linkage() { + local inspect_name="$1" + local expected_linkage="$2" + local library="$3" + local candidate_blob="$4" + local inspect_file + local output_file + local pattern + + inspect_file="$(resolve_inspect_file "$inspect_name" "$candidate_blob")" + output_file="${TEST_TMPDIR:-.}/linkage-${inspect_name}-${library}-${RANDOM}.txt" + inspect_dynamic_deps "$inspect_file" "$output_file" + pattern="$(shared_pattern_for "$library")" + + if [[ "$expected_linkage" == "dynamic" ]]; then + grep -Eqi "$pattern" "$output_file" || { + echo >&2 "$inspect_name should dynamically link $library" + echo >&2 "inspect file: $inspect_file" + cat "$output_file" >&2 + rm -f "$output_file" + exit 1 + } + elif [[ "$expected_linkage" == "static" ]]; then + if grep -Eqi "$pattern" "$output_file"; then + echo >&2 "$inspect_name should statically link $library" + echo >&2 "inspect file: $inspect_file" + cat "$output_file" >&2 + rm -f "$output_file" + exit 1 + fi + else + echo >&2 "unknown linkage mode: $expected_linkage" + rm -f "$output_file" + exit 1 + fi + + rm -f "$output_file" +} + +while IFS=$'\t' read -r record inspect_name expected_linkage library candidates; do + case "$record" in + ""|"#"?*) + ;; + check) + verify_linkage "$inspect_name" "$expected_linkage" "$library" "$candidates" + ;; + *) + echo >&2 "unknown linkage manifest record: $record" + exit 1 + ;; + esac +done <"$manifest" diff --git a/examples/integration_tests/transitive_matrix/provider_parity/BUILD.bazel b/examples/integration_tests/transitive_matrix/provider_parity/BUILD.bazel new file mode 100644 index 000000000..42e254cb3 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/provider_parity/BUILD.bazel @@ -0,0 +1,95 @@ +load("//integration_tests/transitive_matrix:provider_semantic_parity_tests.bzl", "provider_semantic_parity_test") + +ALL_SUPPORTED_PLATFORMS = select({ + "@platforms//os:linux": [], + "@platforms//os:macos": [], + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], +}) + +# Provider parity: zlib static +provider_semantic_parity_test( + name = "p001", + size = "small", + actual = "@examples_zlib//:zlib_foreign_static", + expected = "@examples_zlib//:zlib_static", + target_compatible_with = ALL_SUPPORTED_PLATFORMS, +) + +# Provider parity: zlib shared +provider_semantic_parity_test( + name = "p002", + size = "small", + actual = "@examples_zlib//:zlib_foreign_shared", + expected = "@examples_zlib//:zlib_dynamic", + target_compatible_with = ALL_SUPPORTED_PLATFORMS, +) + +# Provider parity: libarchive static -> native static zlib +provider_semantic_parity_test( + name = "p003", + size = "small", + actual = "@examples_libarchive//:libarchive_foreign_static_zlib_static", + expected = "@examples_libarchive//:libarchive_static_zlib_static", + target_compatible_with = ALL_SUPPORTED_PLATFORMS, +) + +# Provider parity: libarchive static -> foreign_cc static zlib +provider_semantic_parity_test( + name = "p004", + size = "small", + actual = "@examples_libarchive//:libarchive_foreign_static_zlib_foreign_static", + expected = "@examples_libarchive//:libarchive_static_zlib_foreign_static", + target_compatible_with = ALL_SUPPORTED_PLATFORMS, +) + +# Provider parity: libarchive static -> native shared zlib wrapper +provider_semantic_parity_test( + name = "p005", + size = "small", + actual = "@examples_libarchive//:libarchive_foreign_static_zlib_dynamic", + expected = "@examples_libarchive//:libarchive_static_zlib_dynamic", + target_compatible_with = ALL_SUPPORTED_PLATFORMS, +) + +# Provider parity: libarchive static -> foreign_cc shared zlib +provider_semantic_parity_test( + name = "p006", + size = "small", + actual = "@examples_libarchive//:libarchive_foreign_static_zlib_foreign_shared", + expected = "@examples_libarchive//:libarchive_static_zlib_foreign_shared", + target_compatible_with = ALL_SUPPORTED_PLATFORMS, +) + +# Provider parity: libarchive shared -> native shared zlib wrapper +provider_semantic_parity_test( + name = "p007", + size = "small", + actual = "@examples_libarchive//:libarchive_foreign_shared_zlib_dynamic", + expected = "@examples_libarchive//:libarchive_dynamic_zlib_dynamic", + target_compatible_with = ALL_SUPPORTED_PLATFORMS, +) + +# Provider parity: libarchive shared -> foreign_cc shared zlib +provider_semantic_parity_test( + name = "p008", + size = "small", + actual = "@examples_libarchive//:libarchive_foreign_shared_zlib_foreign_shared", + expected = "@examples_libarchive//:libarchive_dynamic_zlib_foreign_shared", + target_compatible_with = ALL_SUPPORTED_PLATFORMS, +) + +test_suite( + name = "tests", + tests = [ + ":p001", + ":p002", + ":p003", + ":p004", + ":p005", + ":p006", + ":p007", + ":p008", + ], + visibility = ["//integration_tests/transitive_matrix:__pkg__"], +) diff --git a/examples/integration_tests/transitive_matrix/provider_semantic_parity_tests.bzl b/examples/integration_tests/transitive_matrix/provider_semantic_parity_tests.bzl new file mode 100644 index 000000000..878961e20 --- /dev/null +++ b/examples/integration_tests/transitive_matrix/provider_semantic_parity_tests.bzl @@ -0,0 +1,182 @@ +"""Provider parity tests for the transitive native/foreign matrix.""" + +load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") +load("@rules_cc//cc:defs.bzl", "CcInfo") + +def _all_digits(value): + for char in value.elems(): + if char < "0" or char > "9": + return False + return bool(value) + +def _canonical_library_name(name): + lower_name = name.lower() + if lower_name in ["z.lib", "zlib.lib", "zlib1.lib", "zlib1.if.lib", "zlib_shared.if.lib"]: + return "zlib.lib" + if lower_name in ["z.dll", "zlib.dll", "zlib1.dll"]: + return "zlib.dll" + if lower_name.startswith("archive_zlib_") and lower_name.endswith(".if.lib"): + return "archive.lib" + if lower_name.startswith("libarchive_shared_zlib_") and lower_name.endswith(".if.lib"): + return "archive.lib" + if lower_name in ["archive.lib", "archive.if.lib", "libarchive_shared.if.lib"]: + return "archive.lib" + if lower_name.startswith("archive_zlib_") and lower_name.endswith(".dll"): + return "archive.dll" + if lower_name in ["archive.dll", "libarchive.dll"]: + return "archive.dll" + if lower_name.startswith("libarchive_static_zlib_") and lower_name.endswith(".lib"): + return "archive.lib" + if lower_name.startswith("liblibarchive_static_zlib_") and lower_name.endswith(".a"): + return "libarchive.a" + if name.endswith(".pic.a"): + return _canonical_library_name(name[:-len(".pic.a")] + ".a") + if lower_name.startswith("libarchive_zlib_") and ".so" in lower_name: + return "libarchive.so" + so_index = name.find(".so") + if so_index != -1: + return name[:so_index] + ".so" + if lower_name.startswith("libarchive_zlib_") and lower_name.endswith(".dylib"): + return "libarchive.dylib" + if name.endswith(".dylib"): + stem = name[:-len(".dylib")] + parts = stem.split(".") + if len(parts) > 1 and all([_all_digits(part) for part in parts[1:]]): + return parts[0] + ".dylib" + return name + +def _dedupe_sorted(values): + return sorted({value: None for value in values}.keys()) + +def _is_solib_path(short_path): + return short_path.startswith("_solib_") + +def _libraries_to_link(linking_context): + libraries = [] + user_link_flags = [] + for linker_input in linking_context.linker_inputs.to_list(): + user_link_flags.extend(linker_input.user_link_flags) + libraries.extend(linker_input.libraries) + return struct( + libraries = libraries, + user_link_flags = _dedupe_sorted(user_link_flags), + ) + +def _compilation_projection(compilation_context): + external_includes = getattr(compilation_context, "external_includes", depset()) + local_defines = getattr(compilation_context, "local_defines", depset()) + include_paths = ( + compilation_context.includes.to_list() + + compilation_context.quote_includes.to_list() + + compilation_context.system_includes.to_list() + + external_includes.to_list() + ) + return struct( + defines = _dedupe_sorted(compilation_context.defines.to_list()), + has_headers = bool(compilation_context.headers.to_list()), + has_include_paths = bool(include_paths), + local_defines = _dedupe_sorted(local_defines.to_list()), + ) + +def _library_path_shapes(libraries, library_attr, resolved_attr): + shapes = {} + for library in libraries: + library_file = getattr(library, library_attr) + resolved_file = getattr(library, resolved_attr) + if not library_file and not resolved_file: + continue + + name = _canonical_library_name( + library_file.basename if library_file else resolved_file.basename, + ) + if name not in shapes: + shapes[name] = { + "all_libraries_are_solibs": True, + "all_resolved_libraries_are_not_solibs": True, + "has_library": False, + "has_resolved_library": False, + } + + shape = shapes[name] + if library_file: + shape["has_library"] = True + if not _is_solib_path(library_file.short_path): + shape["all_libraries_are_solibs"] = False + if resolved_file: + shape["has_resolved_library"] = True + if _is_solib_path(resolved_file.short_path): + shape["all_resolved_libraries_are_not_solibs"] = False + + return [ + struct( + all_libraries_are_solibs = shapes[name]["all_libraries_are_solibs"], + all_resolved_libraries_are_not_solibs = shapes[name]["all_resolved_libraries_are_not_solibs"], + has_library = shapes[name]["has_library"], + has_resolved_library = shapes[name]["has_resolved_library"], + name = name, + ) + for name in sorted(shapes.keys()) + ] + +def _linking_projection(linking_context): + linking_inputs = _libraries_to_link(linking_context) + static_libraries = [] + dynamic_libraries = [] + interface_libraries = [] + for library in linking_inputs.libraries: + if library.static_library: + static_libraries.append(_canonical_library_name(library.static_library.basename)) + if library.pic_static_library: + static_libraries.append(_canonical_library_name(library.pic_static_library.basename)) + if library.dynamic_library: + dynamic_libraries.append(_canonical_library_name(library.dynamic_library.basename)) + if library.interface_library: + interface_libraries.append(_canonical_library_name(library.interface_library.basename)) + return struct( + dynamic_library_path_shapes = _library_path_shapes( + linking_inputs.libraries, + "dynamic_library", + "resolved_symlink_dynamic_library", + ), + dynamic_libraries = _dedupe_sorted(dynamic_libraries), + interface_library_path_shapes = _library_path_shapes( + linking_inputs.libraries, + "interface_library", + "resolved_symlink_interface_library", + ), + interface_libraries = _dedupe_sorted(interface_libraries), + static_libraries = _dedupe_sorted(static_libraries), + user_link_flags = linking_inputs.user_link_flags, + ) + +def _cc_info_projection(target): + cc_info = target[CcInfo] + return struct( + compilation = _compilation_projection(cc_info.compilation_context), + linking = _linking_projection(cc_info.linking_context), + ) + +def _provider_semantic_parity_test_impl(ctx): + env = analysistest.begin(ctx) + actual = _cc_info_projection(analysistest.target_under_test(env)) + expected = _cc_info_projection(ctx.attr.expected) + + asserts.equals(env, expected.compilation, actual.compilation, "compilation context") + asserts.equals(env, expected.linking, actual.linking, "linking context") + + return analysistest.end(env) + +_provider_semantic_parity_test = analysistest.make( + _provider_semantic_parity_test_impl, + attrs = { + "expected": attr.label(mandatory = True, providers = [CcInfo]), + }, +) + +def provider_semantic_parity_test(name, actual, expected, **kwargs): + _provider_semantic_parity_test( + name = name, + target_under_test = actual, + expected = expected, + **kwargs + ) diff --git a/examples/integration_tests/transitive_matrix/runtime_test.sh b/examples/integration_tests/transitive_matrix/runtime_test.sh new file mode 100755 index 000000000..7a7e49faf --- /dev/null +++ b/examples/integration_tests/transitive_matrix/runtime_test.sh @@ -0,0 +1,342 @@ +#!/usr/bin/env bash + +set -euo pipefail + +set +u +f=bazel_tools/tools/bash/runfiles/runfiles.bash +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -d ' ' -f 2-)" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -d ' ' -f 2-)" 2>/dev/null || { + echo >&2 "cannot find $f" + exit 1 + } +set -u + +# The runtime manifest is a tab-separated file generated by the test macro. +# It contains one binary name, one list of binary runfile candidates, and zero +# or more expected loaded-library groups. +# +# Example: +# +# binary_name app +# binary integration_tests/.../case/app integration_tests/.../case/app.exe +# expect libarchive external/.../examples_libarchive/.../bin/archive.dll +# expect zlib external/.../examples_zlib/.../bin/zlib1.dll +# +# `binary` and `expect` path fields may contain multiple space-separated +# runfile paths because they come from Bazel `$(rlocationpaths ...)`. +usage() { + echo "usage: COREUTILS_RLOCATION_PATH= $0 " >&2 +} + +is_windows() { + case "$(uname -s 2>/dev/null || true)" in + CYGWIN*|MINGW*|MSYS*) + return 0 + ;; + esac + return 1 +} + +windows_shell_path() { + if command -v cygpath >/dev/null; then + cygpath -u "$1" + return + fi + printf '%s\n' "$1" +} + +real_file_path() { + "$coreutils_bin" realpath "$1" +} + +runfile_path() { + local path="$1" + local resolved + + resolved="$(rlocation "$path")" + if [[ -z "$resolved" || ! -f "$resolved" ]]; then + echo "runfile not found: $path" >&2 + exit 1 + fi + + printf '%s\n' "$resolved" +} + +canonical_path() { + local path + + path="$(real_file_path "$1")" + if is_windows; then + if command -v cygpath >/dev/null; then + path="$(cygpath -m "$path")" + fi + path="${path//\\//}" + printf '%s\n' "$path" | tr '[:upper:]' '[:lower:]' + return + fi + + printf '%s\n' "$path" +} + +shared_library_candidate() { + case "$(basename "$1")" in + *.so|*.so.*|*.dylib|*.dll) + return 0 + ;; + esac + return 1 +} + +resolve_shared_library_runfile() { + local candidate="$1" + local resolved_candidate + + if [[ -z "$candidate" ]] || ! shared_library_candidate "$candidate"; then + return 1 + fi + + resolved_candidate="$(rlocation "$candidate")" + if [[ -z "$resolved_candidate" || ! -e "$resolved_candidate" ]]; then + return 1 + fi + + printf '%s\n' "$resolved_candidate" +} + +binary_name_matches() { + local candidate_basename + candidate_basename="$(basename "$1")" + if [[ "$candidate_basename" == "$binary_name" ]]; then + return 0 + fi + if is_windows && [[ "$candidate_basename" == "${binary_name}.exe" ]]; then + return 0 + fi + return 1 +} + +loaded_path_for() { + local name="$1" + local line + line="$(grep -m1 "^loaded ${name}: " "$stdout_file" || true)" + if [[ -z "$line" ]]; then + echo "missing loaded path for ${name}" >&2 + cat "$stdout_file" >&2 + exit 1 + fi + printf '%s\n' "${line#loaded ${name}: }" +} + +assert_loaded_from_expected() { + local name="$1" + local candidate_blob="$2" + local candidate + local candidate_canonical + local loaded_path + local loaded_canonical + local expected_canonical_paths=() + local resolved_candidate + + loaded_path="$(loaded_path_for "$name")" + # app.c prints sentinel values such as `` when it cannot map a + # symbol back to a loaded shared library, so do not treat that as a real path. + if [[ "$loaded_path" == \<*\> ]]; then + echo "${name} did not resolve to a loaded shared library" >&2 + cat "$stdout_file" >&2 + exit 1 + fi + loaded_canonical="$(canonical_path "$loaded_path")" + + while IFS= read -r candidate; do + resolved_candidate="$(resolve_shared_library_runfile "$candidate")" || continue + candidate_canonical="$(canonical_path "$resolved_candidate")" + expected_canonical_paths+=("$candidate_canonical") + if [[ "$loaded_canonical" == "$candidate_canonical" ]]; then + return + fi + done <<< "$candidate_blob" + + echo "${name} loaded from unexpected path" >&2 + echo "actual: $loaded_canonical" >&2 + echo "expected one of:" >&2 + printf ' %s\n' "${expected_canonical_paths[@]}" >&2 + exit 1 +} + +append_windows_dll_search_dir() { + local candidate_dir="$1" + local candidate_dir_path + + if [[ ! -d "$candidate_dir" ]]; then + return + fi + + candidate_dir_path="$(windows_shell_path "$candidate_dir")" + case ":$windows_dll_search_path:" in + *":$candidate_dir_path:"*) + ;; + *) + if [[ -n "$windows_dll_search_path" ]]; then + windows_dll_search_path+=":" + fi + windows_dll_search_path+="$candidate_dir_path" + ;; + esac +} + +append_windows_dll_search_dirs() { + local candidate_blob="$1" + local candidate + local resolved_candidate + local candidate_dir + + while IFS= read -r candidate; do + resolved_candidate="$(resolve_shared_library_runfile "$candidate")" || continue + resolved_candidate="$(real_file_path "$resolved_candidate")" + candidate_dir="$(dirname "$resolved_candidate")" + append_windows_dll_search_dir "$candidate_dir" + done <<< "$candidate_blob" +} + +if [[ "$#" -ne 1 ]]; then + usage + exit 1 +fi + +manifest_runfile_path="$1" +manifest="$(runfile_path "$manifest_runfile_path")" + +if [[ -z "${COREUTILS_RLOCATION_PATH:-}" ]]; then + echo "COREUTILS_RLOCATION_PATH is not set" >&2 + exit 1 +fi + +coreutils_bin="$(runfile_path "$COREUTILS_RLOCATION_PATH")" + +binary_name="" +binary_candidates=() +expected_names=() +expected_candidate_blobs=() + +while IFS=$'\t' read -r record name paths; do + words=() + case "$record" in + "") + ;; + binary_name) + binary_name="$name" + ;; + binary) + read -r -a words <<< "$name" + binary_candidates+=("${words[@]}") + ;; + expect) + read -r -a words <<< "${paths:-}" + expected_candidate_blob="$(printf '%s\n' "${words[@]}")" + if [[ -z "$name" || -z "$expected_candidate_blob" ]]; then + echo "invalid expect record in runtime manifest: $record $name ${paths:-}" >&2 + exit 1 + fi + expected_names+=("$name") + expected_candidate_blobs+=("$expected_candidate_blob") + ;; + *) + echo "unknown runtime manifest record: $record" >&2 + exit 1 + ;; + esac +done < "$manifest" + +if [[ -z "$binary_name" ]]; then + echo "runtime manifest missing binary_name record" >&2 + exit 1 +fi +if [[ "${#binary_candidates[@]}" -eq 0 ]]; then + echo "runtime manifest missing binary record" >&2 + exit 1 +fi + +binary_runfile_path="" +for candidate in "${binary_candidates[@]}"; do + if binary_name_matches "$candidate"; then + binary_runfile_path="$candidate" + break + fi +done + +if [[ -z "$binary_runfile_path" ]]; then + echo "$binary_name runfile path not found in: ${binary_candidates[*]}" >&2 + exit 1 +fi + +binary="$(rlocation "$binary_runfile_path")" +if [[ -z "$binary" || ! -f "$binary" ]]; then + echo "$binary_name is not executable: $binary_runfile_path" >&2 + exit 1 +fi +if ! is_windows && [[ ! -x "$binary" ]]; then + echo "$binary_name is not executable: $binary_runfile_path" >&2 + exit 1 +fi + +stdout_file="$TEST_TMPDIR/transitive-matrix-stdout.txt" +stderr_file="$TEST_TMPDIR/transitive-matrix-stderr.txt" + +set +e +if is_windows; then + # Windows resolves imported DLLs by searching the executable directory, + # system locations, then PATH; it does not honor ELF/Mach-O rpath. In Bazel + # runfiles, dependency DLLs can live in separate output directories instead + # of beside the test binary, so prepend the expected Bazel-built DLL + # directories to PATH before launching it. Prepending keeps ambient PATH + # entries from winning when they contain a DLL with the same basename. + # + # Example: the test binary may be in `.../case/`, while expected DLLs are in + # `.../examples_libarchive/.../bin/archive.dll` and + # `.../examples_zlib/.../bin/zlib1.dll`. The manifest lists those DLL files. + # This loop resolves them, adds their parent `bin` directories to PATH, then + # runs the binary. The app prints the actual loaded DLL paths, and the final + # assertions check they match the manifest files. + windows_dll_search_path="" + for index in "${!expected_candidate_blobs[@]}"; do + append_windows_dll_search_dirs "${expected_candidate_blobs[$index]}" + done + windows_child_path="$windows_dll_search_path" + if [[ -n "$windows_child_path" && -n "${PATH:-}" ]]; then + windows_child_path+=":" + fi + windows_child_path+="${PATH:-}" + PATH="$windows_child_path" "$binary" >"$stdout_file" 2>"$stderr_file" +else + env -u LD_LIBRARY_PATH -u DYLD_LIBRARY_PATH "$binary" >"$stdout_file" 2>"$stderr_file" +fi +status="$?" +set -e + +if [[ "$status" -ne 0 ]]; then + echo "$binary_name failed with exit code $status: $binary" >&2 + if is_windows; then + echo "windows dll search path: ${windows_dll_search_path:-}" >&2 + fi + cat "$stdout_file" >&2 + cat "$stderr_file" >&2 + exit "$status" +fi + +expected="expected libarchive+zlib loaded: payload=rules_foreign_cc_transitive_test" +if ! grep -Fxq "$expected" "$stdout_file"; then + echo "unexpected transitive matrix output" >&2 + echo "expected: $expected" >&2 + echo "actual:" >&2 + cat "$stdout_file" >&2 + cat "$stderr_file" >&2 + exit 1 +fi + +for index in "${!expected_names[@]}"; do + assert_loaded_from_expected \ + "${expected_names[$index]}" \ + "${expected_candidate_blobs[$index]}" +done diff --git a/examples/third_party/MODULE.bazel b/examples/third_party/MODULE.bazel index c5c763012..57ab108ec 100644 --- a/examples/third_party/MODULE.bazel +++ b/examples/third_party/MODULE.bazel @@ -71,6 +71,7 @@ use_repo( "bison", "cares", "curl", + "examples_libarchive", "examples_zlib", "expat", "flex", diff --git a/examples/third_party/libarchive/BUILD.bazel b/examples/third_party/libarchive/BUILD.bazel new file mode 100644 index 000000000..86b902380 --- /dev/null +++ b/examples/third_party/libarchive/BUILD.bazel @@ -0,0 +1,32 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +exports_files( + [ + "BUILD.libarchive.bazel", + "libarchive_config_darwin.h", + "libarchive_config_linux.h", + "libarchive_config_windows.h", + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "config_darwin", + hdrs = ["libarchive_config_darwin.h"], + includes = ["."], + visibility = ["//visibility:public"], +) + +cc_library( + name = "config_linux", + hdrs = ["libarchive_config_linux.h"], + includes = ["."], + visibility = ["//visibility:public"], +) + +cc_library( + name = "config_windows", + hdrs = ["libarchive_config_windows.h"], + includes = ["."], + visibility = ["//visibility:public"], +) diff --git a/examples/third_party/libarchive/BUILD.libarchive.bazel b/examples/third_party/libarchive/BUILD.libarchive.bazel new file mode 100644 index 000000000..fc7437b3e --- /dev/null +++ b/examples/third_party/libarchive/BUILD.libarchive.bazel @@ -0,0 +1,602 @@ +load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library", "cc_shared_library") +load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") + +package(default_visibility = ["//visibility:public"]) + +ALL_SUPPORTED_PLATFORMS = select({ + "@platforms//os:linux": [], + "@platforms//os:macos": [], + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], +}) + +LIBARCHIVE_SHARED_LIB = select({ + "@platforms//os:macos": [ + "libarchive.dylib", + "libarchive.13.dylib", + "libarchive.13.7.7.dylib", + ], + "@platforms//os:windows": ["archive.dll"], + "//conditions:default": [ + "libarchive.so", + "libarchive.so.13", + "libarchive.so.13.7.7", + ], +}) + +LIBARCHIVE_INTERFACE_LIB = select({ + "@platforms//os:windows": ["archive.lib"], + "//conditions:default": [], +}) + +LIBARCHIVE_STATIC_LIB = select({ + "@platforms//os:windows": ["archive.lib"], + "//conditions:default": ["libarchive.a"], +}) + +LIBARCHIVE_COMMON_SRCS = glob( + ["libarchive/*.c"], + exclude = [ + "libarchive/archive_disk_acl_darwin.c", + "libarchive/archive_disk_acl_freebsd.c", + "libarchive/archive_disk_acl_linux.c", + "libarchive/archive_disk_acl_sunos.c", + "libarchive/archive_entry_copy_bhfi.c", + "libarchive/archive_read_disk_windows.c", + "libarchive/archive_read_disk_posix.c", + "libarchive/archive_windows.c", + "libarchive/archive_write_disk_posix.c", + "libarchive/archive_write_disk_windows.c", + "libarchive/filter_fork_windows.c", + "libarchive/filter_fork_posix.c", + ], +) + +LIBARCHIVE_PUBLIC_HDRS = [ + "libarchive/archive.h", + "libarchive/archive_entry.h", +] + +LIBARCHIVE_PRIVATE_HDRS = glob( + ["libarchive/*.h"], + exclude = LIBARCHIVE_PUBLIC_HDRS, +) + +LIBARCHIVE_CONFIG_DEPS = select({ + "@platforms//os:macos": ["@rules_foreign_cc_examples_third_party//libarchive:config_darwin"], + "@platforms//os:windows": ["@rules_foreign_cc_examples_third_party//libarchive:config_windows"], + "//conditions:default": ["@rules_foreign_cc_examples_third_party//libarchive:config_linux"], +}) + +LIBARCHIVE_COPTS = select({ + "@platforms//os:macos": ["-DPLATFORM_CONFIG_H=\\\"libarchive_config_darwin.h\\\""], + "@platforms//os:windows": ["/DPLATFORM_CONFIG_H=\\\"libarchive_config_windows.h\\\""], + "//conditions:default": ["-DPLATFORM_CONFIG_H=\\\"libarchive_config_linux.h\\\""], +}) + select({ + "@platforms//os:windows": [], + "//conditions:default": [ + "-Wno-deprecated-non-prototype", + "-Wno-implicit-function-declaration", + "-Wno-unused-function", + "-Wno-unused-variable", + ], +}) + +LIBARCHIVE_STATIC_DEFINES = select({ + "@platforms//os:windows": ["LIBARCHIVE_STATIC"], + "//conditions:default": [], +}) + +LIBARCHIVE_SRCS = select({ + "@platforms//os:macos": LIBARCHIVE_COMMON_SRCS + [ + "libarchive/archive_disk_acl_darwin.c", + "libarchive/archive_read_disk_posix.c", + "libarchive/archive_write_disk_posix.c", + "libarchive/filter_fork_posix.c", + ], + "@platforms//os:windows": LIBARCHIVE_COMMON_SRCS + [ + "libarchive/archive_read_disk_windows.c", + "libarchive/archive_windows.c", + "libarchive/archive_write_disk_windows.c", + "libarchive/filter_fork_windows.c", + ], + "//conditions:default": LIBARCHIVE_COMMON_SRCS + [ + "libarchive/archive_read_disk_posix.c", + "libarchive/archive_write_disk_posix.c", + "libarchive/filter_fork_posix.c", + ], +}) + +LIBARCHIVE_STATIC_COPTS = LIBARCHIVE_COPTS + [ + "-DLIBARCHIVE_STATIC", +] + +LIBARCHIVE_SHARED_FEATURES = select({ + "@platforms//os:macos": ["set_install_name"], + "@platforms//os:windows": [], + "//conditions:default": ["set_soname"], +}) + +LIBARCHIVE_CMAKE_CACHE = { + "CMAKE_BUILD_TYPE": "RELEASE", + "CMAKE_POLICY_DEFAULT_CMP0074": "NEW", + "CMAKE_POLICY_VERSION_MINIMUM": "3.5", + "ENABLE_ACL": "OFF", + "ENABLE_BZip2": "OFF", + "ENABLE_CAT": "OFF", + "ENABLE_CPIO": "OFF", + "ENABLE_EXPAT": "OFF", + "ENABLE_ICONV": "OFF", + "ENABLE_INSTALL": "ON", + "ENABLE_LIBB2": "OFF", + "ENABLE_LIBXML2": "OFF", + "ENABLE_LZ4": "OFF", + "ENABLE_LZMA": "OFF", + "ENABLE_LZO": "OFF", + "ENABLE_MBEDTLS": "OFF", + "ENABLE_NETTLE": "OFF", + "ENABLE_OPENSSL": "OFF", + "ENABLE_PCRE2POSIX": "OFF", + "ENABLE_PCREPOSIX": "OFF", + "ENABLE_TAR": "OFF", + "ENABLE_TEST": "OFF", + "ENABLE_UNZIP": "OFF", + "ENABLE_XATTR": "OFF", + "ENABLE_ZLIB": "ON", + "ENABLE_ZSTD": "OFF", +} + +LIBARCHIVE_STATIC_CMAKE_CACHE = dict(LIBARCHIVE_CMAKE_CACHE.items() + { + "BUILD_SHARED_LIBS": "OFF", +}.items()) + +LIBARCHIVE_SHARED_CMAKE_CACHE = dict(LIBARCHIVE_CMAKE_CACHE.items() + { + "BUILD_SHARED_LIBS": "ON", +}.items()) + +filegroup( + name = "all_srcs", + srcs = glob( + include = ["**"], + exclude = ["*.bazel"], + ), +) + +cc_library( + name = "libarchive_headers", + hdrs = LIBARCHIVE_PUBLIC_HDRS, + includes = ["libarchive"], + linkstatic = True, +) + +cc_library( + name = "libarchive_static_zlib_static", + srcs = LIBARCHIVE_SRCS + LIBARCHIVE_PRIVATE_HDRS, + hdrs = LIBARCHIVE_PUBLIC_HDRS, + copts = LIBARCHIVE_STATIC_COPTS, + defines = LIBARCHIVE_STATIC_DEFINES, + implementation_deps = LIBARCHIVE_CONFIG_DEPS, + includes = ["libarchive"], + linkstatic = True, + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_static"], +) + +cc_library( + name = "libarchive_static_zlib_foreign_static", + srcs = LIBARCHIVE_SRCS + LIBARCHIVE_PRIVATE_HDRS, + hdrs = LIBARCHIVE_PUBLIC_HDRS, + copts = LIBARCHIVE_STATIC_COPTS, + defines = LIBARCHIVE_STATIC_DEFINES, + implementation_deps = LIBARCHIVE_CONFIG_DEPS, + includes = ["libarchive"], + linkstatic = True, + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_foreign_static"], +) + +cc_library( + name = "libarchive_static_zlib_dynamic", + srcs = LIBARCHIVE_SRCS + LIBARCHIVE_PRIVATE_HDRS, + hdrs = LIBARCHIVE_PUBLIC_HDRS, + copts = LIBARCHIVE_STATIC_COPTS, + defines = LIBARCHIVE_STATIC_DEFINES, + implementation_deps = LIBARCHIVE_CONFIG_DEPS, + includes = ["libarchive"], + linkstatic = True, + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_dynamic"], +) + +cc_library( + name = "libarchive_static_zlib_foreign_shared", + srcs = LIBARCHIVE_SRCS + LIBARCHIVE_PRIVATE_HDRS, + hdrs = LIBARCHIVE_PUBLIC_HDRS, + copts = LIBARCHIVE_STATIC_COPTS, + defines = LIBARCHIVE_STATIC_DEFINES, + implementation_deps = LIBARCHIVE_CONFIG_DEPS, + includes = ["libarchive"], + linkstatic = True, + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_foreign_shared"], +) + +cc_library( + name = "libarchive_impl_zlib_static", + srcs = LIBARCHIVE_SRCS + LIBARCHIVE_PRIVATE_HDRS, + hdrs = LIBARCHIVE_PUBLIC_HDRS, + copts = LIBARCHIVE_COPTS, + implementation_deps = LIBARCHIVE_CONFIG_DEPS, + includes = ["libarchive"], + linkstatic = True, + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_static"], +) + +cc_library( + name = "libarchive_impl_zlib_foreign_static", + srcs = LIBARCHIVE_SRCS + LIBARCHIVE_PRIVATE_HDRS, + hdrs = LIBARCHIVE_PUBLIC_HDRS, + copts = LIBARCHIVE_COPTS, + implementation_deps = LIBARCHIVE_CONFIG_DEPS, + includes = ["libarchive"], + linkstatic = True, + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_foreign_static"], +) + +cc_library( + name = "libarchive_impl_zlib_dynamic", + srcs = LIBARCHIVE_SRCS + LIBARCHIVE_PRIVATE_HDRS, + hdrs = LIBARCHIVE_PUBLIC_HDRS, + copts = LIBARCHIVE_COPTS, + implementation_deps = LIBARCHIVE_CONFIG_DEPS, + includes = ["libarchive"], + linkstatic = True, + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_dynamic_headers"], +) + +cc_library( + name = "libarchive_impl_zlib_foreign_shared", + srcs = LIBARCHIVE_SRCS + LIBARCHIVE_PRIVATE_HDRS, + hdrs = LIBARCHIVE_PUBLIC_HDRS, + copts = LIBARCHIVE_COPTS, + implementation_deps = LIBARCHIVE_CONFIG_DEPS, + includes = ["libarchive"], + linkstatic = True, + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_foreign_shared"], +) + +cc_shared_library( + name = "libarchive_shared_zlib_static", + features = LIBARCHIVE_SHARED_FEATURES, + shared_lib_name = select({ + "@platforms//os:macos": "libarchive_zlib_static.dylib", + "@platforms//os:windows": "archive_zlib_static.dll", + "//conditions:default": "libarchive_zlib_static.so", + }), + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = [":libarchive_impl_zlib_static"], +) + +filegroup( + name = "libarchive_shared_zlib_static_interface_library", + srcs = [":libarchive_shared_zlib_static"], + output_group = "interface_library", + target_compatible_with = select({ + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) + +cc_import( + name = "libarchive_shared_zlib_static_import", + interface_library = ":libarchive_shared_zlib_static_interface_library", + shared_library = ":libarchive_shared_zlib_static", + target_compatible_with = select({ + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) + +cc_library( + name = "libarchive_dynamic_zlib_static", + srcs = select({ + "@platforms//os:windows": [], + "//conditions:default": [":libarchive_shared_zlib_static"], + }), + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = [":libarchive_headers"] + select({ + "@platforms//os:windows": [":libarchive_shared_zlib_static_import"], + "//conditions:default": [], + }), +) + +cc_shared_library( + name = "libarchive_shared_zlib_foreign_static", + features = LIBARCHIVE_SHARED_FEATURES, + shared_lib_name = select({ + "@platforms//os:macos": "libarchive_zlib_foreign_static.dylib", + "@platforms//os:windows": "archive_zlib_foreign_static.dll", + "//conditions:default": "libarchive_zlib_foreign_static.so", + }), + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = [":libarchive_impl_zlib_foreign_static"], +) + +filegroup( + name = "libarchive_shared_zlib_foreign_static_interface_library", + srcs = [":libarchive_shared_zlib_foreign_static"], + output_group = "interface_library", + target_compatible_with = select({ + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) + +cc_import( + name = "libarchive_shared_zlib_foreign_static_import", + interface_library = ":libarchive_shared_zlib_foreign_static_interface_library", + shared_library = ":libarchive_shared_zlib_foreign_static", + target_compatible_with = select({ + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) + +cc_library( + name = "libarchive_dynamic_zlib_foreign_static", + srcs = select({ + "@platforms//os:windows": [], + "//conditions:default": [":libarchive_shared_zlib_foreign_static"], + }), + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = [":libarchive_headers"] + select({ + "@platforms//os:windows": [":libarchive_shared_zlib_foreign_static_import"], + "//conditions:default": [], + }), +) + +cc_shared_library( + name = "libarchive_shared_zlib_dynamic", + dynamic_deps = ["@examples_zlib//:zlib_shared"], + features = LIBARCHIVE_SHARED_FEATURES, + shared_lib_name = select({ + "@platforms//os:macos": "libarchive_zlib_dynamic.dylib", + "@platforms//os:windows": "archive_zlib_dynamic.dll", + "//conditions:default": "libarchive_zlib_dynamic.so", + }), + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = [":libarchive_impl_zlib_dynamic"], +) + +filegroup( + name = "libarchive_shared_zlib_dynamic_interface_library", + srcs = [":libarchive_shared_zlib_dynamic"], + output_group = "interface_library", + target_compatible_with = select({ + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) + +cc_import( + name = "libarchive_shared_zlib_dynamic_import", + interface_library = ":libarchive_shared_zlib_dynamic_interface_library", + shared_library = ":libarchive_shared_zlib_dynamic", + target_compatible_with = select({ + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) + +cc_library( + name = "libarchive_dynamic_zlib_dynamic", + srcs = select({ + "@platforms//os:windows": [], + "//conditions:default": [":libarchive_shared_zlib_dynamic"], + }), + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = [ + ":libarchive_headers", + "@examples_zlib//:zlib_dynamic", + ] + select({ + "@platforms//os:windows": [":libarchive_shared_zlib_dynamic_import"], + "//conditions:default": [], + }), +) + +cc_shared_library( + name = "libarchive_shared_zlib_foreign_shared", + features = LIBARCHIVE_SHARED_FEATURES, + shared_lib_name = select({ + "@platforms//os:macos": "libarchive_zlib_foreign_shared.dylib", + "@platforms//os:windows": "archive_zlib_foreign_shared.dll", + "//conditions:default": "libarchive_zlib_foreign_shared.so", + }), + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = [":libarchive_impl_zlib_foreign_shared"], +) + +filegroup( + name = "libarchive_shared_zlib_foreign_shared_interface_library", + srcs = [":libarchive_shared_zlib_foreign_shared"], + output_group = "interface_library", + target_compatible_with = select({ + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) + +cc_import( + name = "libarchive_shared_zlib_foreign_shared_import", + interface_library = ":libarchive_shared_zlib_foreign_shared_interface_library", + shared_library = ":libarchive_shared_zlib_foreign_shared", + target_compatible_with = select({ + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) + +cc_library( + name = "libarchive_dynamic_zlib_foreign_shared", + srcs = select({ + "@platforms//os:windows": [], + "//conditions:default": [":libarchive_shared_zlib_foreign_shared"], + }), + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = [ + ":libarchive_headers", + "@examples_zlib//:zlib_foreign_shared", + ] + select({ + "@platforms//os:windows": [":libarchive_shared_zlib_foreign_shared_import"], + "//conditions:default": [], + }), +) + +cmake( + name = "libarchive_foreign_static_zlib_static", + cache_entries = select({ + "@platforms//os:windows": dict(LIBARCHIVE_STATIC_CMAKE_CACHE.items() + { + "ZLIB_INCLUDE_DIR": "$$EXT_BUILD_DEPS/include", + "ZLIB_LIBRARY": "$$EXT_BUILD_DEPS/lib/z.lib", + }.items()), + "//conditions:default": dict(LIBARCHIVE_STATIC_CMAKE_CACHE.items() + { + "CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC", + "ZLIB_ROOT": "$$EXT_BUILD_DEPS/zlib_static", + }.items()), + }), + defines = select({ + "@platforms//os:windows": ["LIBARCHIVE_STATIC"], + "//conditions:default": [], + }), + lib_source = ":all_srcs", + out_static_libs = LIBARCHIVE_STATIC_LIB, + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_static"], +) + +cmake( + name = "libarchive_foreign_static_zlib_foreign_static", + cache_entries = dict(LIBARCHIVE_STATIC_CMAKE_CACHE.items() + { + "CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC", + "ZLIB_ROOT": "$$EXT_BUILD_DEPS/zlib", + }.items()), + defines = select({ + "@platforms//os:windows": ["LIBARCHIVE_STATIC"], + "//conditions:default": [], + }), + lib_source = ":all_srcs", + out_static_libs = LIBARCHIVE_STATIC_LIB, + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_foreign_static"], +) + +cmake( + name = "libarchive_foreign_static_zlib_dynamic", + cache_entries = select({ + "@platforms//os:windows": dict(LIBARCHIVE_STATIC_CMAKE_CACHE.items() + { + "CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC", + "ZLIB_INCLUDE_DIR": "$$EXT_BUILD_DEPS/include", + "ZLIB_LIBRARY": "$$EXT_BUILD_DEPS/include/zlib_shared.if.lib", + }.items()), + "//conditions:default": dict(LIBARCHIVE_STATIC_CMAKE_CACHE.items() + { + "CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC", + "ZLIB_ROOT": "$$EXT_BUILD_DEPS/zlib_dynamic", + }.items()), + }), + defines = select({ + "@platforms//os:windows": ["LIBARCHIVE_STATIC"], + "//conditions:default": [], + }), + lib_source = ":all_srcs", + out_static_libs = LIBARCHIVE_STATIC_LIB, + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_dynamic"], +) + +cmake( + name = "libarchive_foreign_static_zlib_foreign_shared", + cache_entries = dict(LIBARCHIVE_STATIC_CMAKE_CACHE.items() + { + "CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC", + "ZLIB_ROOT": "$$EXT_BUILD_DEPS/zlib_foreign_shared", + }.items()), + defines = select({ + "@platforms//os:windows": ["LIBARCHIVE_STATIC"], + "//conditions:default": [], + }), + lib_source = ":all_srcs", + out_static_libs = LIBARCHIVE_STATIC_LIB, + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_foreign_shared"], +) + +cmake( + name = "libarchive_foreign_shared_zlib_static", + cache_entries = select({ + "@platforms//os:windows": dict(LIBARCHIVE_SHARED_CMAKE_CACHE.items() + { + "ZLIB_INCLUDE_DIR": "$$EXT_BUILD_DEPS/include", + "ZLIB_LIBRARY": "$$EXT_BUILD_DEPS/lib/z.lib", + }.items()), + "//conditions:default": dict(LIBARCHIVE_SHARED_CMAKE_CACHE.items() + { + "ZLIB_ROOT": "$$EXT_BUILD_DEPS/zlib_static", + }.items()), + }), + lib_source = ":all_srcs", + out_interface_libs = LIBARCHIVE_INTERFACE_LIB, + out_shared_libs = LIBARCHIVE_SHARED_LIB, + runtime_library_search_directories = "enabled", + runtime_library_search_mode = "shared", + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_static"], +) + +cmake( + name = "libarchive_foreign_shared_zlib_foreign_static", + cache_entries = dict(LIBARCHIVE_SHARED_CMAKE_CACHE.items() + { + "ZLIB_ROOT": "$$EXT_BUILD_DEPS/zlib", + }.items()), + lib_source = ":all_srcs", + out_interface_libs = LIBARCHIVE_INTERFACE_LIB, + out_shared_libs = LIBARCHIVE_SHARED_LIB, + runtime_library_search_directories = "enabled", + runtime_library_search_mode = "shared", + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_foreign_static"], +) + +cmake( + name = "libarchive_foreign_shared_zlib_dynamic", + cache_entries = select({ + "@platforms//os:windows": dict(LIBARCHIVE_SHARED_CMAKE_CACHE.items() + { + "ZLIB_INCLUDE_DIR": "$$EXT_BUILD_DEPS/include", + "ZLIB_LIBRARY": "$$EXT_BUILD_DEPS/include/zlib_shared.if.lib", + }.items()), + "//conditions:default": dict(LIBARCHIVE_SHARED_CMAKE_CACHE.items() + { + "ZLIB_ROOT": "$$EXT_BUILD_DEPS/zlib_dynamic", + }.items()), + }), + lib_source = ":all_srcs", + out_interface_libs = LIBARCHIVE_INTERFACE_LIB, + out_shared_libs = LIBARCHIVE_SHARED_LIB, + runtime_library_search_directories = "enabled", + runtime_library_search_mode = "shared", + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_dynamic"], +) + +cmake( + name = "libarchive_foreign_shared_zlib_foreign_shared", + cache_entries = dict(LIBARCHIVE_SHARED_CMAKE_CACHE.items() + { + "ZLIB_ROOT": "$$EXT_BUILD_DEPS/zlib_foreign_shared", + }.items()), + lib_source = ":all_srcs", + out_interface_libs = LIBARCHIVE_INTERFACE_LIB, + out_shared_libs = LIBARCHIVE_SHARED_LIB, + runtime_library_search_directories = "enabled", + runtime_library_search_mode = "shared", + target_compatible_with = ALL_SUPPORTED_PLATFORMS, + deps = ["@examples_zlib//:zlib_foreign_shared"], +) diff --git a/examples/third_party/libarchive/libarchive_config_darwin.h b/examples/third_party/libarchive/libarchive_config_darwin.h new file mode 100644 index 000000000..1483589de --- /dev/null +++ b/examples/third_party/libarchive/libarchive_config_darwin.h @@ -0,0 +1,1468 @@ +/* config.h. Best-effort Darwin config for libarchive 3.7.7 native cc_library + * examples. */ +#define __LIBARCHIVE_CONFIG_H_INCLUDED 1 + +/* + * Ensure we have C99-style int64_t, etc, all defined. + */ + +/* First, we need to know if the system has already defined them. */ +#define HAVE_INT16_T +#define HAVE_INT32_T +#define HAVE_INT64_T +#define HAVE_INTMAX_T + +#define HAVE_UINT8_T +#define HAVE_UINT16_T +#define HAVE_UINT32_T +#define HAVE_UINT64_T +#define HAVE_UINTMAX_T + +/* We might have the types we want under other spellings. */ +/* #undef HAVE___INT64 */ +/* #undef HAVE_U_INT64_T */ +/* #undef HAVE_UNSIGNED___INT64 */ + +/* The sizes of various standard integer types. */ +#define SIZEOF_SHORT 2 +#define SIZEOF_INT 4 +#define SIZEOF_LONG 8 +#define SIZEOF_LONG_LONG 8 +#define SIZEOF_UNSIGNED_SHORT 2 +#define SIZEOF_UNSIGNED 4 +#define SIZEOF_UNSIGNED_LONG 8 +#define SIZEOF_UNSIGNED_LONG_LONG 8 + +/* + * If we lack int64_t, define it to the first of __int64, int, long, and long + * long that exists and is the right size. + */ +#if !defined(HAVE_INT64_T) && defined(HAVE___INT64) +typedef __int64 int64_t; +#define HAVE_INT64_T +#endif + +#if !defined(HAVE_INT64_T) && SIZEOF_INT == 8 +typedef int int64_t; +#define HAVE_INT64_T +#endif + +#if !defined(HAVE_INT64_T) && SIZEOF_LONG == 8 +typedef long int64_t; +#define HAVE_INT64_T +#endif + +#if !defined(HAVE_INT64_T) && SIZEOF_LONG_LONG == 8 +typedef long long int64_t; +#define HAVE_INT64_T +#endif + +#if !defined(HAVE_INT64_T) +#error No 64-bit integer type was found. +#endif + +/* + * Similarly for int32_t + */ +#if !defined(HAVE_INT32_T) && SIZEOF_INT == 4 +typedef int int32_t; +#define HAVE_INT32_T +#endif + +#if !defined(HAVE_INT32_T) && SIZEOF_LONG == 4 +typedef long int32_t; +#define HAVE_INT32_T +#endif + +#if !defined(HAVE_INT32_T) +#error No 32-bit integer type was found. +#endif + +/* + * Similarly for int16_t + */ +#if !defined(HAVE_INT16_T) && SIZEOF_INT == 2 +typedef int int16_t; +#define HAVE_INT16_T +#endif + +#if !defined(HAVE_INT16_T) && SIZEOF_SHORT == 2 +typedef short int16_t; +#define HAVE_INT16_T +#endif + +#if !defined(HAVE_INT16_T) +#error No 16-bit integer type was found. +#endif + +/* + * Similarly for uint64_t + */ +#if !defined(HAVE_UINT64_T) && defined(HAVE_UNSIGNED___INT64) +typedef unsigned __int64 uint64_t; +#define HAVE_UINT64_T +#endif + +#if !defined(HAVE_UINT64_T) && SIZEOF_UNSIGNED == 8 +typedef unsigned uint64_t; +#define HAVE_UINT64_T +#endif + +#if !defined(HAVE_UINT64_T) && SIZEOF_UNSIGNED_LONG == 8 +typedef unsigned long uint64_t; +#define HAVE_UINT64_T +#endif + +#if !defined(HAVE_UINT64_T) && SIZEOF_UNSIGNED_LONG_LONG == 8 +typedef unsigned long long uint64_t; +#define HAVE_UINT64_T +#endif + +#if !defined(HAVE_UINT64_T) +#error No 64-bit unsigned integer type was found. +#endif + +/* + * Similarly for uint32_t + */ +#if !defined(HAVE_UINT32_T) && SIZEOF_UNSIGNED == 4 +typedef unsigned uint32_t; +#define HAVE_UINT32_T +#endif + +#if !defined(HAVE_UINT32_T) && SIZEOF_UNSIGNED_LONG == 4 +typedef unsigned long uint32_t; +#define HAVE_UINT32_T +#endif + +#if !defined(HAVE_UINT32_T) +#error No 32-bit unsigned integer type was found. +#endif + +/* + * Similarly for uint16_t + */ +#if !defined(HAVE_UINT16_T) && SIZEOF_UNSIGNED == 2 +typedef unsigned uint16_t; +#define HAVE_UINT16_T +#endif + +#if !defined(HAVE_UINT16_T) && SIZEOF_UNSIGNED_SHORT == 2 +typedef unsigned short uint16_t; +#define HAVE_UINT16_T +#endif + +#if !defined(HAVE_UINT16_T) +#error No 16-bit unsigned integer type was found. +#endif + +/* + * Similarly for uint8_t + */ +#if !defined(HAVE_UINT8_T) +typedef unsigned char uint8_t; +#define HAVE_UINT8_T +#endif + +#if !defined(HAVE_UINT8_T) +#error No 8-bit unsigned integer type was found. +#endif + +/* Define intmax_t and uintmax_t if they are not already defined. */ +#if !defined(HAVE_INTMAX_T) +typedef int64_t intmax_t; +#endif + +#if !defined(HAVE_UINTMAX_T) +typedef uint64_t uintmax_t; +#endif + +/* Define ZLIB_WINAPI if zlib was built on Visual Studio. */ +/* #undef ZLIB_WINAPI */ + +/* Darwin ACL support */ +/* #undef ARCHIVE_ACL_DARWIN */ + +/* FreeBSD ACL support */ +/* #undef ARCHIVE_ACL_FREEBSD */ + +/* FreeBSD NFSv4 ACL support */ +/* #undef ARCHIVE_ACL_FREEBSD_NFS4 */ + +/* Linux POSIX.1e ACL support via libacl */ +/* #undef ARCHIVE_ACL_LIBACL */ + +/* Linux NFSv4 ACL support via librichacl */ +/* #undef ARCHIVE_ACL_LIBRICHACL */ + +/* Solaris ACL support */ +/* #undef ARCHIVE_ACL_SUNOS */ + +/* Solaris NFSv4 ACL support */ +/* #undef ARCHIVE_ACL_SUNOS_NFS4 */ + +/* MD5 via ARCHIVE_CRYPTO_MD5_LIBC supported. */ +/* #undef ARCHIVE_CRYPTO_MD5_LIBC */ + +/* MD5 via ARCHIVE_CRYPTO_MD5_LIBSYSTEM supported. */ +/* #undef ARCHIVE_CRYPTO_MD5_LIBSYSTEM */ + +/* MD5 via ARCHIVE_CRYPTO_MD5_MBEDTLS supported. */ +/* #undef ARCHIVE_CRYPTO_MD5_MBEDTLS */ + +/* MD5 via ARCHIVE_CRYPTO_MD5_NETTLE supported. */ +/* #undef ARCHIVE_CRYPTO_MD5_NETTLE */ + +/* MD5 via ARCHIVE_CRYPTO_MD5_OPENSSL supported. */ +/* #undef ARCHIVE_CRYPTO_MD5_OPENSSL */ + +/* MD5 via ARCHIVE_CRYPTO_MD5_WIN supported. */ +/* #undef ARCHIVE_CRYPTO_MD5_WIN */ + +/* RMD160 via ARCHIVE_CRYPTO_RMD160_LIBC supported. */ +/* #undef ARCHIVE_CRYPTO_RMD160_LIBC */ + +/* RMD160 via ARCHIVE_CRYPTO_RMD160_NETTLE supported. */ +/* #undef ARCHIVE_CRYPTO_RMD160_NETTLE */ + +/* RMD160 via ARCHIVE_CRYPTO_RMD160_MBEDTLS supported. */ +/* #undef ARCHIVE_CRYPTO_RMD160_MBEDTLS */ + +/* RMD160 via ARCHIVE_CRYPTO_RMD160_OPENSSL supported. */ +/* #undef ARCHIVE_CRYPTO_RMD160_OPENSSL */ + +/* SHA1 via ARCHIVE_CRYPTO_SHA1_LIBC supported. */ +/* #undef ARCHIVE_CRYPTO_SHA1_LIBC */ + +/* SHA1 via ARCHIVE_CRYPTO_SHA1_LIBSYSTEM supported. */ +/* #undef ARCHIVE_CRYPTO_SHA1_LIBSYSTEM */ + +/* SHA1 via ARCHIVE_CRYPTO_SHA1_MBEDTLS supported. */ +/* #undef ARCHIVE_CRYPTO_SHA1_MBEDTLS */ + +/* SHA1 via ARCHIVE_CRYPTO_SHA1_NETTLE supported. */ +/* #undef ARCHIVE_CRYPTO_SHA1_NETTLE */ + +/* SHA1 via ARCHIVE_CRYPTO_SHA1_OPENSSL supported. */ +/* #undef ARCHIVE_CRYPTO_SHA1_OPENSSL */ + +/* SHA1 via ARCHIVE_CRYPTO_SHA1_WIN supported. */ +/* #undef ARCHIVE_CRYPTO_SHA1_WIN */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBC supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_LIBC */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBC2 supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_LIBC2 */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBC3 supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_LIBC3 */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBSYSTEM supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_LIBSYSTEM */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_MBEDTLS supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_MBEDTLS */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_NETTLE supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_NETTLE */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_OPENSSL supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_OPENSSL */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_WIN supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_WIN */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBC supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_LIBC */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBC2 supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_LIBC2 */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBC3 supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_LIBC3 */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBSYSTEM supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_LIBSYSTEM */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_MBEDTLS supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_MBEDTLS */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_NETTLE supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_NETTLE */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_OPENSSL supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_OPENSSL */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_WIN supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_WIN */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBC supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_LIBC */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBC2 supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_LIBC2 */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBC3 supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_LIBC3 */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBSYSTEM supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_LIBSYSTEM */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_MBEDTLS supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_MBEDTLS */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_NETTLE supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_NETTLE */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_OPENSSL supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_OPENSSL */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_WIN supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_WIN */ + +/* AIX xattr support */ +/* #undef ARCHIVE_XATTR_AIX */ + +/* Darwin xattr support */ +/* #undef ARCHIVE_XATTR_DARWIN */ + +/* FreeBSD xattr support */ +/* #undef ARCHIVE_XATTR_FREEBSD */ + +/* Linux xattr support */ +/* #undef ARCHIVE_XATTR_LINUX */ + +/* Version number of bsdcpio */ +#define BSDCPIO_VERSION_STRING "3.7.7" + +/* Version number of bsdtar */ +#define BSDTAR_VERSION_STRING "3.7.7" + +/* Version number of bsdcat */ +#define BSDCAT_VERSION_STRING "3.7.7" + +/* Version number of bsdunzip */ +#define BSDUNZIP_VERSION_STRING "3.7.7" + +/* Define to 1 if you have the `acl_create_entry' function. */ +/* #undef HAVE_ACL_CREATE_ENTRY */ + +/* Define to 1 if you have the `acl_get_fd_np' function. */ +/* #undef HAVE_ACL_GET_FD_NP */ + +/* Define to 1 if you have the `acl_get_link' function. */ +/* #undef HAVE_ACL_GET_LINK */ + +/* Define to 1 if you have the `acl_get_link_np' function. */ +/* #undef HAVE_ACL_GET_LINK_NP */ + +/* Define to 1 if you have the `acl_get_perm' function. */ +/* #undef HAVE_ACL_GET_PERM */ + +/* Define to 1 if you have the `acl_get_perm_np' function. */ +/* #undef HAVE_ACL_GET_PERM_NP */ + +/* Define to 1 if you have the `acl_init' function. */ +/* #undef HAVE_ACL_INIT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ACL_LIBACL_H */ + +/* Define to 1 if the system has the type `acl_permset_t'. */ +/* #undef HAVE_ACL_PERMSET_T */ + +/* Define to 1 if you have the `acl_set_fd' function. */ +/* #undef HAVE_ACL_SET_FD */ + +/* Define to 1 if you have the `acl_set_fd_np' function. */ +/* #undef HAVE_ACL_SET_FD_NP */ + +/* Define to 1 if you have the `acl_set_file' function. */ +/* #undef HAVE_ACL_SET_FILE */ + +/* Define to 1 if you have the `arc4random_buf' function. */ +/* #undef HAVE_ARC4RANDOM_BUF */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ATTR_XATTR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BCRYPT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BSDXML_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BZLIB_H */ + +/* Define to 1 if you have the `chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define to 1 if you have the `chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_COPYFILE_H */ + +/* Define to 1 if you have the `ctime_r' function. */ +#define HAVE_CTIME_R 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_CTYPE_H 1 + +/* Define to 1 if you have the `cygwin_conv_path' function. */ +/* #undef HAVE_CYGWIN_CONV_PATH */ + +/* Define to 1 if you have the declaration of `ACE_GETACL', and to 0 if you + don't. */ +/* #undef HAVE_DECL_ACE_GETACL */ + +/* Define to 1 if you have the declaration of `ACE_GETACLCNT', and to 0 if you + don't. */ +/* #undef HAVE_DECL_ACE_GETACLCNT */ + +/* Define to 1 if you have the declaration of `ACE_SETACL', and to 0 if you + don't. */ +/* #undef HAVE_DECL_ACE_SETACL */ + +/* Define to 1 if you have the declaration of `ACL_SYNCHRONIZE', and to 0 if + you don't. */ +/* #undef HAVE_DECL_ACL_SYNCHRONIZE */ + +/* Define to 1 if you have the declaration of `ACL_TYPE_EXTENDED', and to 0 if + you don't. */ +/* #undef HAVE_DECL_ACL_TYPE_EXTENDED */ + +/* Define to 1 if you have the declaration of `ACL_TYPE_NFS4', and to 0 if you + don't. */ +/* #undef HAVE_DECL_ACL_TYPE_NFS4 */ + +/* Define to 1 if you have the declaration of `ACL_USER', and to 0 if you + don't. */ +/* #undef HAVE_DECL_ACL_USER */ + +/* Define to 1 if you have the declaration of `INT32_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_INT32_MAX 1 + +/* Define to 1 if you have the declaration of `INT32_MIN', and to 0 if you + don't. */ +#define HAVE_DECL_INT32_MIN 1 + +/* Define to 1 if you have the declaration of `INT64_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_INT64_MAX 1 + +/* Define to 1 if you have the declaration of `INT64_MIN', and to 0 if you + don't. */ +#define HAVE_DECL_INT64_MIN 1 + +/* Define to 1 if you have the declaration of `INTMAX_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_INTMAX_MAX 1 + +/* Define to 1 if you have the declaration of `INTMAX_MIN', and to 0 if you + don't. */ +#define HAVE_DECL_INTMAX_MIN 1 + +/* Define to 1 if you have the declaration of `SETACL', and to 0 if you don't. + */ +/* #undef HAVE_DECL_SETACL */ + +/* Define to 1 if you have the declaration of `SIZE_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_SIZE_MAX 1 + +/* Define to 1 if you have the declaration of `SSIZE_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_SSIZE_MAX 1 + +/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you + don't. */ +#define HAVE_DECL_STRERROR_R 1 + +/* Define to 1 if you have the declaration of `UINT32_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_UINT32_MAX 1 + +/* Define to 1 if you have the declaration of `UINT64_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_UINT64_MAX 1 + +/* Define to 1 if you have the declaration of `UINTMAX_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_UINTMAX_MAX 1 + +/* Define to 1 if you have the declaration of `XATTR_NOFOLLOW', and to 0 if + you don't. */ +/* #undef HAVE_DECL_XATTR_NOFOLLOW */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the `dirfd' function. */ +#define HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +/* #undef HAVE_DOPRNT */ + +/* Define to 1 if nl_langinfo supports D_MD_ORDER */ +/* #undef HAVE_D_MD_ORDER */ + +/* A possible errno value for invalid file format errors */ +/* #undef HAVE_EFTYPE */ + +/* A possible errno value for invalid file format errors */ +#define HAVE_EILSEQ 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_EXPAT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_EXT2FS_EXT2_FS_H */ + +/* Define to 1 if you have the `extattr_get_file' function. */ +/* #undef HAVE_EXTATTR_GET_FILE */ + +/* Define to 1 if you have the `extattr_list_file' function. */ +/* #undef HAVE_EXTATTR_LIST_FILE */ + +/* Define to 1 if you have the `extattr_set_fd' function. */ +/* #undef HAVE_EXTATTR_SET_FD */ + +/* Define to 1 if you have the `extattr_set_file' function. */ +/* #undef HAVE_EXTATTR_SET_FILE */ + +/* Define to 1 if EXTATTR_NAMESPACE_USER is defined in sys/extattr.h. */ +/* #undef HAVE_DECL_EXTATTR_NAMESPACE_USER */ + +/* Define to 1 if you have the declaration of `GETACL', and to 0 if you don't. + */ +/* #undef HAVE_DECL_GETACL */ + +/* Define to 1 if you have the declaration of `GETACLCNT', and to 0 if you + don't. */ +/* #undef HAVE_DECL_GETACLCNT */ + +/* Define to 1 if you have the `fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchflags' function. */ +/* #undef HAVE_FCHFLAGS */ + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the `fcntl' function. */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `fdopendir' function. */ +#define HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the `fgetea' function. */ +/* #undef HAVE_FGETEA */ + +/* Define to 1 if you have the `fgetxattr' function. */ +/* #undef HAVE_FGETXATTR */ + +/* Define to 1 if you have the `flistea' function. */ +/* #undef HAVE_FLISTEA */ + +/* Define to 1 if you have the `flistxattr' function. */ +/* #undef HAVE_FLISTXATTR */ + +/* Define to 1 if you have the `fnmatch' function. */ +#define HAVE_FNMATCH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FNMATCH_H 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fsetea' function. */ +/* #undef HAVE_FSETEA */ + +/* Define to 1 if you have the `fsetxattr' function. */ +/* #undef HAVE_FSETXATTR */ + +/* Define to 1 if you have the `fstat' function. */ +#define HAVE_FSTAT 1 + +/* Define to 1 if you have the `fstatat' function. */ +#define HAVE_FSTATAT 1 + +/* Define to 1 if you have the `fstatfs' function. */ +#define HAVE_FSTATFS 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +#define HAVE_FSTATVFS 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `futimens' function. */ +#define HAVE_FUTIMENS 1 + +/* Define to 1 if you have the `futimes' function. */ +#define HAVE_FUTIMES 1 + +/* Define to 1 if you have the `futimesat' function. */ +#define HAVE_FUTIMESAT 1 + +/* Define to 1 if you have the `getea' function. */ +/* #undef HAVE_GETEA */ + +/* Define to 1 if you have the `geteuid' function. */ +#define HAVE_GETEUID 1 + +/* Define to 1 if you have the `getgrgid_r' function. */ +#define HAVE_GETGRGID_R 1 + +/* Define to 1 if you have the `getgrnam_r' function. */ +#define HAVE_GETGRNAM_R 1 + +/* Define to 1 if you have the `getline' function. */ +#define HAVE_GETLINE 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpwnam_r' function. */ +#define HAVE_GETPWNAM_R 1 + +/* Define to 1 if you have the `getpwuid_r' function. */ +#define HAVE_GETPWUID_R 1 + +/* Define to 1 if you have the `getvfsbyname' function. */ +/* #undef HAVE_GETVFSBYNAME */ + +/* Define to 1 if you have the `getxattr' function. */ +/* #undef HAVE_GETXATTR */ + +/* Define to 1 if you have the `gmtime_r' function. */ +#define HAVE_GMTIME_R 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define to 1 if you have the `iconv' function. */ +/* #undef HAVE_ICONV */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ICONV_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Define to 1 if you have the `lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +#define HAVE_LCHMOD 1 + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgetea' function. */ +/* #undef HAVE_LGETEA */ + +/* Define to 1 if you have the `lgetxattr' function. */ +/* #undef HAVE_LGETXATTR */ + +/* Define to 1 if you have the `acl' library (-lacl). */ +/* #undef HAVE_LIBACL */ + +/* Define to 1 if you have the `attr' library (-lattr). */ +/* #undef HAVE_LIBATTR */ + +/* Define to 1 if you have the `bsdxml' library (-lbsdxml). */ +/* #undef HAVE_LIBBSDXML */ + +/* Define to 1 if you have the `bz2' library (-lbz2). */ +/* #undef HAVE_LIBBZ2 */ + +/* Define to 1 if you have the `b2' library (-lb2). */ +/* #undef HAVE_LIBB2 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLAKE2_H */ + +/* Define to 1 if you have the `charset' library (-lcharset). */ +/* #undef HAVE_LIBCHARSET */ + +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +/* #undef HAVE_LIBCRYPTO */ + +/* Define to 1 if you have the `expat' library (-lexpat). */ +/* #undef HAVE_LIBEXPAT */ + +/* Define to 1 if you have the `gcc' library (-lgcc). */ +/* #undef HAVE_LIBGCC */ + +/* Define to 1 if you have the `lz4' library (-llz4). */ +/* #undef HAVE_LIBLZ4 */ + +/* Define to 1 if you have the `lzma' library (-llzma). */ +/* #undef HAVE_LIBLZMA */ + +/* Define to 1 if you have the `lzmadec' library (-llzmadec). */ +/* #undef HAVE_LIBLZMADEC */ + +/* Define to 1 if you have the `lzo2' library (-llzo2). */ +/* #undef HAVE_LIBLZO2 */ + +/* Define to 1 if you have the `mbedcrypto' library (-lmbedcrypto). */ +/* #undef HAVE_LIBMBEDCRYPTO */ + +/* Define to 1 if you have the `nettle' library (-lnettle). */ +/* #undef HAVE_LIBNETTLE */ + +/* Define to 1 if you have the `pcre' library (-lpcre). */ +/* #undef HAVE_LIBPCRE */ + +/* Define to 1 if you have the `pcreposix' library (-lpcreposix). */ +/* #undef HAVE_LIBPCREPOSIX */ + +/* Define to 1 if you have the `pcre2-8' library (-lpcre2-8). */ +/* #undef HAVE_LIBPCRE2 */ + +/* Define to 1 if you have the `pcreposix' library (-lpcre2posix). */ +/* #undef HAVE_LIBPCRE2POSIX */ + +/* Define to 1 if you have the `xml2' library (-lxml2). */ +/* #undef HAVE_LIBXML2 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBXML_XMLREADER_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBXML_XMLWRITER_H */ + +/* Define to 1 if you have the `z' library (-lz). */ +#define HAVE_LIBZ 1 + +/* Define to 1 if you have the `zstd' library (-lzstd). */ +/* #undef HAVE_LIBZSTD */ + +/* Define to 1 if you have the ZSTD_compressStream function. */ +/* #undef HAVE_ZSTD_compressStream */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the `link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the `linkat' function. */ +#define HAVE_LINKAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_FIEMAP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_FS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_MAGIC_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_TYPES_H 1 + +/* Define to 1 if you have the `listea' function. */ +/* #undef HAVE_LISTEA */ + +/* Define to 1 if you have the `listxattr' function. */ +/* #undef HAVE_LISTXATTR */ + +/* Define to 1 if you have the `llistea' function. */ +/* #undef HAVE_LLISTEA */ + +/* Define to 1 if you have the `llistxattr' function. */ +/* #undef HAVE_LLISTXATTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LOCALCHARSET_H */ + +/* Define to 1 if you have the `locale_charset' function. */ +/* #undef HAVE_LOCALE_CHARSET */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the `localtime_r' function. */ +#define HAVE_LOCALTIME_R 1 + +/* Define to 1 if the system has the type `long long int'. */ +/* #undef HAVE_LONG_LONG_INT */ + +/* Define to 1 if you have the `lsetea' function. */ +/* #undef HAVE_LSETEA */ + +/* Define to 1 if you have the `lsetxattr' function. */ +/* #undef HAVE_LSETXATTR */ + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define to 1 if `lstat' has the bug that it succeeds when given the + zero-length file name argument. */ +/* #undef HAVE_LSTAT_EMPTY_STRING_BUG */ + +/* Define to 1 if you have the `lutimes' function. */ +#define HAVE_LUTIMES 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZ4HC_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZ4_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZMADEC_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZMA_H */ + +/* Define to 1 if you have a working `lzma_stream_encoder_mt' function. */ +/* #undef HAVE_LZMA_STREAM_ENCODER_MT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZO_LZO1X_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZO_LZOCONF_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MBEDTLS_AES_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MBEDTLS_MD_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MBEDTLS_PKCS5_H */ + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MEMBERSHIP_H */ + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkdir' function. */ +#define HAVE_MKDIR 1 + +/* Define to 1 if you have the `mkfifo' function. */ +#define HAVE_MKFIFO 1 + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_AES_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_HMAC_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_MD5_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_PBKDF2_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_RIPEMD160_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_SHA_H */ + +/* Define to 1 if you have the `nl_langinfo' function. */ +#define HAVE_NL_LANGINFO 1 + +/* Define to 1 if you have the `openat' function. */ +#define HAVE_OPENAT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENSSL_EVP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PATHS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PCREPOSIX_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PCRE2POSIX_H */ + +/* Define to 1 if you have the `pipe' function. */ +#define HAVE_PIPE 1 + +/* Define to 1 if you have the `PKCS5_PBKDF2_HMAC_SHA1' function. */ +/* #undef HAVE_PKCS5_PBKDF2_HMAC_SHA1 */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_spawnp' function. */ +#define HAVE_POSIX_SPAWNP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `readdir_r' function. */ +#define HAVE_READDIR_R 1 + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. */ +#define HAVE_READLINKAT 1 + +/* Define to 1 if you have the `readpassphrase' function. */ +/* #undef HAVE_READPASSPHRASE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_READPASSPHRASE_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_REGEX_H 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `setenv' function. */ +#define HAVE_SETENV 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SPAWN_H 1 + +/* Define to 1 if you have the `statfs' function. */ +#define HAVE_STATFS 1 + +/* Define to 1 if you have the `statvfs' function. */ +#define HAVE_STATVFS 1 + +/* Define to 1 if `stat' has the bug that it succeeds when given the + zero-length file name argument. */ +/* #undef HAVE_STAT_EMPTY_STRING_BUG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDARG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strnlen' function. */ +#define HAVE_STRNLEN 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strerror_r' function. */ +#define HAVE_STRERROR_R 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strrchr' function. */ +#define HAVE_STRRCHR 1 + +/* Define to 1 if the system has the type `struct statfs'. */ +/* #undef HAVE_STRUCT_STATFS */ + +/* Define to 1 if `f_iosize' is a member of `struct statfs'. */ +/* #undef HAVE_STRUCT_STATFS_F_IOSIZE */ + +/* Define to 1 if `f_namemax' is a member of `struct statfs'. */ +/* #undef HAVE_STRUCT_STATFS_F_NAMEMAX */ + +/* Define to 1 if `f_iosize' is a member of `struct statvfs'. */ +/* #undef HAVE_STRUCT_STATVFS_F_IOSIZE */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_birthtimespec.tv_nsec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_mtimespec.tv_nsec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC */ + +/* Define to 1 if `st_mtime_n' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_MTIME_N */ + +/* Define to 1 if `st_mtime_usec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_MTIME_USEC */ + +/* Define to 1 if `st_mtim.tv_nsec' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 + +/* Define to 1 if `st_umtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_UMTIME */ + +/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_GMTOFF 1 + +/* Define to 1 if `__tm_gmtoff' is a member of `struct tm'. */ +/* #undef HAVE_STRUCT_TM___TM_GMTOFF */ + +/* Define to 1 if you have `struct vfsconf'. */ +/* #undef HAVE_STRUCT_VFSCONF */ + +/* Define to 1 if you have `struct xvfsconf'. */ +/* #undef HAVE_STRUCT_XVFSCONF */ + +/* Define to 1 if you have the `symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_ACL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_CDEFS_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_EA_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_EXTATTR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MOUNT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_RICHACL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSMACROS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UTIME_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_VFS_H 1 + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_XATTR_H 1 + +/* Define to 1 if you have the `timegm' function. */ +#define HAVE_TIMEGM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the `tzset' function. */ +#define HAVE_TZSET 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlinkat' function. */ +#define HAVE_UNLINKAT 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define to 1 if the system has the type `unsigned long long'. */ +/* #undef HAVE_UNSIGNED_LONG_LONG */ + +/* Define to 1 if the system has the type `unsigned long long int'. */ +/* #undef HAVE_UNSIGNED_LONG_LONG_INT */ + +/* Define to 1 if you have the `utime' function. */ +#define HAVE_UTIME 1 + +/* Define to 1 if you have the `utimensat' function. */ +#define HAVE_UTIMENSAT 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `vfork' function. */ +#define HAVE_VFORK 1 + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if the system has the type `wchar_t'. */ +#define HAVE_WCHAR_T 1 + +/* Define to 1 if you have the `wcrtomb' function. */ +#define HAVE_WCRTOMB 1 + +/* Define to 1 if you have the `wcscmp' function. */ +#define HAVE_WCSCMP 1 + +/* Define to 1 if you have the `wcscpy' function. */ +#define HAVE_WCSCPY 1 + +/* Define to 1 if you have the `wcslen' function. */ +#define HAVE_WCSLEN 1 + +/* Define to 1 if you have the `wctomb' function. */ +#define HAVE_WCTOMB 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_WCTYPE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINCRYPT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINDOWS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINIOCTL_H */ + +/* Define to 1 if you have _CrtSetReportMode in */ +/* #undef HAVE__CrtSetReportMode */ + +/* Define to 1 if you have the `wmemcmp' function. */ +#define HAVE_WMEMCMP 1 + +/* Define to 1 if you have the `wmemcpy' function. */ +#define HAVE_WMEMCPY 1 + +/* Define to 1 if you have the `wmemmove' function. */ +#define HAVE_WMEMMOVE 1 + +/* Define to 1 if you have a working EXT2_IOC_GETFLAGS */ +/* #undef HAVE_WORKING_EXT2_IOC_GETFLAGS */ + +/* Define to 1 if you have a working FS_IOC_GETFLAGS */ +#define HAVE_WORKING_FS_IOC_GETFLAGS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ZLIB_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ZSTD_H */ + +/* Define to 1 if you have the `ctime_s' function. */ +/* #undef HAVE_CTIME_S */ + +/* Define to 1 if you have the `_fseeki64' function. */ +/* #undef HAVE__FSEEKI64 */ + +/* Define to 1 if you have the `_get_timezone' function. */ +/* #undef HAVE__GET_TIMEZONE */ + +/* Define to 1 if you have the `gmtime_s' function. */ +/* #undef HAVE_GMTIME_S */ + +/* Define to 1 if you have the `localtime_s' function. */ +/* #undef HAVE_LOCALTIME_S */ + +/* Define to 1 if you have the `_mkgmtime' function. */ +/* #undef HAVE__MKGMTIME */ + +/* Define as const if the declaration of iconv() needs const. */ +#define ICONV_CONST + +/* Version number of libarchive as a single integer */ +#define LIBARCHIVE_VERSION_NUMBER "3007007" + +/* Version number of libarchive */ +#define LIBARCHIVE_VERSION_STRING "3.7.7" + +/* Define to 1 if `lstat' dereferences a symlink specified with a trailing + slash. */ +/* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* Define to 1 if strerror_r returns char *. */ +/* #undef STRERROR_R_CHAR_P */ + +/* Define to 1 if you can safely include both and . */ +/* #undef TIME_WITH_SYS_TIME */ + +/* + * Some platform requires a macro to use extension functions. + */ +#define SAFE_TO_DEFINE_EXTENSIONS 1 +#ifdef SAFE_TO_DEFINE_EXTENSIONS +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +#define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +#define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +#define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +#define __EXTENSIONS__ 1 +#endif +#endif /* SAFE_TO_DEFINE_EXTENSIONS */ + +/* Version number of package */ +#define VERSION "3.7.7" + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +/* #undef _LARGEFILE_SOURCE */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define to control Windows SDK version */ +#ifndef NTDDI_VERSION +/* #undef NTDDI_VERSION */ +#endif // NTDDI_VERSION + +#ifndef _WIN32_WINNT +/* #undef _WIN32_WINNT */ +#endif // _WIN32_WINNT + +#ifndef WINVER +/* #undef WINVER */ +#endif // WINVER + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `unsigned long' if does not define. */ +/* #undef id_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long long' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if doesn't define. */ +/* #undef pid_t */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef ssize_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to `int' if does not define. */ +/* #undef intptr_t */ + +/* Define to `unsigned int' if does not define. */ +/* #undef uintptr_t */ + +/* + * This header starts from the Linux CMake-generated config used by the native + * cc_library example, then overrides platform-sensitive probes for Darwin. It + * intentionally keeps ACL and xattr disabled, matching the example CMake + * configuration and keeping the native test focused on libarchive+zlib linking. + */ +#if !defined(__APPLE__) +#error libarchive_config_darwin.h is only intended for Darwin builds. +#endif + +#undef ARCHIVE_ACL_DARWIN +#undef ARCHIVE_XATTR_DARWIN + +#undef HAVE_ARC4RANDOM_BUF +#define HAVE_ARC4RANDOM_BUF 1 +#undef HAVE_CHFLAGS +#define HAVE_CHFLAGS 1 +#undef HAVE_COPYFILE_H +#define HAVE_COPYFILE_H 1 +#undef HAVE_FCHFLAGS +#define HAVE_FCHFLAGS 1 +#undef HAVE_GETVFSBYNAME +#define HAVE_GETVFSBYNAME 1 +#undef HAVE_LCHFLAGS +#define HAVE_LCHFLAGS 1 +#undef HAVE_MEMBERSHIP_H +#define HAVE_MEMBERSHIP_H 1 +#undef HAVE_READPASSPHRASE +#define HAVE_READPASSPHRASE 1 +#undef HAVE_READPASSPHRASE_H +#define HAVE_READPASSPHRASE_H 1 +#undef HAVE_FUTIMESAT +#undef HAVE_STRUCT_STATFS_F_IOSIZE +#define HAVE_STRUCT_STATFS_F_IOSIZE 1 +#undef HAVE_STRUCT_STAT_ST_BIRTHTIME +#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1 +#undef HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC +#define HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1 +#undef HAVE_STRUCT_STAT_ST_FLAGS +#define HAVE_STRUCT_STAT_ST_FLAGS 1 +#undef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC +#undef HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC +#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1 +#undef HAVE_SYS_MOUNT_H +#define HAVE_SYS_MOUNT_H 1 +#undef HAVE_SYS_STATFS_H +#undef HAVE_SYS_SYSMACROS_H +#undef HAVE_SYS_XATTR_H +#define HAVE_SYS_XATTR_H 1 +#undef MAJOR_IN_SYSMACROS + +#undef HAVE_DECL_XATTR_NOFOLLOW +#undef HAVE_EXT2FS_EXT2_FS_H +#undef HAVE_LINUX_FIEMAP_H +#undef HAVE_LINUX_FS_H +#undef HAVE_LINUX_MAGIC_H +#undef HAVE_LINUX_TYPES_H +#undef HAVE_SYS_EXTATTR_H +#undef HAVE_SYS_VFS_H +#undef HAVE_WORKING_FS_IOC_GETFLAGS diff --git a/examples/third_party/libarchive/libarchive_config_linux.h b/examples/third_party/libarchive/libarchive_config_linux.h new file mode 100644 index 000000000..c27926055 --- /dev/null +++ b/examples/third_party/libarchive/libarchive_config_linux.h @@ -0,0 +1,1407 @@ +/* config.h. Generated from libarchive 3.7.7 build/cmake/config.h.in by cmake + * configure for Linux native cc_library examples. */ +#define __LIBARCHIVE_CONFIG_H_INCLUDED 1 + +/* + * Ensure we have C99-style int64_t, etc, all defined. + */ + +/* First, we need to know if the system has already defined them. */ +#define HAVE_INT16_T +#define HAVE_INT32_T +#define HAVE_INT64_T +#define HAVE_INTMAX_T + +#define HAVE_UINT8_T +#define HAVE_UINT16_T +#define HAVE_UINT32_T +#define HAVE_UINT64_T +#define HAVE_UINTMAX_T + +/* We might have the types we want under other spellings. */ +/* #undef HAVE___INT64 */ +/* #undef HAVE_U_INT64_T */ +/* #undef HAVE_UNSIGNED___INT64 */ + +/* The sizes of various standard integer types. */ +#define SIZEOF_SHORT 2 +#define SIZEOF_INT 4 +#define SIZEOF_LONG 8 +#define SIZEOF_LONG_LONG 8 +#define SIZEOF_UNSIGNED_SHORT 2 +#define SIZEOF_UNSIGNED 4 +#define SIZEOF_UNSIGNED_LONG 8 +#define SIZEOF_UNSIGNED_LONG_LONG 8 + +/* + * If we lack int64_t, define it to the first of __int64, int, long, and long + * long that exists and is the right size. + */ +#if !defined(HAVE_INT64_T) && defined(HAVE___INT64) +typedef __int64 int64_t; +#define HAVE_INT64_T +#endif + +#if !defined(HAVE_INT64_T) && SIZEOF_INT == 8 +typedef int int64_t; +#define HAVE_INT64_T +#endif + +#if !defined(HAVE_INT64_T) && SIZEOF_LONG == 8 +typedef long int64_t; +#define HAVE_INT64_T +#endif + +#if !defined(HAVE_INT64_T) && SIZEOF_LONG_LONG == 8 +typedef long long int64_t; +#define HAVE_INT64_T +#endif + +#if !defined(HAVE_INT64_T) +#error No 64-bit integer type was found. +#endif + +/* + * Similarly for int32_t + */ +#if !defined(HAVE_INT32_T) && SIZEOF_INT == 4 +typedef int int32_t; +#define HAVE_INT32_T +#endif + +#if !defined(HAVE_INT32_T) && SIZEOF_LONG == 4 +typedef long int32_t; +#define HAVE_INT32_T +#endif + +#if !defined(HAVE_INT32_T) +#error No 32-bit integer type was found. +#endif + +/* + * Similarly for int16_t + */ +#if !defined(HAVE_INT16_T) && SIZEOF_INT == 2 +typedef int int16_t; +#define HAVE_INT16_T +#endif + +#if !defined(HAVE_INT16_T) && SIZEOF_SHORT == 2 +typedef short int16_t; +#define HAVE_INT16_T +#endif + +#if !defined(HAVE_INT16_T) +#error No 16-bit integer type was found. +#endif + +/* + * Similarly for uint64_t + */ +#if !defined(HAVE_UINT64_T) && defined(HAVE_UNSIGNED___INT64) +typedef unsigned __int64 uint64_t; +#define HAVE_UINT64_T +#endif + +#if !defined(HAVE_UINT64_T) && SIZEOF_UNSIGNED == 8 +typedef unsigned uint64_t; +#define HAVE_UINT64_T +#endif + +#if !defined(HAVE_UINT64_T) && SIZEOF_UNSIGNED_LONG == 8 +typedef unsigned long uint64_t; +#define HAVE_UINT64_T +#endif + +#if !defined(HAVE_UINT64_T) && SIZEOF_UNSIGNED_LONG_LONG == 8 +typedef unsigned long long uint64_t; +#define HAVE_UINT64_T +#endif + +#if !defined(HAVE_UINT64_T) +#error No 64-bit unsigned integer type was found. +#endif + +/* + * Similarly for uint32_t + */ +#if !defined(HAVE_UINT32_T) && SIZEOF_UNSIGNED == 4 +typedef unsigned uint32_t; +#define HAVE_UINT32_T +#endif + +#if !defined(HAVE_UINT32_T) && SIZEOF_UNSIGNED_LONG == 4 +typedef unsigned long uint32_t; +#define HAVE_UINT32_T +#endif + +#if !defined(HAVE_UINT32_T) +#error No 32-bit unsigned integer type was found. +#endif + +/* + * Similarly for uint16_t + */ +#if !defined(HAVE_UINT16_T) && SIZEOF_UNSIGNED == 2 +typedef unsigned uint16_t; +#define HAVE_UINT16_T +#endif + +#if !defined(HAVE_UINT16_T) && SIZEOF_UNSIGNED_SHORT == 2 +typedef unsigned short uint16_t; +#define HAVE_UINT16_T +#endif + +#if !defined(HAVE_UINT16_T) +#error No 16-bit unsigned integer type was found. +#endif + +/* + * Similarly for uint8_t + */ +#if !defined(HAVE_UINT8_T) +typedef unsigned char uint8_t; +#define HAVE_UINT8_T +#endif + +#if !defined(HAVE_UINT8_T) +#error No 8-bit unsigned integer type was found. +#endif + +/* Define intmax_t and uintmax_t if they are not already defined. */ +#if !defined(HAVE_INTMAX_T) +typedef int64_t intmax_t; +#endif + +#if !defined(HAVE_UINTMAX_T) +typedef uint64_t uintmax_t; +#endif + +/* Define ZLIB_WINAPI if zlib was built on Visual Studio. */ +/* #undef ZLIB_WINAPI */ + +/* Darwin ACL support */ +/* #undef ARCHIVE_ACL_DARWIN */ + +/* FreeBSD ACL support */ +/* #undef ARCHIVE_ACL_FREEBSD */ + +/* FreeBSD NFSv4 ACL support */ +/* #undef ARCHIVE_ACL_FREEBSD_NFS4 */ + +/* Linux POSIX.1e ACL support via libacl */ +/* #undef ARCHIVE_ACL_LIBACL */ + +/* Linux NFSv4 ACL support via librichacl */ +/* #undef ARCHIVE_ACL_LIBRICHACL */ + +/* Solaris ACL support */ +/* #undef ARCHIVE_ACL_SUNOS */ + +/* Solaris NFSv4 ACL support */ +/* #undef ARCHIVE_ACL_SUNOS_NFS4 */ + +/* MD5 via ARCHIVE_CRYPTO_MD5_LIBC supported. */ +/* #undef ARCHIVE_CRYPTO_MD5_LIBC */ + +/* MD5 via ARCHIVE_CRYPTO_MD5_LIBSYSTEM supported. */ +/* #undef ARCHIVE_CRYPTO_MD5_LIBSYSTEM */ + +/* MD5 via ARCHIVE_CRYPTO_MD5_MBEDTLS supported. */ +/* #undef ARCHIVE_CRYPTO_MD5_MBEDTLS */ + +/* MD5 via ARCHIVE_CRYPTO_MD5_NETTLE supported. */ +/* #undef ARCHIVE_CRYPTO_MD5_NETTLE */ + +/* MD5 via ARCHIVE_CRYPTO_MD5_OPENSSL supported. */ +/* #undef ARCHIVE_CRYPTO_MD5_OPENSSL */ + +/* MD5 via ARCHIVE_CRYPTO_MD5_WIN supported. */ +/* #undef ARCHIVE_CRYPTO_MD5_WIN */ + +/* RMD160 via ARCHIVE_CRYPTO_RMD160_LIBC supported. */ +/* #undef ARCHIVE_CRYPTO_RMD160_LIBC */ + +/* RMD160 via ARCHIVE_CRYPTO_RMD160_NETTLE supported. */ +/* #undef ARCHIVE_CRYPTO_RMD160_NETTLE */ + +/* RMD160 via ARCHIVE_CRYPTO_RMD160_MBEDTLS supported. */ +/* #undef ARCHIVE_CRYPTO_RMD160_MBEDTLS */ + +/* RMD160 via ARCHIVE_CRYPTO_RMD160_OPENSSL supported. */ +/* #undef ARCHIVE_CRYPTO_RMD160_OPENSSL */ + +/* SHA1 via ARCHIVE_CRYPTO_SHA1_LIBC supported. */ +/* #undef ARCHIVE_CRYPTO_SHA1_LIBC */ + +/* SHA1 via ARCHIVE_CRYPTO_SHA1_LIBSYSTEM supported. */ +/* #undef ARCHIVE_CRYPTO_SHA1_LIBSYSTEM */ + +/* SHA1 via ARCHIVE_CRYPTO_SHA1_MBEDTLS supported. */ +/* #undef ARCHIVE_CRYPTO_SHA1_MBEDTLS */ + +/* SHA1 via ARCHIVE_CRYPTO_SHA1_NETTLE supported. */ +/* #undef ARCHIVE_CRYPTO_SHA1_NETTLE */ + +/* SHA1 via ARCHIVE_CRYPTO_SHA1_OPENSSL supported. */ +/* #undef ARCHIVE_CRYPTO_SHA1_OPENSSL */ + +/* SHA1 via ARCHIVE_CRYPTO_SHA1_WIN supported. */ +/* #undef ARCHIVE_CRYPTO_SHA1_WIN */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBC supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_LIBC */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBC2 supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_LIBC2 */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBC3 supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_LIBC3 */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_LIBSYSTEM supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_LIBSYSTEM */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_MBEDTLS supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_MBEDTLS */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_NETTLE supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_NETTLE */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_OPENSSL supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_OPENSSL */ + +/* SHA256 via ARCHIVE_CRYPTO_SHA256_WIN supported. */ +/* #undef ARCHIVE_CRYPTO_SHA256_WIN */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBC supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_LIBC */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBC2 supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_LIBC2 */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBC3 supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_LIBC3 */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_LIBSYSTEM supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_LIBSYSTEM */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_MBEDTLS supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_MBEDTLS */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_NETTLE supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_NETTLE */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_OPENSSL supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_OPENSSL */ + +/* SHA384 via ARCHIVE_CRYPTO_SHA384_WIN supported. */ +/* #undef ARCHIVE_CRYPTO_SHA384_WIN */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBC supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_LIBC */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBC2 supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_LIBC2 */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBC3 supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_LIBC3 */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_LIBSYSTEM supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_LIBSYSTEM */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_MBEDTLS supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_MBEDTLS */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_NETTLE supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_NETTLE */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_OPENSSL supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_OPENSSL */ + +/* SHA512 via ARCHIVE_CRYPTO_SHA512_WIN supported. */ +/* #undef ARCHIVE_CRYPTO_SHA512_WIN */ + +/* AIX xattr support */ +/* #undef ARCHIVE_XATTR_AIX */ + +/* Darwin xattr support */ +/* #undef ARCHIVE_XATTR_DARWIN */ + +/* FreeBSD xattr support */ +/* #undef ARCHIVE_XATTR_FREEBSD */ + +/* Linux xattr support */ +/* #undef ARCHIVE_XATTR_LINUX */ + +/* Version number of bsdcpio */ +#define BSDCPIO_VERSION_STRING "3.7.7" + +/* Version number of bsdtar */ +#define BSDTAR_VERSION_STRING "3.7.7" + +/* Version number of bsdcat */ +#define BSDCAT_VERSION_STRING "3.7.7" + +/* Version number of bsdunzip */ +#define BSDUNZIP_VERSION_STRING "3.7.7" + +/* Define to 1 if you have the `acl_create_entry' function. */ +/* #undef HAVE_ACL_CREATE_ENTRY */ + +/* Define to 1 if you have the `acl_get_fd_np' function. */ +/* #undef HAVE_ACL_GET_FD_NP */ + +/* Define to 1 if you have the `acl_get_link' function. */ +/* #undef HAVE_ACL_GET_LINK */ + +/* Define to 1 if you have the `acl_get_link_np' function. */ +/* #undef HAVE_ACL_GET_LINK_NP */ + +/* Define to 1 if you have the `acl_get_perm' function. */ +/* #undef HAVE_ACL_GET_PERM */ + +/* Define to 1 if you have the `acl_get_perm_np' function. */ +/* #undef HAVE_ACL_GET_PERM_NP */ + +/* Define to 1 if you have the `acl_init' function. */ +/* #undef HAVE_ACL_INIT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ACL_LIBACL_H */ + +/* Define to 1 if the system has the type `acl_permset_t'. */ +/* #undef HAVE_ACL_PERMSET_T */ + +/* Define to 1 if you have the `acl_set_fd' function. */ +/* #undef HAVE_ACL_SET_FD */ + +/* Define to 1 if you have the `acl_set_fd_np' function. */ +/* #undef HAVE_ACL_SET_FD_NP */ + +/* Define to 1 if you have the `acl_set_file' function. */ +/* #undef HAVE_ACL_SET_FILE */ + +/* Define to 1 if you have the `arc4random_buf' function. */ +/* #undef HAVE_ARC4RANDOM_BUF */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ATTR_XATTR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BCRYPT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BSDXML_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BZLIB_H */ + +/* Define to 1 if you have the `chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define to 1 if you have the `chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_COPYFILE_H */ + +/* Define to 1 if you have the `ctime_r' function. */ +#define HAVE_CTIME_R 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_CTYPE_H 1 + +/* Define to 1 if you have the `cygwin_conv_path' function. */ +/* #undef HAVE_CYGWIN_CONV_PATH */ + +/* Define to 1 if you have the declaration of `ACE_GETACL', and to 0 if you + don't. */ +/* #undef HAVE_DECL_ACE_GETACL */ + +/* Define to 1 if you have the declaration of `ACE_GETACLCNT', and to 0 if you + don't. */ +/* #undef HAVE_DECL_ACE_GETACLCNT */ + +/* Define to 1 if you have the declaration of `ACE_SETACL', and to 0 if you + don't. */ +/* #undef HAVE_DECL_ACE_SETACL */ + +/* Define to 1 if you have the declaration of `ACL_SYNCHRONIZE', and to 0 if + you don't. */ +/* #undef HAVE_DECL_ACL_SYNCHRONIZE */ + +/* Define to 1 if you have the declaration of `ACL_TYPE_EXTENDED', and to 0 if + you don't. */ +/* #undef HAVE_DECL_ACL_TYPE_EXTENDED */ + +/* Define to 1 if you have the declaration of `ACL_TYPE_NFS4', and to 0 if you + don't. */ +/* #undef HAVE_DECL_ACL_TYPE_NFS4 */ + +/* Define to 1 if you have the declaration of `ACL_USER', and to 0 if you + don't. */ +/* #undef HAVE_DECL_ACL_USER */ + +/* Define to 1 if you have the declaration of `INT32_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_INT32_MAX 1 + +/* Define to 1 if you have the declaration of `INT32_MIN', and to 0 if you + don't. */ +#define HAVE_DECL_INT32_MIN 1 + +/* Define to 1 if you have the declaration of `INT64_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_INT64_MAX 1 + +/* Define to 1 if you have the declaration of `INT64_MIN', and to 0 if you + don't. */ +#define HAVE_DECL_INT64_MIN 1 + +/* Define to 1 if you have the declaration of `INTMAX_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_INTMAX_MAX 1 + +/* Define to 1 if you have the declaration of `INTMAX_MIN', and to 0 if you + don't. */ +#define HAVE_DECL_INTMAX_MIN 1 + +/* Define to 1 if you have the declaration of `SETACL', and to 0 if you don't. + */ +/* #undef HAVE_DECL_SETACL */ + +/* Define to 1 if you have the declaration of `SIZE_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_SIZE_MAX 1 + +/* Define to 1 if you have the declaration of `SSIZE_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_SSIZE_MAX 1 + +/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you + don't. */ +#define HAVE_DECL_STRERROR_R 1 + +/* Define to 1 if you have the declaration of `UINT32_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_UINT32_MAX 1 + +/* Define to 1 if you have the declaration of `UINT64_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_UINT64_MAX 1 + +/* Define to 1 if you have the declaration of `UINTMAX_MAX', and to 0 if you + don't. */ +#define HAVE_DECL_UINTMAX_MAX 1 + +/* Define to 1 if you have the declaration of `XATTR_NOFOLLOW', and to 0 if + you don't. */ +/* #undef HAVE_DECL_XATTR_NOFOLLOW */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the `dirfd' function. */ +#define HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +/* #undef HAVE_DOPRNT */ + +/* Define to 1 if nl_langinfo supports D_MD_ORDER */ +/* #undef HAVE_D_MD_ORDER */ + +/* A possible errno value for invalid file format errors */ +/* #undef HAVE_EFTYPE */ + +/* A possible errno value for invalid file format errors */ +#define HAVE_EILSEQ 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_EXPAT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_EXT2FS_EXT2_FS_H */ + +/* Define to 1 if you have the `extattr_get_file' function. */ +/* #undef HAVE_EXTATTR_GET_FILE */ + +/* Define to 1 if you have the `extattr_list_file' function. */ +/* #undef HAVE_EXTATTR_LIST_FILE */ + +/* Define to 1 if you have the `extattr_set_fd' function. */ +/* #undef HAVE_EXTATTR_SET_FD */ + +/* Define to 1 if you have the `extattr_set_file' function. */ +/* #undef HAVE_EXTATTR_SET_FILE */ + +/* Define to 1 if EXTATTR_NAMESPACE_USER is defined in sys/extattr.h. */ +/* #undef HAVE_DECL_EXTATTR_NAMESPACE_USER */ + +/* Define to 1 if you have the declaration of `GETACL', and to 0 if you don't. + */ +/* #undef HAVE_DECL_GETACL */ + +/* Define to 1 if you have the declaration of `GETACLCNT', and to 0 if you + don't. */ +/* #undef HAVE_DECL_GETACLCNT */ + +/* Define to 1 if you have the `fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchflags' function. */ +/* #undef HAVE_FCHFLAGS */ + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the `fcntl' function. */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `fdopendir' function. */ +#define HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the `fgetea' function. */ +/* #undef HAVE_FGETEA */ + +/* Define to 1 if you have the `fgetxattr' function. */ +/* #undef HAVE_FGETXATTR */ + +/* Define to 1 if you have the `flistea' function. */ +/* #undef HAVE_FLISTEA */ + +/* Define to 1 if you have the `flistxattr' function. */ +/* #undef HAVE_FLISTXATTR */ + +/* Define to 1 if you have the `fnmatch' function. */ +#define HAVE_FNMATCH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FNMATCH_H 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fsetea' function. */ +/* #undef HAVE_FSETEA */ + +/* Define to 1 if you have the `fsetxattr' function. */ +/* #undef HAVE_FSETXATTR */ + +/* Define to 1 if you have the `fstat' function. */ +#define HAVE_FSTAT 1 + +/* Define to 1 if you have the `fstatat' function. */ +#define HAVE_FSTATAT 1 + +/* Define to 1 if you have the `fstatfs' function. */ +#define HAVE_FSTATFS 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +#define HAVE_FSTATVFS 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `futimens' function. */ +#define HAVE_FUTIMENS 1 + +/* Define to 1 if you have the `futimes' function. */ +#define HAVE_FUTIMES 1 + +/* Define to 1 if you have the `futimesat' function. */ +#define HAVE_FUTIMESAT 1 + +/* Define to 1 if you have the `getea' function. */ +/* #undef HAVE_GETEA */ + +/* Define to 1 if you have the `geteuid' function. */ +#define HAVE_GETEUID 1 + +/* Define to 1 if you have the `getgrgid_r' function. */ +#define HAVE_GETGRGID_R 1 + +/* Define to 1 if you have the `getgrnam_r' function. */ +#define HAVE_GETGRNAM_R 1 + +/* Define to 1 if you have the `getline' function. */ +#define HAVE_GETLINE 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpwnam_r' function. */ +#define HAVE_GETPWNAM_R 1 + +/* Define to 1 if you have the `getpwuid_r' function. */ +#define HAVE_GETPWUID_R 1 + +/* Define to 1 if you have the `getvfsbyname' function. */ +/* #undef HAVE_GETVFSBYNAME */ + +/* Define to 1 if you have the `getxattr' function. */ +/* #undef HAVE_GETXATTR */ + +/* Define to 1 if you have the `gmtime_r' function. */ +#define HAVE_GMTIME_R 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define to 1 if you have the `iconv' function. */ +/* #undef HAVE_ICONV */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ICONV_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Define to 1 if you have the `lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +#define HAVE_LCHMOD 1 + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgetea' function. */ +/* #undef HAVE_LGETEA */ + +/* Define to 1 if you have the `lgetxattr' function. */ +/* #undef HAVE_LGETXATTR */ + +/* Define to 1 if you have the `acl' library (-lacl). */ +/* #undef HAVE_LIBACL */ + +/* Define to 1 if you have the `attr' library (-lattr). */ +/* #undef HAVE_LIBATTR */ + +/* Define to 1 if you have the `bsdxml' library (-lbsdxml). */ +/* #undef HAVE_LIBBSDXML */ + +/* Define to 1 if you have the `bz2' library (-lbz2). */ +/* #undef HAVE_LIBBZ2 */ + +/* Define to 1 if you have the `b2' library (-lb2). */ +/* #undef HAVE_LIBB2 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLAKE2_H */ + +/* Define to 1 if you have the `charset' library (-lcharset). */ +/* #undef HAVE_LIBCHARSET */ + +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +/* #undef HAVE_LIBCRYPTO */ + +/* Define to 1 if you have the `expat' library (-lexpat). */ +/* #undef HAVE_LIBEXPAT */ + +/* Define to 1 if you have the `gcc' library (-lgcc). */ +/* #undef HAVE_LIBGCC */ + +/* Define to 1 if you have the `lz4' library (-llz4). */ +/* #undef HAVE_LIBLZ4 */ + +/* Define to 1 if you have the `lzma' library (-llzma). */ +/* #undef HAVE_LIBLZMA */ + +/* Define to 1 if you have the `lzmadec' library (-llzmadec). */ +/* #undef HAVE_LIBLZMADEC */ + +/* Define to 1 if you have the `lzo2' library (-llzo2). */ +/* #undef HAVE_LIBLZO2 */ + +/* Define to 1 if you have the `mbedcrypto' library (-lmbedcrypto). */ +/* #undef HAVE_LIBMBEDCRYPTO */ + +/* Define to 1 if you have the `nettle' library (-lnettle). */ +/* #undef HAVE_LIBNETTLE */ + +/* Define to 1 if you have the `pcre' library (-lpcre). */ +/* #undef HAVE_LIBPCRE */ + +/* Define to 1 if you have the `pcreposix' library (-lpcreposix). */ +/* #undef HAVE_LIBPCREPOSIX */ + +/* Define to 1 if you have the `pcre2-8' library (-lpcre2-8). */ +/* #undef HAVE_LIBPCRE2 */ + +/* Define to 1 if you have the `pcreposix' library (-lpcre2posix). */ +/* #undef HAVE_LIBPCRE2POSIX */ + +/* Define to 1 if you have the `xml2' library (-lxml2). */ +/* #undef HAVE_LIBXML2 */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBXML_XMLREADER_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBXML_XMLWRITER_H */ + +/* Define to 1 if you have the `z' library (-lz). */ +#define HAVE_LIBZ 1 + +/* Define to 1 if you have the `zstd' library (-lzstd). */ +/* #undef HAVE_LIBZSTD */ + +/* Define to 1 if you have the ZSTD_compressStream function. */ +/* #undef HAVE_ZSTD_compressStream */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the `link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the `linkat' function. */ +#define HAVE_LINKAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_FIEMAP_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_FS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_MAGIC_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_TYPES_H 1 + +/* Define to 1 if you have the `listea' function. */ +/* #undef HAVE_LISTEA */ + +/* Define to 1 if you have the `listxattr' function. */ +/* #undef HAVE_LISTXATTR */ + +/* Define to 1 if you have the `llistea' function. */ +/* #undef HAVE_LLISTEA */ + +/* Define to 1 if you have the `llistxattr' function. */ +/* #undef HAVE_LLISTXATTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LOCALCHARSET_H */ + +/* Define to 1 if you have the `locale_charset' function. */ +/* #undef HAVE_LOCALE_CHARSET */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the `localtime_r' function. */ +#define HAVE_LOCALTIME_R 1 + +/* Define to 1 if the system has the type `long long int'. */ +/* #undef HAVE_LONG_LONG_INT */ + +/* Define to 1 if you have the `lsetea' function. */ +/* #undef HAVE_LSETEA */ + +/* Define to 1 if you have the `lsetxattr' function. */ +/* #undef HAVE_LSETXATTR */ + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define to 1 if `lstat' has the bug that it succeeds when given the + zero-length file name argument. */ +/* #undef HAVE_LSTAT_EMPTY_STRING_BUG */ + +/* Define to 1 if you have the `lutimes' function. */ +#define HAVE_LUTIMES 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZ4HC_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZ4_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZMADEC_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZMA_H */ + +/* Define to 1 if you have a working `lzma_stream_encoder_mt' function. */ +/* #undef HAVE_LZMA_STREAM_ENCODER_MT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZO_LZO1X_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LZO_LZOCONF_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MBEDTLS_AES_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MBEDTLS_MD_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MBEDTLS_PKCS5_H */ + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_MEMBERSHIP_H */ + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkdir' function. */ +#define HAVE_MKDIR 1 + +/* Define to 1 if you have the `mkfifo' function. */ +#define HAVE_MKFIFO 1 + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_AES_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_HMAC_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_MD5_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_PBKDF2_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_RIPEMD160_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETTLE_SHA_H */ + +/* Define to 1 if you have the `nl_langinfo' function. */ +#define HAVE_NL_LANGINFO 1 + +/* Define to 1 if you have the `openat' function. */ +#define HAVE_OPENAT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENSSL_EVP_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PATHS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PCREPOSIX_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PCRE2POSIX_H */ + +/* Define to 1 if you have the `pipe' function. */ +#define HAVE_PIPE 1 + +/* Define to 1 if you have the `PKCS5_PBKDF2_HMAC_SHA1' function. */ +/* #undef HAVE_PKCS5_PBKDF2_HMAC_SHA1 */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_spawnp' function. */ +#define HAVE_POSIX_SPAWNP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the `readdir_r' function. */ +#define HAVE_READDIR_R 1 + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. */ +#define HAVE_READLINKAT 1 + +/* Define to 1 if you have the `readpassphrase' function. */ +/* #undef HAVE_READPASSPHRASE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_READPASSPHRASE_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_REGEX_H 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `setenv' function. */ +#define HAVE_SETENV 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SPAWN_H 1 + +/* Define to 1 if you have the `statfs' function. */ +#define HAVE_STATFS 1 + +/* Define to 1 if you have the `statvfs' function. */ +#define HAVE_STATVFS 1 + +/* Define to 1 if `stat' has the bug that it succeeds when given the + zero-length file name argument. */ +/* #undef HAVE_STAT_EMPTY_STRING_BUG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDARG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strnlen' function. */ +#define HAVE_STRNLEN 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strerror_r' function. */ +#define HAVE_STRERROR_R 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strrchr' function. */ +#define HAVE_STRRCHR 1 + +/* Define to 1 if the system has the type `struct statfs'. */ +/* #undef HAVE_STRUCT_STATFS */ + +/* Define to 1 if `f_iosize' is a member of `struct statfs'. */ +/* #undef HAVE_STRUCT_STATFS_F_IOSIZE */ + +/* Define to 1 if `f_namemax' is a member of `struct statfs'. */ +/* #undef HAVE_STRUCT_STATFS_F_NAMEMAX */ + +/* Define to 1 if `f_iosize' is a member of `struct statvfs'. */ +/* #undef HAVE_STRUCT_STATVFS_F_IOSIZE */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_birthtimespec.tv_nsec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_mtimespec.tv_nsec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC */ + +/* Define to 1 if `st_mtime_n' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_MTIME_N */ + +/* Define to 1 if `st_mtime_usec' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_MTIME_USEC */ + +/* Define to 1 if `st_mtim.tv_nsec' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1 + +/* Define to 1 if `st_umtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_UMTIME */ + +/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_GMTOFF 1 + +/* Define to 1 if `__tm_gmtoff' is a member of `struct tm'. */ +/* #undef HAVE_STRUCT_TM___TM_GMTOFF */ + +/* Define to 1 if you have `struct vfsconf'. */ +/* #undef HAVE_STRUCT_VFSCONF */ + +/* Define to 1 if you have `struct xvfsconf'. */ +/* #undef HAVE_STRUCT_XVFSCONF */ + +/* Define to 1 if you have the `symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_ACL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_CDEFS_H 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_EA_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_EXTATTR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MOUNT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_RICHACL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSMACROS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_UTIME_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_VFS_H 1 + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_XATTR_H 1 + +/* Define to 1 if you have the `timegm' function. */ +#define HAVE_TIMEGM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the `tzset' function. */ +#define HAVE_TZSET 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlinkat' function. */ +#define HAVE_UNLINKAT 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define to 1 if the system has the type `unsigned long long'. */ +/* #undef HAVE_UNSIGNED_LONG_LONG */ + +/* Define to 1 if the system has the type `unsigned long long int'. */ +/* #undef HAVE_UNSIGNED_LONG_LONG_INT */ + +/* Define to 1 if you have the `utime' function. */ +#define HAVE_UTIME 1 + +/* Define to 1 if you have the `utimensat' function. */ +#define HAVE_UTIMENSAT 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `vfork' function. */ +#define HAVE_VFORK 1 + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if the system has the type `wchar_t'. */ +#define HAVE_WCHAR_T 1 + +/* Define to 1 if you have the `wcrtomb' function. */ +#define HAVE_WCRTOMB 1 + +/* Define to 1 if you have the `wcscmp' function. */ +#define HAVE_WCSCMP 1 + +/* Define to 1 if you have the `wcscpy' function. */ +#define HAVE_WCSCPY 1 + +/* Define to 1 if you have the `wcslen' function. */ +#define HAVE_WCSLEN 1 + +/* Define to 1 if you have the `wctomb' function. */ +#define HAVE_WCTOMB 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_WCTYPE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINCRYPT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINDOWS_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_WINIOCTL_H */ + +/* Define to 1 if you have _CrtSetReportMode in */ +/* #undef HAVE__CrtSetReportMode */ + +/* Define to 1 if you have the `wmemcmp' function. */ +#define HAVE_WMEMCMP 1 + +/* Define to 1 if you have the `wmemcpy' function. */ +#define HAVE_WMEMCPY 1 + +/* Define to 1 if you have the `wmemmove' function. */ +#define HAVE_WMEMMOVE 1 + +/* Define to 1 if you have a working EXT2_IOC_GETFLAGS */ +/* #undef HAVE_WORKING_EXT2_IOC_GETFLAGS */ + +/* Define to 1 if you have a working FS_IOC_GETFLAGS */ +#define HAVE_WORKING_FS_IOC_GETFLAGS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ZLIB_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ZSTD_H */ + +/* Define to 1 if you have the `ctime_s' function. */ +/* #undef HAVE_CTIME_S */ + +/* Define to 1 if you have the `_fseeki64' function. */ +/* #undef HAVE__FSEEKI64 */ + +/* Define to 1 if you have the `_get_timezone' function. */ +/* #undef HAVE__GET_TIMEZONE */ + +/* Define to 1 if you have the `gmtime_s' function. */ +/* #undef HAVE_GMTIME_S */ + +/* Define to 1 if you have the `localtime_s' function. */ +/* #undef HAVE_LOCALTIME_S */ + +/* Define to 1 if you have the `_mkgmtime' function. */ +/* #undef HAVE__MKGMTIME */ + +/* Define as const if the declaration of iconv() needs const. */ +#define ICONV_CONST + +/* Version number of libarchive as a single integer */ +#define LIBARCHIVE_VERSION_NUMBER "3007007" + +/* Version number of libarchive */ +#define LIBARCHIVE_VERSION_STRING "3.7.7" + +/* Define to 1 if `lstat' dereferences a symlink specified with a trailing + slash. */ +/* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* Define to 1 if strerror_r returns char *. */ +/* #undef STRERROR_R_CHAR_P */ + +/* Define to 1 if you can safely include both and . */ +/* #undef TIME_WITH_SYS_TIME */ + +/* + * Some platform requires a macro to use extension functions. + */ +#define SAFE_TO_DEFINE_EXTENSIONS 1 +#ifdef SAFE_TO_DEFINE_EXTENSIONS +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +#define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +#define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +#define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +#define __EXTENSIONS__ 1 +#endif +#endif /* SAFE_TO_DEFINE_EXTENSIONS */ + +/* Version number of package */ +#define VERSION "3.7.7" + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +/* #undef _LARGEFILE_SOURCE */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define to control Windows SDK version */ +#ifndef NTDDI_VERSION +/* #undef NTDDI_VERSION */ +#endif // NTDDI_VERSION + +#ifndef _WIN32_WINNT +/* #undef _WIN32_WINNT */ +#endif // _WIN32_WINNT + +#ifndef WINVER +/* #undef WINVER */ +#endif // WINVER + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `unsigned long' if does not define. */ +/* #undef id_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long long' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if doesn't define. */ +/* #undef pid_t */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef ssize_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to `int' if does not define. */ +/* #undef intptr_t */ + +/* Define to `unsigned int' if does not define. */ +/* #undef uintptr_t */ diff --git a/examples/third_party/libarchive/libarchive_config_windows.h b/examples/third_party/libarchive/libarchive_config_windows.h new file mode 100644 index 000000000..cb3bdd882 --- /dev/null +++ b/examples/third_party/libarchive/libarchive_config_windows.h @@ -0,0 +1,123 @@ +/* config.h for Windows native cc_library examples. */ +#define __LIBARCHIVE_CONFIG_H_INCLUDED 1 + +#define HAVE_INT16_T 1 +#define HAVE_INT32_T 1 +#define HAVE_INT64_T 1 +#define HAVE_INTMAX_T 1 +#define HAVE_UINT8_T 1 +#define HAVE_UINT16_T 1 +#define HAVE_UINT32_T 1 +#define HAVE_UINT64_T 1 +#define HAVE_UINTMAX_T 1 + +#define SIZEOF_SHORT 2 +#define SIZEOF_INT 4 +#define SIZEOF_LONG 4 +#define SIZEOF_LONG_LONG 8 +#define SIZEOF_UNSIGNED_SHORT 2 +#define SIZEOF_UNSIGNED 4 +#define SIZEOF_UNSIGNED_LONG 4 +#define SIZEOF_UNSIGNED_LONG_LONG 8 + +#define HAVE_BCRYPT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_DIRECT_H 1 +#define HAVE_ERRNO_H 1 +#define HAVE_FCNTL_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_IO_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_PROCESS_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRING_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_TIME_H 1 +#define HAVE_WCHAR_H 1 +#define HAVE_WINCRYPT_H 1 +#define HAVE_WINDOWS_H 1 +#define HAVE_ZLIB_H 1 + +#define HAVE_BCRYPT 1 +#define HAVE_LIBZ 1 + +#define HAVE_CHMOD 1 +#define HAVE_DECL_EXTATTR_NAMESPACE_USER 0 +#define HAVE_DECL_INT64_MAX 1 +#define HAVE_DECL_INT64_MIN 1 +#define HAVE_DECL_SIZE_MAX 1 +#define HAVE_DECL_SSIZE_MAX 0 +#define HAVE_DECL_STRERROR_R 0 +#define HAVE_DECL_UINT32_MAX 1 +#define HAVE_DECL_UINT64_MAX 1 +#define HAVE_DECL_UINTMAX_MAX 1 +#define HAVE_DECL_XATTR_NOFOLLOW 0 +#define HAVE_FSTAT 1 +#define HAVE_FTRUNCATE 1 +#define HAVE_GETPID 1 +#define HAVE_LOCALTIME_S 1 +#define HAVE_LSTAT 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMSET 1 +#define HAVE_MKDIR 1 +#define HAVE_READ 1 +#define HAVE_SELECT 1 +#define HAVE_STAT 1 +#define HAVE_STRCHR 1 +#define HAVE_STRDUP 1 +#define HAVE_STRERROR 1 +#define HAVE_STRRCHR 1 +#define HAVE_TIME 1 +#define HAVE_UMASK 1 +#define HAVE_WCSCPY 1 +#define HAVE_WCSLEN 1 +#define HAVE_WMEMCMP 1 +#define HAVE_WMEMCPY 1 +#define HAVE_WRITE 1 +#define HAVE__GET_TIMEZONE 1 + +#define HAVE_STRUCT_STAT_ST_MTIME 1 +#define HAVE_STRUCT_STAT_ST_SIZE 1 + +#define ICONV_CONST + +#ifndef _SSIZE_T_DEFINED +typedef __int64 ssize_t; +#define _SSIZE_T_DEFINED +#endif + +#ifndef _PID_T_ +typedef int pid_t; +#define _PID_T_ +#endif + +#ifndef _MODE_T_DEFINED +typedef int mode_t; +#define _MODE_T_DEFINED +#endif + +#ifndef _UID_T_DEFINED +typedef int uid_t; +#define _UID_T_DEFINED +#endif + +#ifndef _GID_T_DEFINED +typedef int gid_t; +#define _GID_T_DEFINED +#endif + +#ifndef _ID_T_DEFINED +typedef int id_t; +#define _ID_T_DEFINED +#endif + +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0601 +#endif + +#ifndef _WIN32 +#error libarchive_config_windows.h is only intended for Windows builds. +#endif diff --git a/examples/third_party/libarchive/libarchive_repositories.bzl b/examples/third_party/libarchive/libarchive_repositories.bzl new file mode 100644 index 000000000..a3d530aa2 --- /dev/null +++ b/examples/third_party/libarchive/libarchive_repositories.bzl @@ -0,0 +1,16 @@ +"""A module defining the third party dependency libarchive.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +def libarchive_repositories(): + maybe( + http_archive, + name = "examples_libarchive", + build_file = Label("//libarchive:BUILD.libarchive.bazel"), + sha256 = "879acd83c3399c7caaee73fe5f7418e06087ab2aaf40af3e99b9e29beb29faee", + strip_prefix = "libarchive-3.7.7", + urls = [ + "https://github.com/libarchive/libarchive/releases/download/v3.7.7/libarchive-3.7.7.tar.xz", + ], + ) diff --git a/examples/third_party/repositories.bzl b/examples/third_party/repositories.bzl index 82ced0bd8..fa4da3df0 100644 --- a/examples/third_party/repositories.bzl +++ b/examples/third_party/repositories.bzl @@ -10,6 +10,7 @@ load("//glib:glib_repositories.bzl", "glib_repositories") load("//gn:gn_repositories.bzl", "gn_repositories") load("//gperftools:gperftools_repositories.bzl", "gperftools_repositories") load("//iconv:iconv_repositories.bzl", "iconv_repositories") +load("//libarchive:libarchive_repositories.bzl", "libarchive_repositories") load("//libgit2:libgit2_repositories.bzl", "libgit2_repositories") load("//libjpeg_turbo:libjpeg_turbo_repositories.bzl", "libjpeg_turbo_repositories") load("//libpng:libpng_repositories.bzl", "libpng_repositories") @@ -36,6 +37,7 @@ def repositories(): gn_repositories() gperftools_repositories() iconv_repositories() + libarchive_repositories() libgit2_repositories() libjpeg_turbo_repositories() libpng_repositories() diff --git a/examples/third_party/zlib/BUILD.zlib.bazel b/examples/third_party/zlib/BUILD.zlib.bazel index cefa6e58b..494bf6c26 100644 --- a/examples/third_party/zlib/BUILD.zlib.bazel +++ b/examples/third_party/zlib/BUILD.zlib.bazel @@ -1,4 +1,4 @@ -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_shared_library") +load("@rules_cc//cc:defs.bzl", "cc_import", "cc_library", "cc_shared_library") load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") package(default_visibility = ["//visibility:public"]) @@ -11,8 +11,50 @@ filegroup( ), ) +ZLIB_PUBLIC_HDRS = [ + "zconf.h", + "zlib.h", +] + +ZLIB_PRIVATE_HDRS = [ + "crc32.h", + "deflate.h", + "gzguts.h", + "inffast.h", + "inffixed.h", + "inflate.h", + "inftrees.h", + "trees.h", + "zutil.h", +] + +ZLIB_SRCS = [ + "adler32.c", + "compress.c", + "crc32.c", + "deflate.c", + "gzclose.c", + "gzlib.c", + "gzread.c", + "gzwrite.c", + "infback.c", + "inffast.c", + "inflate.c", + "inftrees.c", + "trees.c", + "uncompr.c", + "zutil.c", +] + +cc_library( + name = "zlib_headers", + hdrs = ZLIB_PUBLIC_HDRS, + includes = ["."], + linkstatic = True, +) + cmake( - name = "zlib", + name = "zlib_foreign_static", cache_entries = select({ "@platforms//os:linux": { "CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC", @@ -31,37 +73,64 @@ cmake( }), ) +alias( + name = "zlib", + actual = ":zlib_foreign_static", +) + +cmake( + name = "zlib_foreign_shared", + cache_entries = select({ + "@platforms//os:linux": { + "BUILD_SHARED_LIBS": "ON", + "CMAKE_C_FLAGS": "$${CMAKE_C_FLAGS:-} -fPIC", + }, + "//conditions:default": { + "BUILD_SHARED_LIBS": "ON", + }, + }), + defines = select({ + "@platforms//os:windows": ["ZLIB_DLL"], + "//conditions:default": [], + }), + generate_args = select({ + "@platforms//os:windows": ["-GNinja"], + "//conditions:default": [], + }), + lib_source = ":all_srcs", + out_include_dir = "include", + out_interface_libs = select({ + "@platforms//os:windows": ["zlib1.lib"], + "//conditions:default": [], + }), + out_shared_libs = select({ + "@platforms//os:macos": [ + "libz.dylib", + "libz.1.dylib", + "libz.1.3.1.dylib", + ], + "@platforms//os:windows": ["zlib1.dll"], + "//conditions:default": [ + "libz.so", + "libz.so.1", + "libz.so.1.3.1", + ], + }), + postfix_script = select({ + # rfcc pairs DLLs and import libs by basename when it builds CcInfo. + # zlib installs zlib1.dll with zdll.lib, so add the Windows alias that + # Bazel consumers expect. + "@platforms//os:windows": "cp -p $$INSTALLDIR/lib/zdll.lib $$INSTALLDIR/lib/zlib1.lib", + "//conditions:default": "", + }), + runtime_library_search_directories = "enabled", + runtime_library_search_mode = "shared", +) + cc_library( - name = "zlib_static", - srcs = [ - "adler32.c", - "compress.c", - "crc32.c", - "deflate.c", - "gzclose.c", - "gzlib.c", - "gzread.c", - "gzwrite.c", - "infback.c", - "inffast.c", - "inflate.c", - "inftrees.c", - "trees.c", - "uncompr.c", - "zutil.c", - ], - hdrs = [ - "crc32.h", - "deflate.h", - "gzguts.h", - "inffast.h", - "inffixed.h", - "inflate.h", - "inftrees.h", - "trees.h", - "zlib.h", - "zutil.h", - ], + name = "z", + srcs = ZLIB_SRCS + ZLIB_PRIVATE_HDRS, + hdrs = ZLIB_PUBLIC_HDRS, copts = select({ "@platforms//os:windows": [], "//conditions:default": [ @@ -72,11 +141,102 @@ cc_library( }), includes = ["."], linkstatic = True, - deps = [":zlib"], + visibility = ["//visibility:private"], +) + +cc_library( + name = "zlib_static", + deps = [":z"], +) + +cc_library( + name = "zlib_dynamic_headers", + hdrs = ZLIB_PUBLIC_HDRS, + defines = select({ + "@platforms//os:windows": ["ZLIB_DLL"], + "//conditions:default": [], + }), + includes = ["."], + linkstatic = True, +) + +cc_library( + name = "zlib_shared_impl", + srcs = ZLIB_SRCS + ZLIB_PRIVATE_HDRS, + hdrs = ZLIB_PUBLIC_HDRS, + copts = select({ + "@platforms//os:windows": [], + "//conditions:default": [ + "-Wno-deprecated-non-prototype", + "-Wno-unused-variable", + "-Wno-implicit-function-declaration", + ], + }), + local_defines = select({ + "@platforms//os:windows": [ + "ZLIB_DLL", + "ZLIB_INTERNAL", + ], + "//conditions:default": [], + }), + target_compatible_with = select({ + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), + deps = [":zlib_dynamic_headers"], ) cc_shared_library( name = "zlib_shared", - shared_lib_name = "libz.so", - deps = ["zlib_static"], + features = select({ + "@platforms//os:macos": ["set_install_name"], + "@platforms//os:windows": [], + "//conditions:default": ["set_soname"], + }), + shared_lib_name = select({ + "@platforms//os:macos": "libz.dylib", + "@platforms//os:windows": "zlib1.dll", + "//conditions:default": "libz.so", + }), + deps = select({ + "@platforms//os:windows": [":zlib_shared_impl"], + "//conditions:default": [":zlib_static"], + }), +) + +filegroup( + name = "zlib_shared_interface_library", + srcs = [":zlib_shared"], + output_group = "interface_library", + target_compatible_with = select({ + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) + +cc_import( + name = "zlib_shared_import", + interface_library = ":zlib_shared_interface_library", + shared_library = ":zlib_shared", + target_compatible_with = select({ + "@platforms//os:windows": [], + "//conditions:default": ["@platforms//:incompatible"], + }), +) + +cc_library( + name = "zlib_dynamic", + srcs = select({ + "@platforms//os:windows": [], + "//conditions:default": [":zlib_shared"], + }), + deps = [":zlib_dynamic_headers"] + select({ + "@platforms//os:windows": [":zlib_shared_import"], + "//conditions:default": [], + }), +) + +alias( + name = "zlib_shared_provider_parity", + actual = ":zlib_dynamic", ) diff --git a/foreign_cc/BUILD.bazel b/foreign_cc/BUILD.bazel index 07d10a81e..e9e3bdc99 100644 --- a/foreign_cc/BUILD.bazel +++ b/foreign_cc/BUILD.bazel @@ -12,6 +12,7 @@ bzl_library( deps = [ "//foreign_cc/private:detect_root", "//foreign_cc/private:framework", + "//foreign_cc/private:runtime_library_search_directories", ], ) @@ -42,6 +43,7 @@ bzl_library( "//foreign_cc/private:configure_script", "//foreign_cc/private:detect_root", "//foreign_cc/private:framework", + "//foreign_cc/private:runtime_library_search_directories", "//foreign_cc/private:transitions", "//toolchains/native_tools:tool_access", "@rules_cc//cc:bzl_srcs", diff --git a/foreign_cc/boost_build.bzl b/foreign_cc/boost_build.bzl index aa5abae81..4dad90783 100644 --- a/foreign_cc/boost_build.bzl +++ b/foreign_cc/boost_build.bzl @@ -10,6 +10,7 @@ load( "create_attrs", "expand_locations_and_make_variables", ) +load("//foreign_cc/private:runtime_library_search_directories.bzl", "RUNTIME_LIBRARY_SEARCH_DIRECTORY_ATTRIBUTES") def _boost_build_impl(ctx): attrs = create_attrs( @@ -39,6 +40,8 @@ def _create_configure_script(configureParameters): def _attrs(): attrs = dict(CC_EXTERNAL_RULE_ATTRIBUTES) attrs.pop("targets") + for attr_name in RUNTIME_LIBRARY_SEARCH_DIRECTORY_ATTRIBUTES: + attrs.pop(attr_name) attrs.update({ "bootstrap_options": attr.string_list( doc = "any additional flags to pass to bootstrap.sh", diff --git a/foreign_cc/cmake.bzl b/foreign_cc/cmake.bzl index 35a663022..2208c167a 100644 --- a/foreign_cc/cmake.bzl +++ b/foreign_cc/cmake.bzl @@ -206,7 +206,11 @@ def _create_configure_script(configureParameters): tools = get_tools_info(ctx) # CMake will replace with the actual output file - flags = get_flags_info(ctx, "") + flags = get_flags_info( + ctx, + "", + runtime_search_context = configureParameters.runtime_search_context, + ) no_toolchain_file = ctx.attr.cache_entries.get("CMAKE_TOOLCHAIN_FILE") or not ctx.attr.generate_crosstool_file cmake_commands = [] diff --git a/foreign_cc/configure.bzl b/foreign_cc/configure.bzl index a35698d17..6132614c3 100644 --- a/foreign_cc/configure.bzl +++ b/foreign_cc/configure.bzl @@ -20,6 +20,10 @@ load( "create_attrs", "expand_locations_and_make_variables", ) +load( + "//foreign_cc/private:runtime_library_search_directories.bzl", + "runtime_library_search_directories_enabled", +) load("//foreign_cc/private:transitions.bzl", "foreign_cc_rule_variant") load( "//toolchains/native_tools:tool_access.bzl", @@ -75,7 +79,10 @@ def _create_configure_script(configureParameters): inputs = configureParameters.inputs tools = get_tools_info(ctx) - flags = get_flags_info(ctx) + flags = get_flags_info( + ctx, + runtime_search_context = configureParameters.runtime_search_context, + ) define_install_prefix = ["export INSTALL_PREFIX=\"" + _get_install_prefix(ctx) + "\""] @@ -124,12 +131,28 @@ def _create_configure_script(configureParameters): make_path = attrs.make_path, make_targets = ctx.attr.targets, make_args = args, - executable_ldflags_vars = ctx.attr.executable_ldflags_vars, + executable_ldflags_vars = _executable_ldflags_vars_for_make(ctx, flags), shared_ldflags_vars = ctx.attr.shared_ldflags_vars, is_msvc = is_msvc, ) return define_install_prefix + configure +def _executable_ldflags_vars_for_make(ctx, flags): + executable_ldflags_vars = list(ctx.attr.executable_ldflags_vars) + if ( + runtime_library_search_directories_enabled(ctx) and + _flags_contain_loader_token(flags.cxx_linker_executable) and + "LDFLAGS" not in executable_ldflags_vars + ): + executable_ldflags_vars.append("LDFLAGS") + return executable_ldflags_vars + +def _flags_contain_loader_token(flags): + for flag in flags: + if "$ORIGIN" in flag or "$EXEC_ORIGIN" in flag: + return True + return False + def _get_install_prefix(ctx): if ctx.attr.install_prefix: return ctx.attr.install_prefix diff --git a/foreign_cc/make.bzl b/foreign_cc/make.bzl index 8ffa23fbd..f24e63433 100644 --- a/foreign_cc/make.bzl +++ b/foreign_cc/make.bzl @@ -45,7 +45,10 @@ def _create_make_script(configureParameters): root = detect_root(ctx.attr.lib_source) tools = get_tools_info(ctx) - flags = get_flags_info(ctx) + flags = get_flags_info( + ctx, + runtime_search_context = configureParameters.runtime_search_context, + ) data = ctx.attr.data + ctx.attr.build_data diff --git a/foreign_cc/meson.bzl b/foreign_cc/meson.bzl index 7b27129c4..4793a4eb5 100644 --- a/foreign_cc/meson.bzl +++ b/foreign_cc/meson.bzl @@ -6,6 +6,7 @@ load("//foreign_cc/built_tools:meson_build.bzl", "meson_tool") load( "//foreign_cc/private:cc_toolchain_util.bzl", "absolutize_path_in_str", + "escape_loader_tokens_for_shell", "get_flags_info", "get_tools_info", ) @@ -71,7 +72,10 @@ def _create_meson_script(configureParameters): inputs = configureParameters.inputs tools = get_tools_info(ctx) - flags = get_flags_info(ctx) + flags = get_flags_info( + ctx, + runtime_search_context = configureParameters.runtime_search_context, + ) script = pkgconfig_script(inputs.ext_build_dirs) # CFLAGS and CXXFLAGS are also set in foreign_cc/private/cmake_script.bzl, so that meson @@ -317,4 +321,8 @@ def _absolutize(workspace_name, text, force = False): return absolutize_path_in_str(workspace_name, "$EXT_BUILD_ROOT/", text, force) def _join_flags_list(workspace_name, flags): - return " ".join([_absolutize(workspace_name, flag) for flag in flags]) + return escape_loader_tokens_for_shell(" ".join([_absolutize(workspace_name, flag) for flag in flags])) + +export_for_test = struct( + join_flags_list = _join_flags_list, +) diff --git a/foreign_cc/ninja.bzl b/foreign_cc/ninja.bzl index 80becb8cb..48d98b471 100644 --- a/foreign_cc/ninja.bzl +++ b/foreign_cc/ninja.bzl @@ -60,7 +60,10 @@ def _create_ninja_script(configureParameters): root = detect_root(ctx.attr.lib_source) tools = get_tools_info(ctx) - flags = get_flags_info(ctx) + flags = get_flags_info( + ctx, + runtime_search_context = configureParameters.runtime_search_context, + ) data = ctx.attr.data + ctx.attr.build_data diff --git a/foreign_cc/private/BUILD.bazel b/foreign_cc/private/BUILD.bazel index 81aebeec5..14e1a5155 100644 --- a/foreign_cc/private/BUILD.bazel +++ b/foreign_cc/private/BUILD.bazel @@ -10,12 +10,25 @@ bzl_library( srcs = ["cc_toolchain_util.bzl"], visibility = ["//foreign_cc:__subpackages__"], deps = [ + ":runtime_library_search_directories", "@bazel_skylib//lib:collections", "@bazel_tools//tools/build_defs/cc:action_names.bzl", "@bazel_tools//tools/cpp:toolchain_utils.bzl", ], ) +bzl_library( + name = "runtime_library_search_directories", + srcs = ["runtime_library_search_directories.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = [ + "@bazel_features//:features", + "@bazel_skylib//lib:paths", + "@bazel_skylib//rules:common_settings", + "@rules_cc//cc:bzl_srcs", + ], +) + bzl_library( name = "cmake_script", srcs = ["cmake_script.bzl"], @@ -46,6 +59,7 @@ bzl_library( ":detect_xcompile.bzl", ":resource_sets", ":run_shell_file_utils", + ":runtime_library_search_directories", "//foreign_cc:providers", "//foreign_cc/private/framework:helpers", "//foreign_cc/private/framework:platform", diff --git a/foreign_cc/private/cc_toolchain_util.bzl b/foreign_cc/private/cc_toolchain_util.bzl index 22cd41876..3ddcc686d 100644 --- a/foreign_cc/private/cc_toolchain_util.bzl +++ b/foreign_cc/private/cc_toolchain_util.bzl @@ -5,6 +5,7 @@ load("@bazel_skylib//lib:collections.bzl", "collections") load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") load("@rules_cc//cc:defs.bzl", "CcInfo", "cc_common") +load(":runtime_library_search_directories.bzl", "runtime_library_search_directories") LibrariesToLinkInfo = provider( doc = "Libraries to be wrapped into CcLinkingInfo", @@ -39,6 +40,48 @@ CxxFlagsInfo = provider( ), ) +_LOADER_TOKEN_ESCAPES_FOR_SHELL = [ + ("$EXEC_ORIGIN", "\\$EXEC_ORIGIN"), + ("$ORIGIN", "\\$ORIGIN"), +] + +_LOADER_TOKEN_ESCAPES_FOR_MAKE = [ + ("$EXEC_ORIGIN", "\\\\$\\$EXEC_ORIGIN"), + ("$ORIGIN", "\\\\$\\$ORIGIN"), +] + +def escape_loader_tokens_for_shell(text): + return _escape_loader_tokens(text, _LOADER_TOKEN_ESCAPES_FOR_SHELL) + +def escape_loader_tokens_for_make(text): + return _escape_loader_tokens(text, _LOADER_TOKEN_ESCAPES_FOR_MAKE) + +def _escape_loader_tokens(text, token_escapes): + result = [] + skip_until = 0 + for index in range(len(text)): + if index < skip_until: + continue + + matched = False + for token, escaped_token in token_escapes: + if text[index:index + len(token)] == token: + if _already_escaped(text, index): + result.append(token) + else: + result.append(escaped_token) + skip_until = index + len(token) + matched = True + break + + if not matched: + result.append(text[index]) + + return "".join(result) + +def _already_escaped(text, index): + return index > 0 and text[index - 1] == "\\" + # Since we're calling an external build system we can't support some # features that may be enabled on the toolchain - so we disable # them here when configuring the toolchain flags to pass to the external @@ -120,6 +163,28 @@ def _files_map(files_list, suffix = ""): def _defines_from_deps(ctx): return depset(transitive = [dep[CcInfo].compilation_context.defines for dep in getattr(ctx.attr, "deps", [])]) +def _create_link_variables( + *, + cc_toolchain, + feature_configuration, + is_using_linker, + is_linking_dynamic_library, + must_keep_debug, + output_file = None, + runtime_library_search_directories = None): + kwargs = { + "cc_toolchain": cc_toolchain, + "feature_configuration": feature_configuration, + "is_linking_dynamic_library": is_linking_dynamic_library, + "is_using_linker": is_using_linker, + "must_keep_debug": must_keep_debug, + } + if output_file != None: + kwargs["output_file"] = output_file + if runtime_library_search_directories != None: + kwargs["runtime_library_search_directories"] = runtime_library_search_directories + return cc_common.create_link_variables(**kwargs) + def targets_windows(ctx, cc_toolchain): """Returns true if build is targeting Windows @@ -229,13 +294,15 @@ def get_tools_info(ctx): ) else "", ) -def get_flags_info(ctx, link_output_file = None): +def get_flags_info(ctx, link_output_file = None, runtime_search_context = None): """Takes information about flags from cc_toolchain, returns CxxFlagsInfo Args: ctx: rule context link_output_file: output file to be specified in the link command line flags + runtime_search_context: install-root and declared-output + metadata used to derive runtime library search directories Returns: CxxFlagsInfo: A provider containing Cxx flags @@ -252,6 +319,11 @@ def get_flags_info(ctx, link_output_file = None): defines = _defines_from_deps(ctx) use_pic = cc_toolchain_.needs_pic_for_dynamic_libraries(feature_configuration = feature_configuration) + if targets_windows(ctx, cc_toolchain_): + runtime_search_directories = struct(shared = None, executable = None) + else: + runtime_search_directories = runtime_library_search_directories(ctx, runtime_search_context) + flags = CxxFlagsInfo( cc = cc_common.get_memory_inefficient_command_line( feature_configuration = feature_configuration, @@ -277,18 +349,19 @@ def get_flags_info(ctx, link_output_file = None): cxx_linker_shared = cc_common.get_memory_inefficient_command_line( feature_configuration = feature_configuration, action_name = ACTION_NAMES.cpp_link_dynamic_library, - variables = cc_common.create_link_variables( + variables = _create_link_variables( cc_toolchain = cc_toolchain_, feature_configuration = feature_configuration, is_using_linker = True, is_linking_dynamic_library = True, must_keep_debug = False, + runtime_library_search_directories = runtime_search_directories.shared, ), ), cxx_linker_static = cc_common.get_memory_inefficient_command_line( feature_configuration = feature_configuration, action_name = ACTION_NAMES.cpp_link_static_library, - variables = cc_common.create_link_variables( + variables = _create_link_variables( cc_toolchain = cc_toolchain_, feature_configuration = feature_configuration, is_using_linker = False, @@ -300,12 +373,13 @@ def get_flags_info(ctx, link_output_file = None): cxx_linker_executable = cc_common.get_memory_inefficient_command_line( feature_configuration = feature_configuration, action_name = ACTION_NAMES.cpp_link_executable, - variables = cc_common.create_link_variables( + variables = _create_link_variables( cc_toolchain = cc_toolchain_, feature_configuration = feature_configuration, is_using_linker = True, is_linking_dynamic_library = False, must_keep_debug = False, + runtime_library_search_directories = runtime_search_directories.executable, ), ), assemble = cc_common.get_memory_inefficient_command_line( diff --git a/foreign_cc/private/cmake_script.bzl b/foreign_cc/private/cmake_script.bzl index b38338bff..bced4b3d9 100644 --- a/foreign_cc/private/cmake_script.bzl +++ b/foreign_cc/private/cmake_script.bzl @@ -1,7 +1,7 @@ """ Contains all logic for calling CMake for building external libraries/binaries """ load("//foreign_cc/private:make_script.bzl", "pkgconfig_script") -load(":cc_toolchain_util.bzl", "absolutize_path_in_str") +load(":cc_toolchain_util.bzl", "absolutize_path_in_str", "escape_loader_tokens_for_shell") def _escape_dquote_bash(text): """ Escape double quotes in flag lists for use in bash strings that set environment variables """ @@ -526,12 +526,13 @@ def _absolutize(workspace_name, text, force = False): return absolutize_path_in_str(workspace_name, "$${EXT_BUILD_ROOT//\\\\//}$$/", text, force) def _join_flags_list(workspace_name, flags): - return " ".join([_absolutize(workspace_name, flag) for flag in flags]) + return escape_loader_tokens_for_shell(" ".join([_absolutize(workspace_name, flag) for flag in flags])) export_for_test = struct( absolutize = _absolutize, tail_if_starts_with = _tail_if_starts_with, find_flag_value = _find_flag_value, + join_flags_list = _join_flags_list, fill_crossfile_from_toolchain = _fill_crossfile_from_toolchain, move_dict_values = _move_dict_values, reverse_descriptor_dict = _reverse_descriptor_dict, diff --git a/foreign_cc/private/framework.bzl b/foreign_cc/private/framework.bzl index 0abad8a7e..50822047f 100644 --- a/foreign_cc/private/framework.bzl +++ b/foreign_cc/private/framework.bzl @@ -2,11 +2,11 @@ with CMake, configure/make, autotools) """ -load("@bazel_features//:features.bzl", "bazel_features") load("@bazel_skylib//lib:collections.bzl", "collections") load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") +load("@cc_compatibility_proxy//:symbols.bzl", "CcSharedLibraryInfo") load("@rules_cc//cc:defs.bzl", "CcInfo", "cc_common") load("//foreign_cc:providers.bzl", "ForeignCcArtifactInfo", "ForeignCcDepsInfo") load("//foreign_cc/private:detect_root.bzl", "filter_containing_dirs_from_inputs") @@ -31,8 +31,7 @@ load( ":run_shell_file_utils.bzl", "copy_directory", ) - -CcSharedLibraryInfo = bazel_features.globals.CcSharedLibraryInfo +load(":runtime_library_search_directories.bzl", "RUNTIME_LIBRARY_SEARCH_DIRECTORY_ATTRIBUTES") # Dict with definitions of the context attributes, that customize cc_external_rule_impl function. # Many of the attributes have default values. @@ -264,6 +263,7 @@ CC_EXTERNAL_RULE_ATTRIBUTES = { } # this would be cleaner as x | y, but that's not supported in bazel 5.4.0 +CC_EXTERNAL_RULE_ATTRIBUTES.update(RUNTIME_LIBRARY_SEARCH_DIRECTORY_ATTRIBUTES) CC_EXTERNAL_RULE_ATTRIBUTES.update(PLATFORM_CONSTRAINTS_RULE_ATTRIBUTES) CC_EXTERNAL_RULE_ATTRIBUTES.update(SIZE_ATTRIBUTES) @@ -318,6 +318,8 @@ of the script, and allows to reuse the inputs structure, created by the framewor inputs = """InputFiles provider: summarized information on rule inputs, created by framework function, to be reused in script creator. Contains in particular merged compilation and linking dependencies.""", + runtime_search_context = """Declared outputs and install-root metadata used to derive +runtime library search directories.""", ), ) @@ -506,6 +508,10 @@ def cc_external_rule_impl(ctx, attrs): installdir_copy = copy_directory(ctx.actions, "$$INSTALLDIR$$", "copy_{}/{}".format(lib_name, lib_name)) target_root = paths.dirname(installdir_copy.file.dirname) + # `installdir` is File.path-style for the build action. Runtime search + # directory calculation needs the same install root in File.short_path space. + install_root_short_path = paths.join(paths.dirname(paths.dirname(installdir_copy.file.short_path)), lib_name) + data_dependencies = ctx.attr.data + ctx.attr.build_data + ctx.attr.toolchains tools_env = {} for tool in attrs.tools_data: @@ -547,7 +553,16 @@ def cc_external_rule_impl(ctx, attrs): "##mkdirs## $$EXT_BUILD_DEPS$$", ] + _print_env() + _copy_deps_and_tools(inputs) + [ "cd $$BUILD_TMPDIR$$", - ] + attrs.create_configure_script(ConfigureParameters(ctx = ctx, attrs = attrs, inputs = inputs)) + postfix_script + validation_script + [ + ] + attrs.create_configure_script(ConfigureParameters( + ctx = ctx, + attrs = attrs, + inputs = inputs, + runtime_search_context = struct( + executable_files = outputs.out_binary_files, + install_root_short_path = install_root_short_path, + shared_files = outputs.libraries.shared_libraries, + ), + )) + postfix_script + validation_script + [ # replace references to the root directory when building ($BUILD_TMPDIR) # and the root where the dependencies were installed ($EXT_BUILD_DEPS) # for the results which are in $INSTALLDIR (with placeholder) diff --git a/foreign_cc/private/make_env_vars.bzl b/foreign_cc/private/make_env_vars.bzl index 9a7401ba2..9a98e29b8 100644 --- a/foreign_cc/private/make_env_vars.bzl +++ b/foreign_cc/private/make_env_vars.bzl @@ -1,6 +1,11 @@ """Helper methods to assemble make env variables from Bazel information.""" -load(":cc_toolchain_util.bzl", "absolutize_path_in_str") +load( + ":cc_toolchain_util.bzl", + "absolutize_path_in_str", + "escape_loader_tokens_for_make", + "escape_loader_tokens_for_shell", +) load(":framework.bzl", "get_foreign_cc_dep") # buildifier: disable=function-docstring @@ -12,7 +17,8 @@ def get_make_env_vars( deps, inputs, is_msvc, - make_commands): + make_commands, + expansion_context = "shell"): vars = _get_make_variables(workspace_name, tools, flags, user_vars, make_commands) deps_flags = _define_deps_flags(deps, inputs, is_msvc) @@ -38,8 +44,7 @@ def get_make_env_vars( else: vars["CPPFLAGS"] = deps_flags.flags - return " ".join(["{}=\"{}\"" - .format(key, _join_flags_list(workspace_name, vars[key])) for key in vars]) + return _format_vars(workspace_name, vars, expansion_context) # buildifier: disable=function-docstring def get_ldflags_make_vars( @@ -57,8 +62,7 @@ def get_ldflags_make_vars( for key in vars.keys(): vars[key] = vars[key] + deps_flags.libs - return " ".join(["{}=\"{}\"" - .format(key, _join_flags_list(workspace_name, vars[key])) for key in vars]) + return _format_vars(workspace_name, vars, "make") def _define_deps_flags(deps, inputs, is_msvc): # It is very important to keep the order for the linker => put them into list @@ -196,6 +200,11 @@ def _merge_env_vars(flags, make_flags, user_env_vars): def _absolutize(workspace_name, text, force = False): return absolutize_path_in_str(workspace_name, "$$EXT_BUILD_ROOT$$/", text, force) +def _format_vars(workspace_name, vars, expansion_context): + escape_loader_tokens = escape_loader_tokens_for_make if expansion_context == "make" else escape_loader_tokens_for_shell + return " ".join(["{}=\"{}\"" + .format(key, escape_loader_tokens(_join_flags_list(workspace_name, vars[key]))) for key in vars]) + def _join_flags_list(workspace_name, flags): return " ".join([_absolutize(workspace_name, flag) for flag in flags]) diff --git a/foreign_cc/private/make_script.bzl b/foreign_cc/private/make_script.bzl index 0dd6126f0..cfccb14f8 100644 --- a/foreign_cc/private/make_script.bzl +++ b/foreign_cc/private/make_script.bzl @@ -40,7 +40,17 @@ def create_make_script( install_prefix = make_install_prefix, )) - configure_vars = get_make_env_vars(workspace_name, tools, flags, env_vars, deps, inputs, is_msvc, make_commands) + configure_vars = get_make_env_vars( + workspace_name, + tools, + flags, + env_vars, + deps, + inputs, + is_msvc, + make_commands, + expansion_context = "make", + ) script.extend(["{env_vars} {command}".format( env_vars = configure_vars, diff --git a/foreign_cc/private/runtime_library_search_directories.bzl b/foreign_cc/private/runtime_library_search_directories.bzl new file mode 100644 index 000000000..b88c2f466 --- /dev/null +++ b/foreign_cc/private/runtime_library_search_directories.bzl @@ -0,0 +1,399 @@ +"""Runtime library search directory helpers.""" + +load("@bazel_skylib//lib:paths.bzl", "paths") +load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") +load("@cc_compatibility_proxy//:symbols.bzl", "CcSharedLibraryInfo") +load("@rules_cc//cc:defs.bzl", "CcInfo") + +RUNTIME_LIBRARY_SEARCH_DIRECTORY_ATTRIBUTES = { + "additional_dynamic_runtime_library_search_origins": attr.string_list( + doc = ( + "Additional install-tree-relative origins for shared-library " + + "link actions. Values are relative to this rule's install root " + + "and should not include lib_name or the rule name. For each " + + "origin, runtime library search directories are derived so " + + "shared libraries loaded from that origin can find shared " + + "libraries from deps and dynamic_deps. When " + + "include_self_runtime_library_search_directories is true, these " + + "origins can also find this rule's own shared libraries." + ), + mandatory = False, + default = [], + ), + "additional_executable_runtime_library_search_origins": attr.string_list( + doc = ( + "Additional install-tree-relative origins for executable link " + + "actions. Values are relative to this rule's install root and " + + "should not include lib_name or the rule name. For each origin, " + + "runtime library search directories are derived so executables " + + "loaded from that origin can find shared libraries from deps " + + "and dynamic_deps. When " + + "include_self_runtime_library_search_directories is true, these " + + "origins can also find this rule's own shared libraries." + ), + mandatory = False, + default = [], + ), + "include_self_runtime_library_search_directories": attr.bool( + doc = ( + "When true, add runtime library search directories that let " + + "this rule's binaries, shared libraries, and additional origins " + + "find this rule's own declared shared-library outputs. Ignored " + + "unless runtime_library_search_directories is enabled." + ), + mandatory = False, + default = False, + ), + "runtime_library_search_directories": attr.string( + doc = ( + "Controls whether this target derives runtime library search " + + "directories. Use 'auto' to follow the global " + + "@rules_foreign_cc//foreign_cc/settings:runtime_library_search_directories " + + "build setting, 'enabled' to force it on for this target, or " + + "'disabled' to force it off. This is not supported for Windows " + + "C++ toolchains." + ), + mandatory = False, + values = ["auto", "enabled", "disabled"], + default = "auto", + ), + "runtime_library_search_mode": attr.string( + doc = ( + "Controls which link action kinds receive derived runtime " + + "library search directories. Use 'shared' for shared-library " + + "link actions, 'executable' for executable link actions, or " + + "'all' for both." + ), + mandatory = False, + values = ["shared", "executable", "all"], + default = "all", + ), + "_runtime_library_search_directories": attr.label( + default = Label("//foreign_cc/settings:runtime_library_search_directories"), + providers = [BuildSettingInfo], + ), +} + +def _dynamic_libraries(linker_input): + dynamic_libraries = [] + for library in linker_input.libraries: + if library.dynamic_library: + dynamic_libraries.append(library.dynamic_library) + return dynamic_libraries + +def _dynamic_libraries_from_dep(dep): + dynamic_libraries = [] + if CcInfo in dep: + for linker_input in dep[CcInfo].linking_context.linker_inputs.to_list(): + dynamic_libraries.extend(_dynamic_libraries(linker_input)) + + if CcSharedLibraryInfo in dep: + cc_shared_library_info = dep[CcSharedLibraryInfo] + dynamic_libraries.extend(_dynamic_libraries(cc_shared_library_info.linker_input)) + for dynamic_dep in cc_shared_library_info.dynamic_deps.to_list(): + dynamic_libraries.extend(_dynamic_libraries(dynamic_dep.linker_input)) + + return dynamic_libraries + +def _path_segments(path): + normalized = paths.normalize(path) + if normalized == ".": + return [] + return [segment for segment in normalized.split("/") if segment] + +def _common_prefix_length(left, right): + max_common_segment_count = len(left) + if len(right) < max_common_segment_count: + max_common_segment_count = len(right) + + for index in range(max_common_segment_count): + if left[index] != right[index]: + return index + + return max_common_segment_count + +# Runtime search entries are relative to the directory of the object being +# loaded, i.e. `$ORIGIN` on ELF or `@loader_path` on Darwin. Calculate those +# entries in Bazel File.short_path-compatible space, not from absolute execroot +# paths. For example: +# +# from "pkg/python/bin" to "pkg/python/lib" -> "../lib" +# from "pkg/python/lib" to "pkg/python/lib" -> "." +# from "pkg/python/lib/python3.10/lib-dynload" to "pkg/python/lib" -> "../.." +# +# The returned value is the part appended after the loader token. +def _relative_path(from_path, to_path): + from_segments = _path_segments(from_path) + to_segments = _path_segments(to_path) + common_segment_count = _common_prefix_length(from_segments, to_segments) + + # Drop the shared prefix, then walk up from the origin and down to the target. + relative_segments = ( + [".."] * (len(from_segments) - common_segment_count) + + to_segments[common_segment_count:] + ) + return "/".join(relative_segments) if relative_segments else "." + +def _dedupe_strings(strings): + # Preserve first-seen order because runtime search directory order affects + # which matching soname the dynamic loader resolves first. + seen = {} + deduped = [] + for string in strings: + if string not in seen: + seen[string] = True + deduped.append(string) + return deduped + +# LibraryToLink.dynamic_library often points at Bazel's solib symlink instead of +# the real generated library: +# +# dynamic_library.short_path: +# "_solib_k8/_Uthirdparty_Szlib/libz.so" +# +# resolved_symlink_dynamic_library.short_path: +# "thirdparty/zlib/zlib/lib/libz.so" +# +# Runtime search entries are interpreted relative to the object being loaded. +# If that object is loaded through Bazel's solib tree, `$ORIGIN` / `@loader_path` +# is its solib artifact directory, not its original install-tree directory. +# +# For a dependency in another solib artifact directory, add a sibling-solib +# search entry: +# +# current origin: +# "_solib_k8/_Uthirdparty_Sarchive" +# +# dependency dynamic_library.short_path: +# "_solib_k8/_Uthirdparty_Szlib/libz.so" +# +# sibling search entry: +# "../_Uthirdparty_Szlib" +# +# This is added in addition to the normal origin-to-dependency path because +# either the install-tree path or the solib symlink path may be the path used by +# the loader. +def _solib_sibling_search_directory(dynamic_library_short_path): + segments = _path_segments(dynamic_library_short_path) + if len(segments) < 3 or not segments[0].startswith("_solib_"): + return None + + artifact_dir_under_solib = "/".join(segments[1:-1]) + if not artifact_dir_under_solib: + return None + + return "../" + artifact_dir_under_solib + +# Calculate runtime search entries from each output origin to each dependency +# dynamic library directory. Both inputs are already in Bazel +# File.short_path-compatible space: +# +# origin_short_paths: +# directories where this rule's binaries or shared libraries may be loaded +# +# dynamic_library_short_paths: +# LibraryToLink.dynamic_library.short_path values from deps/dynamic_deps +# +# Example: a foreign_cc shared library installed under this target's "lib/" +# directory depends on a Bazel shared library exposed through the solib tree: +# +# origin: +# "thirdparty/python/python/lib" +# +# dependency dynamic_library.short_path: +# "_solib_k8/_Uthirdparty_Szlib/libz.so" +# +# dependency directory: +# "_solib_k8/_Uthirdparty_Szlib" +# +# rpath entry: +# "../../../../_solib_k8/_Uthirdparty_Szlib" +# +# That entry is later interpreted relative to `$ORIGIN` / `@loader_path`, so a +# library loaded from the install-tree "lib/" directory can find the dependency +# in Bazel's solib tree. +# +# For solib dependencies, also add a sibling-solib entry. This covers the case +# where the current library is loaded through Bazel's solib symlink rather than +# through its install-tree path. +def _search_directories_for_dynamic_libraries( + origin_short_paths, + dynamic_library_short_paths): + directories = [] + for dynamic_library_short_path in dynamic_library_short_paths: + library_dir = paths.dirname(dynamic_library_short_path) + for origin_short_path in origin_short_paths: + directories.append(_relative_path(origin_short_path, library_dir)) + + solib_sibling_directory = _solib_sibling_search_directory(dynamic_library_short_path) + if solib_sibling_directory: + directories.append(solib_sibling_directory) + + return _dedupe_strings(directories) + +def _dynamic_library_short_paths_from_deps(ctx): + dynamic_library_short_paths = [] + for dep in getattr(ctx.attr, "deps", []) + getattr(ctx.attr, "dynamic_deps", []): + for dynamic_library in _dynamic_libraries_from_dep(dep): + dynamic_library_short_paths.append(dynamic_library.short_path) + return dynamic_library_short_paths + +# Declared output files are already in Bazel File.short_path-compatible space. +# Use their parent directories as default runtime origins: +# +# "pkg/python/bin/python3.10" -> "pkg/python/bin" +# "pkg/python/lib/libpython.so" -> "pkg/python/lib" +# +# These defaults come from actual declared outputs, not from out_bin_dir or +# out_lib_dir strings. +def _origin_short_paths_from_files(files): + return _dedupe_strings([ + paths.dirname(file.short_path) + for file in files + ]) + +# Additional origins are user-facing install-tree paths, so they are relative to +# the foreign build's install root, not to the Bazel execroot or package. The +# framework gives us that install root in File.short_path-compatible space: +# +# install root: "third_party/python/python" +# user origin: "lib/python3.10/lib-dynload" +# short path: "third_party/python/python/lib/python3.10/lib-dynload" +# +# This keeps additional origins comparable with dependency LibraryToLink +# short_path values. +def _origin_short_paths_from_install_tree(runtime_search_context, install_tree_origins): + origin_short_paths = [] + for install_tree_origin in install_tree_origins: + origin = install_tree_origin.lstrip("/") + origin_short_paths.append(paths.join( + runtime_search_context.install_root_short_path, + origin, + ) if origin else runtime_search_context.install_root_short_path) + return _dedupe_strings(origin_short_paths) + +def _mode_context(ctx, runtime_search_context, mode): + if mode == "shared": + return struct( + additional_origins = getattr(ctx.attr, "additional_dynamic_runtime_library_search_origins", []), + output_files = runtime_search_context.shared_files, + ) + if mode == "executable": + return struct( + additional_origins = getattr(ctx.attr, "additional_executable_runtime_library_search_origins", []), + output_files = runtime_search_context.executable_files, + ) + fail("Unknown runtime library search mode: {}".format(mode)) + +def _origin_short_paths_from_mode(runtime_search_context, mode_context): + return _dedupe_strings( + _origin_short_paths_from_files(mode_context.output_files) + + _origin_short_paths_from_install_tree( + runtime_search_context, + mode_context.additional_origins, + ), + ) + +def _self_search_directories(origin_short_paths, runtime_search_context): + # Self output directories let this rule's binaries and shared libraries + # find this rule's own declared shared libraries. + directories = [] + self_library_origin_short_paths = _origin_short_paths_from_files(runtime_search_context.shared_files) + for origin_short_path in origin_short_paths: + for self_library_origin_short_path in self_library_origin_short_paths: + directories.append(_relative_path(origin_short_path, self_library_origin_short_path)) + return directories + +def _dependency_search_directories(ctx, origin_short_paths): + # Dependency output directories let this rule's outputs find linked + # dynamic libraries exposed by deps and dynamic_deps. + return _search_directories_for_dynamic_libraries( + origin_short_paths, + _dynamic_library_short_paths_from_deps(ctx), + ) + +def _runtime_library_search_directories_for_mode(ctx, runtime_search_context, mode): + mode_context = _mode_context(ctx, runtime_search_context, mode) + origin_short_paths = _origin_short_paths_from_mode(runtime_search_context, mode_context) + + directories = [] + if getattr(ctx.attr, "include_self_runtime_library_search_directories", False): + directories.extend(_self_search_directories(origin_short_paths, runtime_search_context)) + + directories.extend(_dependency_search_directories(ctx, origin_short_paths)) + return _dedupe_strings(directories) + +def _mode_includes(ctx, mode): + runtime_library_search_mode = ctx.attr.runtime_library_search_mode + return runtime_library_search_mode == "all" or runtime_library_search_mode == mode + +def runtime_library_search_directories_enabled(ctx): + """Returns whether runtime library search directory derivation is enabled. + + Args: + ctx: Rule context. + + Returns: + True when runtime library search directory derivation is enabled for this + target. + """ + + value = getattr(ctx.attr, "runtime_library_search_directories", "disabled") + if value == "enabled": + return True + if value == "disabled": + return False + + setting = getattr(ctx.attr, "_runtime_library_search_directories", None) + return setting[BuildSettingInfo].value == "enabled" + +def _ignored_attrs(ctx): + ignored_attrs = [] + if getattr(ctx.attr, "additional_dynamic_runtime_library_search_origins", []): + ignored_attrs.append("additional_dynamic_runtime_library_search_origins") + if getattr(ctx.attr, "additional_executable_runtime_library_search_origins", []): + ignored_attrs.append("additional_executable_runtime_library_search_origins") + if getattr(ctx.attr, "include_self_runtime_library_search_directories", False): + ignored_attrs.append("include_self_runtime_library_search_directories") + return ignored_attrs + +# buildifier: disable=print +def _warn_if_attrs_ignored(ctx): + ignored_attrs = _ignored_attrs(ctx) + if ignored_attrs: + print(( + "WARNING: {} sets runtime_library_search attrs ({}) but " + + "runtime_library_search_directories is disabled; " + + "ignoring runtime_library_search attrs." + ).format(ctx.label, ", ".join(ignored_attrs))) + +def runtime_library_search_directories(ctx, runtime_search_context): + """Returns runtime library search directories for link actions. + + Args: + ctx: Rule context. + runtime_search_context: Runtime search metadata for declared outputs and + the install root in File.short_path-compatible space. + + Returns: + A struct with `shared` and `executable` depset fields. Each field contains + runtime library search directories for that link action kind, or None when + the current runtime library search mode excludes that action kind. + """ + + if not runtime_library_search_directories_enabled(ctx): + _warn_if_attrs_ignored(ctx) + return struct(shared = None, executable = None) + + if runtime_search_context == None: + fail("Runtime library search directory derivation requires runtime search context.") + + return struct( + shared = depset(_runtime_library_search_directories_for_mode(ctx, runtime_search_context, "shared")) if _mode_includes(ctx, "shared") else None, + executable = depset(_runtime_library_search_directories_for_mode(ctx, runtime_search_context, "executable")) if _mode_includes(ctx, "executable") else None, + ) + +export_for_test = struct( + runtime_library_search_directories = runtime_library_search_directories, + search_directories_for_dynamic_libraries = _search_directories_for_dynamic_libraries, +) diff --git a/foreign_cc/settings/BUILD.bazel b/foreign_cc/settings/BUILD.bazel index b5c5baee1..d1fd915c5 100644 --- a/foreign_cc/settings/BUILD.bazel +++ b/foreign_cc/settings/BUILD.bazel @@ -1,4 +1,4 @@ -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") +load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag") load("//foreign_cc/private:resource_sets.bzl", _create_settings = "create_settings") _create_settings() @@ -8,3 +8,13 @@ bool_flag( build_setting_default = False, visibility = ["//visibility:public"], ) + +string_flag( + name = "runtime_library_search_directories", + build_setting_default = "disabled", + values = [ + "enabled", + "disabled", + ], + visibility = ["//visibility:public"], +) diff --git a/test/BUILD.bazel b/test/BUILD.bazel index ef7571533..5eafa1a2a 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -4,6 +4,9 @@ load("@rules_shell//shell:sh_test.bzl", "sh_test") load("//tools/lint:linters.bzl", "shellcheck_test") load(":cmake_text_tests.bzl", "cmake_script_test_suite") load(":convert_shell_script_test.bzl", "shell_script_conversion_suite") +load(":make_env_vars_test.bzl", "make_env_vars_test_suite") +load(":meson_text_tests.bzl", "meson_text_test_suite") +load(":runtime_library_search_directories_test.bzl", "runtime_library_search_directories_test_suite") load(":shell_script_helper_test_rule.bzl", "shell_script_helper_test_rule") load(":symlink_contents_to_dir_test_rule.bzl", "symlink_contents_to_dir_test_rule") load(":utils_test.bzl", "utils_test_suite") @@ -54,8 +57,14 @@ shellcheck_test( cmake_script_test_suite() +runtime_library_search_directories_test_suite() + shell_script_conversion_suite() +make_env_vars_test_suite() + +meson_text_test_suite() + utils_test_suite() shell_script_helper_test_rule( diff --git a/test/cmake_text_tests.bzl b/test/cmake_text_tests.bzl index 7786082df..8f9f8b5c1 100644 --- a/test/cmake_text_tests.bzl +++ b/test/cmake_text_tests.bzl @@ -27,6 +27,38 @@ def _absolutize_test(ctx): return unittest.end(env) +def _join_flags_list_escapes_loader_tokens_for_shell_test(ctx): + env = unittest.begin(ctx) + + result = export_for_test.join_flags_list("ws", [ + "-Wl,-rpath,$ORIGIN/lib", + "-Wl,-rpath,$EXEC_ORIGIN/bin", + ]) + + asserts.equals( + env, + "-Wl,-rpath,\\$ORIGIN/lib -Wl,-rpath,\\$EXEC_ORIGIN/bin", + result, + ) + + return unittest.end(env) + +def _join_flags_list_preserves_escaped_loader_tokens_for_shell_test(ctx): + env = unittest.begin(ctx) + + result = export_for_test.join_flags_list("ws", [ + "-Wl,-rpath,\\$ORIGIN/lib", + "-Wl,-rpath,\\$EXEC_ORIGIN/bin", + ]) + + asserts.equals( + env, + "-Wl,-rpath,\\$ORIGIN/lib -Wl,-rpath,\\$EXEC_ORIGIN/bin", + result, + ) + + return unittest.end(env) + def _tail_extraction_test(ctx): env = unittest.begin(ctx) @@ -914,6 +946,8 @@ cmake -DCUSTOM_CACHE="YES" -DCMAKE_TOOLCHAIN_FILE="$$BUILD_TMPDIR$$/crosstool_ba return unittest.end(env) absolutize_test = unittest.make(_absolutize_test) +join_flags_list_escapes_loader_tokens_for_shell_test = unittest.make(_join_flags_list_escapes_loader_tokens_for_shell_test) +join_flags_list_preserves_escaped_loader_tokens_for_shell_test = unittest.make(_join_flags_list_preserves_escaped_loader_tokens_for_shell_test) tail_extraction_test = unittest.make(_tail_extraction_test) find_flag_value_test = unittest.make(_find_flag_value_test) fill_crossfile_from_toolchain_test = unittest.make(_fill_crossfile_from_toolchain_test) @@ -935,6 +969,8 @@ def cmake_script_test_suite(): unittest.suite( "cmake_script_test_suite", partial.make(absolutize_test, size = "small"), + partial.make(join_flags_list_escapes_loader_tokens_for_shell_test, size = "small"), + partial.make(join_flags_list_preserves_escaped_loader_tokens_for_shell_test, size = "small"), partial.make(tail_extraction_test, size = "small"), partial.make(find_flag_value_test, size = "small"), partial.make(fill_crossfile_from_toolchain_test, size = "small"), diff --git a/test/make_env_vars_test.bzl b/test/make_env_vars_test.bzl new file mode 100644 index 000000000..362aac3f9 --- /dev/null +++ b/test/make_env_vars_test.bzl @@ -0,0 +1,162 @@ +"""Unit tests for make environment variable rendering.""" + +load("@bazel_skylib//lib:partial.bzl", "partial") +load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest") + +# buildifier: disable=bzl-visibility +load("//foreign_cc/private:make_env_vars.bzl", "get_ldflags_make_vars", "get_make_env_vars") + +def _tools(): + return struct( + cc = "", + cxx = "", + cxx_linker_static = "", + ld = "", + ) + +def _flags(): + return struct( + assemble = [], + cc = [], + cxx = [], + cxx_linker_executable = [ + "-Wl,-rpath,$ORIGIN/lib", + "-Wl,-rpath,$EXEC_ORIGIN/bin", + ], + cxx_linker_static = [], + ) + +def _escaped_flags(): + return struct( + assemble = [], + cc = [], + cxx = [], + cxx_linker_executable = [ + "-Wl,-rpath,\\$ORIGIN/lib", + "-Wl,-rpath,\\$EXEC_ORIGIN/bin", + ], + cxx_linker_static = [], + ) + +def _inputs(): + return struct( + headers = [], + include_dirs = [], + libs = [], + ) + +def _get_make_env_vars_escapes_loader_tokens_for_shell_test(ctx): + env = unittest.begin(ctx) + + result = get_make_env_vars("workspace", _tools(), _flags(), {}, [], _inputs(), False, []) + + asserts.equals( + env, + "LDFLAGS=\"-Wl,-rpath,\\$ORIGIN/lib -Wl,-rpath,\\$EXEC_ORIGIN/bin\" RANLIB=\":\" CPPFLAGS=\"\"", + result, + ) + + return unittest.end(env) + +def _get_make_env_vars_preserves_escaped_loader_tokens_for_shell_test(ctx): + env = unittest.begin(ctx) + + result = get_make_env_vars("workspace", _tools(), _escaped_flags(), {}, [], _inputs(), False, []) + + asserts.equals( + env, + "LDFLAGS=\"-Wl,-rpath,\\$ORIGIN/lib -Wl,-rpath,\\$EXEC_ORIGIN/bin\" RANLIB=\":\" CPPFLAGS=\"\"", + result, + ) + + return unittest.end(env) + +def _get_make_env_vars_make_context_escapes_loader_tokens_for_make_test(ctx): + env = unittest.begin(ctx) + + result = get_make_env_vars( + "workspace", + _tools(), + _flags(), + {}, + [], + _inputs(), + False, + [], + expansion_context = "make", + ) + + asserts.equals( + env, + "LDFLAGS=\"-Wl,-rpath,\\\\$\\$ORIGIN/lib -Wl,-rpath,\\\\$\\$EXEC_ORIGIN/bin\" RANLIB=\":\" CPPFLAGS=\"\"", + result, + ) + + return unittest.end(env) + +def _get_make_env_vars_make_context_preserves_escaped_loader_tokens_test(ctx): + env = unittest.begin(ctx) + + result = get_make_env_vars( + "workspace", + _tools(), + _escaped_flags(), + {}, + [], + _inputs(), + False, + [], + expansion_context = "make", + ) + + asserts.equals( + env, + "LDFLAGS=\"-Wl,-rpath,\\$ORIGIN/lib -Wl,-rpath,\\$EXEC_ORIGIN/bin\" RANLIB=\":\" CPPFLAGS=\"\"", + result, + ) + + return unittest.end(env) + +def _get_ldflags_make_vars_escapes_loader_tokens_for_make_test(ctx): + env = unittest.begin(ctx) + + result = get_ldflags_make_vars(["LDFLAGS"], [], "workspace", _flags(), {}, [], _inputs(), False) + + asserts.equals( + env, + "LDFLAGS=\"-Wl,-rpath,\\\\$\\$ORIGIN/lib -Wl,-rpath,\\\\$\\$EXEC_ORIGIN/bin\"", + result, + ) + + return unittest.end(env) + +def _get_ldflags_make_vars_preserves_escaped_loader_tokens_for_make_test(ctx): + env = unittest.begin(ctx) + + result = get_ldflags_make_vars(["LDFLAGS"], [], "workspace", _escaped_flags(), {}, [], _inputs(), False) + + asserts.equals( + env, + "LDFLAGS=\"-Wl,-rpath,\\$ORIGIN/lib -Wl,-rpath,\\$EXEC_ORIGIN/bin\"", + result, + ) + + return unittest.end(env) + +get_make_env_vars_escapes_loader_tokens_for_shell_test = unittest.make(_get_make_env_vars_escapes_loader_tokens_for_shell_test) +get_make_env_vars_preserves_escaped_loader_tokens_for_shell_test = unittest.make(_get_make_env_vars_preserves_escaped_loader_tokens_for_shell_test) +get_make_env_vars_make_context_escapes_loader_tokens_for_make_test = unittest.make(_get_make_env_vars_make_context_escapes_loader_tokens_for_make_test) +get_make_env_vars_make_context_preserves_escaped_loader_tokens_test = unittest.make(_get_make_env_vars_make_context_preserves_escaped_loader_tokens_test) +get_ldflags_make_vars_escapes_loader_tokens_for_make_test = unittest.make(_get_ldflags_make_vars_escapes_loader_tokens_for_make_test) +get_ldflags_make_vars_preserves_escaped_loader_tokens_for_make_test = unittest.make(_get_ldflags_make_vars_preserves_escaped_loader_tokens_for_make_test) + +def make_env_vars_test_suite(): + unittest.suite( + "make_env_vars_test_suite", + partial.make(get_make_env_vars_escapes_loader_tokens_for_shell_test, size = "small"), + partial.make(get_make_env_vars_preserves_escaped_loader_tokens_for_shell_test, size = "small"), + partial.make(get_make_env_vars_make_context_escapes_loader_tokens_for_make_test, size = "small"), + partial.make(get_make_env_vars_make_context_preserves_escaped_loader_tokens_test, size = "small"), + partial.make(get_ldflags_make_vars_escapes_loader_tokens_for_make_test, size = "small"), + partial.make(get_ldflags_make_vars_preserves_escaped_loader_tokens_for_make_test, size = "small"), + ) diff --git a/test/meson_text_tests.bzl b/test/meson_text_tests.bzl new file mode 100644 index 000000000..21d439600 --- /dev/null +++ b/test/meson_text_tests.bzl @@ -0,0 +1,49 @@ +"""Unit tests for Meson script helpers.""" + +load("@bazel_skylib//lib:partial.bzl", "partial") +load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest") + +# buildifier: disable=bzl-visibility +load("//foreign_cc:meson.bzl", "export_for_test") + +def _join_flags_list_escapes_loader_tokens_for_shell_test(ctx): + env = unittest.begin(ctx) + + result = export_for_test.join_flags_list("ws", [ + "-Wl,-rpath,$ORIGIN/lib", + "-Wl,-rpath,$EXEC_ORIGIN/bin", + ]) + + asserts.equals( + env, + "-Wl,-rpath,\\$ORIGIN/lib -Wl,-rpath,\\$EXEC_ORIGIN/bin", + result, + ) + + return unittest.end(env) + +def _join_flags_list_preserves_escaped_loader_tokens_for_shell_test(ctx): + env = unittest.begin(ctx) + + result = export_for_test.join_flags_list("ws", [ + "-Wl,-rpath,\\$ORIGIN/lib", + "-Wl,-rpath,\\$EXEC_ORIGIN/bin", + ]) + + asserts.equals( + env, + "-Wl,-rpath,\\$ORIGIN/lib -Wl,-rpath,\\$EXEC_ORIGIN/bin", + result, + ) + + return unittest.end(env) + +join_flags_list_escapes_loader_tokens_for_shell_test = unittest.make(_join_flags_list_escapes_loader_tokens_for_shell_test) +join_flags_list_preserves_escaped_loader_tokens_for_shell_test = unittest.make(_join_flags_list_preserves_escaped_loader_tokens_for_shell_test) + +def meson_text_test_suite(): + unittest.suite( + "meson_text_test_suite", + partial.make(join_flags_list_escapes_loader_tokens_for_shell_test, size = "small"), + partial.make(join_flags_list_preserves_escaped_loader_tokens_for_shell_test, size = "small"), + ) diff --git a/test/runtime_library_search_directories_test.bzl b/test/runtime_library_search_directories_test.bzl new file mode 100644 index 000000000..7e1f0519c --- /dev/null +++ b/test/runtime_library_search_directories_test.bzl @@ -0,0 +1,515 @@ +"""Unit tests for runtime library search directory helpers.""" + +load("@bazel_skylib//lib:partial.bzl", "partial") +load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest") + +# buildifier: disable=bzl-visibility +load( + "//foreign_cc/private:runtime_library_search_directories.bzl", + "RUNTIME_LIBRARY_SEARCH_DIRECTORY_ATTRIBUTES", + "export_for_test", + "runtime_library_search_directories_enabled", +) + +_RuntimeSearchEnabledInfo = provider( + "Runtime library search directory enablement state.", + fields = ["enabled"], +) +_RUNTIME_SEARCH_SETTING = str(Label("//foreign_cc/settings:runtime_library_search_directories")) + +def _runtime_search_enabled_subject_impl(ctx): + return [_RuntimeSearchEnabledInfo( + enabled = runtime_library_search_directories_enabled(ctx), + )] + +_runtime_search_enabled_subject = rule( + implementation = _runtime_search_enabled_subject_impl, + attrs = RUNTIME_LIBRARY_SEARCH_DIRECTORY_ATTRIBUTES, +) + +def _ctx( + name = "python", + lib_name = "", + package = "pkg", + repo_name = "", + out_lib_dir = "lib", + out_bin_dir = "bin", + out_shared_libs = [], + out_binaries = [], + out_data_dirs = [], + additional_dynamic_origins = [], + additional_executable_origins = [], + runtime_library_search_directories = "disabled", + include_self_runtime_library_search_directories = False, + runtime_library_search_mode = "all"): + return struct( + attr = struct( + additional_dynamic_runtime_library_search_origins = additional_dynamic_origins, + additional_executable_runtime_library_search_origins = additional_executable_origins, + include_self_runtime_library_search_directories = include_self_runtime_library_search_directories, + lib_name = lib_name, + name = name, + out_bin_dir = out_bin_dir, + out_binaries = out_binaries, + out_data_dirs = out_data_dirs, + out_lib_dir = out_lib_dir, + out_shared_libs = out_shared_libs, + runtime_library_search_directories = runtime_library_search_directories, + runtime_library_search_mode = runtime_library_search_mode, + ), + label = struct( + package = package, + repo_name = repo_name, + ), + ) + +def _file(short_path): + return struct(short_path = short_path) + +def _runtime_search_context( + install_root_short_path = "pkg/python", + shared_files = [], + executable_files = []): + return struct( + executable_files = [_file(short_path) for short_path in executable_files], + install_root_short_path = install_root_short_path, + shared_files = [_file(short_path) for short_path in shared_files], + ) + +def _runtime_library_search_directories( + ctx, + install_root_short_path = "pkg/python", + shared_files = [], + executable_files = []): + return export_for_test.runtime_library_search_directories( + ctx, + _runtime_search_context( + install_root_short_path = install_root_short_path, + shared_files = shared_files, + executable_files = executable_files, + ), + ) + +def _default_dynamic_origin_only_when_out_shared_libs_exist_test(ctx): + env = unittest.begin(ctx) + + with_shared_libs = _runtime_library_search_directories( + _ctx( + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_shared_libs = ["libpython3.10.so"], + runtime_library_search_mode = "shared", + ), + shared_files = ["pkg/python/lib/libpython3.10.so"], + ) + without_shared_libs = _runtime_library_search_directories( + _ctx( + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_data_dirs = ["lib/python3.10/lib-dynload"], + runtime_library_search_mode = "shared", + ), + ) + + asserts.equals(env, ["."], with_shared_libs.shared.to_list()) + asserts.equals(env, [], without_shared_libs.shared.to_list()) + + return unittest.end(env) + +def _default_executable_origin_only_when_out_binaries_exist_test(ctx): + env = unittest.begin(ctx) + + with_binaries = _runtime_library_search_directories( + _ctx( + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_binaries = ["python3.10"], + out_shared_libs = ["libpython3.10.so"], + runtime_library_search_mode = "executable", + ), + executable_files = ["pkg/python/bin/python3.10"], + shared_files = ["pkg/python/lib/libpython3.10.so"], + ) + without_binaries = _runtime_library_search_directories( + _ctx( + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_data_dirs = ["bin"], + out_shared_libs = ["libpython3.10.so"], + runtime_library_search_mode = "executable", + ), + shared_files = ["pkg/python/lib/libpython3.10.so"], + ) + + asserts.equals(env, ["../lib"], with_binaries.executable.to_list()) + asserts.equals(env, [], without_binaries.executable.to_list()) + + return unittest.end(env) + +def _additional_dynamic_origins_do_not_affect_executable_origins_test(ctx): + env = unittest.begin(ctx) + + result = _runtime_library_search_directories( + _ctx( + additional_dynamic_origins = ["lib/python3.10/lib-dynload"], + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_binaries = ["python3.10"], + out_shared_libs = ["libpython3.10.so"], + runtime_library_search_mode = "executable", + ), + executable_files = ["pkg/python/bin/python3.10"], + shared_files = ["pkg/python/lib/libpython3.10.so"], + ) + + asserts.equals(env, ["../lib"], result.executable.to_list()) + + return unittest.end(env) + +def _additional_executable_origins_do_not_affect_dynamic_origins_test(ctx): + env = unittest.begin(ctx) + + result = _runtime_library_search_directories( + _ctx( + additional_executable_origins = ["libexec"], + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_shared_libs = ["libpython3.10.so"], + runtime_library_search_mode = "shared", + ), + shared_files = ["pkg/python/lib/libpython3.10.so"], + ) + + asserts.equals(env, ["."], result.shared.to_list()) + + return unittest.end(env) + +def _additional_origins_are_install_tree_relative_test(ctx): + env = unittest.begin(ctx) + + result = _runtime_library_search_directories( + _ctx( + additional_dynamic_origins = ["lib/python3.10/lib-dynload"], + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_shared_libs = ["libpython3.10.so"], + runtime_library_search_mode = "shared", + ), + shared_files = ["pkg/python/lib/libpython3.10.so"], + ) + + asserts.equals( + env, + [ + ".", + "../..", + ], + result.shared.to_list(), + ) + + return unittest.end(env) + +def _additional_executable_origins_are_install_tree_relative_test(ctx): + env = unittest.begin(ctx) + + result = _runtime_library_search_directories( + _ctx( + additional_executable_origins = ["libexec/bin"], + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_binaries = ["python3.10"], + out_shared_libs = ["libpython3.10.so"], + runtime_library_search_mode = "executable", + ), + executable_files = ["pkg/python/bin/python3.10"], + shared_files = ["pkg/python/lib/libpython3.10.so"], + ) + + asserts.equals( + env, + [ + "../lib", + "../../lib", + ], + result.executable.to_list(), + ) + + return unittest.end(env) + +def _self_runtime_search_directories_are_disabled_by_default_test(ctx): + env = unittest.begin(ctx) + + result = _runtime_library_search_directories( + _ctx( + out_binaries = ["python3.10"], + out_shared_libs = ["libpython3.10.so"], + ), + executable_files = ["pkg/python/bin/python3.10"], + shared_files = ["pkg/python/lib/libpython3.10.so"], + ) + + asserts.equals(env, None, result.shared) + asserts.equals(env, None, result.executable) + + return unittest.end(env) + +def _self_runtime_search_directories_use_default_paths_test(ctx): + env = unittest.begin(ctx) + + result = _runtime_library_search_directories( + _ctx( + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_binaries = ["python3.10"], + out_shared_libs = ["libpython3.10.so"], + ), + executable_files = ["pkg/python/bin/python3.10"], + shared_files = ["pkg/python/lib/libpython3.10.so"], + ) + + asserts.equals(env, ["."], result.shared.to_list()) + asserts.equals(env, ["../lib"], result.executable.to_list()) + + return unittest.end(env) + +def _self_runtime_search_directories_use_custom_paths_test(ctx): + env = unittest.begin(ctx) + + result = _runtime_library_search_directories( + _ctx( + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_bin_dir = "tools/bin", + out_binaries = ["python3.10"], + out_lib_dir = "lib64", + out_shared_libs = ["libpython3.10.so"], + ), + executable_files = ["pkg/python/tools/bin/python3.10"], + shared_files = ["pkg/python/lib64/libpython3.10.so"], + ) + + asserts.equals(env, ["."], result.shared.to_list()) + asserts.equals(env, ["../../lib64"], result.executable.to_list()) + + return unittest.end(env) + +def _self_runtime_search_directories_include_additional_dynamic_origins_test(ctx): + env = unittest.begin(ctx) + + result = _runtime_library_search_directories( + _ctx( + additional_dynamic_origins = ["lib/python3.10/lib-dynload"], + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_shared_libs = ["libpython3.10.so"], + ), + shared_files = ["pkg/python/lib/libpython3.10.so"], + ) + + asserts.equals(env, [".", "../.."], result.shared.to_list()) + + return unittest.end(env) + +def _self_runtime_search_directories_respect_mode_test(ctx): + env = unittest.begin(ctx) + + shared_only = _runtime_library_search_directories( + _ctx( + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_binaries = ["python3.10"], + out_shared_libs = ["libpython3.10.so"], + runtime_library_search_mode = "shared", + ), + executable_files = ["pkg/python/bin/python3.10"], + shared_files = ["pkg/python/lib/libpython3.10.so"], + ) + executable_only = _runtime_library_search_directories( + _ctx( + runtime_library_search_directories = "enabled", + include_self_runtime_library_search_directories = True, + out_binaries = ["python3.10"], + out_shared_libs = ["libpython3.10.so"], + runtime_library_search_mode = "executable", + ), + executable_files = ["pkg/python/bin/python3.10"], + shared_files = ["pkg/python/lib/libpython3.10.so"], + ) + + asserts.equals(env, ["."], shared_only.shared.to_list()) + asserts.equals(env, None, shared_only.executable) + asserts.equals(env, None, executable_only.shared) + asserts.equals(env, ["../lib"], executable_only.executable.to_list()) + + return unittest.end(env) + +def _auto_mode_uses_global_build_setting_test(ctx): + env = analysistest.begin(ctx) + + target = analysistest.target_under_test(env) + asserts.equals(env, True, target[_RuntimeSearchEnabledInfo].enabled) + + return analysistest.end(env) + +def _disabled_overrides_enabled_global_build_setting_test(ctx): + env = analysistest.begin(ctx) + + target = analysistest.target_under_test(env) + asserts.equals(env, False, target[_RuntimeSearchEnabledInfo].enabled) + + return analysistest.end(env) + +def _runtime_search_directories_dedupe_dynamic_library_dirs_test(ctx): + env = unittest.begin(ctx) + + result = export_for_test.search_directories_for_dynamic_libraries( + ["pkg/python/lib"], + [ + "pkg/python/lib/libpython3.10.so", + "pkg/python/lib/libother.so", + ], + ) + + asserts.equals(env, ["."], result) + + return unittest.end(env) + +def _solib_dynamic_library_gets_output_and_sibling_rpaths_test(ctx): + env = unittest.begin(ctx) + + result = export_for_test.search_directories_for_dynamic_libraries( + ["thirdparty/python39/python39/lib/python3.9/lib-dynload"], + ["_solib_local/_Uthirdparty_Sbzip2/libbz2.so"], + ) + + asserts.equals( + env, + [ + "../../../../../../_solib_local/_Uthirdparty_Sbzip2", + "../_Uthirdparty_Sbzip2", + ], + result, + ) + + return unittest.end(env) + +def _non_solib_dynamic_library_gets_only_output_rpath_test(ctx): + env = unittest.begin(ctx) + + result = export_for_test.search_directories_for_dynamic_libraries( + ["pkg/python/bin"], + ["pkg/python/lib/libpython3.10.so"], + ) + + asserts.equals(env, ["../lib"], result) + + return unittest.end(env) + +def _solib_path_without_directory_gets_only_output_rpath_test(ctx): + env = unittest.begin(ctx) + + result = export_for_test.search_directories_for_dynamic_libraries( + ["pkg/python/lib"], + ["_solib_local/libpython3.10.so"], + ) + + asserts.equals(env, ["../../../_solib_local"], result) + + return unittest.end(env) + +default_dynamic_origin_only_when_out_shared_libs_exist_test = unittest.make( + _default_dynamic_origin_only_when_out_shared_libs_exist_test, +) +default_executable_origin_only_when_out_binaries_exist_test = unittest.make( + _default_executable_origin_only_when_out_binaries_exist_test, +) +additional_dynamic_origins_do_not_affect_executable_origins_test = unittest.make( + _additional_dynamic_origins_do_not_affect_executable_origins_test, +) +additional_executable_origins_do_not_affect_dynamic_origins_test = unittest.make( + _additional_executable_origins_do_not_affect_dynamic_origins_test, +) +additional_origins_are_install_tree_relative_test = unittest.make( + _additional_origins_are_install_tree_relative_test, +) +additional_executable_origins_are_install_tree_relative_test = unittest.make( + _additional_executable_origins_are_install_tree_relative_test, +) +self_runtime_search_directories_are_disabled_by_default_test = unittest.make( + _self_runtime_search_directories_are_disabled_by_default_test, +) +self_runtime_search_directories_use_default_paths_test = unittest.make( + _self_runtime_search_directories_use_default_paths_test, +) +self_runtime_search_directories_use_custom_paths_test = unittest.make( + _self_runtime_search_directories_use_custom_paths_test, +) +self_runtime_search_directories_include_additional_dynamic_origins_test = unittest.make( + _self_runtime_search_directories_include_additional_dynamic_origins_test, +) +self_runtime_search_directories_respect_mode_test = unittest.make( + _self_runtime_search_directories_respect_mode_test, +) +auto_mode_uses_global_build_setting_test = analysistest.make( + _auto_mode_uses_global_build_setting_test, + config_settings = { + _RUNTIME_SEARCH_SETTING: "enabled", + }, +) +disabled_overrides_enabled_global_build_setting_test = analysistest.make( + _disabled_overrides_enabled_global_build_setting_test, + config_settings = { + _RUNTIME_SEARCH_SETTING: "enabled", + }, +) +runtime_search_directories_dedupe_dynamic_library_dirs_test = unittest.make( + _runtime_search_directories_dedupe_dynamic_library_dirs_test, +) +solib_dynamic_library_gets_output_and_sibling_rpaths_test = unittest.make( + _solib_dynamic_library_gets_output_and_sibling_rpaths_test, +) +non_solib_dynamic_library_gets_only_output_rpath_test = unittest.make( + _non_solib_dynamic_library_gets_only_output_rpath_test, +) +solib_path_without_directory_gets_only_output_rpath_test = unittest.make( + _solib_path_without_directory_gets_only_output_rpath_test, +) + +def runtime_library_search_directories_test_suite(name = "runtime_library_search_directories_test_suite"): + _runtime_search_enabled_subject( + name = name + "_auto_subject", + runtime_library_search_directories = "auto", + ) + _runtime_search_enabled_subject( + name = name + "_disabled_subject", + runtime_library_search_directories = "disabled", + ) + + unittest.suite( + name, + partial.make(default_dynamic_origin_only_when_out_shared_libs_exist_test, size = "small"), + partial.make(default_executable_origin_only_when_out_binaries_exist_test, size = "small"), + partial.make(additional_dynamic_origins_do_not_affect_executable_origins_test, size = "small"), + partial.make(additional_executable_origins_do_not_affect_dynamic_origins_test, size = "small"), + partial.make(additional_origins_are_install_tree_relative_test, size = "small"), + partial.make(additional_executable_origins_are_install_tree_relative_test, size = "small"), + partial.make(self_runtime_search_directories_are_disabled_by_default_test, size = "small"), + partial.make(self_runtime_search_directories_use_default_paths_test, size = "small"), + partial.make(self_runtime_search_directories_use_custom_paths_test, size = "small"), + partial.make(self_runtime_search_directories_include_additional_dynamic_origins_test, size = "small"), + partial.make(self_runtime_search_directories_respect_mode_test, size = "small"), + partial.make( + auto_mode_uses_global_build_setting_test, + size = "small", + target_under_test = ":" + name + "_auto_subject", + ), + partial.make( + disabled_overrides_enabled_global_build_setting_test, + size = "small", + target_under_test = ":" + name + "_disabled_subject", + ), + partial.make(runtime_search_directories_dedupe_dynamic_library_dirs_test, size = "small"), + partial.make(solib_dynamic_library_gets_output_and_sibling_rpaths_test, size = "small"), + partial.make(non_solib_dynamic_library_gets_only_output_rpath_test, size = "small"), + partial.make(solib_path_without_directory_gets_only_output_rpath_test, size = "small"), + ) diff --git a/toolchains/built_toolchains.bzl b/toolchains/built_toolchains.bzl index c4287e894..dfc13e12e 100644 --- a/toolchains/built_toolchains.bzl +++ b/toolchains/built_toolchains.bzl @@ -281,6 +281,8 @@ def _pkgconfig_toolchain(version, register_toolchains): http_archive, name = "glib_dev", build_file_content = ''' +load("@rules_cc//cc:defs.bzl", "cc_import") + cc_import( name = "glib_dev", hdrs = glob(["include/**"]), @@ -299,6 +301,8 @@ cc_import( http_archive, name = "glib_src", build_file_content = ''' +load("@rules_cc//cc:defs.bzl", "cc_import") + cc_import( name = "msvc_hdr", hdrs = ["msvc_recommended_pragmas.h"], @@ -339,6 +343,8 @@ exports_files( http_archive, name = "gettext_runtime", build_file_content = ''' +load("@rules_cc//cc:defs.bzl", "cc_import") + cc_import( name = "gettext_runtime", shared_library = "bin/libintl-8.dll",