@@ -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+
3854task 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
4460task 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
5398task 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
87149clean. 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}
0 commit comments