rules_xcodeproj icon indicating copy to clipboard operation
rules_xcodeproj copied to clipboard

Feature Request: Runfiles support

Open jfirebaugh opened this issue 3 years ago • 6 comments

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.

jfirebaugh avatar Jul 27 '22 03:07 jfirebaugh

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

jfirebaugh avatar Jul 27 '22 05:07 jfirebaugh

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.

brentleyjones avatar Jul 27 '22 11:07 brentleyjones

FYI, I don't think we will get to this by 1.0.

brentleyjones avatar Sep 01 '22 16:09 brentleyjones

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.

brentleyjones avatar Oct 19 '22 13:10 brentleyjones