So I want to use bazel and the googletest framework for running unittests of a simulation. For this, I want to have sample-inputfiles ans sample-outputfiles.
I want to get the absolute path of the source file, the test file or any file in the repository, so I can create a relative path to input files from there.
std::string path = __SOME_PATH_IN_REPO__+"/../inputfiles/input.txt";
name = "gtest_capabilities",
srcs = [
deps = [
copts = [
bazel info --show_make_env
Ugh, this is a terrible output. Basically,
--show_make_env mushes together the output of
bazel info and the make variables, giving no indication of which is which. To find the make variables, you can diff the outputs to remove the non-make info:
$ bazel info --show_make_env > make-vars $ bazel info > no-make-vars $ diff make-vars no-make-vars 1,22d0 < ABI: local < ABI_GLIBC_VERSION: local < ANDROID_CPU: armeabi < AR: /usr/bin/ar < BINDIR: bazel-out/local-fastbuild/bin < BINMODE: -dbg < CC: /usr/bin/gcc < CC_FLAGS: < COMPILATION_MODE: fastbuild < CROSSTOOLTOP: external/local_config_cc < C_COMPILER: compiler < GENDIR: bazel-out/local-fastbuild/genfiles < GLIBC_VERSION: local < JAVA: external/local_jdk/bin/java < JAVABASE: external/local_jdk < JAVA_CPU: k8 < JAVA_TRANSLATIONS: 0 < NM: /usr/bin/nm < OBJCOPY: /usr/bin/objcopy < STACK_FRAME_UNLIMITED: < STRIP: /usr/bin/strip < TARGET_CPU: k8
Those are the make variables that are available.
Could you find the PWD in your test, instead of using a
-D to hardcode it?