diff --git a/.clangd b/.clangd deleted file mode 100644 index c36b4792d750c..0000000000000 --- a/.clangd +++ /dev/null @@ -1,10 +0,0 @@ -# Used to allow clangd to run on CI platforms as part of //tools/clangd_check. -# -# Intended to have no effect elsewhere. -# -# See also: -# - https://clangd.llvm.org/config#compileflags -# - https://github.com/clangd/clangd/issues/662 -CompileFlags: - Add: -Wno-unknown-warning-option - Remove: [-m*, -f*] diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 1f2f795bef59c..8cee3d263b758 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -45160,7 +45160,6 @@ ORIGIN: ../../../flutter/vulkan/vulkan_utilities.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/vulkan/vulkan_window.cc + ../../../flutter/LICENSE ORIGIN: ../../../flutter/vulkan/vulkan_window.h + ../../../flutter/LICENSE TYPE: LicenseType.bsd -FILE: ../../../flutter/.clangd FILE: ../../../flutter/.engine-release.version FILE: ../../../flutter/.pylintrc FILE: ../../../flutter/assets/asset_manager.cc diff --git a/tools/clangd_check/bin/main.dart b/tools/clangd_check/bin/main.dart index d2e19dbb5c7dd..d5badb009dc34 100644 --- a/tools/clangd_check/bin/main.dart +++ b/tools/clangd_check/bin/main.dart @@ -106,8 +106,21 @@ void main(List args) { return; } - // Run clangd. + final Engine engineRoot = Engine.findWithin(p.canonicalize(compileCommandsDir)); + final io.File clangdConfig = io.File(p.join(engineRoot.flutterDir.path, '.clangd')); try { + // Write a .clangd file to the engine root directory. + // + // See: + // - https://clangd.llvm.org/config#compileflags + // - https://github.com/clangd/clangd/issues/662 + clangdConfig.writeAsStringSync( + 'CompileFlags:\n' + ' Add: -Wno-unknown-warning-option\n' + ' Remove: [-m*, -f*]\n' + ); + + // Run clangd. final io.ProcessResult result = io.Process.runSync(clangd, [ '--compile-commands-dir', compileCommandsDir, @@ -128,5 +141,8 @@ void main(List args) { io.stderr.writeln('Failed to run clangd: $e'); io.stderr.writeln(const JsonEncoder.withIndent(' ').convert(entry)); io.exitCode = 1; + } finally { + // Remove the copied .clangd file from the engine root directory. + clangdConfig.deleteSync(); } }