Code Monkey home page Code Monkey logo

rules_foreign_cc's Introduction

rules_foreign_cc

Build status

Rules for building C/C++ projects using foreign build systems inside Bazel projects.

This is not an officially supported Google product (meaning, support and/or new releases may be limited.)

Documentation

Documentation for all rules and providers are available at: https://bazelbuild.github.io/rules_foreign_cc/

Bazel versions compatibility

Works with Bazel after 5.4.0.

Note that the rules may be compatible with older versions of Bazel but support may break in future changes as these older versions are not tested.

Note also that the runnable_binary macro requires bazel 5.4.0, for the rlocationpath path variable

News

For more generalized updates, please see NEWS.md or checkout the release notes of current or previous releases

Design document

External C/C++ libraries rules

Caveats

  • FreeBSD support is currently experimental and on a best-effort basis. Google currently doesn't have a CI test environment for FreeBSD, but please make your voice heard by upvoting this issue.

rules_foreign_cc's People

Contributors

al-tu avatar alexeagle avatar attilaolah avatar bcsgh avatar calebzulawski avatar cgrushko avatar dig-doug avatar djmarcin avatar dstufft avatar fmeum avatar fweikert avatar hlopko avatar illicitonion avatar irengrig avatar jheaff1 avatar jsharpe avatar jsun-splunk avatar keith avatar laszlocsomor avatar laurentlb avatar matt-sm avatar meteorcloudy avatar mishazharov avatar novas0x2a avatar philwo avatar sgowroji avatar slam avatar uebelandre avatar whs-dot-hk avatar xytan0056 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rules_foreign_cc's Issues

unable to find header file (written to BUILD_TMPDIR, never symlinked into subdirectory of execroot)

pretty sure this is a catkin-specific issue -

I'm trying to build an external Cmake package (roscpp) which contains the following directive:
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/ros/common.h.in ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION}/ros/common.h)

followed by:
include_directories(include ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION}/ros

CMAKE_CURRENT_SOURCE_DIR points to the relevant directory under execroot/main/external
CATKIN_DEVEL_PREFIX is $BUILD_TMPDIR/devel
CATKIN_GLOBAL_INCLUDE_DESTINATION is include

the build fails because cmake cannot find common.h, I assume because it is outside the sandbox and never symlinked in.

if I try updating the CATKIN_DEVEL_PREFIX (by specifying a value like $INSTALLDIR or $EXT_BUILD_DEPS in cache_entries) I get an Invalid cross-device link, which I assume has something to do with hardlinking in the sandbox.

I'm curious how to handle this issue, hoping you can lend your expertise! More generally, how can we handle these types of cmake directives (hardlinking a file outside the sandbox, then attempting it to add the file path to include directories for cmake to search?)

not all outputs were created or valid

Writing /tmp/tmp.MbivBdIFdS/catkin/lib/python2.7/dist-packages/catkin-0.7.14.egg-info
/home/brian/.cache/bazel/_bazel_brian/19fc196dfacab0a373352db9ae53e0f1/sandbox/linux-sandbox/1/execroot/__main__
ERROR: /home/brian/git/cloud/third_party/cmake/catkin/BUILD:7:1: output 'third_party/cmake/catkin/catkin/lib/catkin.a' was not created
ERROR: /home/brian/git/cloud/third_party/cmake/catkin/BUILD:7:1: not all outputs were created or valid

building catkin (https://github.com/ros/catkin/blob/kinetic-devel/CMakeLists.txt)

this is a question not an issue, not sure if there is a better forum to post. what are the cmake_external arguments I might need to set to resolve this issue?

thank you for your assistance

Build not working anymore

Hey, since the latest master i am getting this error:

ERROR: error loading package '': Extension file not found. Unable to load package for '//tools/build_defs:version.bzl': BUILD file not found on package path

My setup is identical to the one described in ReadMe.md. I am running on Bazel 19.2

Could not find compiler set in environment variable CXX

Setting and exporting the env variable CXX does not resolve the issue.

System info:
MacBook Pro (15-inch, 2017)
OS: High Sierra 10.13.1
Processor: 3.1 GHz Intel Core i7
Memory: 16 GB 2133 MHz LPDDR3

Error message:
ERROR: /Users/brian/cloud/roboflow/omg/BUILD:20:1: error executing shell command: 'set -e
export EXT_BUILD_ROOT=$(pwd)
source external/rules_foreign_cc/tools/build_defs/utils.sh
echo "Building external library 'pybind11'"
export TMPDIR=$(mktemp -d)
trap "{ rm -rf $TMPDIR; }" EXIT...' failed (Exit 1)
Building external library 'pybind11'
INSTALLDIR: "/private/var/tmp/_bazel_brian/773e68ba09138a3e0d933a215b2b78a9/sandbox/darwin-sandbox/1/execroot/main/bazel-out/darwin-fastbuild/genfiles/roboflow/omg/pybind11"
EXT_BUILD_DEPS: ""
EXT_BUILD_ROOT: "/private/var/tmp/_bazel_brian/773e68ba09138a3e0d933a215b2b78a9/sandbox/darwin-sandbox/1/execroot/main"
PATH: "/bin:/Users/brian/git/bazel/bazel-bin/src:/Users/brian/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/bin"
/var/folders/sg/_2yjj6v54lbckvqwr3jc4zdc0007t6/T/tmp.Vn8w1XYI /private/var/tmp/_bazel_brian/773e68ba09138a3e0d933a215b2b78a9/sandbox/darwin-sandbox/1/execroot/main
-- Configuring incomplete, errors occurred!
See also "/var/folders/sg/_2yjj6v54lbckvqwr3jc4zdc0007t6/T/tmp.Vn8w1XYI/CMakeFiles/CMakeOutput.log".
mktemp: illegal option -- -
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
mktemp [-d] [-q] [-u] -t prefix
CMake Error at /usr/local/Cellar/cmake/3.12.0/share/cmake/Modules/CMakeDetermineCXXCompiler.cmake:47 (message):
Could not find compiler set in environment variable CXX:

/private/var/tmp/_bazel_brian/773e68ba09138a3e0d933a215b2b78a9/sandbox/darwin-sandbox/1/execroot/main/external/local_config_cc/cc_wrapper.sh.

Call Stack (most recent call first):
CMakeLists.txt:19 (project)

CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
Target //roboflow/omg:omg failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.638s, Critical Path: 0.17s
INFO: 0 processes.

Linker flags passed to ar

I set up a build for openssl with

configure_make(
    name = "openssl",
    configure_command = "config",
    configure_options = [
        "no-shared",
    ],
    lib_source = "@com_github_openssl_openssl//:all",
    static_libraries = [
        "libcrypto.a",
        "libssl.a",
    ],
)

When I build with ASAN using bazel build --copt=-fsanitize=address --linkopt=-fsanitize=address //..., the linker flag --linkopt=-fsanitize=address gets pased to ar and the build fails with

/usr/bin/ar rcsD -fsanitize=address apps/libapps.a apps/app_rand.o apps/apps.o apps/bf_prefix.o apps/opt.o apps/s_cb.o apps/s_socket.o
/usr/bin/ar: invalid option -- 'n'

Could --linkopt's not be passed to ar as it won't understand the options you would use with ld?

sandbox builds search in non-existent directories

CMake Error at /blaze/a08c2e4811c846650b733c6fc815a920/sandbox/processwrapper-sandbox/1/execroot/__main__/bazel_foreign_cc_deps_rosgraph_msgs/cpp_common/share/cpp_common/cmake/cpp_commonConfig.cmake:113 (message):
  Project 'cpp_common' specifies
  '/blaze/a08c2e4811c846650b733c6fc815a920/sandbox/processwrapper-sandbox/12/execroot/__main__/bazel_foreign_cc_deps_cpp_common/boost/include'
  as an include dir, which is not found.  It does neither exist as an 
  absolute directory nor in '/tmp/tmp.COXdz1ZDYu/cpp_common//blaze/a08c2e4811c846650b733c6fc815a920/sandbox/processwrapper-sandbox/12/execroot/__main__/bazel_foreign_cc_deps_cpp_common/boost/include'.

the cpp_commonConfig.cmake does exist, but it is in processwrapper-sandbox/1/execroot/main/bazel_foreign_cc_deps_rosgraph_msgs/boost/include

if my understanding is correct, the config is being written to the appropriate location, but bazel is later searching in the wrong directory?

out.txt

outputs written outside CMAKE_PREFIX_PATH

CMake Warning at CMakeLists.txt:4 (find_package):
  By not providing "Findcatkin.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "catkin", but
  CMake did not find one.

  Could not find a package configuration file provided by "catkin" with any
  of the following names:

    catkinConfig.cmake
    catkin-config.cmake

  Add the installation prefix of "catkin" to CMAKE_PREFIX_PATH or set
  "catkin_DIR" to a directory containing one of the above files.  If "catkin"
  provides a separate development package or SDK, be sure it has been
  installed.

Can be resolved by adding something like cache_entries = {"CMAKE_PREFIX_PATH": "/workspace/.bazel/execroot/__main__/bazel-out/k8-fastbuild/genfiles/third_party/cmake/catkin/catkin"} to the target that depends on the target that generates the above files

Is it possible to write to /workspace/.bazel/sandbox/processwrapper-sandbox/1/execroot/__main__/bazel_foreign_cc_deps such that every dependent does not have to specify this cache_entries value?

BUILD:

package(default_visibility = ["//visibility:public"])

load("@rules_foreign_cc//tools/build_defs:cmake.bzl", "cmake_external")

filegroup(
    name = "example_src",
    srcs = glob(["src/**"]),
)

cmake_external(
        name = "example",
        lib_source = ":example_src",
        #cache_entries = {"CMAKE_PREFIX_PATH": "/workspace/.bazel/execroot/__main__/bazel-out/k8-fastbuild/genfiles/third_party/cmake/catkin/catkin"},
        deps = [":catkin"],
)

cmake_external( 
        name = "catkin",
        lib_source = "@catkin//:all",
        headers_only = True,
)

osx libtool paramater error

This seems to be related to #49 although I don't see a resolution in that issue. I am trying to compile on OSX 10.14.1 (18B75) Mojave with bazel 0.21 and am getting the following errors when I try to build libz from the examples:

error: /Library/Developer/CommandLineTools/usr/bin/libtool: no output file specified (specify with -o output)
Usage: /Library/Developer/CommandLineTools/usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT] [-no_warning_for_no_symbols]
Usage: /Library/Developer/CommandLineTools/usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table <filename>] [-seg_addr_table_filename <file_system_path>] [-all_load] [-noall_load]
make[2]: *** [lib/libopenblas.a] Error 1
make[1]: *** [CMakeFiles/openblas.dir/all] Error 2
make: *** [all] Error 2

