tensorflow - Building a CMake library within a Bazel project -


i've written module on top of private fork off of tensorflow uses nanomsg.

for local development server, used cmake install install nanomsg (to /usr/local) , accessed header files installed location. project runs fine locally.

however, need package nanomsg within tensorflow workspace. i've tried following 2 approaches, , find neither satisfactory:

  1. similar this answer opencv, precompiled nanomsg private repository, loaded within workspace (within tensorflow/workspace.bzl) using http_archive directive included headers , libraries in relevant build script. runs fine, not portable solution.

  2. a more portable solution, created genrule run specific sequence of cmake commands can used build nanomsg. approach neater, genrule cannot reused cmake other projects. (i referred this discussion).

clearly cmake not supported first-class citizen in bazel builds. there has faced problem in own projects created generic, portable way include libraries within bazel projects built using cmake? if so, how did approach it?

as ulf wrote, think suggested option 2 should work fine.

regarding "can identify if cmake fails", yes: cmake should return error exit code (!= 0) when fails. in turn cause bazel automatically recognize genrule action failed , fail build. because bazel sets "set -e -o pipefail" before running command (cf. https://docs.bazel.build/versions/master/be/general.html#genrule-environment), should work if chain multiple cmake commands in genrule "cmd".

if call out shell script in "cmd" attribute runs cmake commands, make sure put "set -e -o pipefail" in first line of script yourself. otherwise script not fail when cmake fails.

if misunderstood question "can identify if cmake fails", please let me know. :)


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -