Skip to content

Commit 2f8414f

Browse files
committed
Fixed initializaion of profile libraries
1 parent 7e9e4ca commit 2f8414f

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

Diff for: commands/compile/compile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
124124
builderCtx.OtherLibrariesDirs = paths.NewPathList(req.GetLibraries()...)
125125
builderCtx.OtherLibrariesDirs.Add(configuration.LibrariesDir(configuration.Settings))
126126
builderCtx.LibraryDirs = paths.NewPathList(req.Library...)
127-
if len(builderCtx.OtherLibrariesDirs) > 0 || len(builderCtx.LibraryDirs) > 0 {
127+
if len(req.GetLibraries()) > 0 || len(req.GetLibrary()) > 0 {
128128
builderCtx.LibrariesManager = nil // let the builder rebuild the library manager
129129
}
130130
if req.GetBuildPath() == "" {

Diff for: test/test_profiles.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This file is part of arduino-cli.
2+
#
3+
# Copyright 2020 ARDUINO SA (http://www.arduino.cc/)
4+
#
5+
# This software is released under the GNU General Public License version 3,
6+
# which covers the main part of arduino-cli.
7+
# The terms of this license can be found at:
8+
# https://www.gnu.org/licenses/gpl-3.0.en.html
9+
#
10+
# You can be released from the requirements of the above licenses by purchasing
11+
# a commercial license. Buying such a license is mandatory if you want to modify or
12+
# otherwise use the software for commercial activities involving the Arduino
13+
# software without disclosing the source code of your own applications. To purchase
14+
# a commercial license, send an email to [email protected].
15+
16+
import os
17+
import platform
18+
import tempfile
19+
import hashlib
20+
from pathlib import Path
21+
import simplejson as json
22+
23+
import pytest
24+
25+
from .common import running_on_ci
26+
27+
28+
def test_compile_with_profiles(run_command, copy_sketch):
29+
# Init the environment explicitly
30+
run_command(["core", "update-index"])
31+
32+
sketch_path = copy_sketch("sketch_with_profile")
33+
34+
# use profile without a required library -> should fail
35+
result = run_command(["compile", "-m", "avr1", sketch_path])
36+
assert result.failed
37+
38+
# use profile with the required library -> should succeed
39+
result = run_command(["compile", "-m", "avr2", sketch_path])
40+
assert result.ok

0 commit comments

Comments
 (0)