Skip to content

Commit 283036f

Browse files
Skip dependency detection if library is fully precompiled (#1139)
* Skip dependency detection if library is fully precompiled Precompiled bits of a library should not depend on any link time dependency (we cannot assure ABI stability). Fixes arduino/ArduinoCore-mbed#119 * Add output when skipping deps detection for precompiled libs Co-authored-by: Silvano Cerza <[email protected]>
1 parent 079bb6c commit 283036f

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

Diff for: legacy/builder/constants/constants.go

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ const MSG_BOOTLOADER_FILE_MISSING = "Bootloader file specified but missing: {0}"
8989
const MSG_BUILD_OPTIONS_CHANGED = "Build options changed, rebuilding all"
9090
const MSG_CANT_FIND_SKETCH_IN_PATH = "Unable to find {0} in {1}"
9191
const MSG_FQBN_INVALID = "{0} is not a valid fully qualified board name. Required format is targetPackageName:targetPlatformName:targetBoardName."
92+
const MSG_SKIP_PRECOMPILED_LIBRARY = "Skipping dependencies detection for precompiled library {0}"
9293
const MSG_FIND_INCLUDES_FAILED = "Error while detecting libraries included by {0}"
9394
const MSG_LIB_LEGACY = "(legacy)"
9495
const MSG_LIBRARIES_MULTIPLE_LIBS_FOUND_FOR = "Multiple libraries were found for \"{0}\""

Diff for: legacy/builder/container_find_includes.go

+13
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,21 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t
316316
if library, ok := sourceFile.Origin.(*libraries.Library); ok && library.UtilityDir != nil {
317317
includes = append(includes, library.UtilityDir)
318318
}
319+
320+
if library, ok := sourceFile.Origin.(*libraries.Library); ok {
321+
if library.Precompiled && library.PrecompiledWithSources {
322+
// Fully precompiled libraries should have no dependencies
323+
// to avoid ABI breakage
324+
if ctx.Verbose {
325+
ctx.GetLogger().Println(constants.LOG_LEVEL_DEBUG, constants.MSG_SKIP_PRECOMPILED_LIBRARY, library.Name)
326+
}
327+
return nil
328+
}
329+
}
330+
319331
var preproc_err error
320332
var preproc_stderr []byte
333+
321334
if unchanged && cache.valid {
322335
include = cache.Next().Include
323336
if first && ctx.Verbose {

Diff for: test/test_compile.py

+39
Original file line numberDiff line numberDiff line change
@@ -590,3 +590,42 @@ def test_compile_with_archives_and_long_paths(run_command):
590590
sketch_path = Path(lib_output[0]["library"]["install_dir"], "examples", "ArduinoIoTCloud-Advanced")
591591

592592
assert run_command(f"compile -b esp8266:esp8266:huzzah {sketch_path}")
593+
594+
595+
def test_compile_with_precompiled_library(run_command, data_dir):
596+
assert run_command("update")
597+
598+
assert run_command("core install arduino:[email protected]")
599+
fqbn = "arduino:samd:mkrzero"
600+
601+
# Install precompiled library
602+
# For more information see:
603+
# https://arduino.github.io/arduino-cli/latest/library-specification/#precompiled-binaries
604+
assert run_command('lib install "BSEC Software [email protected]"')
605+
sketch_folder = Path(data_dir, "libraries", "BSEC_Software_Library", "examples", "basic")
606+
607+
# Compile and verify dependencies detection for fully precompiled library is not skipped
608+
result = run_command(f"compile -b {fqbn} {sketch_folder} -v")
609+
assert result.ok
610+
assert "Skipping dependencies detection for precompiled library BSEC Software Library" not in result.stdout
611+
612+
613+
def test_compile_with_fully_precompiled_library(run_command, data_dir):
614+
assert run_command("update")
615+
616+
assert run_command("core install arduino:[email protected]")
617+
fqbn = "arduino:mbed:nano33ble"
618+
619+
# Install fully precompiled library
620+
# For more information see:
621+
# https://arduino.github.io/arduino-cli/latest/library-specification/#precompiled-binaries
622+
assert run_command("lib install [email protected]")
623+
sketch_folder = Path(data_dir, "libraries", "Arduino_TensorFlowLite", "examples", "hello_world")
624+
625+
# Install example dependency
626+
# assert run_command("lib install Arduino_LSM9DS1")
627+
628+
# Compile and verify dependencies detection for fully precompiled library is skipped
629+
result = run_command(f"compile -b {fqbn} {sketch_folder} -v")
630+
assert result.ok
631+
assert "Skipping dependencies detection for precompiled library Arduino_TensorFlowLite" in result.stdout

0 commit comments

Comments
 (0)