我在为我的项目而拼命地跑。我正试图为我的项目运行clang,以便将数据发送到Codacy。我是这样做的:
clang-tidy $PWD -header-filter=.*,-checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus* | ./codacy-clang-tidy-1.1.1 | \
curl -XPOST -L -H "project-token: $CODACY_PROJECT_TOKEN" \
-H "Content-type: application/json" -d @- \
"https://api.codacy.com/2.0/commit/$TRAVIS_COMMIT/issuesRemoteResults"
curl -XPOST -L -H "project-token: $CODACY_PROJECT_TOKEN" \
-H "Content-type: application/json" \
"https://api.codacy.com/2.0/commit/$TRAVIS_COMMIT/resultsFinal"但它抱怨说,无法找到汇编数据:
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "/home/travis/build/mVento3/Duckvil/build"
No compilation database found in /home/travis/build/mVento3/Duckvil or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory我确信compile_commands.json位于build目录中,在那里我试图运行clang。
主CMakeLists.txt:
cmake_minimum_required(VERSION 3.17)
project(Duckvil)
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
if(NOT CLANG_TIDY_COMMAND)
message(WARNING "Could not find clang-tidy!")
set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE)
else()
message(WARNING "Found clang-tidy")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_CLANG_TIDY
clang-tidy;
-header-filter=.*;
-checks=*;
--dump-config > .clang-tidy;
)
endif()
if(WIN32)
add_definitions(-DDUCKVIL_PLATFORM_WINDOWS)
else()
if(UNIX)
add_definitions(-DDUCKVIL_PLATFORM_LINUX)
SET(GCC_COVERAGE_COMPILE_FLAGS "-g -O0 -coverage -fprofile-arcs -ftest-coverage")
SET(GCC_COVERAGE_LINK_FLAGS "-coverage -lgcov")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
endif()
endif()
add_definitions(-DDUCKVIL_OUTPUT="${CMAKE_SOURCE_DIR}/bin")
add_subdirectory(source)
list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure")
ENABLE_TESTING()
add_subdirectory(test)我是否需要指定其他选项,还是我误解了什么?
编辑
再想一想,也许我不应该在单独的"go“中这样做,但是在生成CMake项目时呢?
EDIT2
我想出了这个:
./codacy-clang-tidy-1.1.1 < compile_commands.json | \
curl -XPOST -L -H "project-token: ${CODACY_PROJECT_TOKEN}" \
-H "Content-type: application/json" -d @- \
"https://api.codacy.com/2.0/commit/${TRAVIS_COMMIT}/issuesRemoteResults"
curl -XPOST -L -H "project-token: ${CODACY_PROJECT_TOKEN}" \
-H "Content-type: application/json" \
"https://api.codacy.com/2.0/commit/${TRAVIS_COMMIT}/resultsFinal"现在它不是在抱怨数据库,它似乎是在将数据发送到codacy,但是我看不到关于codacy的任何东西。我阅读了娇惯,似乎是从stdin获得数据。
发布于 2022-04-11 10:28:18
使用-p (如-p ${CMAKE_BUILD_DIR} )显式指定位置
-p <build-path> is used to read a compile command database.
For example, it can be a CMake build directory in which a file named
compile_commands.json exists (use -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
CMake option to get this output). When no build path is specified,
a search for compile_commands.json will be attempted through all
parent paths of the first input file . See:
https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html for an
example of setting up Clang Tooling on a source tree.https://stackoverflow.com/questions/63944447
复制相似问题