How do you read gcno and gdna files to see test coverage? - c++
I am using gcovr to try to see how much my tests cover the codebase. In fact I have a single super small test so I am expecting gcovr to return a very small number, probably less than a percent.
I compiled with the --coverage flag enabled in every single compilation unit and the -lgcov flag active on ever single linking command. Then i ran both the executable and the tests and generated the gcno and gdna files.
Then I do:
gcovr --root ../Src/ ../Src/ ./GeometryTests.p
------------------------------------------------------------------------------
GCC Code Coverage Report
Directory: ../Src/
------------------------------------------------------------------------------
File Lines Exec Cover Missing
------------------------------------------------------------------------------
Engine/Geometry/GeometryUtils.hpp 18 18 100%
Engine/Geometry/tests/GeometryTests.cpp 3 3 100%
Engine/Geometry/tests/TestsGeometryUtils.cpp
18 18 100%
------------------------------------------------------------------------------
TOTAL 39 39 100%
-----------------------------------------------------------------------------
Well this isn't right, I have dozens of files and my tiny test only tests 2 functions, this is clearly wrong.
I then tried:
gcovr --root ../Src/ ../Src/ ./GeometryTests.p ./SponzaScene.p
------------------------------------------------------------------------------
GCC Code Coverage Report
Directory: ../Src/
------------------------------------------------------------------------------
File Lines Exec Cover Missing
------------------------------------------------------------------------------
Engine/Animation/GltfLib.hpp 1 1 100%
Engine/Animation/Image/CpuImage.hpp 1 1 100%
Engine/Geometry/GeometryUtils.hpp 18 18 100%
Engine/Geometry/HMesh.hpp 592 0 0% 37,87-89,92-94,96-98,100-101,103,105-107,110,114-118,121,123-125,127,129,132-133,135,137-139,141,143,146,148-150,174-176,180,182-184,186,188-190,192,194-196,198,200-201,203,205-206,208,210,212-213,215,217-218,220,222-223,225,227-228,230,232-233,236,238-239,241,243-244,246,248-249,251,253-254,256,258-259,261,263,265,267-268,271,273,275,277,280,282,285,291,297-298,309,311,313,315,317-318,320,322-324,326-327,329,332,334,336-343,345,348,350-351,354,357,359-360,362,365,367-368,370,373,375-376,378,381,383-384,386,398,410,413-418,420,429-432,434-437,439-441,445,559,561,563-564,566-571,573-574,577-578,580,584,587-588,590-591,593,595-596,598-600,604-605,609,612,614,616-618,620,622-625,631,635-641,643-648,651-653,657-659,661-662,665-670,672-675,677-678,682-684,686-690,692-695,697-699,701-704,706-707,709-711,715,718-719,721-725,727-729,732,737,741-745,747-750,753-755,757-758,760,763-768,770-772,774,778-780,782-788,790-792,794-796,798-800,802,804,808,811-813,815-821,823-828,830-832,834-836,838-840,842-844,846-848,850-852,854-856,858-860,865,867-868,870-871,873,876,882,885-886,888,890-892,895,897,900,913,916-917,919-920,924,926-927,931,933-934,938,941-943,945,947-949,953,955-956,961,969-973,975-976,978,980-983,986,988,990-992,994,996-997,999,1002-1003,1007,1009-1010,1015-1026,1028,1030,1032,1034-1036,1039,1041-1042,1044-1045,1048,1050,1052-1057,1059,1062,1067-1068,1070-1071,1075,1079-1080,1082,1084-1086,1088,1090-1091,1094-1096,1099-1101,1104-1108,1113,1115-1117,1119-1121,1125,1127,1130-1131,1135,1138,1141,1145-1146,1148-1151,1153-1155,1157,1162,1164-1170,1175,1177-1183,1188,1191-1192,1194,1196,1198-1200,1202-1204,1206-1208,1210-1213,1215-1217,1220,1222,1228,1230-1231,1233-1236,1238-1239,1241-1243,1246-1248,1252,1254-1259,1263,1266-1268,1270-1273,1275,1279,1281-1282,1285-1286
Engine/Geometry/tests/GeometryTests.cpp 3 3 100%
Engine/Geometry/tests/TestsGeometryUtils.cpp
18 18 100%
Engine/Helpers/EigenHelpers.hpp 4 0 0% 187,189,192,195
Engine/Renderer/Camera/Camera.hpp 13 12 92% 46
Engine/Renderer/IO/Window.hpp 3 3 100%
Engine/Renderer/Renderer.hpp 7 7 100%
Engine/Renderer/Rendering/Effects.hpp 35 35 100%
Engine/Renderer/Rendering/Gallery.hpp 82 78 95% 294-296,298
Engine/Renderer/Rendering/RenderTargetStorage.hpp
1 1 100%
Engine/Renderer/Rendering/VulkanLayer/Image.hpp
1 1 100%
Engine/Renderer/Rendering/VulkanLayer/Memory.hpp
3 3 100%
Engine/Renderer/Rendering/VulkanLayer/RenderTarget.hpp
1 1 100%
Engine/Renderer/Rendering/VulkanLayer/RenderingPipeline.hpp
3 3 100%
Engine/Renderer/Rendering/VulkanLayer/ShaderProgram.hpp
1 1 100%
Engine/Renderer/Rendering/VulkanLayer/Utils.hpp
5 5 100%
Engine/Shared/Shared.hpp 8 3 37% 71,73,181,184-185
examples/SponzaScene/sponza_scene.cpp 180 172 95% 236,240,242-243,245-246,341,343
------------------------------------------------------------------------------
TOTAL 980 366 37%
------------------------------------------------------------------------------
At least it is not 100% but I can guarantee that my test doesn't touch most of the files and i don't quite understand how I should be setting up the compilation, linking and gcovr invocation to analyze test coverage.
Looks like previous results were not cleaned. Try to compile with -ftest-coverage
Maybe lcov + htmlgen will works for you.
Here is an example:
rm -f *.gcno *.gcda coverage.info coverage_dir
gcc -I${INCLUDE_PATH} -fprofile-arcs -ftest-coverage -O0 --coverage main.c -o test-coverage
rm -f *.gcda coverage.info
./test-coverage
lcov --capture --rc lcov_branch_coverage=1 --directory . --config-file ./lcovrc --output coverage.info
genhtml --branch-coverage --output ./coverage_dir coverage.info
Related
Why are there duplicate C/C++ compilers (e.g g++, gcc)?
According to this answer, gcc and g++ have some functional differences. As confirmed by this script, the commands point to the exact same binary, effectively making them duplicates. Why is that so? $ uname Darwin $ md5 `which cc c++ gcc g++ clang clang++` fac4668657765c8dfe89d8995acfb5a2 /usr/bin/cc fac4668657765c8dfe89d8995acfb5a2 /usr/bin/c++ fac4668657765c8dfe89d8995acfb5a2 /usr/bin/gcc fac4668657765c8dfe89d8995acfb5a2 /usr/bin/g++ fac4668657765c8dfe89d8995acfb5a2 /usr/bin/clang fac4668657765c8dfe89d8995acfb5a2 /usr/bin/clang++
The executable can determine the name it was called with by inspecting the first (or zeroth) command line argument passed to it. By convention it is the name of the executable and is passed by whatever program is invoking the compiler (typically e.g. a shell). Although it is the same executable, it can then take different actions based on whether or not that value is gcc or g++. Also, the files you are seeing are unlikely to be duplicate files. They are most likely just (soft or hard) links to the same file. For the part that clang/clang++ and gcc/g++ seem to be the same, although they are completely different compilers, that is an Apple quirk. They link gcc and g++ to clang and clang++ for some reason, but in reality both refer to Apple clang, which is also different from upstream clang. It often causes confusion (at least for me).
the commands point to the exact same binary, effectively making them duplicates Yes, they're intended to be the same, and are actually the same single file on disk, given the inode number of them is the same $ which cc c++ gcc g++ clang clang++ | xargs ls -li 1152921500312779808 -rwxr-xr-x 76 root wheel 167120 May 10 04:30 /usr/bin/c++ 1152921500312779808 -rwxr-xr-x 76 root wheel 167120 May 10 04:30 /usr/bin/cc 1152921500312779808 -rwxr-xr-x 76 root wheel 167120 May 10 04:30 /usr/bin/clang 1152921500312779808 -rwxr-xr-x 76 root wheel 167120 May 10 04:30 /usr/bin/clang++ 1152921500312779808 -rwxr-xr-x 76 root wheel 167120 May 10 04:30 /usr/bin/g++ 1152921500312779808 -rwxr-xr-x 76 root wheel 167120 May 10 04:30 /usr/bin/gcc On a typical *nix system symlinks are usually used instead of hard links like that $ ls -al /usr/bin | grep 'vim' lrwxr-xr-x 1 root wheel 3 May 10 04:30 ex -> vim lrwxr-xr-x 1 root wheel 3 May 10 04:30 rview -> vim lrwxr-xr-x 1 root wheel 3 May 10 04:30 rvim -> vim lrwxr-xr-x 1 root wheel 3 May 10 04:30 vi -> vim lrwxr-xr-x 1 root wheel 3 May 10 04:30 view -> vim -rwxr-xr-x 1 root wheel 5056496 May 10 04:30 vim lrwxr-xr-x 1 root wheel 3 May 10 04:30 vimdiff -> vim -rwxr-xr-x 1 root wheel 2154 May 10 04:30 vimtutor That said, in any case the command can be determined easily, regardless of the full executable file, a hard link or a symlink, by checking the command executed which is argv[0] in a typical C or C++ program, or $0 in bash. This is extremely common and one notable usage of it is in BusyBox where almost all POSIX utilities are in a single busybox binary and anything you run like ls, mv, test, rm... will eventually run busybox But why is gcc and clang the same binary? It's another weird thing in macOS because Apple stopped using/including gcc for more than a decade ago due to licensing issues. They lie to others by telling "clang is gcc" and the only way you can know it is by running gcc --version OS X: installed gcc links to clang What is the difference between c++ and g++ on Mac OS X (CommandLineTools)? How do I make sure that my default C/C++ compiler is GCC OS X 10.9 gcc links to clang
"string.h" not found message in building qt app for iOS
I've recently updated Xcode to version 10.0 and after that when I try to build version for iOS I've the following problem. 1:04:17: Running steps for project Diasteca... 11:04:17: Starting: "/Users/belladellifabio/Qt/5.11.1/ios/bin/qmake" /Users/belladellifabio/Desktop/QtProjects/Diasteca/mqtt_test/mqtt_test.pro -spec macx-ios-clang CONFIG+=iphoneos CONFIG+=device CONFIG+=qml_debug Project MESSAGE: This project is using private headers and will therefore be tied to this specific Qt module build version. Project MESSAGE: Running this project against other versions of the Qt modules may crash at any arbitrary point. Project MESSAGE: This is not a bug, but a result of using Qt internals. You have been warned! 11:04:18: The process "/Users/belladellifabio/Qt/5.11.1/ios/bin/qmake" exited normally. 11:04:18: Starting: "/usr/bin/make" qmake_all make: Nothing to be done for `qmake_all'. 11:04:18: The process "/usr/bin/make" exited normally. 11:04:18: Starting: "/usr/bin/make" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -fPIC -std=gnu++11 -arch arm64 -arch x86_64 -Xarch_arm64 -miphoneos-version-min=12.0 -Xarch_arm64 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk -Xarch_x86_64 -mios-simulator-version-min=12.0 -Xarch_x86_64 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.3.sdk -fobjc-nonfragile-abi -fobjc-legacy-dispatch -fembed-bitcode-marker -Wall -W -DQT_COMPILER_SUPPORTS_SSE2 -DMQTT_TEST_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I../../Diasteca/mqtt_test -I. -I../../../../Qt/5.11.1/ios/mkspecs/common/uikit -I../../../../Qt/5.11.1/ios/include -I../../../../Qt/5.11.1/ios/include/QtNetwork -I../../../../Qt/5.11.1/ios/include/QtCore/5.11.1 -I../../../../Qt/5.11.1/ios/include/QtCore/5.11.1/QtCore -I../../../../Qt/5.11.1/ios/include/QtCore -I. -I../../../../Qt/5.11.1/ios/mkspecs/macx-ios-clang -o qmqttclient.o ../../Diasteca/mqtt_test/qmqttclient.cpp clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk' [-Wmissing-sysroot] clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.3.sdk' [-Wmissing-sysroot] In file included from ../../Diasteca/mqtt_test/qmqttclient.cpp:30: In file included from ../../Diasteca/mqtt_test/qmqttclient.h:33: In file included from ../../Diasteca/mqtt_test/qmqttglobal.h:33: In file included from ../../../../Qt/5.11.1/ios/include/QtCore/qglobal.h:47: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/utility:202: In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:61: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h:61:15: fatal error: 'string.h' file not found Probably the real problem is not the file not found error, but is connected to the fact that qty tries to build the app using an SDK that is no more installed on the system. Is this a qt problem? How could I specify the version of iOS SDK to use to build the app? Is it possible?
Finally, I've found and delete .qmake.cache and .qmake.stash files. I've restart QtCreator and now it seems to work.
Qt stores SDK information somewhere deep in the build output and the .pro.user file. Remove the user file (you might want to backup your user file in case you have custom build steps), the complete (shadow) build tree and modify your .pro file so that there is no such line as QMAKE_MAC_SDK = macosx10.13. Then call qmake and build your project again, the inconsistency should be gone.
This occurs when the iOS SDK that Qt is expecting is different than the iOS SDK that you have installed. For instance Qt 5.13.1 expects iPhoneOS13.1.sdk but my Xcode currently has iPhoneOS13.2.sdk: $ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs $ ls -l total 0 drwxrwxr-x 7 root wheel 224 Nov 5 2019 iPhoneOS.sdk lrwxr-xr-x 1 root wheel 12 Jan 15 2020 iPhoneOS13.2.sdk -> iPhoneOS.sdk $ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs $ ls -l total 0 drwxrwxr-x 8 root wheel 256 Jul 22 14:14 iPhoneSimulator.sdk lrwxr-xr-x 1 root wheel 19 Jan 15 2020 iPhoneSimulator13.2.sdk -> iPhoneSimulator.sdk To remedy this, we can get Qt to use the iPhoneOS13.2.sdk: $ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs $ ls -l total 0 drwxrwxr-x 7 root wheel 224 Nov 5 2019 iPhoneOS.sdk lrwxr-xr-x 1 root wheel 12 Jan 15 2020 iPhoneOS13.2.sdk -> iPhoneOS.sdk $ sudo ln -s iPhoneOS.sdk iPhoneOS13.1.sdk $ ls -l total 0 drwxrwxr-x 8 root wheel 256 Jul 22 14:20 iPhoneOS.sdk lrwxr-xr-x 1 root wheel 12 Jul 22 14:20 iPhoneOS13.1.sdk -> iPhoneOS.sdk lrwxr-xr-x 1 root wheel 12 Jan 15 2020 iPhoneOS13.2.sdk -> iPhoneOS.sdk $ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs $ ls -l total 0 drwxrwxr-x 8 root wheel 256 Jul 22 14:14 iPhoneSimulator.sdk lrwxr-xr-x 1 root wheel 19 Jan 15 2020 iPhoneSimulator13.2.sdk -> iPhoneSimulator.sdk $ sudo ln -s iPhoneSimulator.sdk iPhoneSimulator13.1.sdk $ ls -l total 0 drwxrwxr-x 8 root wheel 256 Jul 22 14:14 iPhoneSimulator.sdk lrwxr-xr-x 1 root wheel 19 Jul 22 14:39 iPhoneSimulator13.1.sdk -> iPhoneSimulator.sdk lrwxr-xr-x 1 root wheel 19 Jan 15 2020 iPhoneSimulator13.2.sdk -> iPhoneSimulator.sdk
I met a similar problem, because my xcode project was created by different XCode SDK, and it's generated by CMake, so I deleted the cache and solved the problem.
How to use Bazel as a build tool in Conan.io
I am trying to use Conan for package management and Bazel as build tool for my C++ Codes. The reason I am using conan is because JFrog Artifactory supports it, which I am using as my Artifactory Repository. To do that I came up with the following plan : $/home/mytimer=> ls -lrt 0 Sep 25 11:57 WORKSPACE 4096 Sep 25 12:00 build/ 4096 Sep 25 12:02 main/ $/home/mytimer=> ls -l main total 4 60 Sep 25 12:02 BUILD 61 Sep 25 11:56 conanfile.txt 955 Sep 25 11:56 timer.cpp $/home/mytimer=> ls -l build total 8 1266 Sep 25 12:00 conanbuildinfo.gcc 1875 Sep 25 12:00 conaninfo.txt ( This is after I executed conan --install ../main ) $/home/mytimer=> cat cat main/conanfile.txt [requires] Poco/1.7.8p3#pocoproject/stable [generators] gcc $/home/mytimer=>cat build/conanbuildinfo.gcc -DPOCO_STATIC=ON -DPOCO_NO_AUTOMATIC_LIBS -I"/home/.conan/data/Poco/1.7.8p3/pocoproject/stable/package/da23483d46b7229cbae8615ce1ea2594635f3a5f/include" -I"/home/.conan/data/OpenSSL/1.0.2l/conan/stable/package/c8dc3f0797f6d24f3c80634ae2854ddf9ee34334/include" -I"/home/.conan/data/zlib/1.2.11/conan/stable/package/82b1dd29b2e9143665c77ef477100c690d719cbf/include" -Wl,-rpath="/home/.conan/data/Poco/1.7.8p3/pocoproject/stable/package/da23483d46b7229cbae8615ce1ea2594635f3a5f/lib" -Wl,-rpath="/home/.conan/data/OpenSSL/1.0.2l/conan/stable/package/c8dc3f0797f6d24f3c80634ae2854ddf9ee34334/lib" -Wl,-rpath="/home/.conan/data/zlib/1.2.11/conan/stable/package/82b1dd29b2e9143665c77ef477100c690d719cbf/lib" -L"/home/.conan/data/Poco/1.7.8p3/pocoproject/stable/package/da23483d46b7229cbae8615ce1ea2594635f3a5f/lib" -L"/home/.conan/data/OpenSSL/1.0.2l/conan/stable/package/c8dc3f0797f6d24f3c80634ae2854ddf9ee34334/lib" -L"/home/.conan/data/zlib/1.2.11/conan/stable/package/82b1dd29b2e9143665c77ef477100c690d719cbf/lib" -lPocoUtil -lPocoMongoDB -lPocoNet -lPocoNetSSL -lPocoCrypto -lPocoData -lPocoDataSQLite -lPocoZip -lPocoXML -lPocoJSON -lPocoFoundation -lpthread -lrt -lssl -lcrypto -ldl -lz -D_GLIBCXX_USE_CXX11_ABI=0 -m64 -s -DNDEBUGdevc $/home/mytimer=> cat build/conaninfo.txt [settings] arch=x86_64 build_type=Release compiler=gcc compiler.libcxx=libstdc++ compiler.version=6.3 os=Linux [requires] Poco/1.Y.Z [options] [full_settings] arch=x86_64 build_type=Release compiler=gcc compiler.libcxx=libstdc++ compiler.version=6.3 os=Linux [full_requires] OpenSSL/1.0.2l#conan/stable:c8dc3f0797f6d24f3c80634ae2854ddf9ee34334 Poco/1.7.8p3#pocoproject/stable:da23483d46b7229cbae8615ce1ea2594635f3a5f zlib/1.2.11#conan/stable:82b1dd29b2e9143665c77ef477100c690d719cbf [full_options] OpenSSL:386=False OpenSSL:no_asm=False OpenSSL:no_bf=False OpenSSL:no_cast=False OpenSSL:no_des=False OpenSSL:no_dh=False OpenSSL:no_dsa=False OpenSSL:no_hmac=False OpenSSL:no_md2=False OpenSSL:no_md5=False OpenSSL:no_mdc2=False OpenSSL:no_rc2=False OpenSSL:no_rc4=False OpenSSL:no_rc5=False OpenSSL:no_rsa=False OpenSSL:no_sha=False OpenSSL:no_sse2=False OpenSSL:no_threads=False OpenSSL:no_zlib=False OpenSSL:shared=False Poco:cxx_14=False Poco:enable_apacheconnector=False Poco:enable_cppparser=False Poco:enable_crypto=True Poco:enable_data=True Poco:enable_data_mysql=False Poco:enable_data_odbc=False Poco:enable_data_sqlite=True Poco:enable_json=True Poco:enable_mongodb=True Poco:enable_net=True Poco:enable_netssl=True Poco:enable_netssl_win=True Poco:enable_pagecompiler=False Poco:enable_pagecompiler_file2page=False Poco:enable_pdf=False Poco:enable_pocodoc=False Poco:enable_sevenzip=False Poco:enable_tests=False Poco:enable_util=True Poco:enable_xml=True Poco:enable_zip=True Poco:force_openssl=True Poco:poco_unbundled=False Poco:shared=False zlib:shared=False [scope] dev=True [recipe_hash] [env] $/home/mytimer=> cat main/BUILD cc_binary( name = "timer", srcs = ["timer.cpp"], ) Now, I want to build the mytimer project using bazel as something like this : $/home/mytimer=> bazel build --(some options) //main:timer What should this some options be , so that bazel can read conanbuildinfo.gcc and use it to create the executable file ?
I used the genrule() feature of bazel to solve my problem in this way : $/home/mytimer=> cat main/BUILD genrule( name = "timer", outs = ["timer.out"], cmd = "g++ /home/mytimer/main/timer.cpp#/home/mytimer/build/conanbuildinfo.gcc -o $# ", ) /home/mytime=> bazel build -s //main:timer WARNING: ignoring http_proxy in environment. WARNING: Output base '/home/.cache/bazel/_bazel_user/274fa1325d85b25c2722794ea' is on NFS. This may lead to surprising failures and undetermined behavior. INFO: Found 1 target... >>>>> # //main:timer [action 'Executing genrule //main:timer'] (cd /home/.cache/bazel/_bazel_user/274fa1325d85b25c2722614/execroot/__main__ && \ exec env - \ LD_LIBRARY_PATH=<library paths> PATH=<all other paths> /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; g++ /home/bazel/examples/cpp-tutorial/mytimer/main/timer.cpp #/home/bazel/examples/cpp-tutorial/mytimer/build/conanbuildinfo.gcc -o bazel-out/local-fastbuild/genfiles/main/timer.out ') Target //main:timer up-to-date: bazel-genfiles/main/timer.out INFO: Elapsed time: 1.050s, Critical Path: 0.50s /home/mytime=> ls -lrt bazel-out/local-fastbuild/genfiles/main/ total 212 212000 Sep 26 14:42 timer.out /home/mytime=> ./bazel-out/local-fastbuild/genfiles/main/timer.out Callback called after 249 milliseconds. Callback called after 749 milliseconds. Callback called after 1249 milliseconds. Callback called after 1749 milliseconds. Callback called after 2249 milliseconds. Callback called after 2749 milliseconds. ^C So, by using genrule() feature, we can execute any shell command in bazel. Although this is not a so-called "bazel" way to generate artifacts (genrule() to bazel is same as "goto" command to C/C++ ), in this scenario, I do not see any other option to solve this issue.
You could also create a custom rule: https://docs.bazel.build/versions/master/skylark/rules.html for this. Ideally you would use a Skylark api to the C++ rules, to prevent reimplementing everything that C++ rules already do, but unfortunately that api is not yet finished (October 2017). I think the best tracking bug is https://github.com/bazelbuild/bazel/issues/1624.
Missing files with code coverage
I have a project that I compile with the intel toolchain. All the .f90 files are compiled to corresponding .o files in the bin directory. When I use the codecov utility I get an HTML with the list of covered files. However that list is missing a bunch of files which should be eligible for coverage. Some of the modules contained in those files are even used during the runs. What could be a reason for these files to be missing from the coverage report? EDIT Running the binary with a debugger I noticed something which might be a clue. If I try to set a breakpoint in the files that are not covered gdb throws an error: No line xxx in file "disturb_coms.f90". However disturb_coms.f90 is in the bin folder: manfredo#cave05:build$ ll bin-dbg-A/disturb* -rw-r--r-- 1 manfredo staff 15K Jun 29 10:41 bin-dbg-A/disturb_coms.f90 -rw-r--r-- 1 manfredo staff 3.9K Jun 29 10:41 bin-dbg-A/disturb_coms.mod -rw-r--r-- 1 manfredo staff 4.9K Jun 29 10:41 bin-dbg-A/disturb_coms.o -rw-r--r-- 1 manfredo staff 221K Jun 29 10:43 bin-dbg-A/disturbance.f90 -rw-r--r-- 1 manfredo staff 4.1M Jun 29 10:43 bin-dbg-A/disturbance.o -rw-r--r-- 1 manfredo staff 3.2M Jun 29 10:43 bin-dbg-A/disturbance_utils.mod and was compiled with: ifort -c -FR -CB -O0 -check -g -prof-gen=srcpos -debug full -debug-parameters all -fpe0 -traceback -ftrapuv -fp-stack-check -implicitnone -assume byterecl -warn unused -warn uncalled -warn usage -gen-interfaces -I../../src/include -I/usr/local/hdf5_mio/include disturb_coms.f90 Furthermore a file called disturbance.f90 contains the following lines: module disturbance_utils contains subroutine apply_disturbances(cgrid) ... use disturb_coms , only : treefall_disturbance_rate ! ! intent(in) ... cpoly%disturbance_rates(2,2,isi) = treefall_disturbance_rate ... end subroutine apply_disturbances end module disturbance_utils where disturb_coms is used, and the file disturbance is actually covered. EDIT By adding a write instruction inside disturb_coms.f90 and trying to compile I get the following error: disturb_coms.f90(44): error #6274: This statement must not appear in the specification part of a module. write(*,*) "try" ^ I don't have much experience with Fortran but it looks to me as if that module is a kind of c-equivalent header file. Would there still be a possibility to cover that file as well? Like just checking that the definitions contained there are used elsewhere?
Unable to link dynamic library : Compiling through Xcode make
My project structure is as follows: Project>src>main.cpp The main.cpp calls methods which have a dependancy to a dynamic library (.dylib). In my /usr/local/bin the dynamic library has the name libgismo.dylib but it is an alias which points to libgismo.0.8.1.dylib My make file is: # Targets SRCPATH = ./src GISMOPATH = /usr/local/include/gismo CXX = g++ INCLUDE = -I/usr/local/bin -I/usr/local/include -I$(GISMOPATH) -I/usr/local/lib DYLD_LIBRARY_PATH = -L/usr/local/lib LIBS = -libgismo all: main main : $(SRCPATH)/main.cpp #$(CXX) $(INCLUDE) $(SRCPATH)/main.cpp -o main $(DYLD_LIBRARY_PATH) $(LIBS) $(info Compiling main) clean : #rm main But when I build it through Xcode the following error is generated: ld: library not found for -libgismo.0 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [main] Error 1 Command /Applications/Xcode.app/Contents/Developer/usr/bin/make failed with exit code 2 The output to: $ make -n is g++ -I/usr/local/bin -I/usr/local/include -I/usr/local/include/gismo -I/usr/local/lib ./src/main.cpp -o main -L/usr/local/lib/ -libgismo AND $ ls -l /usr/local/lib/*gismo* is -rw-r--r-- 1 root wheel 1337 May 14 11:35 /usr/local/lib/gismoConfig.cmake -rw-r--r-- 1 root wheel 366 May 14 11:35 /usr/local/lib/gismoConfigVersion.cmake -rw-r--r-- 1 root wheel 3900 May 14 11:34 /usr/local/lib/gismoUse.cmake -rwxr-xr-x 1 root wheel 9195544 May 14 11:52 /usr/local/lib/libgismo.0.8.1.dylib lrwxr-xr-x 1 root wheel 20 May 12 10:23 /usr/local/lib/libgismo.0.dylib -> libgismo.0.8.1.dylib lrwxr-xr-x 1 root wheel 16 May 12 10:23 /usr/local/lib/libgismo.dylib -> libgismo.0.dylib How do I fix this? Thanks!