Skip to content

Commit 1068440

Browse files
umbynosper1234
andcommitted
Apply suggestions from code review
Co-authored-by: per1234 <[email protected]>
1 parent 0e4cc3f commit 1068440

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# cslt-tool
22

33
`cslt-tool` is a convenient wrapper of [arduino-cli](https://github.com/arduino/arduino-cli), it compiles Arduino sketches outputting a precompiled library in the current working directory.
4-
It generates a json file in `extra/` folder that contains information regarding libraries and core to use in order to build the sketch. The result is achieved by parsing the verbose output of `arduino-cli` and by using [GNU ar](https://sourceware.org/binutils/docs/binutils/ar.html) to generate an archive of the object files.
4+
It generates a json file in the `extras/` folder that contains information regarding libraries and core to use in order to build the sketch. The result is achieved by parsing the verbose output of `arduino-cli` and by using [GNU ar](https://sourceware.org/binutils/docs/binutils/ar.html) to generate an archive of the object files.
55

66
## Prequisites
7-
In order to run this tool you have to install first the [arduino-cli](https://github.com/arduino/arduino-cli) and have `arduino-cli` binary in your `$PATH`, otherwise `cslt-tool` won't work.
8-
Please use a version of the arduino CLI that has [this](https://github.com/arduino/arduino-cli/pull/1608) change (version > 0.20.2).
7+
In order to run this tool you have to install first the [Arduino CLI](https://github.com/arduino/arduino-cli) and have `arduino-cli` binary in your `$PATH`, otherwise `cslt-tool` won't work.
8+
Please use a version of the Arduino CLI that has [this](https://github.com/arduino/arduino-cli/pull/1608) change (version > 0.20.2).
99

1010
Another requirement is [`gcc-ar`](https://sourceware.org/binutils/docs/binutils/ar.html) (installable with `apt-get install gcc`) in your `$PATH`.
1111

@@ -21,7 +21,7 @@ libsketch/
2121
├── examples
2222
│ └── sketch
2323
│ └── sketch.ino <-- the actual sketch we are going to compile with the arduino-cli later
24-
├── extra
24+
├── extras
2525
│ └── result.json
2626
├── library.properties
2727
└── src
@@ -31,7 +31,7 @@ libsketch/
3131
```
3232

3333
This is an example execution:
34-
``` bash
34+
```
3535
$ ./cslt-tool compile -b arduino:samd:mkrwifi1010 sketch/sketch.ino
3636
INFO[0000] arduino-cli version: git-snapshot
3737
INFO[0000] GNU ar (GNU Binutils) 2.37
@@ -48,10 +48,10 @@ INFO[0001] created libsketch/src/libsketch.h
4848
INFO[0001] created libsketch/examples/sketch/sketch.ino
4949
INFO[0001] running: gcc-ar rcs libsketch/src/cortex-m0plus/libsketch.a /tmp/arduino-sketch-E4D76B1781E9EB73A7B3491CAC68F374/sketch/sketch.ino.cpp.o
5050
INFO[0001] created libsketch/src/cortex-m0plus/libsketch.a
51-
INFO[0001] created libsketch/extra/result.json
51+
INFO[0001] created libsketch/extras/result.json
5252
```
5353

54-
And the content of `libsketch/extra/result.json` is:
54+
And the content of `libsketch/extras/result.json` is:
5555
```json
5656
{
5757
"coreInfo": {
@@ -78,20 +78,20 @@ And the content of `libsketch/extra/result.json` is:
7878
```
7979

8080
## How to compile the precompiled sketch
81-
In order to compile the sketch you have first to install manually the libraries and the core listed in the `<libsketch>/extra/result.json` file.
81+
In order to compile the sketch you have first to install manually the libraries and the core listed in the `<libsketch>/extras/result.json` file.
8282

83-
You can install a library with [`arduino-cli lib install LIBRARY[@VERSION_NUMBER]`](https://arduino.github.io/arduino-cli/0.20/commands/arduino-cli_lib_install/).
83+
You can install a library with [`arduino-cli lib install LIBRARY[@VERSION_NUMBER]`](https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_lib_install/).
8484

85-
You can install a core with [`arduino-cli core install PACKAGER:ARCH[@VERSION]`](https://arduino.github.io/arduino-cli/0.20/commands/arduino-cli_core_install/).
85+
You can install a core with [`arduino-cli core install PACKAGER:ARCH[@VERSION]`](https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_core_install/).
8686

8787
After completing that operation you can compile it with:
8888

8989
`arduino-cli compile -b <fqbn> <libsketch>/examples/sketch/sketch.ino --library <libsketch>`.
9090

91-
It's important to use the `--library` flag to include the precompiled library generated with cslt-tool otherwise the arduino CLI won't find it.
91+
It's important to use the `--library` flag to include the precompiled library generated with cslt-tool otherwise the Arduino CLI won't find it.
9292

9393
For example a legit execution looks like this:
94-
``` bash
94+
```
9595
$ arduino-cli compile -b arduino:samd:mkrwifi1010 libsketch/examples/sketch/sketch.ino --library libsketch/
9696
9797
Library libsketch has been declared precompiled:

cmd/compile.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func getInoSketchPath(argSketchPath string) (inoPath *paths.Path) {
198198
if len(files) == 0 {
199199
logrus.Fatal("the sketch path specified does not contain an .ino file")
200200
} else if len(files) > 1 {
201-
logrus.Fatalf("the sketch path specified contains multiple .ino files:\n %s \nIn order to make the magic please use the path of the .ino file containing the setup() and loop() functions", strings.Join(files.AsStrings(), "\n"))
201+
logrus.Fatalf("the sketch path specified contains multiple .ino files:\n%s\nIn order to make the magic please use the path of the .ino file containing the setup() and loop() functions", strings.Join(files.AsStrings(), "\n"))
202202
}
203203
inoPath = files[0]
204204
}
@@ -273,7 +273,7 @@ func createLib(sketchName string, buildMcu string, returnJson *ResultJson, objFi
273273
// ├── examples
274274
// │ └── sketch
275275
// │ └── sketch.ino <-- the actual sketch we are going to compile with the arduino-cli later
276-
// ├── extra
276+
// ├── extras
277277
// │ └── result.json
278278
// ├── library.properties
279279
// └── src
@@ -302,7 +302,7 @@ func createLib(sketchName string, buildMcu string, returnJson *ResultJson, objFi
302302
if err = exampleDir.MkdirAll(); err != nil {
303303
logrus.Fatal(err)
304304
}
305-
extraDir := libDir.Join("extra")
305+
extraDir := libDir.Join("extras")
306306
if err = extraDir.Mkdir(); err != nil {
307307
logrus.Fatal(err)
308308
}
@@ -312,9 +312,12 @@ func createLib(sketchName string, buildMcu string, returnJson *ResultJson, objFi
312312
// create a library.properties file in the root dir of the lib
313313
// the library.properties contains the following:
314314
libraryProperties := `name=` + sketchName + `
315-
sentence=This tecnically is not a library but a precompiled sketch. The result is produced using ` + os.Args[0] + `
315+
author=TODO
316+
maintainer=TODO
317+
sentence=This technically is not a library but a precompiled sketch. The result is produced using ` + os.Args[0] + `
318+
paragraph=
316319
url=https://github.com/arduino/cslt-tool
317-
version=1.0
320+
version=1.0.0
318321
precompiled=true`
319322

320323
libraryPropertyPath := libDir.Join("library.properties")
@@ -344,10 +347,10 @@ void _loop();`
344347
// the sketch.ino contains the following:
345348
sketchFile := `#include <` + "lib" + sketchName + `.h>
346349
void setup() {
347-
_setup();
350+
_setup();
348351
}
349352
void loop() {
350-
_loop();
353+
_loop();
351354
}`
352355
sketchFilePath := exampleDir.Join(sketchName + ".ino")
353356
createFile(sketchFilePath, sketchFile)

0 commit comments

Comments
 (0)