I have a py_binary which executes another cc_binary, and I put the cc_binary as data dep of the py_binary.
cc_binary(
name = "main",
srcs = ["main.cc"],
data = [":runfile.txt"]
)
py_binary(
name = "py_main",
srcs = ["py_main.py"],
data = [":main"],
)
Inspecting the output directory hierarchy, I noticed the runfiles of py_binary contains the data needed for both, but there's no main.runfiles directory or symlink to the root of runfiles.
~/bazeltest (master) $ ls -R bazel-bin/py_main.runfiles
bazel-bin/py_main.runfiles:
__main__ MANIFEST
bazel-bin/py_main.runfiles/__main__:
main py_main py_main.py runfile.txt
That means, if I invoke the cc binary in the py, it cannot use $0.runfiles/runfile.txt because that will point to
bazel-bin/py_main.runfiles/__main__/main.runfiles/runfile.txt, which doesn't exist.
What's the best way for main to get the runfile, and works in both cases where it's directly executed or it's executed as part of py_binary?
--
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/49f25cb3-7d23-4ca8-8171-1e3af8597abf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nevertheless, what I wanted to know was there an officially supported way to
obtain a path to the runfiles for a java_binary from a skylark rule?
Currently, I am leveraging an implementation detail in the java_binary
wrapper script to set a number of system properties, relative to the
runfiles path.
Concretely, in the macro that creates a java_binary, one of the
jvm_flags I use is
-Dsome.company.required.config=$(readlink -f ${RUNPATH:-.})/<path>
After the java_binary is compiled, the bazel-bin wrapper script contains
the above as a JVM_FLAG. This causes no issues since it explicitly defines
the RUNPATH variable earlier in the script [0].
The fundamental reason, I am doing all of this is that I need to define
a set of java system properties that require the paths of key configuration
files.
--
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/92b24fd4-6964-4634-bc6a-c4011353cbda%40googlegroups.com.