Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
c9836a97
Unverified
Commit
c9836a97
authored
Sep 26, 2019
by
Cristian Maglie
Committed by
GitHub
Sep 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder.GenBuildPath now tolerates missing sketch folder (#428)
parent
c23bb9c4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
11 deletions
+18
-11
arduino/builder/builder.go
arduino/builder/builder.go
+10
-6
arduino/builder/builder_test.go
arduino/builder/builder_test.go
+5
-1
legacy/builder/builder.go
legacy/builder/builder.go
+3
-4
No files found.
arduino/builder/builder.go
View file @
c9836a97
...
...
@@ -19,18 +19,22 @@ import (
"crypto/md5"
"encoding/hex"
"os"
"path/filepath"
"strings"
"github.com/arduino/go-paths-helper"
"github.com/pkg/errors"
)
// GenBuildPath generates a suitable name for the build folder
func
GenBuildPath
(
sketchPath
string
)
string
{
md5SumBytes
:=
md5
.
Sum
([]
byte
(
sketchPath
))
// GenBuildPath generates a suitable name for the build folder.
// The sketchPath, if not nil, is also used to furhter differentiate build paths.
func
GenBuildPath
(
sketchPath
*
paths
.
Path
)
*
paths
.
Path
{
path
:=
""
if
sketchPath
!=
nil
{
path
=
sketchPath
.
String
()
}
md5SumBytes
:=
md5
.
Sum
([]
byte
(
path
))
md5Sum
:=
strings
.
ToUpper
(
hex
.
EncodeToString
(
md5SumBytes
[
:
]))
return
filepath
.
Join
(
os
.
TempDir
(),
"arduino-sketch-"
+
md5Sum
)
return
paths
.
TempDir
()
.
Join
(
"arduino-sketch-"
+
md5Sum
)
}
// EnsureBuildPathExists creates the build path if doesn't already exists.
...
...
arduino/builder/builder_test.go
View file @
c9836a97
...
...
@@ -23,6 +23,7 @@ import (
"testing"
"github.com/arduino/arduino-cli/arduino/builder"
"github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/assert"
)
...
...
@@ -36,7 +37,10 @@ func tmpDirOrDie() string {
func
TestGenBuildPath
(
t
*
testing
.
T
)
{
want
:=
filepath
.
Join
(
os
.
TempDir
(),
"arduino-sketch-ACBD18DB4CC2F85CEDEF654FCCC4A4D8"
)
assert
.
Equal
(
t
,
want
,
builder
.
GenBuildPath
(
"foo"
))
assert
.
Equal
(
t
,
want
,
builder
.
GenBuildPath
(
paths
.
New
(
"foo"
))
.
String
())
want
=
filepath
.
Join
(
os
.
TempDir
(),
"arduino-sketch-D41D8CD98F00B204E9800998ECF8427E"
)
assert
.
Equal
(
t
,
want
,
builder
.
GenBuildPath
(
nil
)
.
String
())
}
func
TestEnsureBuildPathExists
(
t
*
testing
.
T
)
{
...
...
legacy/builder/builder.go
View file @
c9836a97
...
...
@@ -43,7 +43,6 @@ import (
"github.com/arduino/arduino-cli/legacy/builder/phases"
"github.com/arduino/arduino-cli/legacy/builder/types"
"github.com/arduino/arduino-cli/legacy/builder/utils"
"github.com/arduino/go-paths-helper"
)
var
MAIN_FILE_VALID_EXTENSIONS
=
map
[
string
]
bool
{
".ino"
:
true
,
".pde"
:
true
}
...
...
@@ -58,7 +57,7 @@ type Builder struct{}
func
(
s
*
Builder
)
Run
(
ctx
*
types
.
Context
)
error
{
if
ctx
.
BuildPath
==
nil
{
ctx
.
BuildPath
=
paths
.
New
(
bldr
.
GenBuildPath
(
ctx
.
SketchLocation
.
String
())
)
ctx
.
BuildPath
=
bldr
.
GenBuildPath
(
ctx
.
SketchLocation
)
}
if
err
:=
bldr
.
EnsureBuildPathExists
(
ctx
.
BuildPath
.
String
());
err
!=
nil
{
...
...
@@ -150,7 +149,7 @@ type Preprocess struct{}
func
(
s
*
Preprocess
)
Run
(
ctx
*
types
.
Context
)
error
{
if
ctx
.
BuildPath
==
nil
{
ctx
.
BuildPath
=
paths
.
New
(
bldr
.
GenBuildPath
(
ctx
.
SketchLocation
.
String
())
)
ctx
.
BuildPath
=
bldr
.
GenBuildPath
(
ctx
.
SketchLocation
)
}
if
err
:=
bldr
.
EnsureBuildPathExists
(
ctx
.
BuildPath
.
String
());
err
!=
nil
{
...
...
@@ -186,7 +185,7 @@ type ParseHardwareAndDumpBuildProperties struct{}
func
(
s
*
ParseHardwareAndDumpBuildProperties
)
Run
(
ctx
*
types
.
Context
)
error
{
if
ctx
.
BuildPath
==
nil
{
ctx
.
BuildPath
=
paths
.
New
(
bldr
.
GenBuildPath
(
ctx
.
SketchLocation
.
String
())
)
ctx
.
BuildPath
=
bldr
.
GenBuildPath
(
ctx
.
SketchLocation
)
}
commands
:=
[]
types
.
Command
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment