Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip dependency detection if library is fully precompiled #1139

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions legacy/builder/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}\""
Expand Down
13 changes: 13 additions & 0 deletions legacy/builder/container_find_includes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
39 changes: 39 additions & 0 deletions test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]")
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 [email protected]"')
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:[email protected]")
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 [email protected]")
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