Skip to content

Commit 658f7a3

Browse files
committed
Merge pull request #27 from Overdrivr/add-arduino-support
arduino support
2 parents 05b7651 + 178c669 commit 658f7a3

File tree

27 files changed

+422
-38
lines changed

27 files changed

+422
-38
lines changed

BUILD.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ testVectorsGenerator.bat
2828
cd ../../../../
2929
```
3030

31+
Next steps can be performed for Mbed or Arduino distributions
32+
33+
## mbed distribution
34+
3135
Generates the Mbed distribution by taking files inside `src/` `cpp_interface/`
3236
and `drivers/`
3337

@@ -38,7 +42,7 @@ gradlew distributeMbed
3842
Compiles and installs in a folder mbedTest (integration tests) module.
3943
```shell
4044
gradlew installMbedTestDebug
41-
gradlew moveTestVector
45+
gradlew moveTestVectorMbed
4246
```
4347

4448
Runs Mbed integration tests
@@ -48,4 +52,35 @@ mbedTest.bat
4852
cd ../../../../
4953
```
5054

51-
If all tests passed, library can be released with good confidence.
55+
If all tests passed, mbed library can be released with good confidence.
56+
57+
## arduino distribution
58+
59+
Generates the Arduino distribution by taking files inside `src/`,
60+
`./cpp_interface/`, `./drivers/` and `./version/`
61+
62+
```shell
63+
gradlew distributeArduino
64+
```
65+
66+
Compiles and installs in a folder mbedTest (integration tests) module.
67+
```shell
68+
gradlew installArduinoTestDebug
69+
gradlew moveTestVectorArduino
70+
```
71+
72+
Runs Mbed integration tests
73+
```shell
74+
cd ./build/install/arduinoTest/debug/
75+
arduinoTest.bat
76+
cd ../../../../
77+
```
78+
79+
If all tests passed, arduino library can be released with good confidence.
80+
81+
```shell
82+
gradle packArduino
83+
```
84+
85+
This last command will generate an archive of the distribution inside
86+
`build/distributions/`

build.gradle

Lines changed: 135 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ task copyToCDistribution(type: Copy) {
88
def d = new File('dist/c/')
99
d.mkdirs()
1010

11-
from '/src/crc16/c/','/src/crc16/headers/','/src/framing/c/',
12-
'/src/framing/headers/','/src/telemetry/c/', '/src/telemetry/headers/',
13-
'/drivers/c/base/'
14-
into 'dist/c/'
11+
from './src/crc16/c/','./src/crc16/headers/','./src/framing/c/',
12+
'./src/framing/headers/','./src/telemetry/c/', './src/telemetry/headers/',
13+
'./drivers/c/base/','./interfaces/c/','./version/','./configs/c/'
14+
into './dist/c/'
1515
include '**.c','**.h'
1616
}
1717

@@ -20,7 +20,8 @@ task copyToCppDistribution(type: Copy) {
2020
d.mkdirs()
2121

2222
from '/src/crc16/c/','/src/crc16/headers/','/src/framing/c/',
23-
'/src/framing/headers/','/src/telemetry/c/', '/src/telemetry/headers/'
23+
'/src/framing/headers/','/src/telemetry/c/', '/src/telemetry/headers/',
24+
'./version/','./configs/cpp/'
2425
into 'dist/cpp/c_api/'
2526
include '**.c','**.h'
2627
}
@@ -30,31 +31,75 @@ task copyToMbedDistribution(type: Copy) {
3031
d.mkdirs()
3132

3233
from '/src/crc16/c/','/src/crc16/headers/','/src/framing/c/',
33-
'/src/framing/headers/','/src/telemetry/c/', '/src/telemetry/headers/'
34+
'/src/framing/headers/','/src/telemetry/c/', '/src/telemetry/headers/',
35+
'./version/'
3436
into 'dist/mbed/c_api/'
3537
include '**.c','**.h'
3638
}
3739

