diff --git a/legacy/builder/constants/constants.go b/legacy/builder/constants/constants.go index c0bde3c7a85..bb1c60bb483 100644 --- a/legacy/builder/constants/constants.go +++ b/legacy/builder/constants/constants.go @@ -89,6 +89,7 @@ const MSG_BOOTLOADER_FILE_MISSING = "Bootloader file specified but missing: {0}" const MSG_BUILD_OPTIONS_CHANGED = "Build options changed, rebuilding all" const MSG_CANT_FIND_SKETCH_IN_PATH = "Unable to find {0} in {1}" const MSG_FQBN_INVALID = "{0} is not a valid fully qualified board name. Required format is targetPackageName:targetPlatformName:targetBoardName." +const MSG_SKIP_PRECOMPILED_LIBRARY = "Skipping dependencies detection for precompiled library {0}" const MSG_FIND_INCLUDES_FAILED = "Error while detecting libraries included by {0}" const MSG_LIB_LEGACY = "(legacy)" const MSG_LIBRARIES_MULTIPLE_LIBS_FOUND_FOR = "Multiple libraries were found for \"{0}\"" diff --git a/legacy/builder/container_find_includes.go b/legacy/builder/container_find_includes.go index 2d980aca4ec..6477a5351ed 100644 --- a/legacy/builder/container_find_includes.go +++ b/legacy/builder/container_find_includes.go @@ -316,8 +316,21 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t if library, ok := sourceFile.Origin.(*libraries.Library); ok && library.UtilityDir != nil { includes = append(includes, library.UtilityDir) } + + if library, ok := sourceFile.Origin.(*libraries.Library); ok { + if library.Precompiled && library.PrecompiledWithSources { + // Fully precompiled libraries should have no dependencies + // to avoid ABI breakage + if ctx.Verbose { + ctx.GetLogger().Println(constants.LOG_LEVEL_DEBUG, constants.MSG_SKIP_PRECOMPILED_LIBRARY, library.Name) + } + return nil + } + } + var preproc_err error var preproc_stderr []byte + if unchanged && cache.valid { include = cache.Next().Include if first && ctx.Verbose { diff --git a/test/test_compile.py b/test/test_compile.py index 6bd1bd5efe4..8b5337e02cf 100644 --- a/test/test_compile.py +++ b/test/test_compile.py @@ -590,3 +590,42 @@ def test_compile_with_archives_and_long_paths(run_command): sketch_path = Path(lib_output[0]["library"]["install_dir"], "examples", "ArduinoIoTCloud-Advanced") assert run_command(f"compile -b esp8266:esp8266:huzzah {sketch_path}") + + +def test_compile_with_precompiled_library(run_command, data_dir): + assert run_command("update") + + assert run_command("core install arduino:samd@1.8.11") + fqbn = "arduino:samd:mkrzero" + + # Install precompiled library + # For more information see: + # https://arduino.github.io/arduino-cli/latest/library-specification/#precompiled-binaries + assert run_command('lib install "BSEC Software Library@1.5.1474"') + sketch_folder = Path(data_dir, "libraries", "BSEC_Software_Library", "examples", "basic") + + # Compile and verify dependencies detection for fully precompiled library is not skipped + result = run_command(f"compile -b {fqbn} {sketch_folder} -v") + assert result.ok + assert "Skipping dependencies detection for precompiled library BSEC Software Library" not in result.stdout + + +def test_compile_with_fully_precompiled_library(run_command, data_dir): + assert run_command("update") + + assert run_command("core install arduino:mbed@1.3.1") + fqbn = "arduino:mbed:nano33ble" + + # Install fully precompiled library + # For more information see: + # https://arduino.github.io/arduino-cli/latest/library-specification/#precompiled-binaries + assert run_command("lib install Arduino_TensorFlowLite@2.1.1-ALPHA-precompiled") + sketch_folder = Path(data_dir, "libraries", "Arduino_TensorFlowLite", "examples", "hello_world") + + # Install example dependency + # assert run_command("lib install Arduino_LSM9DS1") + + # Compile and verify dependencies detection for fully precompiled library is skipped + result = run_command(f"compile -b {fqbn} {sketch_folder} -v") + assert result.ok + assert "Skipping dependencies detection for precompiled library Arduino_TensorFlowLite" in result.stdout