-
-
Notifications
You must be signed in to change notification settings - Fork 0
add README.md generation in the sketch-dist
folder
#17
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
Conversation
The generated README.md contains commands that helps on how to replicate the build environment
cmd/compile.go
Outdated
for _, readmeLib := range returnJson.LibsInfo { | ||
readmeContent = append(readmeContent, "`arduino-cli lib install "+readmeLib.Name+"@"+readmeLib.Version+"`") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for _, readmeLib := range returnJson.LibsInfo { | |
readmeContent = append(readmeContent, "`arduino-cli lib install "+readmeLib.Name+"@"+readmeLib.Version+"`") | |
} | |
libs := []string{} | |
for _, l := range returnJson.LibsInfo { | |
libs = append(libs, l.Name+"@"+l.Version) | |
} | |
readmeContent = append(readmeContent, fmt.Sprintf("`arduino-cli lib install %s`", strings.Join(libs, " "))) |
If this change is applied you'll also need to update the example in README.md
.
cmd/compile.go
Outdated
// generate the commands to run to successfully reproduce the build environment, they will be used as content for the README.md | ||
var readmeContent []string | ||
readmeContent = append(readmeContent, "`arduino-cli core install "+returnJson.CoreInfo.Id+"@"+returnJson.CoreInfo.Version+"`") | ||
for _, readmeLib := range returnJson.LibsInfo { | ||
readmeContent = append(readmeContent, "`arduino-cli lib install "+readmeLib.Name+"@"+readmeLib.Version+"`") | ||
} | ||
// make the paths relative, absolute paths are too long and are different on the user machine | ||
sketchFileRelPath, _ := sketchFilePath.RelFrom(workingDir) | ||
libRelDir, _ := libDir.RelFrom(workingDir) | ||
readmeCompile := "`arduino-cli compile -b " + fqbn + " " + sketchFileRelPath.String() + " --library " + libRelDir.String() + "`" | ||
|
||
//create the README.md file containig instructions regarding what commands to run in order to have again a working binary | ||
// the README.md contains the following: | ||
readmeMd := `This package contains firmware code loaded in your product. | ||
The firmware contains additional code licensed with LGPL clause; in order to re-compile the entire firmware bundle, please execute the following. | ||
|
||
## Install core and libraries | ||
` + strings.Join(readmeContent, "\n") + "\n" + ` | ||
## Compile | ||
` + readmeCompile + "\n" | ||
|
||
readmeMdPath := rootDir.Join("README.md") | ||
createFile(readmeMdPath, readmeMd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this logic into a separate function. The createLib
function is quite big already, separating parts of in different function will make it easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments.
aa54c38
to
1ace2cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great.
I'd change a bit the docstrings of the newly added functions, just to make them more readable. You repeat as the name suggest
in most of them, I'd just remove it, the docs wrong nicely without it.
…s for better readability
1ace2cf
to
7b9831a
Compare
The generated
README.md
contains commands that help on how to replicate the build environment