Skip to content

Commit 283036f

Browse files
Skip dependency detection if library is fully precompiled (arduino#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 <silvanocerza@gmail.com>
1 parent 079bb6c commit 283036f

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

legacy/builder/constants/constants.go

Lines changed: 1 addition & 0 deletions
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}\""

legacy/builder/container_find_includes.go

Lines changed: 13 additions & 0 deletions
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 {

test/test_compile.py

Lines changed: 39 additions & 0 deletions
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:samd@1.8.11")
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 Library@1.5.1474"')
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:mbed@1.3.1")
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 Arduino_TensorFlowLite@2.1.1-ALPHA-precompiled")
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy