Unverified Commit 283036fc authored by Martino Facchin's avatar Martino Facchin Committed by GitHub

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 https://github.com/arduino/ArduinoCore-mbed/issues/119

* Add output when skipping deps detection for precompiled libs
Co-authored-by: default avatarSilvano Cerza <silvanocerza@gmail.com>
parent 079bb6c6
...@@ -89,6 +89,7 @@ const MSG_BOOTLOADER_FILE_MISSING = "Bootloader file specified but missing: {0}" ...@@ -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_BUILD_OPTIONS_CHANGED = "Build options changed, rebuilding all"
const MSG_CANT_FIND_SKETCH_IN_PATH = "Unable to find {0} in {1}" 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_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_FIND_INCLUDES_FAILED = "Error while detecting libraries included by {0}"
const MSG_LIB_LEGACY = "(legacy)" const MSG_LIB_LEGACY = "(legacy)"
const MSG_LIBRARIES_MULTIPLE_LIBS_FOUND_FOR = "Multiple libraries were found for \"{0}\"" const MSG_LIBRARIES_MULTIPLE_LIBS_FOUND_FOR = "Multiple libraries were found for \"{0}\""
......
...@@ -316,8 +316,21 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t ...@@ -316,8 +316,21 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t
if library, ok := sourceFile.Origin.(*libraries.Library); ok && library.UtilityDir != nil { if library, ok := sourceFile.Origin.(*libraries.Library); ok && library.UtilityDir != nil {
includes = append(includes, library.UtilityDir) 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_err error
var preproc_stderr []byte var preproc_stderr []byte
if unchanged && cache.valid { if unchanged && cache.valid {
include = cache.Next().Include include = cache.Next().Include
if first && ctx.Verbose { if first && ctx.Verbose {
......
...@@ -590,3 +590,42 @@ def test_compile_with_archives_and_long_paths(run_command): ...@@ -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") sketch_path = Path(lib_output[0]["library"]["install_dir"], "examples", "ArduinoIoTCloud-Advanced")
assert run_command(f"compile -b esp8266:esp8266:huzzah {sketch_path}") 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment