In CMake, I did add_executable, target_link_libraries, and install to build, link and install grok , and eventually it was installed into /usr/local/bin (or wherever the user wanted to install it), and was therefore on the user's PATH
Then I would run `grok foo.log foo.summary` to analyze the foo.log file in my working directory and produce a summary file called foo.summary, again in my working directory.
Now that I've ported this tool to bazel, I can build it with `bazel build grok`, but running it is problematic.
Running it with `bazel run grok -- foo.log foo.summary` cannot find foo.log (because it's now running in the runfiles directory) and now the user can't find foo.summary, because it is created in the runfiles directory.
I can run `bazel run grok -- $(pwd)/foo.log $(pwd)/foo.summary` and get the previous result, but this it a lot of extra typing and tab-completion no longer works, so it slows down the user's workflow considerably.
Further, for the sake of argument, let's say that grok relies on some data file (say, a pre-built database of analysis rules) that the bazel-ported version finds using a workspace-relative path. Previously grok was using the absolute, installed path of this data file, but now grok relies on being executed within its runfiles tree to find its resources correctly.
This leads to the following questions:
* Does bazel provide a mechanism for installing binaries, or some other way to put them on the PATH? How is this achieved within google?
* Does bazel provide a working-directory agnostic mechanism for finding resource files? How is this done within google?
* How should I pass file arguments to my program? Do I always need to pass absolute paths or is there a better way?
Any advice would be appreciated,
Thanks,
-Austin
I'm porting some command-line tools that are used for analyzing log files from CMake to Bazel. For the sake of example, let's call this tool grok
In CMake, I did add_executable, target_link_libraries, and install to build, link and install grok , and eventually it was installed into /usr/local/bin (or wherever the user wanted to install it), and was therefore on the user's PATH
Then I would run `grok foo.log foo.summary` to analyze the foo.log file in my working directory and produce a summary file called foo.summary, again in my working directory.
Now that I've ported this tool to bazel, I can build it with `bazel build grok`, but running it is problematic.
Running it with `bazel run grok -- foo.log foo.summary` cannot find foo.log (because it's now running in the runfiles directory) and now the user can't find foo.summary, because it is created in the runfiles directory.
I can run `bazel run grok -- $(pwd)/foo.log $(pwd)/foo.summary` and get the previous result, but this it a lot of extra typing and tab-completion no longer works, so it slows down the user's workflow considerably.
Further, for the sake of argument, let's say that grok relies on some data file (say, a pre-built database of analysis rules) that the bazel-ported version finds using a workspace-relative path. Previously grok was using the absolute, installed path of this data file, but now grok relies on being executed within its runfiles tree to find its resources correctly.
This leads to the following questions:
* Does bazel provide a mechanism for installing binaries, or some other way to put them on the PATH? How is this achieved within google?
* Does bazel provide a working-directory agnostic mechanism for finding resource files? How is this done within google?
* How should I pass file arguments to my program? Do I always need to pass absolute paths or is there a better way?
Any advice would be appreciated,
Thanks,
-Austin
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/f27e134d-d6bb-47b7-9d32-4a02b058b1ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On 2017-04-27 04:31, 'Damien Martin-Guillerez' via bazel-discuss wrote:
> On Thu, Apr 27, 2017 at 6:47 AM <aus...@zoox.com> wrote:
>> * Does bazel provide a mechanism for installing binaries, or some other
>> way to put them on the PATH?
No.
> We generally build bundled binary that are self-contained (e.g. par for
> python archive) and just deploy that binary.
This is completely unacceptable for any sane Linux distribution. (I know
absolutely that Fedora will not accept any packages like this. AFAIK the
same is true for most major distributions.)
> We do not have a proper mechanisms for installation but you can build
> one:
> http://stackoverflow.com/questions/43549923/how-do-i-install-a-project-built-with-bazel
This needs to be added to Bazel. In particular, this:
"do checksums to check if there are change to the installed file and
does the actual copy of the files if they have changed"
...needs to be part of Bazel itself, for the sake of portability.
CMake does all these things for you. Personally, if you have a choice, I
would recommend staying with CMake, at least until Bazel is more mature
and ready to be used in an open source ecosystem.
I *might* be able to work on some of these problems in the
not-so-distant future (our customer for the project I am working on is
very insistent about using Bazel in spite of its shortcomings, and they
are running into these same issues).
Right now I have a stand-alone shell script that has a bunch of
hard-coded logic to copy stuff around into a "scratch" install tree
which can then be turned into a tarball and/or copied (with
modified-content checks, per above) to a user specified install tree.
This is a really ugly approach, however, as it is a) not portable (at
least not to Windows), and b) puts the what-to-build and what-to-install
logic in widely divergent locations.
What I want from Bazel - what I *expect* from a modern build tool - is
the moral equivalent of CMake's `install` commands. That is, I want a
command that I can write next to (or even as part of?) `cc_binary` that
says 'this target/file should be installed' and (optionally) 'this
target should be available for import into other projects'.
(I'd anticipate the way this would be implemented is that each such call
records information that is later used by another process that collects
all such information and generates a build and/or run target to generate
the export information and perform the install. It's okay if that
includes having to call an extra function/macro for that purpose.)
--
Matthew
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/69b2eeb8-8102-000d-0580-e2975876e644%40kitware.com.