Here is my command line:
bazel build //examples/cmake:libz

Any thoughts?

Improve code readability for collecting input dependencies

Link to the originally introduced place:

https://github.com/irengrig/rules_foreign_cc/blob/3889eb2ed21903b77c393912135c028aaedca217/tools/build_defs/framework.bzl#L455

code fragment:
`
for dep in attrs.deps:
external_deps = dep[ForeignCcDeps]

    linking_infos_all += [dep[CcLinkingInfo]]
    compilation_infos_all += [dep[CcCompilationInfo]]

    if external_deps:
        for artifact in external_deps.artifacts:
            if not ext_build_dirs_set.get(artifact.gen_dir):
                ext_build_dirs_set[artifact.gen_dir] = 1
                ext_build_dirs += [artifact.gen_dir]
    else:
        headers_info = _get_headers(dep[CcCompilationInfo])
        bazel_headers += headers_info.headers
        bazel_system_includes += headers_info.include_dirs
        bazel_libs += _collect_libs(dep[CcLinkingInfo])`

problem: there might be a better solution for creating a unique list, at least it can be expressed in code in a more elegant way.
Original review comment from #112

Also, put the comment explaning when the specific provider is available

boost build fails

Attaching the output here as a file (it's quite long), I suspect this part is the error:

./boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or directory

out.txt

_merge function not WAI

https://github.com/bazelbuild/rules_foreign_cc/blob/master/tools/build_defs/cmake_script.bzl#L178

If I were to add a cache_entry such as CMAKE_CXX_FLAGS, my builds will fail because the command passed to the compiler is invalid syntax. this is because the strip commands remove trailing quotations that are actually necessary.

for example, if I have CXXFLAGS="foo="bar"", and I add a cache_entry {CMAKE_CXX_FLAGS: "-Fbat}, this will yield CXXFLAGS="foo="bar -Fbat", which results in an unterminated quotation error when cmake is eventually called.

Just removing the "strip" calls worked for me, but I wanted to make sure there is not some other corner case where this would be problematic. If this is a reasonable fix, happy to submit a PR!

--action_env=PATH does not appear to import environment's PATH on MacOSX

I'm getting a failure when building https://github.com/envoyproxy/envoy with bazel on Mac OS X 10.13.6 of not being able to find "cmake". My cmake is installed in /opt/local/bin and when I symlink that (and ninja) to /usr/local/bin the build succeeds. This would seem to be a problem with the bazel restrictions recently put on the what bazel children can access (in order to make builds more reproducible) but in that case I would expect --action_env=PATH to succeed without the symlinks, and it does not.

I did some additional debugging by putting an "env" in a script at /usr/local/bin and running my build with --action_env=PATH and that had no effect on the path that was output from that script.

The attached zip archive contains four files:

  • reproduction.txt: Shell log of simply reproducing the problem in my default environment.
  • action-env-failure.txt: Demonstration that --action_env didn't do anything different.
  • symlink-success.txt: Demonstration that linking ninja & cmake into /usr/local/bin allowed compilation.
  • env-dump.txt: Dump of the environmental variables present when doing a default run.
  • env-dump-aciton-env.txt (sic): Running with the above env dump script with --action_env.

Please let me know if there's more debugging I can do to help you get to the root of htis problem.

bazel-bug.zip

ranlib issues with custom toolchains

Currently rules_foreign_cc pulls the linker from cc_common. In some cmake builds, such as c-ares and libevent, their cmake build systems end up calling ranlib directly, which isn't propagated to cmake, and therefore ends up pulling the system one, which results in issues when you're cross compiling and the system's ranlib isn't compatible with the library it's being run on.

As far as I can tell there isn't a action name that translates to ranlib. In the 2 examples above, disabling ranlib all together by setting CMAKE_RANLIB: "" in cache_entries works, but is probably pretty risky.

Does anyone have any idea how we can correctly pass ranlib through to cmake when it needs it, to not fall back on the system one?

This is kinda related to #185 I think

feature request: additional_deps attribute

Use case: I am building ROS packages using bazel. The default build tool, catkin (which is really just CMake syntactic sugar) has a macro (catkin_package) including a field CATKIN_DEPENDS which declares additional packages which dependent packages must depend on.

AFAIK there is no way to replicate this functionality with the existing cmake_external rule, nor is it straightforward to accomplish with a macro (or a custom rule that wraps cmake_external).

This feature request is for a new attribute additional_deps which accepts a list of targets, such that if A depends on B, and B has nonempty additional_deps, the additional_deps of B will be added to A's deps.

cross_compiling opencv with CMAKE on OSX

I'm trying to cross compile opencv on OSX to arm with cmake (normal compile works). It tries to make a test program and then use the results to test the compiler, but make doesn't exist. This is the same for generate_crosstool_file is True or false.

CMake Error at /usr/local/Cellar/cmake/3.12.2/share/cmake/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/var/tmp/_bazel_pweaver/71d0419a9087e644b4b0b7d44c342517/sandbox/darwin-sandbox/1/execroot/__main__/external/local_config_cc/wrapped_clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /var/folders/zg/r56_bp193gsc44tdmhmbjbzw0000gn/T/tmp.24IWHpsD/CMakeFiles/CMakeTmp

    Run Build Command:"/usr/bin/make" "cmTC_23de2/fast"
    make: error: unable to find utility "make", not a developer tool or in PATH

builds completing successfully when they should not

when I upgraded to the most recent commit, all of my builds suddenly started passing. for example, I can remove all the deps of a given target, and the build will pass, even though those deps are hard requirements of the given package.

to reproduce this issue, try building the eigen example and commenting out the openblas dependency.

@irengrig

Example Request: LLVM

LLVM is a big CMake only dependency for many C++ projects (e.g. Tensorflow). It would be awesome if it could be explicitly supported as an example.

Thanks for the awesome work on this library!

Don't set --prefix to a subdirectory of where you're building.

I'm building apache with configure_make. The config log shows that the prefix is set to tmp/tmp.jocLKX7QSG/./httpd

configure: summary of build options:

    Server Version: 2.4.38
    Install prefix: /tmp/tmp.jocLKX7QSG/./httpd

But the project is building in /tmp/tmp.jocLKX7QSG/ and already generates an httpd dir as part of the build, so it fails later with

mkdir /tmp/tmp.jocLKX7QSG/./httpd
mkdir: cannot create directory '/tmp/tmp.jocLKX7QSG/./httpd': File exists

I was able to work around this by changing the name attribute to something other than httpd, but it would be much better to keep the installation directory totally separate from the build directory so there's no possibility of clashing.

Copts attribute?

Looking through the documentation for generating CMake targets, I don't see a way to pass in copts. Ideally I'd like to call these functions from a wrapper function around cc_library and cc_test so we don't have to change our BUILD files to get our generated CMake. Am I missing how to do this?

[low priority] reduce debug output on clean cmake builds

Here is a clean build for Envoy with the new foreign cmake rules:

It would be great if in the common clean case there was no/minimal debug output, but additional output could be required via a debug flag.

cc @htuch

/opt/slickedit-pro2018/bin/vsbuild -signal 43437 -command build_envoy.sh
 VSLICKERRORPATH=/home/mklein/Source/envoy
build_envoy.sh 
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
/home/mklein/Source/envoy/tools/bazel.rc
INFO: Invocation ID: 54d8e913-3007-4d83-8253-256f4172cdec
INFO: Reading 'startup' options from /home/mklein/Source/envoy/.bazelrc: --host_jvm_args=-Xmx512m
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=0 --terminal_columns=80
INFO: Reading rc options for 'build' from /home/mklein/Source/envoy/.bazelrc:
  'build' options: --workspace_status_command=bazel/get_workspace_status
INFO: Reading rc options for 'build' from /home/mklein/.bazelrc:
  'build' options: --action_env=CXX=clang++-7 --action_env=CC=clang-7 --experimental_strict_action_env=true --linkopt=-fuse-ld=lld-7 --announce_rc
Loading: 
Loading: 0 packages loaded
Analyzing: 9 targets (0 packages loaded, 0 targets configured)
DEBUG: /home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/foreign_cc_impl/framework.bzl:269:5: script text: function cleanup_function() {
  local ecode=$?
  if [ $ecode -eq 0 ]; then
  printf "$CLEANUP_MSG"
  rm -rf $BUILD_TMPDIR $EXT_BUILD_DEPS
  else
  printf ""
  printf "$KEEP_MSG"
  printf ""
  fi
}
function children_to_path() {
  if [ -d $EXT_BUILD_DEPS/bin ]; then
    local tools=$(find $EXT_BUILD_DEPS/bin -maxdepth 1 -mindepth 1)
    for tool in $tools;
    do
      if  [[ -d "$tool" ]] || [[ -L "$tool" ]]; then
        export PATH=$PATH:$tool
      fi
    done
  fi
}
function replace_in_files() {
  if [ -d "$1" ]; then
    find -L $1 -print -type f   \( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.cmake" \)   -exec sed -i 's@'"$2"'@'"$3"'@g' {} ';'
  fi
}
printf ""
printf "Bazel external C/C++ Rules #0.0.6. Building library 'event'"
printf ""
set -e

export EXT_BUILD_ROOT=$(pwd)
export BUILD_TMPDIR=$(mktemp -d)
export EXT_BUILD_DEPS=$EXT_BUILD_ROOT/bazel_foreign_cc_deps_event
export INSTALLDIR=$EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/event
export PATH="$EXT_BUILD_ROOT:$PATH"
mkdir -p $EXT_BUILD_DEPS
mkdir -p $INSTALLDIR
printf "Environment:______________"
env
printf "__________________________"
export CLEANUP_MSG="rules_foreign_cc: Cleaning temp directories"
export KEEP_MSG="rules_foreign_cc: Keeping temp build directory $BUILD_TMPDIR and dependencies directory $EXT_BUILD_DEPS for debug.\nrules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify '--sandbox_debug' Bazel command line flag."
trap "cleanup_function" EXIT
children_to_path $EXT_BUILD_DEPS/bin
export PATH="$EXT_BUILD_DEPS/bin:$PATH"
replace_in_files $EXT_BUILD_DEPS BAZEL_GEN_ROOT $EXT_BUILD_DEPS
cd $BUILD_TMPDIR
export INSTALL_PREFIX="./event"
CC="/home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/local_config_cc/extra_tools/envoy_cc_wrapper" CXX="/home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/local_config_cc/extra_tools/envoy_cc_wrapper" CFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" CXXFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -std=c++0x -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" ASMFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" cmake -DCMAKE_AR="/usr/bin/ar" -DCMAKE_SHARED_LINKER_FLAGS="-shared -fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -lstdc++ -lm -fuse-ld=lld-7" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -lstdc++ -lm -fuse-ld=lld-7" -DEVENT__DISABLE_OPENSSL="on" -DEVENT__DISABLE_REGRESS="on" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_PREFIX_PATH="$EXT_BUILD_DEPS" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" -GNinja $EXT_BUILD_ROOT/external/com_github_libevent_libevent
ninja
ninja install
cp -L -r --no-target-directory "$BUILD_TMPDIR/$INSTALL_PREFIX" "$INSTALLDIR" 
replace_in_files $INSTALLDIR $BUILD_TMPDIR BAZEL_GEN_ROOT
replace_in_files $INSTALLDIR $EXT_BUILD_DEPS BAZEL_GEN_ROOT
mkdir -p $EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/copy_event/event
cp -L -r --no-target-directory "$INSTALLDIR" "$EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/copy_event/event" 
touch $EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/empty_event.txt
cd $EXT_BUILD_ROOT
DEBUG: /home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/foreign_cc_impl/framework.bzl:269:5: script text: function cleanup_function() {
  local ecode=$?
  if [ $ecode -eq 0 ]; then
  printf "$CLEANUP_MSG"
  rm -rf $BUILD_TMPDIR $EXT_BUILD_DEPS
  else
  printf ""
  printf "$KEEP_MSG"
  printf ""
  fi
}
function children_to_path() {
  if [ -d $EXT_BUILD_DEPS/bin ]; then
    local tools=$(find $EXT_BUILD_DEPS/bin -maxdepth 1 -mindepth 1)
    for tool in $tools;
    do
      if  [[ -d "$tool" ]] || [[ -L "$tool" ]]; then
        export PATH=$PATH:$tool
      fi
    done
  fi
}
function replace_in_files() {
  if [ -d "$1" ]; then
    find -L $1 -print -type f   \( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.cmake" \)   -exec sed -i 's@'"$2"'@'"$3"'@g' {} ';'
  fi
}
printf ""
printf "Bazel external C/C++ Rules #0.0.6. Building library 'yaml'"
printf ""
set -e

export EXT_BUILD_ROOT=$(pwd)
export BUILD_TMPDIR=$(mktemp -d)
export EXT_BUILD_DEPS=$EXT_BUILD_ROOT/bazel_foreign_cc_deps_yaml
export INSTALLDIR=$EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/yaml
export PATH="$EXT_BUILD_ROOT:$PATH"
mkdir -p $EXT_BUILD_DEPS
mkdir -p $INSTALLDIR
printf "Environment:______________"
env
printf "__________________________"
export CLEANUP_MSG="rules_foreign_cc: Cleaning temp directories"
export KEEP_MSG="rules_foreign_cc: Keeping temp build directory $BUILD_TMPDIR and dependencies directory $EXT_BUILD_DEPS for debug.\nrules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify '--sandbox_debug' Bazel command line flag."
trap "cleanup_function" EXIT
children_to_path $EXT_BUILD_DEPS/bin
export PATH="$EXT_BUILD_DEPS/bin:$PATH"
replace_in_files $EXT_BUILD_DEPS BAZEL_GEN_ROOT $EXT_BUILD_DEPS
cd $BUILD_TMPDIR
export INSTALL_PREFIX="./yaml"
CC="/home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/local_config_cc/extra_tools/envoy_cc_wrapper" CXX="/home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/local_config_cc/extra_tools/envoy_cc_wrapper" CFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" CXXFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -std=c++0x -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" ASMFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" cmake -DCMAKE_AR="/usr/bin/ar" -DCMAKE_SHARED_LINKER_FLAGS="-shared -fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -lstdc++ -lm -fuse-ld=lld-7" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -lstdc++ -lm -fuse-ld=lld-7" -DYAML_CPP_BUILD_TESTS="off" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_PREFIX_PATH="$EXT_BUILD_DEPS" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" -GNinja $EXT_BUILD_ROOT/external/com_github_jbeder_yaml_cpp
ninja
ninja install
cp -L -r --no-target-directory "$BUILD_TMPDIR/$INSTALL_PREFIX" "$INSTALLDIR" 
replace_in_files $INSTALLDIR $BUILD_TMPDIR BAZEL_GEN_ROOT
replace_in_files $INSTALLDIR $EXT_BUILD_DEPS BAZEL_GEN_ROOT
mkdir -p $EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/copy_yaml/yaml
cp -L -r --no-target-directory "$INSTALLDIR" "$EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/copy_yaml/yaml" 
touch $EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/empty_yaml.txt
cd $EXT_BUILD_ROOT
DEBUG: /home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/foreign_cc_impl/framework.bzl:269:5: script text: function cleanup_function() {
  local ecode=$?
  if [ $ecode -eq 0 ]; then
  printf "$CLEANUP_MSG"
  rm -rf $BUILD_TMPDIR $EXT_BUILD_DEPS
  else
  printf ""
  printf "$KEEP_MSG"
  printf ""
  fi
}
function children_to_path() {
  if [ -d $EXT_BUILD_DEPS/bin ]; then
    local tools=$(find $EXT_BUILD_DEPS/bin -maxdepth 1 -mindepth 1)
    for tool in $tools;
    do
      if  [[ -d "$tool" ]] || [[ -L "$tool" ]]; then
        export PATH=$PATH:$tool
      fi
    done
  fi
}
function replace_in_files() {
  if [ -d "$1" ]; then
    find -L $1 -print -type f   \( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.cmake" \)   -exec sed -i 's@'"$2"'@'"$3"'@g' {} ';'
  fi
}
printf ""
printf "Bazel external C/C++ Rules #0.0.6. Building library 'ares'"
printf ""
set -e

export EXT_BUILD_ROOT=$(pwd)
export BUILD_TMPDIR=$(mktemp -d)
export EXT_BUILD_DEPS=$EXT_BUILD_ROOT/bazel_foreign_cc_deps_ares
export INSTALLDIR=$EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/ares
export PATH="$EXT_BUILD_ROOT:$PATH"
mkdir -p $EXT_BUILD_DEPS
mkdir -p $INSTALLDIR
printf "Environment:______________"
env
printf "__________________________"
export CLEANUP_MSG="rules_foreign_cc: Cleaning temp directories"
export KEEP_MSG="rules_foreign_cc: Keeping temp build directory $BUILD_TMPDIR and dependencies directory $EXT_BUILD_DEPS for debug.\nrules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify '--sandbox_debug' Bazel command line flag."
trap "cleanup_function" EXIT
children_to_path $EXT_BUILD_DEPS/bin
export PATH="$EXT_BUILD_DEPS/bin:$PATH"
replace_in_files $EXT_BUILD_DEPS BAZEL_GEN_ROOT $EXT_BUILD_DEPS
cd $BUILD_TMPDIR
export INSTALL_PREFIX="./ares"
CC="/home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/local_config_cc/extra_tools/envoy_cc_wrapper" CXX="/home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/local_config_cc/extra_tools/envoy_cc_wrapper" CFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" CXXFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -std=c++0x -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" ASMFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" cmake -DCMAKE_AR="/usr/bin/ar" -DCMAKE_SHARED_LINKER_FLAGS="-shared -fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -lstdc++ -lm -fuse-ld=lld-7" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -lstdc++ -lm -fuse-ld=lld-7" -DCARES_SHARED="no" -DCARES_STATIC="on" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_PREFIX_PATH="$EXT_BUILD_DEPS" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" -GNinja $EXT_BUILD_ROOT/external/com_github_c_ares_c_ares
ninja
ninja install
cp -L -r --no-target-directory "$BUILD_TMPDIR/$INSTALL_PREFIX" "$INSTALLDIR" 
replace_in_files $INSTALLDIR $BUILD_TMPDIR BAZEL_GEN_ROOT
replace_in_files $INSTALLDIR $EXT_BUILD_DEPS BAZEL_GEN_ROOT
mkdir -p $EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/copy_ares/ares
cp -L -r --no-target-directory "$INSTALLDIR" "$EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/copy_ares/ares" 
touch $EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/empty_ares.txt
cd $EXT_BUILD_ROOT
DEBUG: /home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/foreign_cc_impl/framework.bzl:269:5: script text: function cleanup_function() {
  local ecode=$?
  if [ $ecode -eq 0 ]; then
  printf "$CLEANUP_MSG"
  rm -rf $BUILD_TMPDIR $EXT_BUILD_DEPS
  else
  printf ""
  printf "$KEEP_MSG"
  printf ""
  fi
}
function children_to_path() {
  if [ -d $EXT_BUILD_DEPS/bin ]; then
    local tools=$(find $EXT_BUILD_DEPS/bin -maxdepth 1 -mindepth 1)
    for tool in $tools;
    do
      if  [[ -d "$tool" ]] || [[ -L "$tool" ]]; then
        export PATH=$PATH:$tool
      fi
    done
  fi
}
function replace_in_files() {
  if [ -d "$1" ]; then
    find -L $1 -print -type f   \( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.cmake" \)   -exec sed -i 's@'"$2"'@'"$3"'@g' {} ';'
  fi
}
printf ""
printf "Bazel external C/C++ Rules #0.0.6. Building library 'nghttp2'"
printf ""
set -e

export EXT_BUILD_ROOT=$(pwd)
export BUILD_TMPDIR=$(mktemp -d)
export EXT_BUILD_DEPS=$EXT_BUILD_ROOT/bazel_foreign_cc_deps_nghttp2
export INSTALLDIR=$EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/nghttp2
export PATH="$EXT_BUILD_ROOT:$PATH"
mkdir -p $EXT_BUILD_DEPS
mkdir -p $INSTALLDIR
printf "Environment:______________"
env
printf "__________________________"
export CLEANUP_MSG="rules_foreign_cc: Cleaning temp directories"
export KEEP_MSG="rules_foreign_cc: Keeping temp build directory $BUILD_TMPDIR and dependencies directory $EXT_BUILD_DEPS for debug.\nrules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify '--sandbox_debug' Bazel command line flag."
trap "cleanup_function" EXIT
children_to_path $EXT_BUILD_DEPS/bin
export PATH="$EXT_BUILD_DEPS/bin:$PATH"
replace_in_files $EXT_BUILD_DEPS BAZEL_GEN_ROOT $EXT_BUILD_DEPS
cd $BUILD_TMPDIR
export INSTALL_PREFIX="./nghttp2"
CC="/home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/local_config_cc/extra_tools/envoy_cc_wrapper" CXX="/home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/local_config_cc/extra_tools/envoy_cc_wrapper" CFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" CXXFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -std=c++0x -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" ASMFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" cmake -DCMAKE_AR="/usr/bin/ar" -DCMAKE_SHARED_LINKER_FLAGS="-shared -fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -lstdc++ -lm -fuse-ld=lld-7" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -lstdc++ -lm -fuse-ld=lld-7" -DENABLE_STATIC_LIB="on" -DENABLE_LIB_ONLY="on" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_PREFIX_PATH="$EXT_BUILD_DEPS" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" -GNinja $EXT_BUILD_ROOT/external/com_github_nghttp2_nghttp2
ninja
ninja install
cp -L -r --no-target-directory "$BUILD_TMPDIR/$INSTALL_PREFIX" "$INSTALLDIR" 
replace_in_files $INSTALLDIR $BUILD_TMPDIR BAZEL_GEN_ROOT
replace_in_files $INSTALLDIR $EXT_BUILD_DEPS BAZEL_GEN_ROOT
mkdir -p $EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/copy_nghttp2/nghttp2
cp -L -r --no-target-directory "$INSTALLDIR" "$EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/copy_nghttp2/nghttp2" 
touch $EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/empty_nghttp2.txt
cd $EXT_BUILD_ROOT
DEBUG: /home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/foreign_cc_impl/framework.bzl:269:5: script text: function cleanup_function() {
  local ecode=$?
  if [ $ecode -eq 0 ]; then
  printf "$CLEANUP_MSG"
  rm -rf $BUILD_TMPDIR $EXT_BUILD_DEPS
  else
  printf ""
  printf "$KEEP_MSG"
  printf ""
  fi
}
function children_to_path() {
  if [ -d $EXT_BUILD_DEPS/bin ]; then
    local tools=$(find $EXT_BUILD_DEPS/bin -maxdepth 1 -mindepth 1)
    for tool in $tools;
    do
      if  [[ -d "$tool" ]] || [[ -L "$tool" ]]; then
        export PATH=$PATH:$tool
      fi
    done
  fi
}
function replace_in_files() {
  if [ -d "$1" ]; then
    find -L $1 -print -type f   \( -name "*.pc" -or -name "*.la" -or -name "*-config" -or -name "*.cmake" \)   -exec sed -i 's@'"$2"'@'"$3"'@g' {} ';'
  fi
}
printf ""
printf "Bazel external C/C++ Rules #0.0.6. Building library 'zlib'"
printf ""
set -e

export EXT_BUILD_ROOT=$(pwd)
export BUILD_TMPDIR=$(mktemp -d)
export EXT_BUILD_DEPS=$EXT_BUILD_ROOT/bazel_foreign_cc_deps_zlib
export INSTALLDIR=$EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/zlib
export PATH="$EXT_BUILD_ROOT:$PATH"
mkdir -p $EXT_BUILD_DEPS
mkdir -p $INSTALLDIR
printf "Environment:______________"
env
printf "__________________________"
export CLEANUP_MSG="rules_foreign_cc: Cleaning temp directories"
export KEEP_MSG="rules_foreign_cc: Keeping temp build directory $BUILD_TMPDIR and dependencies directory $EXT_BUILD_DEPS for debug.\nrules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify '--sandbox_debug' Bazel command line flag."
trap "cleanup_function" EXIT
children_to_path $EXT_BUILD_DEPS/bin
export PATH="$EXT_BUILD_DEPS/bin:$PATH"
replace_in_files $EXT_BUILD_DEPS BAZEL_GEN_ROOT $EXT_BUILD_DEPS
cd $BUILD_TMPDIR
export INSTALL_PREFIX="./zlib"
CC="/home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/local_config_cc/extra_tools/envoy_cc_wrapper" CXX="/home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/local_config_cc/extra_tools/envoy_cc_wrapper" CFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" CXXFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -std=c++0x -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" ASMFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fcolor-diagnostics -fno-omit-frame-pointer -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=\"redacted\" -D__TIMESTAMP__=\"redacted\" -D__TIME__=\"redacted\"" cmake -DCMAKE_AR="/usr/bin/ar" -DCMAKE_SHARED_LINKER_FLAGS="-shared -fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -lstdc++ -lm -fuse-ld=lld-7" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -lstdc++ -lm -fuse-ld=lld-7" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_PREFIX_PATH="$EXT_BUILD_DEPS" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" -GNinja $EXT_BUILD_ROOT/external/com_github_madler_zlib
ninja
ninja install
cp -L -r --no-target-directory "$BUILD_TMPDIR/$INSTALL_PREFIX" "$INSTALLDIR" 
replace_in_files $INSTALLDIR $BUILD_TMPDIR BAZEL_GEN_ROOT
replace_in_files $INSTALLDIR $EXT_BUILD_DEPS BAZEL_GEN_ROOT
mkdir -p $EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/copy_zlib/zlib
cp -L -r --no-target-directory "$INSTALLDIR" "$EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/copy_zlib/zlib" 
touch $EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/bazel/foreign_cc/empty_zlib.txt
cd $EXT_BUILD_ROOT
DEBUG: /home/mklein/Source/envoy/bazel/repositories.bzl:89:5: Fetching external dependencies...
DEBUG: /home/mklein/Source/envoy/bazel/repositories.bzl:95:5: 
DEBUG: /home/mklein/Source/envoy/bazel/repositories.bzl:96:5: External dependency cache directory /home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/envoy_deps_cache_98bb5acb9d3b3dd417aa7cbace7d01e9
make: Entering directory '/home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/envoy_deps'
No need to rebuild /home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/envoy_deps_cache_98bb5acb9d3b3dd417aa7cbace7d01e9/gperftools.dep.env
No need to rebuild /home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/envoy_deps_cache_98bb5acb9d3b3dd417aa7cbace7d01e9/luajit.dep.env
make: Leaving directory '/home/mklein/.cache/bazel/_bazel_mklein/0eed830f48870bc411befee27d7940f5/external/envoy_deps'

real	0m0.112s
user	0m0.012s
sys	0m0.001s
DEBUG: /home/mklein/Source/envoy/bazel/repositories.bzl:97:5: External dep build exited with return code: 0
INFO: Analysed 9 targets (0 packages loaded, 0 targets configured).
INFO: Found 9 targets...
[0 / 1] [-----] BazelWorkspaceStatusAction stable-status.txt
INFO: Elapsed time: 0.216s, Critical Path: 0.04s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
[SE mklein@localhost envoy]$ 

executable rule?

Hi,

First, thanks for doing this rule, it's definitely an improvement over our previous pipeline!

When trying to build libjpeg-turbo, I found out that I needed nasm.
I then found out that while I could build nasm (after adding a macro to patch bazel's ?), I had no easy way to use the result of the configure_make as a binary, and had to hack it with a genrule. It works, but I'm not sure if I'm doing this the right way (I couldn't find a way to make the output of configure_make executable).

Would it be possible to, say, if there is only one entry in "binaries", make these rules executable?

Thanks !

For those who are interested, here is what I ended up doing.
BUILD

load("@rules_foreign_cc//tools/build_defs:configure.bzl", "configure_make")

configure_make(
    name = "nasm_build",
    # nasm contains a macro __DATE__ which would cause the build to be not reproducible
    # bazel replace these macro with 'redacted'.
    # Somehow, it would have been remplaced in this library without quote, so we'll add another
    # macro to add the quotes.
    configure_options = ["CFLAGS='-Dredacted=\"redacted\"'"],
    lib_source = "@nasm_src//:all",
    out_bin_dir = "bin",
    binaries = ["nasm"],
)

genrule(
    name = "nasm",
    srcs = ["//:nasm_build"],
    outs = ["nasm"],
    cmd = "cp `ls $(locations //:nasm_build) | grep /bin/nasm$$` $(@)",
    executable = True,
)

configure_make(
    name = "libjpeg_turbo",
    configure_options = ["--with-jpeg8"],
    lib_source = "@libjpeg_turbo_src//:all",
    out_lib_dir = "lib",
    static_libraries = ["libjpeg.a"],
    tools_deps = ["//:nasm"],
)

with the workspace

http_archive(
    name = "nasm_src",
    build_file_content = all_content,
    strip_prefix = "nasm-2.14.02",
    urls = ["http://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.xz"],
)

http_archive(
   name = "libjpeg_turbo_src",
   build_file_content = all_content,
   strip_prefix = "libjpeg-turbo-1.5.2",
   urls = ["http://downloads.sourceforge.net/libjpeg-turbo/libjpeg-turbo-1.5.2.tar.gz"],
)

Permit __DATE__, __TIME__, etc in foreign builds

I'm using configure_make with apache and get this error

<command-line>:0:10: error: 'redacted' undeclared here (not in a function); did you mean 'rename'?
/root/.cache/bazel/_bazel_root/f8087e59fd95af1ae29e8fcb7ff1a3dc/sandbox/linux-sandbox/5/execroot/apache_bazel_example/external/org_apache_httpd/server/buildmark.c:21:36: note: in expansion of macro '__DATE__'
 static const char server_built[] = __DATE__ " " __TIME__;

because of the options

-Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted"

Could those be disabled by default for these external builds?

extra steps required when using these rules in a separate repo

Needed to perform the following steps (not outlined in README) to get this to work:

  1. define all_content variable
  2. add bazel_skylib http_archive, rules_foreign_cc git_repository in WORKSPACE
  3. load("@rules_foreign_cc//tools/build_defs:cmake.bzl", "cmake_external")
  4. Use the flag --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs

Would be happy to contribute just unsure of intended behavior.

Very excited about this functionality, thank you for contributing to open source :D

Shared library dependencies aren't properly handled

I'm setting up configure_build with something like the following:

configure_make(
    name = "pcre",
    lib_source = "@org_pcre//:all",
    static_libraries = ["libpcre.a"],
    shared_libraries = ["libpcre.so.1"],
)

configure_make(
    name = "apache_httpd",
    configure_options = [
        "--with-apr=$EXT_BUILD_DEPS/apr",
        "--with-apr-util=$EXT_BUILD_DEPS/apr_util",
        "--with-pcre=$EXT_BUILD_DEPS/pcre",
    ],
    lib_source = "@org_apache_httpd//:all",
    binaries = [
        "httpd",
    ],
    deps = [
        ":apr",
        ":apr_util",
        ":pcre",
    ],
    visibility = [
        "//visibility:public",
    ],
)

If I then create a small test script that runs apache_httpd/bin/httpd -h

filegroup(
    name = "httpd_binary",
    srcs = [
        ":apache_httpd",
    ],

)

sh_test(
    name = "t",
    srcs = [
        "t.sh",
    ],
    data = [
        ":httpd_binary",
        ":apr",
        ":apr_util",
        ":pcre",
    ],
)

I get this error when it runs:

apache_httpd/bin/httpd: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

Fix cc_library dependencies

Currently, adding a cc_library as a dependency to a cmake_external target results in an error:

File "/home/schoppmp/.cache/bazel/_bazel_schoppmp/8789c298ba24e10c10d14ed722cfe2d9/external/rules_foreign_cc/tools/build_defs/cmake.bzl", line 47, in _cmake_external
		cc_external_rule_impl(ctx, attrs)
	File "/home/schoppmp/.cache/bazel/_bazel_schoppmp/8789c298ba24e10c10d14ed722cfe2d9/external/foreign_cc_impl/framework.bzl", line 207, in cc_external_rule_impl
		_define_inputs(attrs)
	File "/home/schoppmp/.cache/bazel/_bazel_schoppmp/8789c298ba24e10c10d14ed722cfe2d9/external/foreign_cc_impl/framework.bzl", line 566, in _define_inputs
		_collect_libs(dep[CcInfo].linking_context)
	File "/home/schoppmp/.cache/bazel/_bazel_schoppmp/8789c298ba24e10c10d14ed722cfe2d9/external/foreign_cc_impl/framework.bzl", line 648, in _collect_libs
		_extract_link_params(cc_linking)
	File "/home/schoppmp/.cache/bazel/_bazel_schoppmp/8789c298ba24e10c10d14ed722cfe2d9/external/foreign_cc_impl/framework.bzl", line 640, in _extract_link_params
		cc_linking.static_mode_params_for_dynamic_library
object of type 'CcLinkingContext' has no field 'static_mode_params_for_dynamic_library'.

I tried fixing that here, but I'm not sure that's all that's needed. Is there an easy way to add a test case for this?

Context: I have a cmake dependency that needs Boost and OpenSSL. I want to use nelhage/rules_boost to compile Boost using Bazel, and Boringssl instead of OpenSSL. Compiling either with Bazel works fine, but adding the resulting libraries as dependencies to my cmake_external target breaks as described above. I know there is a way to compile Boost libraries using rules_foreign_cc, but even if I were to switch to that, it doesn't work for Boringssl.

QEMU build fails

load("@rules_foreign_cc//tools/build_defs:configure.bzl", "configure_make")

licenses(["restricted"])  # GPL
exports_files(["LICENSE"])

filegroup(
	name = "all", 
	srcs = glob(["**"]), 
	visibility = ["//visibility:public"],
)

configure_make(
    name = "qemu",
    lib_source = ":all",
    configure_options = [
        "--enable-debug",
        "--target-list=x86_64-softmmu",
    ],
    out_bin_dir = "qemu",
    binaries = ["bin/qemu-system-x86_64"],
)
ERROR: qemu/BUILD:12:1: in configure_make rule //third_party/qemu:qemu: 
Traceback (most recent call last):
	File "qemu/BUILD", line 12
		configure_make(name = 'qemu')
	File ".cache/bazel/_bazel_kayab/21035df2e517bca2eb66693e8b13ea02/external/rules_foreign_cc/tools/build_defs/configure.bzl", line 29, in _configure_make
		cc_external_rule_impl(ctx, attrs)
	File "cache/bazel/_bazel_kayab/21035df2e517bca2eb66693e8b13ea02/external/rules_foreign_cc/tools/build_defs/framework.bzl", line 192, in cc_external_rule_impl
		_define_outputs(ctx, attrs, lib_name)
	File ".cache/bazel/_bazel_kayab/21035df2e517bca2eb66693e8b13ea02/external/rules_foreign_cc/tools/build_defs/framework.bzl", line 383, in _define_outputs
		_declare_out(ctx, lib_name, attrs.out_bin_dir, file)
	File ".cache/bazel/_bazel_kayab/21035df2e517bca2eb66693e8b13ea02/external/rules_foreign_cc/tools/build_defs/framework.bzl", line 411, in _declare_out
		ctx.actions.declare_file("/".join([lib_name, dir.basename...]))
	File ".cache/bazel/_bazel_kayab/21035df2e517bca2eb66693e8b13ea02/external/rules_foreign_cc/tools/build_defs/framework.bzl", line 411, in ctx.actions.declare_file
		"/".join([lib_name, dir.basename, file])
	File ".cache/bazel/_bazel_kayab/21035df2e517bca2eb66693e8b13ea02/external/rules_foreign_cc/tools/build_defs/framework.bzl", line 411, in "/".join
		dir.basename
object of type 'string' has no field 'basename'

This error occurs with and without supplying out_bin_dir.

cmake: Permit consuming target transitive dependencies (possibly modern CMake interfaces)?

Is it possible to have cmake_external (or some other target) support consuming transitive deps of a target? If possible, can it be taught to consume CMake Interface Libraries?

I tinkered with a version of cmake_external, but couldn't make it work for my intended use case, which is to consume the includes + libs of CMake targets. My hack-and-slash attempt (coupled with Python bits - sorry for the mess!):

ros2_bazel_prototype:

More background: colcon/colcon-bazel#14

Failure on `boost_build` compilations.

The latest refactor to add shell_toolchain appears to be causing problems on boost_build compilations. The following is the result of building using the current master.

Source repo: https://github.com/psigen/rules_foreign_cc_example

$ bazel build //...
Starting local Bazel server and connecting to it...
INFO: Invocation ID: 6cd2a9d0-cdf7-49d6-84e5-45eb745e9225
INFO: Rule 'rules_foreign_cc' modified arguments {"shallow_since": "1547833417 +0100"}
ERROR: /home/pkv/Desktop/test_boost/BUILD.bazel:3:1: in boost_build rule //:boost_graph: 
Traceback (most recent call last):
	File "/home/pkv/Desktop/test_boost/BUILD.bazel", line 3
		boost_build(name = 'boost_graph')
	File "/home/pkv/.cache/bazel/_bazel_pkv/250043debb56c0706f5c2dfb2313c03e/external/rules_foreign_cc/tools/build_defs/boost_build.bzl", line 18, in _boost_build
		cc_external_rule_impl(ctx, attrs)
	File "/home/pkv/.cache/bazel/_bazel_pkv/250043debb56c0706f5c2dfb2313c03e/external/foreign_cc_impl/framework.bzl", line 204, in cc_external_rule_impl
		os_name(ctx)
	File "/home/pkv/.cache/bazel/_bazel_pkv/250043debb56c0706f5c2dfb2313c03e/external/rules_foreign_cc/tools/build_defs/shell_script_helper.bzl", line 38, in os_name
		call_shell(create_context(ctx), "os_name")
	File "/home/pkv/.cache/bazel/_bazel_pkv/250043debb56c0706f5c2dfb2313c03e/external/rules_foreign_cc/tools/build_defs/shell_script_helper.bzl", line 38, in call_shell
		create_context(ctx)
	File "/home/pkv/.cache/bazel/_bazel_pkv/250043debb56c0706f5c2dfb2313c03e/external/rules_foreign_cc/tools/build_defs/shell_toolchain/toolchains/access.bzl", line 8, in create_context
		struct(shell = ctx.toolchains["@rules_f..., ... {})
	File "/home/pkv/.cache/bazel/_bazel_pkv/250043debb56c0706f5c2dfb2313c03e/external/rules_foreign_cc/tools/build_defs/shell_toolchain/toolchains/access.bzl", line 9, in struct
		ctx.toolchains["@rules_foreign_cc//tools/build_defs/shell_toolchain/toolchains:shell_commands"]
In boost_build rule //:boost_graph, toolchain type @rules_foreign_cc//tools/build_defs/shell_toolchain/toolchains:shell_commands was requested but only types [] are configured
ERROR: Analysis of target '//:boost_graph' failed; build aborted: Analysis of target '//:boost_graph' failed; build aborted
INFO: Elapsed time: 11.768s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (6 packages loaded, 61196 targets configured)

Platform: Ubuntu 16.04

$ bazel version
INFO: Invocation ID: 0751525e-de0a-4bfb-9b7e-e2e1fcb484c0
Build label: 0.21.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Dec 19 12:58:44 2018 (1545224324)
Build timestamp: 1545224324
Build timestamp as int: 1545224324

bazel looks in wrong sandbox dir for dependency information

The files are located at processwrapper-sandbox/1/, there is nothing written to processwrapper-sandbox/2

CMake Error at /workspace/.bazel/sandbox/processwrapper-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/genfiles/third_party/cmake/rostime/rostime/share/rostime/cmake/rostimeConfig.cmake:113 (message):
  Project 'rostime' specifies
  '/workspace/.bazel/sandbox/processwrapper-sandbox/2/execroot/__main__/bazel-out/k8-fastbuild/genfiles/third_party/cmake/boost/boost/include'
  as an include dir, which is not found.  It does neither exist as an
  absolute directory nor in
  '/tmp/tmp.nSUT4qCgFi/rostime//workspace/.bazel/sandbox/processwrapper-sandbox/2/execroot/__main__/bazel-out/k8-fastbuild/genfiles/third_party/cmake/boost/boost/include'.

Ancillary binaries are confused by outer linkeropts

I've recently been chasing down why Envoy's oss-fuzz build regressed in early Jan. There have been multiple issues, but one is related to our adoption of external_cmake, this can be seen in https://oss-fuzz-build-logs.storage.googleapis.com/log-ae2debc3-c07f-47aa-93ff-7eb4c9fe21af.txt.

The problem is that we have a fairly hokey invocation of Bazel, which you can see at https://github.com/google/oss-fuzz/blob/master/projects/envoy/build.sh. This is telling Bazel to use -lFuzzingEnginer everywhere. Unfortunately, zlib, when built under external_cmake, tries to do this with its test executables; that linker option is only safe to use with the target fuzzer binaries.

It might be reasonable to try and disable test binaries in external_cmake deps, but this doesn't work in general; e.g. zlib and c-ares don't support it by default, so we need to fix upstream, maybe a dep needs some host binary, etc.

I think one work around for us is to separate out the final link from Bazel, I'll look into this, but I'm interested the thoughts of others on the cleanest way to address this via either external_cmake support or changes to how we are structuring our fuzzer build.

CC @Dor1s

How to make derived header-only libraries?

I'm using bazel to build an apache module. I have dependencies set up like this

configure_make(
    name = "apr",
    configure_options = [
        "--enable-shared=no",
        "--with-pic",
    ],
    lib_source = "@org_apache_apr//:all",
    static_libraries = ["libapr-1.a"],
)
...
configure_make(
    name = "apache_httpd",
    configure_options = [
        "--with-apr=$EXT_BUILD_DEPS/apr",
        "--with-apr-util=$EXT_BUILD_DEPS/apr_util",
        "--with-pcre=$EXT_BUILD_DEPS/pcre",
        "--enable-mods-static='proxy proxy_balancer unixd authz_core slotmem_shm'",
    ],
    lib_source = "@org_apache_httpd//:all",
    out_bin_dir = ".",
    binaries = [
        "bin/httpd",
        "bin/apachectl",
    ],
    deps = [
        ":apr",
        ":apr_util",
        ":pcre",
    ],
    visibility = [
        "//visibility:public",
    ],
)

When I build a .so apache module, I need to include the apr dependency headers but not link to libapr-1.a because those symbols are resolved when the module is loaded into the apache binary. Is there a way that I can make a derived cc_library from :apr that only has the headers?

I'm currently adding an additional configure_make like this

configure_make(
    name = "apr_headers",
    configure_options = [
        "--enable-shared=no",
        "--with-pic",
    ],
    lib_source = "@org_apache_apr//:all",
    out_include_dir = "include/apr-1",
    headers_only = True,
)

But that hardly seems optimal as I have to configure_make apr twice.

generate test targets for cmake

Looking through the documentation, it looks like there is no way to generate CMake test targets currently. I'm investigating using these rules for Abseil CMake builds, but we can't ditch our hand-rolled CMakeLists files without also being able to generate tests.

should _cmake_dep attribute be configured to `host` environment

this is not so much an issue as a question, let me know if there is a better forum.

could you help me understand why the implicit _cmake_dep attribute is configured to the target environment? I would have thought that since cmake is a build dependency and not a runtime dependency that it would be configured to the host environment.

boost build fails on MacOS on rerun

It fails in non-sandbox mode only. To repro, build the boost example back to back with --spawn_strategy=stanalone.

➜  examples git:(master) bazel build --spawn_strategy=standalone boost:boost_filesystem
INFO: Analyzed target //boost:boost_filesystem (15 packages loaded, 61294 targets configured).
INFO: Found 1 target...
INFO: From CcBuildboostMakeRule boost/boost_filesystem/include:
Target //boost:boost_filesystem up-to-date:
  bazel-bin/boost/boost_filesystem/include
  bazel-bin/boost/boost_filesystem/lib/libboost_filesystem.a
  bazel-bin/boost/copy_boost_filesystem/boost_filesystem
  bazel-bin/boost/boost_filesystem/logs/BuildBoost_script.sh
  bazel-bin/boost/boost_filesystem/logs/BuildBoost.log
  bazel-bin/boost/boost_filesystem/logs/wrapper_script.sh

INFO: Elapsed time: 149.571s, Critical Path: 142.57s
INFO: 1 process: 1 local.
INFO: Build completed successfully, 4 total actions
➜  examples git:(master) bazel build --spawn_strategy=standalone boost:boost_filesystem
INFO: Analyzed target //boost:boost_filesystem (1 packages loaded, 61180 targets configured).
INFO: Found 1 target...
ERROR: /Users/slam/src/github.com/bazelbuild/rules_foreign_cc/examples/boost/BUILD:12:1: error executing shell command: '/bin/bash -c function cleanup_function() {
local ecode=$?
if [ $ecode -eq 0 ]; then
cleanup_on_success
else
cleanup_on_failure
fi
}
set -e
function cleanup_on_success() {
printf "rules_foreign_cc: ...' failed (Exit 1)

rules_foreign_cc: Build failed!
rules_foreign_cc: Keeping temp build directory  and dependencies directory  for debug.
rules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify '--sandbox_debug' Bazel command line flag.

rules_foreign_cc: Printing build logs:

_____ BEGIN BUILD LOGS _____
Bazel external C/C++ Rules #0.0.8. Building library 'boost_filesystem'
Environment:______________DEVELOPER_DIR=/Applications/Xcode-10.2.app/Contents/Developer
TMPDIR=/var/folders/cy/m7zj1t990qzdb8t3gv7btz3h0000gn/T/
SDKROOT=/Applications/Xcode-10.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
EXT_BUILD_ROOT=/private/var/tmp/_bazel_slam/f7c7e62231163bda5a58ee81a9ec972d/execroot/rules_foreign_cc_tests
XCODE_VERSION_OVERRIDE=10.2.0.10E125
INSTALLDIR=/private/var/tmp/_bazel_slam/f7c7e62231163bda5a58ee81a9ec972d/execroot/rules_foreign_cc_tests/bazel-out/darwin-fastbuild/bin/boost/boost_filesystem
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
PATH=/private/var/tmp/_bazel_slam/f7c7e62231163bda5a58ee81a9ec972d/execroot/rules_foreign_cc_tests:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
BUILD_TMPDIR=/var/folders/cy/m7zj1t990qzdb8t3gv7btz3h0000gn/T/tmp.93HnrFq8
PWD=/private/var/tmp/_bazel_slam/f7c7e62231163bda5a58ee81a9ec972d/execroot/rules_foreign_cc_tests
EXT_BUILD_DEPS=/private/var/tmp/_bazel_slam/f7c7e62231163bda5a58ee81a9ec972d/execroot/rules_foreign_cc_tests/bazel_foreign_cc_deps_boost_filesystem
SHLVL=2
BUILD_LOG=bazel-out/darwin-fastbuild/bin/boost/boost_filesystem/logs/BuildBoost.log
BUILD_SCRIPT=bazel-out/darwin-fastbuild/bin/boost/boost_filesystem/logs/BuildBoost_script.sh
APPLE_SDK_PLATFORM=MacOSX
APPLE_SDK_VERSION_OVERRIDE=10.14
_=/usr/bin/env
__________________________cp: cannot overwrite directory ./tools with non-directory /private/var/tmp/_bazel_slam/f7c7e62231163bda5a58ee81a9ec972d/execroot/rules_foreign_cc_tests/external/boost/./tools

_____ END BUILD LOGS _____
rules_foreign_cc: Build script location: bazel-out/darwin-fastbuild/bin/boost/boost_filesystem/logs/BuildBoost_script.sh
rules_foreign_cc: Build log location: bazel-out/darwin-fastbuild/bin/boost/boost_filesystem/logs/BuildBoost.log

Target //boost:boost_filesystem failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 25.796s, Critical Path: 12.71s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

using system package as dependency in cmake_external

I'd like to depend on a system package. When invoking cmake directly, I would just set CMAKE_PREFIX_PATH to the appropriate path. Is there a mechanism to accomplish the same with cmake_external?

The error I get is

Could not find the required component 'foo'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.

I imagine the solution is to copy the package into $EXT_BUILD_DEPS, or else add the package path to $CMAKE_PREFIX_PATH. However, I have been unable to figure out how to accomplish this with the cmake_external API.

Thanks as always for your help, and let me know if there's a forum you would prefer I use for such questions!

Cmake linkopts not passed

Hi,

I'm trying to build the CGAL library using the cmake_external rule. Everything builds successfully, but the library also requires some additional linker flags when it's used. I've listed the necessary flags in the linkopts attribute, however they do not seem to be passed to other rules.

I've created a small reproduction of my problem here. The repo has 3 different test cases:

  1. Building cgal and using it all within bazel - I believe this is the ideal usage, but doesn't work
  2. CGAL is built externally and wrapped in a cc_library with linkopts. - I think this is roughly equivalent to what cmake_external is doing and it works.
  3. Similar to case 1, except linkopts are added to the cc_binary. - This works, but is not ideal. I don't want to add the linkopts to all binaries (e.g. all my tests) that have CGAL as a dependency.

Please let me know if you need any more info.

Thanks for your help!

P.S. Thanks for your work on this library, I've been using it to build some other libs and it works well :)

create_library_to_link not called with correct arguments

#117 changed the method from create_symlink_library_to_link to create_library_to_link, but did not update the method parameters accordingly. any builds that execute this code will fail. simply rolling back that change, however, does not resolve the issue, as it leads to dangling symlink errors.

unable to find shared object files

disclaimer: not a bug or FR, hoping for assistance troubleshooting, let me know if there is a better forum

I am trying to run a simple hello_world cc_binary target that depends on some cmake_external targets. the build completes successfully, but I get the following linking error when the target is blaze run:

/blaze/a08c2e4811c846650b733c6fc815a920/execroot/__main__/bazel-out/k8-fastbuild/bin/src/examples/hello_world/hello_world: error while loading shared libraries: libconsole_bridge.so.0.4: cannot open shared object file: No such file or directory

libconsole_bridge.so.0.4 is created by the build, and is located at $EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/third_party/ros/console_bridge/copy_console_bridge/console_bridge/ in my filesystem, as expected.

would love to get your expertise on how to proceed @irengrig . in general, how can I ensure the linker can find .so files generated by cmake external targets? simply adding -L<path_to_dynamic_lib> to linkopts does not resolve the issue.

error building PCL with cmake_external

ERROR:

Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
-- Not found OpenMP
-- Configuring incomplete, errors occurred!
See also "/var/folders/sg/_2yjj6v54lbckvqwr3jc4zdc0007t6/T/tmp.VwfY2XEP/CMakeFiles/CMakeOutput.log".
mktemp: illegal option -- -
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
CMake Deprecation Warning at CMakeLists.txt:15 (cmake_policy):
  The OLD behavior for policy CMP0048 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:19 (cmake_policy):
  The OLD behavior for policy CMP0054 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Error at /usr/local/Cellar/cmake/3.12.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Eigen (missing: EIGEN_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.12.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  cmake/Modules/FindEigen.cmake:44 (find_package_handle_standard_args)
  CMakeLists.txt:276 (find_package)

Target //roboflow/omg:pcl failed to build

System:

System info:
MacBook Pro (15-inch, 2017)
OS: High Sierra 10.13.1
Processor: 3.1 GHz Intel Core i7
Memory: 16 GB 2133 MHz LPDDR3

BUILD:

cmake_external(
        name = "pcl",
        cmake_options = ["-DBUILD_WITH_OPENMP=False"],
        headers_only = True,
        lib_source = "@pcl//:all",
)

WORKSPACE:

new_http_archive(
        name = "pcl",
        build_file_content = all_content,
        strip_prefix = "pcl-pcl-1.8.1",
        urls = ["https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.1.tar.gz"],
)

Support for arm64 / aarch64

Envoy Proxy just implemented rules_foreign_cc today with PR envoyproxy/envoy#5218. My builds for Linux x86_64 and macOS are working fine. However my arm64 / aarch64 builds are failing with the following error.

ERROR: While resolving toolchains for target //bazel/foreign_cc:zlib: no matching toolchains found for types @rules_foreign_cc//tools/build_defs/shell_toolchain/toolchains:shell_commands

It looks like only Linux, Windows and macOS are supported on the x86_64 architecture after looking at https://github.com/bazelbuild/rules_foreign_cc/blob/master/tools/build_defs/shell_toolchain/toolchains/toolchain_mappings.bzl

/cc @htuch

Pass linkopts from cmake_external and cc_libraries dependencies into CMake script

There is a possibility in the Bazel standard cc_library to supply link options for linking the current target,
passing the values in linkopts attribute.

This should be passed to the CMake script then, for all the dependencies.

Currently the values from dependencies are ignored (but passed up the dependency chain in C/C++ providers);
the value of linkopts of cmake_external is passed up the dependency chain in C/C++ provider (this is correct)

Unable to 'source' function definitions from files local to the project inside configure script

Hello - I'm trying to build librdkafka using configure_make. The library uses mklove instead of autoconf, and mklove is distributed alongside the source code. One of the early steps of the configure script is sourcing the mklove bash functions, defined in the file "mklove/modules/configure.base", where the mklove directory is inside the project folder and at the same level as the configure script.

librdkafka
  - configure
  - mklove/...
  - other files
#!/usr/bin/env bash
# Load base module
source mklove/modules/configure.base
...
mkl_in_list <do stuff>
... 

The build fails with command not found errors, since the mklove/modules/configure.base is not found.

Inside of a configure script, how does one 'source' definitions from files relative to the scripts location?

__________________________PKG_CONFIG_PATH=
/home/ronmexico/.cache/bazel/_bazel_ronmexico/dc9d11a71c518156e18cc15c4d21f77b/sandbox/linux-sandbox/2/execroot/orderinbound/external/kafka/configure: line 15: mklove/modules/configure.base: No such file or directory
/home/ronmexico/.cache/bazel/_bazel_ronmexico/dc9d11a71c518156e18cc15c4d21f77b/sandbox/linux-sandbox/2/execroot/orderinbound/external/kafka/configure: line 19: mkl_in_list: command not found
/home/ronmexico/.cache/bazel/_bazel_ronmexico/dc9d11a71c518156e18cc15c4d21f77b/sandbox/linux-sandbox/2/execroot/orderinbound/external/kafka/configure: line 21: mkl_in_list: command not found

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.