1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-16 11:21:18 +03:00

Merge remote-tracking branch 'origin/ide-1.5.x' into ide-1.5.x

This commit is contained in:
Fede85
2013-10-14 17:19:48 +02:00
8 changed files with 153 additions and 28 deletions

View File

@ -32,7 +32,6 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.swing.*; import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.apache.commons.logging.impl.LogFactoryImpl; import org.apache.commons.logging.impl.LogFactoryImpl;
import org.apache.commons.logging.impl.NoOpLog; import org.apache.commons.logging.impl.NoOpLog;
@ -46,6 +45,7 @@ import processing.app.helpers.FileUtils;
import processing.app.helpers.PreferencesMap; import processing.app.helpers.PreferencesMap;
import processing.app.helpers.filefilters.OnlyDirs; import processing.app.helpers.filefilters.OnlyDirs;
import processing.app.helpers.filefilters.OnlyFilesWithExtension; import processing.app.helpers.filefilters.OnlyFilesWithExtension;
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
import processing.app.packages.Library; import processing.app.packages.Library;
import processing.app.packages.LibraryList; import processing.app.packages.LibraryList;
import processing.app.tools.ZipDeflater; import processing.app.tools.ZipDeflater;
@ -1523,35 +1523,39 @@ public class Base {
* should replace the sketch in the current window, or false when the * should replace the sketch in the current window, or false when the
* sketch should open in a new window. * sketch should open in a new window.
*/ */
protected boolean addSketches(JMenu menu, File folder, protected boolean addSketches(JMenu menu, File folder, final boolean replaceExisting) throws IOException {
final boolean replaceExisting) throws IOException {
if (folder == null) if (folder == null)
return false; return false;
// skip .DS_Store files, etc (this shouldn't actually be necessary)
if (!folder.isDirectory()) return false; if (!folder.isDirectory()) return false;
String[] list = folder.list(); File[] files = folder.listFiles();
// If a bad folder or unreadable or whatever, this will come back null // If a bad folder or unreadable or whatever, this will come back null
if (list == null) return false; if (files == null) return false;
// Alphabetize list, since it's not always alpha order // Alphabetize files, since it's not always alpha order
Arrays.sort(list, String.CASE_INSENSITIVE_ORDER); Arrays.sort(files, new Comparator<File>() {
@Override
public int compare(File file, File file2) {
return file.getName().compareToIgnoreCase(file2.getName());
}
});
boolean ifound = false; boolean ifound = false;
for (String name : list) { for (File subfolder : files) {
if ((name.charAt(0) == '.') || if (FileUtils.isSCCSOrHiddenFile(subfolder)) {
name.equals("CVS")) continue; continue;
File subfolder = new File(folder, name);
if (!subfolder.isDirectory()) continue;
if (addSketchesSubmenu(menu, name, subfolder, replaceExisting))
ifound = true;
} }
return ifound; // actually ignored, but.. if (!subfolder.isDirectory()) continue;
if (addSketchesSubmenu(menu, subfolder.getName(), subfolder, replaceExisting)) {
ifound = true;
}
}
return ifound;
} }
private boolean addSketchesSubmenu(JMenu menu, Library lib, private boolean addSketchesSubmenu(JMenu menu, Library lib,

View File

@ -38,6 +38,7 @@ import processing.app.I18n;
import processing.app.Preferences; import processing.app.Preferences;
import processing.app.Sketch; import processing.app.Sketch;
import processing.app.SketchCode; import processing.app.SketchCode;
import processing.app.helpers.FileUtils;
import processing.app.helpers.PreferencesMap; import processing.app.helpers.PreferencesMap;
import processing.app.helpers.ProcessUtils; import processing.app.helpers.ProcessUtils;
import processing.app.helpers.StringReplacer; import processing.app.helpers.StringReplacer;
@ -235,7 +236,7 @@ public class Compiler implements MessageConsumer {
File objectFile = new File(objectPath); File objectFile = new File(objectPath);
File dependFile = new File(dependPath); File dependFile = new File(dependPath);
objectPaths.add(objectFile); objectPaths.add(objectFile);
if (is_already_compiled(file, objectFile, dependFile, prefs)) if (isAlreadyCompiled(file, objectFile, dependFile, prefs))
continue; continue;
String[] cmd = getCommandCompilerC(includePaths, file.getAbsolutePath(), String[] cmd = getCommandCompilerC(includePaths, file.getAbsolutePath(),
objectPath); objectPath);
@ -248,7 +249,7 @@ public class Compiler implements MessageConsumer {
File objectFile = new File(objectPath); File objectFile = new File(objectPath);
File dependFile = new File(dependPath); File dependFile = new File(dependPath);
objectPaths.add(objectFile); objectPaths.add(objectFile);
if (is_already_compiled(file, objectFile, dependFile, prefs)) if (isAlreadyCompiled(file, objectFile, dependFile, prefs))
continue; continue;
String[] cmd = getCommandCompilerCPP(includePaths, String[] cmd = getCommandCompilerCPP(includePaths,
file.getAbsolutePath(), objectPath); file.getAbsolutePath(), objectPath);
@ -258,10 +259,10 @@ public class Compiler implements MessageConsumer {
return objectPaths; return objectPaths;
} }
private boolean is_already_compiled(File src, File obj, File dep, Map<String, String> prefs) { private boolean isAlreadyCompiled(File src, File obj, File dep, Map<String, String> prefs) {
boolean ret=true; boolean ret=true;
try { try {
//System.out.println("\n is_already_compiled: begin checks: " + obj.getPath()); //System.out.println("\n isAlreadyCompiled: begin checks: " + obj.getPath());
if (!obj.exists()) return false; // object file (.o) does not exist if (!obj.exists()) return false; // object file (.o) does not exist
if (!dep.exists()) return false; // dep file (.d) does not exist if (!dep.exists()) return false; // dep file (.d) does not exist
long src_modified = src.lastModified(); long src_modified = src.lastModified();
@ -284,8 +285,8 @@ public class Compiler implements MessageConsumer {
String objpath = obj.getCanonicalPath(); String objpath = obj.getCanonicalPath();
File linefile = new File(line); File linefile = new File(line);
String linepath = linefile.getCanonicalPath(); String linepath = linefile.getCanonicalPath();
//System.out.println(" is_already_compiled: obj = " + objpath); //System.out.println(" isAlreadyCompiled: obj = " + objpath);
//System.out.println(" is_already_compiled: line = " + linepath); //System.out.println(" isAlreadyCompiled: line = " + linepath);
if (objpath.compareTo(linepath) == 0) { if (objpath.compareTo(linepath) == 0) {
need_obj_parse = false; need_obj_parse = false;
continue; continue;
@ -308,7 +309,7 @@ public class Compiler implements MessageConsumer {
ret = false; // prerequisite modified since object was compiled ret = false; // prerequisite modified since object was compiled
break; break;
} }
//System.out.println(" is_already_compiled: prerequisite ok"); //System.out.println(" isAlreadyCompiled: prerequisite ok");
} }
} }
reader.close(); reader.close();
@ -575,12 +576,19 @@ public class Compiler implements MessageConsumer {
boolean recurse) { boolean recurse) {
List<File> files = new ArrayList<File>(); List<File> files = new ArrayList<File>();
if (folder.listFiles() == null) if (FileUtils.isSCCSOrHiddenFile(folder)) {
return files; return files;
}
for (File file : folder.listFiles()) { File[] listFiles = folder.listFiles();
if (file.getName().startsWith(".")) if (listFiles == null) {
return files;
}
for (File file : listFiles) {
if (FileUtils.isSCCSOrHiddenFile(file)) {
continue; // skip hidden files continue; // skip hidden files
}
if (file.getName().endsWith("." + extension)) if (file.getName().endsWith("." + extension))
files.add(file); files.add(file);

View File

@ -4,11 +4,14 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class FileUtils { public class FileUtils {
private static final List<String> SOURCE_CONTROL_FOLDERS = Arrays.asList("CVS", "RCS", ".git", ".svn", ".hg", ".bzr");
private static final Pattern BACKSLASH = Pattern.compile("\\\\"); private static final Pattern BACKSLASH = Pattern.compile("\\\\");
/** /**
@ -163,4 +166,8 @@ public class FileUtils {
public static String getLinuxPathFrom(File file) { public static String getLinuxPathFrom(File file) {
return BACKSLASH.matcher(file.getAbsolutePath()).replaceAll("/"); return BACKSLASH.matcher(file.getAbsolutePath()).replaceAll("/");
} }
public static boolean isSCCSOrHiddenFile(File file) {
return file.isHidden() || file.getName().charAt(0) == '.' || (file.isDirectory() && SOURCE_CONTROL_FOLDERS.contains(file.getName()));
}
} }

View File

@ -1,5 +1,6 @@
package processing.app.packages; package processing.app.packages;
import processing.app.helpers.FileUtils;
import processing.app.helpers.PreferencesMap; import processing.app.helpers.PreferencesMap;
import java.io.File; import java.io.File;
@ -35,6 +36,7 @@ public class Library {
private static final List<String> OPTIONAL_FILES = Arrays private static final List<String> OPTIONAL_FILES = Arrays
.asList(new String[] { "keywords.txt", "library.properties" }); .asList(new String[] { "keywords.txt", "library.properties" });
/** /**
* Scans inside a folder and create a Library object out of it. Automatically * Scans inside a folder and create a Library object out of it. Automatically
* detects pre-1.5 libraries. Automatically fills metadata from * detects pre-1.5 libraries. Automatically fills metadata from
@ -75,6 +77,10 @@ public class Library {
// 3. check if root folder contains prohibited stuff // 3. check if root folder contains prohibited stuff
for (File file : libFolder.listFiles()) { for (File file : libFolder.listFiles()) {
if (file.isDirectory()) { if (file.isDirectory()) {
if (FileUtils.isSCCSOrHiddenFile(file)) {
System.out.println("WARNING: Ignoring spurious " + file.getName() + " folder in '" + properties.get("name") + "' library");
continue;
}
if (!OPTIONAL_FOLDERS.contains(file.getName())) if (!OPTIONAL_FOLDERS.contains(file.getName()))
throw new IOException("Invalid folder '" + file.getName() + "'."); throw new IOException("Invalid folder '" + file.getName() + "'.");
} else { } else {
@ -124,7 +130,7 @@ public class Library {
res.folder = libFolder; res.folder = libFolder;
res.srcFolder = libFolder; res.srcFolder = libFolder;
res.name = libFolder.getName(); res.name = libFolder.getName();
res.architectures = Arrays.asList(new String[]{"*"}); res.architectures = Arrays.asList("*");
res.pre15Lib = true; res.pre15Lib = true;
return res; return res;
} }

View File

@ -28,5 +28,10 @@ public class SystemProfilerParserTest {
assertEquals("0X2341_0X0041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodem04101")); assertEquals("0X2341_0X0041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodem04101"));
assertEquals("0X2341_0X0041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem04101")); assertEquals("0X2341_0X0041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem04101"));
output = TestHelper.inputStreamToString(SystemProfilerParserTest.class.getResourceAsStream("system_profiler_output5.txt"));
assertEquals("0X2341_0X8041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/cu.usbmodem06201"));
assertEquals("0X2341_0X8041", new SystemProfilerParser().extractVIDAndPID(output, "/dev/tty.usbmodem06201"));
} }
} }

View File

@ -0,0 +1,94 @@
USB:
USB Hi-Speed Bus:
Host Controller Location: Built-in USB
Host Controller Driver: AppleUSBEHCI
PCI Device ID: 0x0d9d
PCI Revision ID: 0x00a2
PCI Vendor ID: 0x10de
Bus Number: 0x24
FaceTime Camera (Built-in):
Product ID: 0x850a
Vendor ID: 0x05ac (Apple Inc.)
Version: 6.26
Serial Number: CCGB1KY362DF9KL0
Speed: Up to 480 Mb/sec
Manufacturer: Apple Inc.
Location ID: 0x24600000 / 2
Current Available (mA): 500
Current Required (mA): 500
USB Hi-Speed Bus:
Host Controller Location: Built-in USB
Host Controller Driver: AppleUSBEHCI
PCI Device ID: 0x0d9d
PCI Revision ID: 0x00a2
PCI Vendor ID: 0x10de
Bus Number: 0x26
USB Bus:
Host Controller Location: Built-in USB
Host Controller Driver: AppleUSBOHCI
PCI Device ID: 0x0d9c
PCI Revision ID: 0x00a1
PCI Vendor ID: 0x10de
Bus Number: 0x04
BRCM2070 Hub:
Product ID: 0x4500
Vendor ID: 0x0a5c (Broadcom Corp.)
Version: 1.00
Speed: Up to 12 Mb/sec
Manufacturer: Apple Inc.
Location ID: 0x04500000 / 3
Current Available (mA): 500
Current Required (mA): 94
Bluetooth USB Host Controller:
Product ID: 0x821b
Vendor ID: 0x05ac (Apple Inc.)
Version: 0.41
Speed: Up to 12 Mb/sec
Manufacturer: Apple Inc.
Location ID: 0x04530000 / 6
Current Available (mA): 500
Current Required (mA): 0
Apple Internal Keyboard / Trackpad:
Product ID: 0x0242
Vendor ID: 0x05ac (Apple Inc.)
Version: 1.07
Speed: Up to 12 Mb/sec
Manufacturer: Apple Inc.
Location ID: 0x04300000 / 2
Current Available (mA): 500
Current Required (mA): 40
USB Bus:
Host Controller Location: Built-in USB
Host Controller Driver: AppleUSBOHCI
PCI Device ID: 0x0d9c
PCI Revision ID: 0x00a1
PCI Vendor ID: 0x10de
Bus Number: 0x06
Arduino Yun:
Product ID: 0x8041
Vendor ID: 0x2341
Version: 1.00
Speed: Up to 12 Mb/sec
Manufacturer: Arduino LLC
Location ID: 0x06200000 / 2
Current Available (mA): 500
Current Required (mA): 500

View File

@ -44,6 +44,7 @@ File::File(void) {
} }
File::~File(void) { File::~File(void) {
close();
// Serial.print("Deleted file object"); // Serial.print("Deleted file object");
} }