40+
task copyToArduinoDistribution(type: Copy) {
41+
def d = new File('dist/arduino/')
42+
d.mkdirs()
43+
44+
from '/src/crc16/c/','/src/crc16/headers/','/src/framing/c/',
45+
'/src/framing/headers/','/src/telemetry/c/', '/src/telemetry/headers/',
46+
'./version/','./configs/arduino/'
47+
into 'dist/arduino/'
48+
rename { String fileName ->
49+
fileName.replace('.c', '.cpp')
50+
}
51+
include '**.c','**.h'
52+
}
53+
3854
task copyCppInterfaceAndDriver(type: Copy) {
39-
from '/cpp_interface/','/drivers/cpp/base/'
55+
from '/interfaces/cpp/','/drivers/cpp/base/'
4056
into 'dist/cpp/'
4157
include '**.c','**.h','**.cpp','**.hpp'
4258
}
4359

4460
task copyMbedInterfaceAndDriver(type: Copy) {
45-
from '/cpp_interface/','/drivers/cpp/mbed/'
61+
from '/interfaces/cpp/','/drivers/cpp/mbed/','./configs/mbed/'
4662
into 'dist/mbed/'
4763
include '**.c','**.h','**.cpp','**.hpp'
4864
}
4965

50-
// distributes the C api.
66+
task copyArduinoInterfaceAndDriver(type: Copy) {
67+
from '/interfaces/cpp/','/drivers/cpp/arduino/'
68+
into 'dist/arduino/'
69+
rename { String fileName ->
70+
fileName.replace('Telemetry.hpp', 'Telemetry.h')
71+
}
72+
include '**.c','**.h','**.cpp','**.hpp'
73+
}
74+
75+
// Moves the generated test vector to the appropriate folder for tests
76+
// testVectorsGenerator generator must be build and executed first for the
77+
// file to be generated
78+
// TODO : Add both things as a dependency
79+
task moveTestVectorMbed(type: Copy) {
80+
from '/build/install/testVectorsGenerator/debug/'
81+
into '/build/install/mbedTest/debug/'
82+
include 'valid_vectors.csv'
83+
}
84+
85+
// Moves the generated test vector to the appropriate folder for tests
86+
// testVectorsGenerator generator must be build and executed first for the
87+
// file to be generated
88+
// TODO : Add both things as a dependency
89+
task moveTestVectorArduino(type: Copy) {
90+
from '/build/install/testVectorsGenerator/debug/'
91+
into '/build/install/arduinoTest/debug/'
92+
include 'valid_vectors.csv'
93+
}
94+
95+
// Generates the C dsitribution, untied to hardware
5196
// Copies files from src/ folders into dist/c folder
5297
// Copies driverBase.h file into dist/c
5398
task distributeC() {
5499
dependsOn << copyToCDistribution
55100
}
56101

57-
// distributes the C++ api.
102+
// Generates the C++ distribution, untied to hardware
58103
// Copies files from src/ folders into dist/cpp folder
59104
// Copies driverBase.h file into dist/cpp
60105
// Copies interface/cpp/* into dist/cpp
@@ -64,7 +109,7 @@ task distributeCpp() {
64109
dependsOn << copyCppInterfaceAndDriver
65110
}
66111

67-
// distributes the Mbed api.
112+
// Generates the Mbed distribution
68113
// Copies files from src/ folders into dist/cpp folder
69114
// Copies driverMbed.h file into dist/cpp
70115
// Copies interface/cpp/* into dist/cpp
@@ -74,14 +119,31 @@ task distributeMbed() {
74119
dependsOn << copyMbedInterfaceAndDriver
75120
}
76121

