To be clear, the problem is not in the IDE front-end, but in the arduino-cli
back-end, which is written in Go. It calls the the compilers like g++
. Taking a quick look, the part in question looks innocuous enough
b.logIfVerbose(false, tr("Detecting libraries used..."))
err := b.libsDetector.FindIncludes(
b.buildPath,
b.buildProperties.GetPath("build.core.path"),
b.buildProperties.GetPath("build.variant.path"),
b.sketchBuildPath,
b.sketch,
b.librariesBuildPath,
b.buildProperties,
b.targetPlatform.Platform.Architecture,
)
if err != nil {
return err
}
b.Progress.CompleteStep()
b.warnAboutArchIncompatibleLibraries(b.libsDetector.ImportedLibraries())
b.Progress.CompleteStep()
b.logIfVerbose(false, tr("Generating function prototypes..."))
if err := b.preprocessSketch(b.libsDetector.IncludeFolders()); err != nil {
return err
}
b.Progress.CompleteStep()
(As of the last release; since then, the file has been moved.) For "Detecting libraries", at the latest commit, there are enticing bits like
if !l.useCachedLibrariesResolution {
sketch := sketch
mergedfile, err := makeSourceFile(sketchBuildPath, sketchBuildPath, paths.New(sketch.MainFile.Base()+".cpp"))
if err != nil {
return err
}
sourceFileQueue.push(mergedfile)
l.queueSourceFilesFromFolder(sourceFileQueue, sketchBuildPath, false /* recurse */, sketchBuildPath, sketchBuildPath)
srcSubfolderPath := sketchBuildPath.Join("src")
if srcSubfolderPath.IsDir() {
l.queueSourceFilesFromFolder(sourceFileQueue, srcSubfolderPath, true /* recurse */, sketchBuildPath, sketchBuildPath)
}
for !sourceFileQueue.empty() {
err := l.findIncludesUntilDone(cache, sourceFileQueue, buildProperties, sketchBuildPath, librariesBuildPath, platformArch)
if err != nil {
cachePath.Remove()
return err
}
}
Seems like useCachedLibrariesResolution
is always false -- if so, why is that?
"Generating function prototypes" is not about the .ino.cpp
, where the magic has been applied. The verbose compiler output shows that file is already present during "Detecting libraries". Instead, it appears to create a very temporary sketch_merged.cpp
, and then run ctags
on it. This might be to enable the code hint/insight/sense/completion feature of the IDE, and therefore not strictly required to create the binary. If so, a better name for this step -- both the function name in the code and the message it prints -- might help; as would running it after the build and/or during the upload.