Skip to content

Commit f1e79fb

Browse files
Draft: Exclude compile_commands.json from sketch loading
This allows users to create a symlink to the autogenerated file in the sketch directory, without that file being handled or causing failure when the target file does not exist yet (or anymore). Draft: This abuses FilterOutSuffix, it should match the filename, but go-paths-helper does not support this now. Draft: Is this really the right place/approach to exclude this file?
1 parent 04f1647 commit f1e79fb

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

arduino/sketch/sketch.go

+8
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ func (s *Sketch) supportedFiles() (*paths.PathList, error) {
166166
}
167167
files.FilterOutDirs()
168168
files.FilterOutHiddenFiles()
169+
// Exclude files named compile_commands.json, to allow the user
170+
// creating a symlink to the autogenerated file in the sketch
171+
// directory, without that being handled or causing failure when
172+
// the target file does not exist yet.
173+
// TODO: This abuses FilterOutSuffix, it should match the
174+
// filename, but go-paths-helper does not support this now.
175+
files.FilterOutSuffix("compile_commands.json")
176+
169177
validExtensions := []string{}
170178
for ext := range globals.MainFileValidExtensions {
171179
validExtensions = append(validExtensions, ext)

test/test_compile.py

+5
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ def test_broken_symlink(sketch_name, link_name, target_name, expect_error):
225225
test_broken_symlink("CompileIntegrationTestSymlinkBrokenH", "link.h", "doesnotexist.h", expect_error=True)
226226
test_broken_symlink("CompileIntegrationTestSymlinkBrokenJson", "link.json", "doesnotexist.json", expect_error=True)
227227
test_broken_symlink("CompileIntegrationTestSymlinkBrokenXXX", "link.xxx", "doesnotexist.xxx", expect_error=False)
228+
# Support a usecase where a user makes a symlink to
229+
# compile_commands.json in the sketch root, even when it does not
230+
# exist yet/anymore
231+
test_broken_symlink("CompileIntegrationTestSymlinkBrokenCompileCommands", "compile_commands.json",
232+
"doesnotexist.json", expect_error=False)
228233

229234

230235
def test_compile_blacklisted_sketchname(run_command, data_dir):

0 commit comments

Comments
 (0)