77-
// Moves the generated test vector to the appropriate folder for tests
78-
// testVectorsGenerator generator must be build and executed first for the
79-
// file to be generated
80-
// TODO : Add both things as a dependency
81-
task moveTestVector(type: Copy) {
82-
from '/build/install/testVectorsGenerator/debug/'
83-
into '/build/install/mbedTest/debug/'
84-
include 'valid_vectors.csv'
122+
//TODO : add version to the zip
123+
task packMbed(type: Zip){
124+
dependsOn << distributeMbed
125+
from './dist/mbed/'
126+
into './Telemetry/'
127+
archiveName 'Telemetry-mbed.zip'
128+
}
129+
130+
131+
// Generates the Arduino distribution
132+
// Copies files from src/ folders into dist/cpp folder
133+
// Copies driverMbed.h file into dist/cpp
134+
// Copies interface/cpp/* into dist/cpp
135+
136+
task distributeArduino() {
137+
dependsOn << copyToArduinoDistribution
138+
dependsOn << copyArduinoInterfaceAndDriver
139+
}
140+
141+
//TODO : add version to the zip
142+
task packArduino(type: Zip){
143+
dependsOn << distributeArduino
144+
from './dist/arduino/'
145+
into './Telemetry/'
146+
archiveName 'Telemetry-arduino.zip'
85147
}
86148

87149
clean.doFirst {
@@ -201,7 +263,7 @@ model {
201263
}
202264
}
203265

204-
/* The following libraries are exclusively for testing Mbed distribution */
266+
/* The following libraries are exclusively for compiling and testing Mbed distribution */
205267

206268
bufferedSerialMock(NativeLibrarySpec) {
207269
sources {
@@ -255,6 +317,59 @@ model {
255317
}
256318
}
257319

320+
/* The following libraries are exclusively for compiling and testing Arduino distribution */
321+
hardwareSerialMock(NativeLibrarySpec) {
322+
sources {
323+
cpp {
324+
source {
325+
srcDirs "mocks/cpp/hardwareserial/"
326+
include "HardwareSerial.cpp"
327+
}
328+
exportedHeaders {
329+
srcDirs "mocks/cpp/hardwareserial/"
330+
include "HardwareSerial.h"
331+
}
332+
}
333+
}
334+
}
335+
336+
arduinoDistribution(NativeLibrarySpec) {
337+
binaries.all {
338+
lib library: "hardwareSerialMock"
339+
}
340+
sources {
341+
cpp {
342+
source {
343+
srcDirs "dist/arduino/"
344+
include "**/*.c", "**/*.cpp"
345+
}
346+
exportedHeaders {
347+
srcDirs "dist/arduino/"
348+
include "**/*.h", "**/*.hpp"
349+
}
350+
}
351+
}
352+
}
353+
354+
arduinoTest(NativeExecutableSpec) {
355+
binaries.all {
356+
lib library: "hardwareSerialMock"
357+
lib library: "arduinoDistribution"
358+
}
359+
sources {
360+
cpp {
361+
source {
362+
srcDirs "integration_tests/cpp/mbed/"
363+
include "**/*.cpp"
364+
}
365+
exportedHeaders {
366+
srcDirs "integration_tests/cpp/mbed/"
367+
include "**/*.hpp"
368+
}
369+
}
370+
}
371+
}
372+
258373

259374
}
260375
}

configs/arduino/telemetry_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef TELEMETRY_CONFIG_H_
2+
#define TELEMETRY_CONFIG_H_
3+
4+
#define TELEMETRY_ARDUINO_DISTRIBUTION
5+
6+
#endif

configs/c/telemetry_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef TELEMETRY_CONFIG_H_
2+
#define TELEMETRY_CONFIG_H_
3+
4+
#define TELEMETRY_C_DISTRIBUTION
5+
6+
#endif

configs/cpp/telemetry_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef TELEMETRY_CONFIG_H_
2+
#define TELEMETRY_CONFIG_H_
3+
4+
#define TELEMETRY_CPP_DISTRIBUTION
5+
6+
#endif

configs/mbed/telemetry_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef TELEMETRY_CONFIG_H_
2+
#define TELEMETRY_CONFIG_H_
3+
4+
#define TELEMETRY_MBED_DISTRIBUTION
5+
6+
#endif

0 commit comments

Comments
 (0)