rules_xcodeproj
rules_xcodeproj copied to clipboard
Feature Request: Runfiles support
Is it possible to support runfiles for executables launched via Xcode?
For instance, I have a cc_test target with a data attribute, whose sources use @bazel_tools//tools/cpp/runfiles to locate those data files. This works when executed with bazel test but not when the same target is run via Xcode, because environment variables like RUNFILES_MANIFEST_FILE, RUNFILES_DIR and TEST_SRCDIR are not set.
https://github.com/jfirebaugh/rules_xcode_reduction/tree/828
bazel test :test:
$ bazel test --test_output=all :test
INFO: Analyzed target //:test (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
Target //:test up-to-date:
bazel-bin/test
INFO: Elapsed time: 0.128s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
PASSED: //:test (see /private/var/tmp/_bazel_johnfirebaugh/4cb9390d112da1357a7950bfb3bc2dce/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/test/test.log)
INFO: From Testing //:test
==================== Test output for //:test:
/private/var/tmp/_bazel_johnfirebaugh/4cb9390d112da1357a7950bfb3bc2dce/sandbox/darwin-sandbox/81/execroot/__main__/bazel-out/darwin-fastbuild/bin/test.runfiles/rules_xcode_reduction/data.txt
================================================================================
//:test (cached) PASSED in 0.1s
Executed 0 out of 1 test: 1 test passes.
INFO: Build completed successfully, 1 total action
Running in Xcode:
ERROR: external/bazel_tools/tools/cpp/runfiles/runfiles.cc(120): cannot find runfiles (argv0="")
Program ended with exit code: 1
I've considered this, but it's tricky. I'll think about it more soon though, maybe recent "stop copying files" changes will make it easier, at least for BwB.
FYI, I don't think we will get to this by 1.0.
Recent changes now make PROJECT_DIR the execution root. We also do far fewer path manipulations. I can see how we can probably support this for BwB mode.