Skip to content

Commit da4ffc7

Browse files
author
jan
committed
2 parents 1e3c4a3 + 8b25ec6 commit da4ffc7

File tree

7 files changed

+125
-123
lines changed

7 files changed

+125
-123
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ script:
1414
- sh -c "if $TRAVIS_SECURE_ENV_VARS; then echo Travis SECURE available -- Deploy; else echo Travis SECURE NOT available -- Verify; fi"
1515

1616
#Execute the maven commands depending on SECURE availabilty and print the elapsed time out periodically.
17-
- sh -c "if $TRAVIS_SECURE_ENV_VARS; then ./travis_exec_and_print_time.sh 'mvn deploy -Dtest=RegressionTest --quiet --settings settings.xml'; else ./travis_exec_and_print_time.sh 'mvn verify -Dtest=RegressionTest --quiet --settings settings.xml'; fi"
17+
- sh -c "if $TRAVIS_SECURE_ENV_VARS; then ./travis_exec_and_print_time.sh 'mvn verify -Dtest=RegressionTest --quiet --settings settings.xml'; else ./travis_exec_and_print_time.sh 'mvn verify -Dtest=RegressionTest --quiet --settings settings.xml'; fi"
1818

1919
#Several usernames and passwords/tokens are required for deployment.
2020
#When testing on your local/remote setup then you need to set/export env. variables:

