Unverified Commit 89368c92 authored by Cristian Maglie's avatar Cristian Maglie Committed by GitHub

fix: Allow build-path to different drive than the sketch (#2163)

This issue is mainly seen on Windows

Fix https://github.com/arduino/arduino-cli/issues/2156
parent ad9ddb88
--- ---
name: github.com/arduino/go-paths-helper name: github.com/arduino/go-paths-helper
version: v1.8.0 version: v1.9.0
type: go type: go
summary: summary:
homepage: https://pkg.go.dev/github.com/arduino/go-paths-helper homepage: https://pkg.go.dev/github.com/arduino/go-paths-helper
license: gpl-2.0-or-later license: gpl-2.0-or-later
licenses: licenses:
......
...@@ -265,10 +265,7 @@ func (pme *Explorer) IsManagedPlatformRelease(platformRelease *cores.PlatformRel ...@@ -265,10 +265,7 @@ func (pme *Explorer) IsManagedPlatformRelease(platformRelease *cores.PlatformRel
if packagesDir.FollowSymLink() != nil { if packagesDir.FollowSymLink() != nil {
return false return false
} }
managed, err := installDir.IsInsideDir(packagesDir) managed := installDir.IsInsideDir(packagesDir)
if err != nil {
return false
}
return managed return managed
} }
...@@ -371,10 +368,7 @@ func (pme *Explorer) IsManagedToolRelease(toolRelease *cores.ToolRelease) bool { ...@@ -371,10 +368,7 @@ func (pme *Explorer) IsManagedToolRelease(toolRelease *cores.ToolRelease) bool {
if packagesDir.FollowSymLink() != nil { if packagesDir.FollowSymLink() != nil {
return false return false
} }
managed, err := installDir.IsInsideDir(packagesDir) managed := installDir.IsInsideDir(packagesDir)
if err != nil {
return false
}
return managed return managed
} }
......
...@@ -135,7 +135,7 @@ func New(path *paths.Path) (*Sketch, error) { ...@@ -135,7 +135,7 @@ func New(path *paths.Path) (*Sketch, error) {
} else if _, found := globals.AdditionalFileValidExtensions[ext]; found { } else if _, found := globals.AdditionalFileValidExtensions[ext]; found {
// If the user exported the compiles binaries to the Sketch "build" folder // If the user exported the compiles binaries to the Sketch "build" folder
// they would be picked up but we don't want them, so we skip them like so // they would be picked up but we don't want them, so we skip them like so
if isInBuildFolder, err := p.IsInsideDir(sketch.FullPath.Join("build")); isInBuildFolder || err != nil { if p.IsInsideDir(sketch.FullPath.Join("build")) {
continue continue
} }
......
...@@ -131,9 +131,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream ...@@ -131,9 +131,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
var buildPath *paths.Path var buildPath *paths.Path
if buildPathArg := req.GetBuildPath(); buildPathArg != "" { if buildPathArg := req.GetBuildPath(); buildPathArg != "" {
buildPath = paths.New(req.GetBuildPath()).Canonical() buildPath = paths.New(req.GetBuildPath()).Canonical()
if in, err := buildPath.IsInsideDir(sk.FullPath); err != nil { if in := buildPath.IsInsideDir(sk.FullPath); in && buildPath.IsDir() {
return nil, &arduino.NotFoundError{Message: tr("Cannot find build path"), Cause: err}
} else if in && buildPath.IsDir() {
if sk.AdditionalFiles, err = removeBuildFromSketchFiles(sk.AdditionalFiles, buildPath); err != nil { if sk.AdditionalFiles, err = removeBuildFromSketchFiles(sk.AdditionalFiles, buildPath); err != nil {
return nil, err return nil, err
} }
...@@ -385,9 +383,7 @@ func removeBuildFromSketchFiles(files paths.PathList, build *paths.Path) (paths. ...@@ -385,9 +383,7 @@ func removeBuildFromSketchFiles(files paths.PathList, build *paths.Path) (paths.
var res paths.PathList var res paths.PathList
ignored := false ignored := false
for _, file := range files { for _, file := range files {
if in, err := file.IsInsideDir(build); err != nil { if !file.IsInsideDir(build) {
return nil, &arduino.NotFoundError{Message: tr("Cannot find build path"), Cause: err}
} else if !in {
res = append(res, file) res = append(res, file)
} else if !ignored { } else if !ignored {
ignored = true ignored = true
......
...@@ -6,7 +6,7 @@ go 1.20 ...@@ -6,7 +6,7 @@ go 1.20
replace github.com/mailru/easyjson => github.com/cmaglie/easyjson v0.8.1 replace github.com/mailru/easyjson => github.com/cmaglie/easyjson v0.8.1
require ( require (
github.com/arduino/go-paths-helper v1.8.0 github.com/arduino/go-paths-helper v1.9.0
github.com/arduino/go-properties-orderedmap v1.7.1 github.com/arduino/go-properties-orderedmap v1.7.1
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b
github.com/arduino/go-win32-utils v0.0.0-20180330194947-ed041402e83b github.com/arduino/go-win32-utils v0.0.0-20180330194947-ed041402e83b
......
...@@ -45,8 +45,8 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo ...@@ -45,8 +45,8 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/arduino/go-paths-helper v1.0.1/go.mod h1:HpxtKph+g238EJHq4geEPv9p+gl3v5YYu35Yb+w31Ck= github.com/arduino/go-paths-helper v1.0.1/go.mod h1:HpxtKph+g238EJHq4geEPv9p+gl3v5YYu35Yb+w31Ck=
github.com/arduino/go-paths-helper v1.8.0 h1:BfA1bq1XktnlqwfUDCoKbUqB3YFPe6X7szPSZj6Rdpk= github.com/arduino/go-paths-helper v1.9.0 h1:IjWhDSF24n5bK/30NyApmzoVH9brWzc52KNPpBsRmMc=
github.com/arduino/go-paths-helper v1.8.0/go.mod h1:V82BWgAAp4IbmlybxQdk9Bpkz8M4Qyx+RAFKaG9NuvU= github.com/arduino/go-paths-helper v1.9.0/go.mod h1:V82BWgAAp4IbmlybxQdk9Bpkz8M4Qyx+RAFKaG9NuvU=
github.com/arduino/go-properties-orderedmap v1.7.1 h1:HQ9Pn/mk3+XyfrE39EEvaZwJkrvgiVSY5Oq3JSEfOR4= github.com/arduino/go-properties-orderedmap v1.7.1 h1:HQ9Pn/mk3+XyfrE39EEvaZwJkrvgiVSY5Oq3JSEfOR4=
github.com/arduino/go-properties-orderedmap v1.7.1/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk= github.com/arduino/go-properties-orderedmap v1.7.1/go.mod h1:DKjD2VXY/NZmlingh4lSFMEYCVubfeArCsGPGDwb2yk=
github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b h1:9hDi4F2st6dbLC3y4i02zFT5quS4X6iioWifGlVwfy4= github.com/arduino/go-timeutils v0.0.0-20171220113728-d1dd9e313b1b h1:9hDi4F2st6dbLC3y4i02zFT5quS4X6iioWifGlVwfy4=
......
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