diff --git a/docs/README.md b/docs/README.md index 8880007f..dffaaaa2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -101,7 +101,7 @@ Rule for building external library with CMake. | headers_only | __deprecated__: Use out_headers_only instead. | Boolean | optional | False | | install | If True, the cmake --install comand will be performed after a build | Boolean | optional | True | | install_args | Arguments for the CMake install command | List of strings | optional | [] | -| install_prefix | Relative install prefix to be passed to CMake in -DCMAKE_INSTALL_PREFIX | String | optional | "" | +| install_prefix | __deprecated__: This field is deprecated and is no longer used. | String | optional | "" | | interface_libraries | __deprecated__: Use out_interface_libs instead. | List of strings | optional | [] | | lib_name | Library name. Defines the name of the install directory and the name of the static library, if no output files parameters are defined (any of static_libraries, shared_libraries, interface_libraries, binaries_names) Optional. If not defined, defaults to the target's name. | String | optional | "" | | lib_source | Label with source code to build. Typically a filegroup for the source of remote repository. Mandatory. | Label | required | | diff --git a/examples/cmake_hello_world_variant/BUILD.bazel b/examples/cmake_hello_world_variant/BUILD.bazel deleted file mode 100644 index 53ca451a..00000000 --- a/examples/cmake_hello_world_variant/BUILD.bazel +++ /dev/null @@ -1,30 +0,0 @@ -load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") - -cmake( - name = "hello_world", - generate_args = ["-GNinja"], - lib_source = "@cmake_hello_world_variant_src//:all", - out_binaries = select({ - "//:macos": ["CMakeHelloWorld"], - "//:windows": ["CMakeHelloWorld.exe"], - "//conditions:default": ["CMakeHelloWorld"], - }), -) - -filegroup( - name = "binary", - srcs = [":hello_world"], - output_group = select({ - "//:macos": "CMakeHelloWorld", - "//:windows": "CMakeHelloWorld.exe", - "//conditions:default": "CMakeHelloWorld", - }), -) - -sh_test( - name = "test_hello_world", - srcs = ["test_hello_world.sh"], - args = ["$(location :binary)"], - data = [":binary"], - deps = ["@bazel_tools//tools/bash/runfiles"], -) diff --git a/examples/cmake_hello_world_variant/test_hello_world.sh b/examples/cmake_hello_world_variant/test_hello_world.sh deleted file mode 100755 index 1f575316..00000000 --- a/examples/cmake_hello_world_variant/test_hello_world.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -# --- begin runfiles.bash initialization --- -# The runfiles library itself defines rlocation which you would need to look -# up the library's runtime location, thus we have a chicken-and-egg problem. -# -# Copy-pasted from Bazel's Bash runfiles library (tools/bash/runfiles/runfiles.bash). -set -euo pipefail -if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then - if [[ -f "$0.runfiles_manifest" ]]; then - export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest" - elif [[ -f "$0.runfiles/MANIFEST" ]]; then - export RUNFILES_MANIFEST_FILE="$0.runfiles/MANIFEST" - elif [[ -f "$0.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then - export RUNFILES_DIR="$0.runfiles" - fi -fi -if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then - source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash" -elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then - source "$(grep -m1 "^bazel_tools/tools/bash/runfiles/runfiles.bash " \ - "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)" -else - echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash" - exit 1 -fi -# --- end runfiles.bash initialization --- - -$(rlocation $TEST_WORKSPACE/$1) diff --git a/examples/deps/repositories.bzl b/examples/deps/repositories.bzl index b45233da..7160f7f3 100644 --- a/examples/deps/repositories.bzl +++ b/examples/deps/repositories.bzl @@ -32,15 +32,3 @@ def repositories(): sha256 = RULES_JVM_EXTERNAL_SHA, url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, ) - - maybe( - http_archive, - name = "cmake_hello_world_variant_src", - build_file_content = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])""", - strip_prefix = "cmake-hello-world-master", - urls = [ - "https://mirror.bazel.build/github.com/jameskbride/cmake-hello-world/archive/master.zip", - "https://github.com/jameskbride/cmake-hello-world/archive/master.zip", - ], - sha256 = "d613cf222bbb05b8cff7a1c03c37345ed33744a4ebaf3a8bfd5f56a76e25ca08", - ) diff --git a/foreign_cc/cmake.bzl b/foreign_cc/cmake.bzl index caeb39d9..e781dcb7 100644 --- a/foreign_cc/cmake.bzl +++ b/foreign_cc/cmake.bzl @@ -50,7 +50,6 @@ def _cmake_impl(ctx): generate_args = generate_args, configure_name = "CMake", create_configure_script = _create_configure_script, - postfix_script = "##copy_dir_contents_to_dir## $$BUILD_TMPDIR$$/$$INSTALL_PREFIX$$ $$INSTALLDIR$$\n" + ctx.attr.postfix_script, tools_deps = tools_deps, cmake_path = cmake_data.path, ) @@ -117,14 +116,13 @@ def _create_configure_script(configureParameters): config = configuration, )) - define_install_prefix = ["export INSTALL_PREFIX=\"" + _get_install_prefix(ctx) + "\""] configure_script = create_cmake_script( workspace_name = ctx.workspace_name, generator = attrs.generator, cmake_path = attrs.cmake_path, tools = tools, flags = flags, - install_prefix = "$$INSTALL_PREFIX$$", + install_prefix = "$$INSTALLDIR$$", root = root, no_toolchain_file = no_toolchain_file, user_cache = dict(ctx.attr.cache_entries), @@ -134,7 +132,7 @@ def _create_configure_script(configureParameters): include_dirs = inputs.include_dirs, is_debug_mode = is_debug_mode(ctx), ) - return define_install_prefix + configure_script + return configure_script def _get_generator_target(ctx): """Parse the genrator arguments for a generator declaration @@ -206,13 +204,6 @@ def _get_generator_target(ctx): fail("`{}` is not a known generator".format(generator)) -def _get_install_prefix(ctx): - if ctx.attr.install_prefix: - return ctx.attr.install_prefix - if ctx.attr.lib_name: - return ctx.attr.lib_name - return ctx.attr.name - def _attrs(): attrs = dict(CC_EXTERNAL_RULE_ATTRIBUTES) attrs.update({ @@ -273,7 +264,7 @@ def _attrs(): mandatory = False, ), "install_prefix": attr.string( - doc = "Relative install prefix to be passed to CMake in `-DCMAKE_INSTALL_PREFIX`", + doc = "__deprecated__: This field is deprecated and is no longer used.", mandatory = False, ), "make_commands": attr.string_list(