io.sloeber.core/src/io/sloeber/core/managers/ArduinoPlatform.java

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public IStatus remove(IProgressMonitor monitor) {
152152
public IStatus install(IProgressMonitor monitor) {
153153
// Check if we're installed already
154154
if (isInstalled()) {
155+
System.out.println("reusing platform "+name + " "+architecture +"("+version+")");
155156
return Status.OK_STATUS;
156157
}
157158

io.sloeber.core/src/io/sloeber/core/managers/WorkAround.java

+92-92
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,30 @@
1919
import io.sloeber.core.tools.Version;
2020

2121
/**
22-
* A class to apply workarounds to installed packages
23-
* workaround are done after installation
24-
* at usage of boards.txt file
25-
* at usage of platform.txt file
22+
* A class to apply workarounds to installed packages workaround are done after
23+
* installation at usage of boards.txt file at usage of platform.txt file
2624
*
27-
* The first line of the worked around files contain a key
28-
* A newer version of sloeber that has a different workaround shuld change the key
29-
* in this way the worked around files can be persisted and updated when needed
25+
* The first line of the worked around files contain a key A newer version of
26+
* sloeber that has a different workaround shuld change the key in this way the
27+
* worked around files can be persisted and updated when needed
3028
*
3129
* @author jan
3230
*
3331
*/
3432
@SuppressWarnings("nls")
3533
public class WorkAround {
36-
//Each time this class is touched consider changing the String below to enforce updates
37-
private static final String FIRST_SLOEBER_WORKAROUND_LINE = "#Sloeber created workaound file V1.00.test 3";
38-
34+
// Each time this class is touched consider changing the String below to enforce
35+
// updates
36+
private static final String FIRST_SLOEBER_WORKAROUND_LINE = "#Sloeber created workaound file V1.00.test 4";
3937

4038
/**
41-
* workarounds done at installation time.
42-
* I try to keep those at a minimum but none platform.txt and boards.txt
43-
* workarounds need to be doine during install time
39+
* workarounds done at installation time. I try to keep those at a minimum but
40+
* none platform.txt and boards.txt workarounds need to be doine during install
41+
* time
4442
*
4543
* @param platform
4644
*/
47-
static public void applyKnownWorkArounds(ArduinoPlatform platform) {
45+
static synchronized public void applyKnownWorkArounds(ArduinoPlatform platform) {
4846

4947
/*
5048
* for STM32 V1.8 and later #include "SrcWrapper.h" to Arduino.h remove the
@@ -70,105 +68,101 @@ static public void applyKnownWorkArounds(ArduinoPlatform platform) {
7068
MakeBoardsSloeberTxt(platform.getBoardsFile());
7169

7270
}
73-
74-
71+
7572
/**
7673
* create a workedaround boards.txt and return that filz
77-
*
74+
*
7875
* @param requestedFileToWorkAround
7976
*
80-
* @return the worked around file or requestedFileToWorkAround is it does not exist or error
77+
* @return the worked around file or requestedFileToWorkAround is it does not
78+
* exist or error
8179
*/
82-
static public File MakeBoardsSloeberTxt(File requestedFileToWorkAround) {
83-
if(!requestedFileToWorkAround.exists()) {
80+
static synchronized public File MakeBoardsSloeberTxt(File requestedFileToWorkAround) {
81+
if (!requestedFileToWorkAround.exists()) {
8482
return requestedFileToWorkAround;
8583
}
86-
String inFile=requestedFileToWorkAround.toString();
87-
String actualFileToLoad=inFile.replace(Const.BOARDS_FILE_NAME,"boards.sloeber.txt");
88-
if(inFile.equals(actualFileToLoad)) {
84+
String inFile = requestedFileToWorkAround.toString();
85+
String actualFileToLoad = inFile.replace(Const.BOARDS_FILE_NAME, "boards.sloeber.txt");
86+
if (inFile.equals(actualFileToLoad)) {
8987
Common.log(new Status(IStatus.ERROR, Activator.getId(),
9088
"Boards.txt file is not recognized " + requestedFileToWorkAround.toString()));
9189
return requestedFileToWorkAround;
9290
}
93-
File boardsSloeberTXT=new File(actualFileToLoad);
94-
if(boardsSloeberTXT.exists()) {
95-
//delete if outdated
91+
File boardsSloeberTXT = new File(actualFileToLoad);
92+
if (boardsSloeberTXT.exists()) {
93+
// delete if outdated
9694
String firstLine = null;
97-
try(BufferedReader Buff = new BufferedReader(new FileReader(boardsSloeberTXT));) {
95+
try (BufferedReader Buff = new BufferedReader(new FileReader(boardsSloeberTXT));) {
9896
firstLine = Buff.readLine();
9997
} catch (Exception e) {
100-
//ignore and delete the file
101-
}
102-
if(!FIRST_SLOEBER_WORKAROUND_LINE.equals(firstLine)) {
98+
// ignore and delete the file
99+
}
100+
if (!FIRST_SLOEBER_WORKAROUND_LINE.equals(firstLine)) {
103101
boardsSloeberTXT.delete();
104102
}
105103
}
106-
if(!boardsSloeberTXT.exists()) {
107-
if (requestedFileToWorkAround.exists()) {
108-
try {
109-
if (SystemUtils.IS_OS_WINDOWS) {
110-
String boardsTXT = FIRST_SLOEBER_WORKAROUND_LINE+"\n";
111-
boardsTXT += FileUtils.readFileToString(requestedFileToWorkAround, Charset.defaultCharset());
112-
boardsTXT = boardsTXT.replace("\r\n", "\n");
113-
114-
115-
// replace FI circuitplay32u4cat.build.usb_manufacturer="Adafruit"
116-
// with circuitplay32u4cat.build.usb_manufacturer=Adafruit
117-
boardsTXT = boardsTXT.replaceAll("(\\S+\\.build\\.usb\\S+)=\\\"(.+)\\\"", "$1=$2");
118-
119-
120-
FileUtils.write(boardsSloeberTXT, boardsTXT, Charset.defaultCharset());
121-
}
122-
} catch (IOException e) {
123-
// TODO Auto-generated catch block
124-
e.printStackTrace();
104+
if (!boardsSloeberTXT.exists()) {
105+
try {
106+
String boardsTXT = FIRST_SLOEBER_WORKAROUND_LINE + "\n";
107+
boardsTXT += FileUtils.readFileToString(requestedFileToWorkAround, Charset.defaultCharset());
108+
boardsTXT = boardsTXT.replace("\r\n", "\n");
109+
110+
if (SystemUtils.IS_OS_WINDOWS) {
111+
// replace FI circuitplay32u4cat.build.usb_manufacturer="Adafruit"
112+
// with circuitplay32u4cat.build.usb_manufacturer=Adafruit
113+
boardsTXT = boardsTXT.replaceAll("(\\S+\\.build\\.usb\\S+)=\\\"(.+)\\\"", "$1=$2");
125114
}
115+
FileUtils.write(boardsSloeberTXT, boardsTXT, Charset.defaultCharset());
116+
} catch (IOException e) {
117+
Common.log(new Status(IStatus.WARNING, Activator.getId(),
118+
"Failed to apply work arounds to " + requestedFileToWorkAround.toString(), e));
119+
return requestedFileToWorkAround;
126120
}
127121
}
128122
return boardsSloeberTXT;
129123
}
130-
131-
124+
132125
/**
133126
* create a workedaround platform.txt and return that filz
134-
*
127+
*
135128
* @param requestedFileToWorkAround
136129
*
137-
* @return the worked around file or requestedFileToWorkAround is it does not exist or error
130+
* @return the worked around file or requestedFileToWorkAround is it does not
131+
* exist or error
138132
*/
139-
public static File MakePlatformSloeberTXT(File requestedFileToWorkAround) {
140-
if(!requestedFileToWorkAround.exists()) {
133+
public synchronized static File MakePlatformSloeberTXT(File requestedFileToWorkAround) {
134+
if (!requestedFileToWorkAround.exists()) {
141135
return requestedFileToWorkAround;
142136
}
143-
String inFile=requestedFileToWorkAround.toString();
144-
String actualFileToLoad=inFile.replace(Const.PLATFORM_FILE_NAME,"platform.sloeber.txt");
145-
if(inFile.equals(actualFileToLoad)) {
137+
String inFile = requestedFileToWorkAround.toString();
138+
String actualFileToLoad = inFile.replace(Const.PLATFORM_FILE_NAME, "platform.sloeber.txt");
139+
if (inFile.equals(actualFileToLoad)) {
146140
Common.log(new Status(IStatus.ERROR, Activator.getId(),
147141
"platform.txt file is not recognized " + requestedFileToWorkAround.toString()));
148142
return requestedFileToWorkAround;
149143
}
150-
File platformSloeberTXT=new File(actualFileToLoad);
151-
if(platformSloeberTXT.exists()) {
152-
//delete if outdated
144+
File platformSloeberTXT = new File(actualFileToLoad);
145+
if (platformSloeberTXT.exists()) {
146+
// delete if outdated
153147
String firstLine = null;
154-
try(BufferedReader Buff = new BufferedReader(new FileReader(platformSloeberTXT));) {
148+
try (BufferedReader Buff = new BufferedReader(new FileReader(platformSloeberTXT));) {
155149
firstLine = Buff.readLine();
156150
} catch (Exception e) {
157-
//ignore and delete the file
158-
}
159-
if(!FIRST_SLOEBER_WORKAROUND_LINE.equals(firstLine)) {
151+
// ignore and delete the file
152+
}
153+
if (!FIRST_SLOEBER_WORKAROUND_LINE.equals(firstLine)) {
160154
platformSloeberTXT.delete();
161155
}
162156
}
163157
if (!platformSloeberTXT.exists()) {
164158
try {
165-
String platformTXT = FIRST_SLOEBER_WORKAROUND_LINE+"\n";
159+
String platformTXT = FIRST_SLOEBER_WORKAROUND_LINE + "\n";
166160
platformTXT += FileUtils.readFileToString(requestedFileToWorkAround, Charset.defaultCharset());
167161
platformTXT = platformTXT.replace("\r\n", "\n");
168-
169-
//Arduino treats core differently so we need to change the location of directly
170-
//referenced files this manifestates only in the combine recipe
171-
int inCombineStartIndex=platformTXT.indexOf("\nrecipe.c.combine.pattern")+1;
162+
163+
// Arduino treats core differently so we need to change the location of directly
164+
// referenced files this manifestates only in the combine recipe
165+
int inCombineStartIndex = platformTXT.indexOf("\nrecipe.c.combine.pattern") + 1;
172166
if (inCombineStartIndex > 0) {
173167
int inCombineEndIndex = platformTXT.indexOf("\n", inCombineStartIndex) - 1;
174168
if (inCombineEndIndex > 0) {
@@ -180,15 +174,14 @@ public static File MakePlatformSloeberTXT(File requestedFileToWorkAround) {
180174
}
181175
}
182176

183-
184177
// workaround for infineon arm v1.4.0 overwriting the default to a wrong value
185178
platformTXT = platformTXT.replace("\nbuild.core.path", "\n#line removed by Sloeber build.core.path");
186179

187-
Path platformTXTPath= new Path (requestedFileToWorkAround.toString());
188-
int totalSegments= platformTXTPath.segmentCount();
189-
String platformVersion= platformTXTPath.segment(totalSegments-2);
190-
String platformArchitecture= platformTXTPath.segment(totalSegments-3);
191-
String platformName= platformTXTPath.segment(totalSegments-5);
180+
Path platformTXTPath = new Path(requestedFileToWorkAround.toString());
181+
int totalSegments = platformTXTPath.segmentCount();
182+
String platformVersion = platformTXTPath.segment(totalSegments - 2);
183+
String platformArchitecture = platformTXTPath.segment(totalSegments - 3);
184+
String platformName = platformTXTPath.segment(totalSegments - 5);
192185
if (Version.compare("1.8.0", platformVersion) != 1) {
193186
if ("stm32".equals(platformArchitecture)) {
194187
if ("STM32".equals(platformName)) {
@@ -198,30 +191,37 @@ public static File MakePlatformSloeberTXT(File requestedFileToWorkAround) {
198191
}
199192
}
200193

201-
202-
//for adafruit nfr
203-
platformTXT = platformTXT.replace("-DARDUINO_BSP_VERSION=\"{version}\"", "\"-DARDUINO_BSP_VERSION=\\\"{version}\\\"\"");
204-
194+
// for adafruit nfr
195+
platformTXT = platformTXT.replace("-DARDUINO_BSP_VERSION=\"{version}\"",
196+
"\"-DARDUINO_BSP_VERSION=\\\"{version}\\\"\"");
197+
205198
if (SystemUtils.IS_OS_WINDOWS) {
206199
// replace FI '-DUSB_PRODUCT={build.usb_product}' with
207200
// "-DUSB_PRODUCT=\"{build.usb_product}\""
208201
platformTXT = platformTXT.replaceAll("\\'-D(\\S+)=\\{(\\S+)}\\'", "\"-D$1=\\\\\"{$2}\\\\\"\"");
209-
210-
211-
//quoting fixes for embedutils
212-
platformTXT = platformTXT.replaceAll("\"?(-DMBEDTLS_\\S+)=\\\\?\"(mbedtls\\S+)\"\\\\?\"*", "\"$1=\\\\\"$2\\\\\"\"");
213-
214-
//Sometimes "-DUSB_MANUFACTURER={build.usb_manufacturer}" "-DUSB_PRODUCT={build.usb_product}"
215-
//is used fi LinKit smart
216-
platformTXT = platformTXT.replace("\"-DUSB_MANUFACTURER={build.usb_manufacturer}\"",
202+
203+
// quoting fixes for embedutils
204+
platformTXT = platformTXT.replaceAll("\"?(-DMBEDTLS_\\S+)=\\\\?\"(mbedtls\\S+)\"\\\\?\"*",
205+
"\"$1=\\\\\"$2\\\\\"\"");
206+
207+
// Sometimes "-DUSB_MANUFACTURER={build.usb_manufacturer}"
208+
// "-DUSB_PRODUCT={build.usb_product}"
209+
// is used fi LinKit smart
210+
platformTXT = platformTXT.replace("\"-DUSB_MANUFACTURER={build.usb_manufacturer}\"",
217211
"\"-DUSB_MANUFACTURER=\\\"{build.usb_manufacturer}\\\"\"");
218-
platformTXT = platformTXT.replace("\"-DUSB_PRODUCT={build.usb_product}\"",
212+
platformTXT = platformTXT.replace("\"-DUSB_PRODUCT={build.usb_product}\"",
219213
"\"-DUSB_PRODUCT=\\\"{build.usb_product}\\\"\"");
220-
platformTXT = platformTXT.replace(" -DARDUINO_BOARD=\"{build.board}\" ",
214+
platformTXT = platformTXT.replace(" -DARDUINO_BOARD=\"{build.board}\" ",
221215
" \"-DARDUINO_BOARD=\\\"{build.board}\\\"\" ");
222-
223216

224-
217+
}
218+
if(SystemUtils.IS_OS_LINUX) {
219+
platformTXT = platformTXT.replace(" -DUSB_MANUFACTURER={build.usb_manufacturer} ",
220+
" '-DUSB_MANUFACTURER=\"{build.usb_manufacturer}\"' ");
221+
platformTXT = platformTXT.replace(" -DUSB_PRODUCT={build.usb_product} ",
222+
" '-DUSB_PRODUCT=\"{build.usb_product}\" '");
223+
platformTXT = platformTXT.replace(" -DARDUINO_BOARD=\"{build.board}\" ",
224+
" '-DARDUINO_BOARD=\"{build.board}\"' ");
225225
}
226226
FileUtils.write(platformSloeberTXT, platformTXT, Charset.defaultCharset());
227227
} catch (IOException e) {

io.sloeber.core/src/io/sloeber/core/tools/TxtFile.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,21 @@ public TxtFile(File boardsFileName, boolean workAround) {
6262

6363
this.mLastLoadedTxtFile =boardsFileName;
6464
File actuallyLoadedTxtFile = mLastLoadedTxtFile;
65+
// If the file doesn't exist ignore it.
66+
if (!boardsFileName.exists()) {
67+
return ;
68+
}
69+
6570
if(workAround) {
6671
actuallyLoadedTxtFile =WorkAround.MakeBoardsSloeberTxt(boardsFileName);
6772
}
68-
// If the file doesn't exist ignore it.
69-
if (!actuallyLoadedTxtFile.exists())
73+
74+
if (!actuallyLoadedTxtFile.exists()) {
75+
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID,
76+
"Worked around file " +actuallyLoadedTxtFile.toString() + " does not exist.")); //$NON-NLS-1$ //$NON-NLS-2$
7077
return ;
78+
}
79+
7180

7281
this.fileContent.clear();
7382

io.sloeber.tests/src/io/sloeber/core/CreateAndCompileDefaultInoOnAllBoardsTest.java

+1-14
Original file line numberDiff line numberDiff line change
@@ -269,20 +269,7 @@ public static Collection boards() {
269269
for (File curBoardFile : PackageManager.getAllBoardsFiles()) {
270270
// TOFIX these options should not be set here but in IBoard.getOptions
271271
Map<String, String> options = null;
272-
// if (curBoardFile.contains("Jantje")) {
273-
// // for jantjes boards as unit testing does not make a exe without the gdb lib
274-
// options = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
275-
// options.put("type", "debug");
276-
// } else if (curBoardFile.contains("avr_boot")) {
277-
// // for avr_boot avr_boot_atmega328 to have variant
278-
// options = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
279-
// options.put("pinout", "avrdevelopers");
280-
// } else if (curBoardFile.contains("/tiny/hardware")) {
281-
// // do not use ATtiny85 @ 128 KHz (watchdog oscillator; 1.8 V BOD)
282-
// // fails in arduino IDE as well
283-
// options = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
284-
// options.put("cpu", "attiny25at1");
285-
// }
272+
System.out.println("Adding boards of "+curBoardFile.toString() );
286273
boards.addAll(BoardDescriptor.makeBoardDescriptors(curBoardFile, options));
287274
}
288275
// to avoid warnings set the upload port to some value

io.sloeber.tests/src/io/sloeber/core/MySystem.java

+16-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class MySystem {
1717
private static final String jantjesWindowsMachineHashKey = "1248215851";
1818
//the one below is based on one mac address Fysiek adres (MAC): C0-3F-D5-66-04-58
1919
private static final String jantjesWindowsMachineHashkeyAfterUpdate="139705674";
20-
private static final String jantjesLinuxMachineHashKey = "-784776710";
20+
private static final String jantjesLinuxMachineHashKey = "88937904";
2121
private static final String jantjeWindowsMachineHashkeyAfterSecondUpdate="-441525448";
2222

2323
public static String getTeensyPlatform() {
@@ -27,7 +27,7 @@ public static String getTeensyPlatform() {
2727
case jantjeWindowsMachineHashkeyAfterSecondUpdate:
2828
return "E:\\arduino\\arduino-1.8.12 - teensy\\hardware\\teensy";
2929
case jantjesLinuxMachineHashKey:
30-
return "/home/jan/nas/linux/arduino/arduino-1.8.8-linux64/arduino-1.8.8/hardware/teensy";
30+
return "/home/jan/tensyduino/arduino-1.8.12/hardware/teensy";
3131
default:
3232
return new String();
3333
}
@@ -39,10 +39,19 @@ public static String getTeensyBoard_txt() {
3939
public static MCUBoard[] getUploadBoards() {
4040
switch (Other.getSystemHash()) {
4141
case jantjesLinuxMachineHashKey: {
42-
MCUBoard[] boards = { Teensy.teensypp2(), ESP8266.wemosD1("COM21"),
43-
Arduino.fried2016("COM26"), Arduino.yun("COM20"), Arduino.uno("COM6"),
44-
Arduino.getMega2560Board("COM11"), Arduino.zeroProgrammingPort("COM14"), Arduino.due("COM8"),
45-
Arduino.leonardo("COM31"), Arduino.arduino_101("COM15") };
42+
MCUBoard[] boards = {
43+
Teensy.teensypp2("/dev/ttyACM0"),
44+
Arduino.leonardo("/dev/ttyS0"), //werkt niet
45+
Arduino.fried2016("/dev/ttyS0"), //werkt niet
46+
Arduino.zeroNatviePort("/dev/ttyS0"), //werkt niet
47+
Arduino.yun("COM20"),
48+
ESP8266.wemosD1("/dev/ttyUSB0"),
49+
Arduino.arduino_101("COM15"),
50+
Arduino.zeroProgrammingPort("COM14"),
51+
Arduino.getMega2560Board("COM11"),
52+
Arduino.dueprogramming("COM8"),
53+
Arduino.uno("COM6"),
54+
};
4655
return boards;
4756
}
4857
case jantjesWindowsMachineHashKey:
@@ -66,7 +75,7 @@ public static MCUBoard[] getUploadBoards() {
6675
return boards;
6776
}
6877
default:
69-
fail("Boards for the system with haskey " + Other.getSystemHash() + "are not found");
78+
fail("Boards for the system with haskey " + Other.getSystemHash() + " are not found");
7079
return null;
7180
}
7281
}

0 commit comments

Comments
 (0)