From 1d8fbff540133dc1b0d0bbca61870bb1f69b90c8 Mon Sep 17 00:00:00 2001 From: +merlan #flirora Date: Sat, 22 Jul 2023 22:21:08 -0400 Subject: [PATCH] Add support for additional tools This adds the following: * A `compile_commands` target for the ninja_build.sh script. This generates a `compile_commands.json` file, which is used by tools such as clangd, in a new target directory called `build.tooldata`. Unity builds must be disabled for the database to be complete; see [this Discord comment by Casper Jeukendrup](https://discord.com/channels/818804595450445834/939880479887327302/1001483416753143818) for more info. * Additionally, a configuration file for clangd has been created to tell it to find the file in the `build.tooldata` directory. * Add a one-line change to the workspace settings for VSCode, telling it where to find the Uncrustify config. --- .clangd | 2 ++ .gitignore | 1 + .vscode/settings.json | 3 ++- ninja_build.sh | 30 ++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .clangd diff --git a/.clangd b/.clangd new file mode 100644 index 0000000000..5d49a0191e --- /dev/null +++ b/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + CompilationDatabase: build.tooldata/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1fc6e218e8..f660df1186 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ build.release build.debug build.install +build.tooldata build.qtc build-* win32build diff --git a/.vscode/settings.json b/.vscode/settings.json index ebf4014c41..707a2696e3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -48,5 +48,6 @@ "qcombobox": "cpp" }, "cmake.buildDirectory": "${workspaceRoot}/build.debug", - "cmake.configureOnOpen": true + "cmake.configureOnOpen": true, + "uncrustify.configPath.linux": "tools/codestyle/uncrustify_musescore.cfg" } \ No newline at end of file diff --git a/ninja_build.sh b/ninja_build.sh index 6ff0cf180f..605126483b 100755 --- a/ninja_build.sh +++ b/ninja_build.sh @@ -135,6 +135,36 @@ case $TARGET in clean) rm -rf build.debug build.release ;; + + compile_commands) + # Generate compile_commands.json file (https://clang.llvm.org/docs/JSONCompilationDatabase.html) + mkdir -p build.tooldata + cd build.tooldata + cmake .. -GNinja \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \ + -DMUE_COMPILE_USE_UNITY=OFF \ + -DCMAKE_BUILD_TYPE="Debug" \ + -DCMAKE_INSTALL_PREFIX="${MUSESCORE_INSTALL_DIR}" \ + -DMUSESCORE_INSTALL_SUFFIX="${MUSESCORE_INSTALL_SUFFIX}" \ + -DMUSESCORE_BUILD_CONFIGURATION="${MUSESCORE_BUILD_CONFIGURATION}" \ + -DMUSESCORE_BUILD_MODE="${MUSESCORE_BUILD_MODE}" \ + -DCMAKE_BUILD_NUMBER="${MUSESCORE_BUILD_NUMBER}" \ + -DMUSESCORE_REVISION="${MUSESCORE_REVISION}" \ + -DMUE_RUN_LRELEASE="${MUSESCORE_RUN_LRELEASE}" \ + -DMUE_BUILD_VST_MODULE="${MUSESCORE_BUILD_VST_MODULE}" \ + -DMUE_BUILD_VIDEOEXPORT_MODULE="${MUSESCORE_BUILD_VIDEOEXPORT_MODULE}" \ + -DMUE_LEARN_YOUTUBE_API_KEY="${MUSESCORE_YOUTUBE_API_KEY}" \ + -DMUE_BUILD_UPDATE_MODULE="${MUSESCORE_BUILD_UPDATE_MODULE}" \ + -DMUE_DOWNLOAD_SOUNDFONT="${MUSESCORE_DOWNLOAD_SOUNDFONT}" \ + -DMUE_BUILD_UNIT_TESTS="${MUSESCORE_BUILD_UNIT_TESTS}" \ + -DMUE_BUILD_CRASHPAD_CLIENT="${MUSESCORE_BUILD_CRASHPAD_CLIENT}" \ + -DMUE_CRASH_REPORT_URL="${MUSESCORE_CRASHREPORT_URL}" \ + -DMUE_LOGGER_DEBUGLEVEL_ENABLED="${MUSESCORE_DEBUGLEVEL_ENABLED}" \ + -DVST3_SDK_PATH="${MUSESCORE_VST3_SDK_PATH}" \ + -DCMAKE_SKIP_RPATH="${MUSESCORE_NO_RPATH}" \ + + + ;; revision) git rev-parse --short=7 HEAD | tr -d '\n' > local_build_revision.env