mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-13 10:29:35 +01:00
Removed the now useless UserLibraryFolder
This commit is contained in:
parent
3c46af8d2c
commit
0056cbc545
@ -57,7 +57,6 @@ import processing.app.legacy.PApplet;
|
||||
import processing.app.macosx.ThinkDifferent;
|
||||
import processing.app.packages.LibraryList;
|
||||
import processing.app.packages.UserLibrary;
|
||||
import processing.app.packages.UserLibraryFolder.Location;
|
||||
import processing.app.syntax.PdeKeywords;
|
||||
import processing.app.syntax.SketchTextAreaDefaultInputMap;
|
||||
import processing.app.tools.MenuScroller;
|
||||
@ -78,6 +77,10 @@ import java.util.stream.Stream;
|
||||
|
||||
import static processing.app.I18n.format;
|
||||
import static processing.app.I18n.tr;
|
||||
import static processing.app.packages.UserLibrary.LOCATION_CORE;
|
||||
import static processing.app.packages.UserLibrary.LOCATION_IDE;
|
||||
import static processing.app.packages.UserLibrary.LOCATION_REF_CORE;
|
||||
import static processing.app.packages.UserLibrary.LOCATION_SKETCHBOOK;
|
||||
|
||||
|
||||
/**
|
||||
@ -1218,7 +1221,7 @@ public class Base {
|
||||
LibraryList otherLibs = new LibraryList();
|
||||
for (UserLibrary lib : allLibraries) {
|
||||
// Get the library's location - used for sorting into categories
|
||||
Location location = lib.getLocation();
|
||||
String location = lib.getLocation();
|
||||
// Is this library compatible?
|
||||
Collection<String> arch = lib.getArchitectures();
|
||||
boolean compatible;
|
||||
@ -1228,7 +1231,7 @@ public class Base {
|
||||
compatible = arch.contains(myArch);
|
||||
}
|
||||
// IDE Libaries (including retired)
|
||||
if (location == Location.IDE_BUILTIN) {
|
||||
if (location.equals(LOCATION_IDE)) {
|
||||
if (compatible) {
|
||||
// only compatible IDE libs are shown
|
||||
if (lib.getTypes().contains("Retired")) {
|
||||
@ -1238,15 +1241,15 @@ public class Base {
|
||||
}
|
||||
}
|
||||
// Platform Libraries
|
||||
} else if (location == Location.CORE) {
|
||||
} else if (location.equals(LOCATION_CORE)) {
|
||||
// all platform libs are assumed to be compatible
|
||||
platformLibs.add(lib);
|
||||
// Referenced Platform Libraries
|
||||
} else if (location == Location.REFERENCED_CORE) {
|
||||
} else if (location.equals(LOCATION_REF_CORE)) {
|
||||
// all referenced platform libs are assumed to be compatible
|
||||
referencedPlatformLibs.add(lib);
|
||||
// Sketchbook Libraries (including incompatible)
|
||||
} else if (location == Location.SKETCHBOOK) {
|
||||
} else if (location.equals(LOCATION_SKETCHBOOK)) {
|
||||
if (compatible) {
|
||||
// libraries promoted from sketchbook (behave as builtin)
|
||||
if (!lib.getTypes().isEmpty() && lib.getTypes().contains("Arduino")
|
||||
@ -2462,7 +2465,7 @@ public class Base {
|
||||
}
|
||||
|
||||
// copy folder
|
||||
File destinationFolder = new File(BaseNoGui.getSketchbookLibrariesFolder().folder, sourceFile.getName());
|
||||
File destinationFolder = new File(BaseNoGui.getSketchbookLibrariesFolder(), sourceFile.getName());
|
||||
if (!destinationFolder.mkdir()) {
|
||||
activeEditor.statusError(format(tr("A library named {0} already exists"), sourceFile.getName()));
|
||||
return;
|
||||
|
@ -249,7 +249,7 @@ public class Compiler implements MessageConsumer {
|
||||
addPathFlagIfPathExists(cmd, "-tools", installedPackagesFolder);
|
||||
|
||||
addPathFlagIfPathExists(cmd, "-built-in-libraries", BaseNoGui.getContentFile("libraries"));
|
||||
addPathFlagIfPathExists(cmd, "-libraries", BaseNoGui.getSketchbookLibrariesFolder().folder);
|
||||
addPathFlagIfPathExists(cmd, "-libraries", BaseNoGui.getSketchbookLibrariesFolder());
|
||||
|
||||
String fqbn = Stream.of(aPackage.getId(), platform.getId(), board.getId(), boardOptions(board)).filter(s -> !s.isEmpty()).collect(Collectors.joining(":"));
|
||||
cmd.add("-fqbn=" + fqbn);
|
||||
|
@ -35,7 +35,8 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import cc.arduino.contributions.VersionComparator;
|
||||
import processing.app.packages.UserLibraryFolder.Location;
|
||||
|
||||
import static processing.app.packages.UserLibrary.LOCATION_SKETCHBOOK;
|
||||
|
||||
public class ContributedLibrary {
|
||||
|
||||
@ -77,12 +78,12 @@ public class ContributedLibrary {
|
||||
return releases.values().stream() //
|
||||
.filter(ContributedLibraryRelease::isLibraryInstalled) //
|
||||
.reduce((x, y) -> {
|
||||
Location lx = x.getInstalledLibrary().get().getLocation();
|
||||
Location ly = y.getInstalledLibrary().get().getLocation();
|
||||
if (lx == ly) {
|
||||
String lx = x.getInstalledLibrary().get().getLocation();
|
||||
String ly = y.getInstalledLibrary().get().getLocation();
|
||||
if (lx.equals(ly)) {
|
||||
return VersionComparator.max(x, y);
|
||||
}
|
||||
return lx == Location.SKETCHBOOK ? x : y;
|
||||
return lx.equals(LOCATION_SKETCHBOOK) ? x : y;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,9 @@ package cc.arduino.contributions.libraries;
|
||||
|
||||
import static processing.app.I18n.format;
|
||||
import static processing.app.I18n.tr;
|
||||
import static processing.app.packages.UserLibrary.LOCATION_CORE;
|
||||
import static processing.app.packages.UserLibrary.LOCATION_REF_CORE;
|
||||
import static processing.app.packages.UserLibrary.LOCATION_SKETCHBOOK;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -49,7 +52,6 @@ import processing.app.debug.TargetPlatform;
|
||||
import processing.app.helpers.FileUtils;
|
||||
import processing.app.packages.LibraryList;
|
||||
import processing.app.packages.UserLibrary;
|
||||
import processing.app.packages.UserLibraryFolder.Location;
|
||||
import processing.app.packages.UserLibraryPriorityComparator;
|
||||
|
||||
public class LibrariesIndexer {
|
||||
@ -206,8 +208,8 @@ public class LibrariesIndexer {
|
||||
lib.getSrcFolder()));
|
||||
}
|
||||
|
||||
Location loc = lib.getLocation();
|
||||
if (loc != Location.CORE && loc != Location.REFERENCED_CORE) {
|
||||
String loc = lib.getLocation();
|
||||
if (!loc.equals(LOCATION_CORE) && !loc.equals(LOCATION_REF_CORE)) {
|
||||
// Check if we can find the same library in the index
|
||||
// and mark it as installed
|
||||
index.find(lib.getName(), lib.getVersion()).ifPresent(foundLib -> {
|
||||
@ -216,7 +218,7 @@ public class LibrariesIndexer {
|
||||
});
|
||||
}
|
||||
|
||||
if (lib.getTypes().isEmpty() && loc == Location.SKETCHBOOK) {
|
||||
if (lib.getTypes().isEmpty() && loc.equals(LOCATION_SKETCHBOOK)) {
|
||||
lib.setTypes(lib.getDeclaredTypes());
|
||||
}
|
||||
|
||||
@ -233,8 +235,8 @@ public class LibrariesIndexer {
|
||||
// TODO: Should be done on the CLI?
|
||||
installedLibraries.stream() //
|
||||
.filter(l -> l.getTypes().contains("Contributed")) //
|
||||
.filter(l -> l.getLocation() == Location.CORE
|
||||
|| l.getLocation() == Location.REFERENCED_CORE) //
|
||||
.filter(l -> l.getLocation().equals(LOCATION_CORE)
|
||||
|| l.getLocation().equals(LOCATION_REF_CORE)) //
|
||||
.forEach(l -> {
|
||||
File libFolder = l.getInstalledFolder();
|
||||
Optional<ContributedPlatform> platform = BaseNoGui.indexer
|
||||
|
@ -21,8 +21,6 @@ import processing.app.helpers.filefilters.OnlyFilesWithExtension;
|
||||
import processing.app.legacy.PApplet;
|
||||
import processing.app.packages.LibraryList;
|
||||
import processing.app.packages.UserLibrary;
|
||||
import processing.app.packages.UserLibraryFolder;
|
||||
import processing.app.packages.UserLibraryFolder.Location;
|
||||
import cc.arduino.files.DeleteFilesOnShutdown;
|
||||
import processing.app.helpers.FileUtils;
|
||||
|
||||
@ -343,7 +341,7 @@ public class BaseNoGui {
|
||||
return new File(getSketchbookFolder(), "hardware");
|
||||
}
|
||||
|
||||
static public UserLibraryFolder getSketchbookLibrariesFolder() {
|
||||
static public File getSketchbookLibrariesFolder() {
|
||||
File libdir = new File(getSketchbookFolder(), "libraries");
|
||||
if (!libdir.exists()) {
|
||||
FileWriter freadme = null;
|
||||
@ -357,7 +355,7 @@ public class BaseNoGui {
|
||||
IOUtils.closeQuietly(freadme);
|
||||
}
|
||||
}
|
||||
return new UserLibraryFolder(libdir, Location.SKETCHBOOK);
|
||||
return libdir;
|
||||
}
|
||||
|
||||
static public String getSketchbookPath() {
|
||||
|
@ -47,7 +47,6 @@ import cc.arduino.Constants;
|
||||
import cc.arduino.contributions.VersionHelper;
|
||||
import cc.arduino.contributions.libraries.ContributedLibraryDependency;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.packages.UserLibraryFolder.Location;
|
||||
|
||||
public class UserLibrary {
|
||||
|
||||
@ -66,12 +65,14 @@ public class UserLibrary {
|
||||
private boolean onGoingDevelopment;
|
||||
private Collection<String> includes;
|
||||
protected File installedFolder;
|
||||
protected Location location;
|
||||
|
||||
public static UserLibrary create(UserLibraryFolder libFolderDesc) throws IOException {
|
||||
File libFolder = libFolderDesc.folder;
|
||||
String location = libFolderDesc.location.toString();
|
||||
public static final String LOCATION_IDE = "ide";
|
||||
public static final String LOCATION_SKETCHBOOK = "sketchbook";
|
||||
public static final String LOCATION_CORE = "platform";
|
||||
public static final String LOCATION_REF_CORE = "ref-platform";
|
||||
protected String location;
|
||||
|
||||
public static UserLibrary create(File libFolder, String location) throws IOException {
|
||||
// Parse metadata
|
||||
File propertiesFile = new File(libFolder, "library.properties");
|
||||
PreferencesMap properties = new PreferencesMap();
|
||||
@ -211,15 +212,12 @@ public class UserLibrary {
|
||||
this.declaredTypes = declaredTypes;
|
||||
this.onGoingDevelopment = onGoingDevelopment;
|
||||
this.includes = includes;
|
||||
this.location = location;
|
||||
switch (location) {
|
||||
case "ide":
|
||||
this.location = Location.IDE_BUILTIN;
|
||||
break;
|
||||
case "sketchbook":
|
||||
this.location = Location.SKETCHBOOK;
|
||||
break;
|
||||
case "platform":
|
||||
this.location = Location.CORE;
|
||||
case LOCATION_IDE:
|
||||
case LOCATION_SKETCHBOOK:
|
||||
case LOCATION_CORE:
|
||||
case LOCATION_REF_CORE:
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
@ -316,12 +314,12 @@ public class UserLibrary {
|
||||
return (layout == LibraryLayout.RECURSIVE);
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public boolean isIDEBuiltIn() {
|
||||
return getLocation() == Location.IDE_BUILTIN;
|
||||
return getLocation().equals(LOCATION_IDE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Copyright 2017 Arduino AG (http://www.arduino.cc/)
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*/
|
||||
|
||||
package processing.app.packages;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class UserLibraryFolder {
|
||||
|
||||
public enum Location {
|
||||
SKETCHBOOK, CORE, REFERENCED_CORE, IDE_BUILTIN,
|
||||
}
|
||||
|
||||
public File folder;
|
||||
|
||||
public Location location;
|
||||
|
||||
public UserLibraryFolder(File folder, Location location) {
|
||||
this.folder = folder;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
}
|
@ -32,16 +32,19 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import processing.app.packages.UserLibraryFolder.Location;
|
||||
import static processing.app.packages.UserLibrary.LOCATION_CORE;
|
||||
import static processing.app.packages.UserLibrary.LOCATION_IDE;
|
||||
import static processing.app.packages.UserLibrary.LOCATION_REF_CORE;
|
||||
import static processing.app.packages.UserLibrary.LOCATION_SKETCHBOOK;
|
||||
|
||||
public class UserLibraryPriorityComparator implements Comparator<UserLibrary> {
|
||||
|
||||
private final static Map<Location, Integer> priorities = new HashMap<>();
|
||||
private final static Map<String, Integer> priorities = new HashMap<>();
|
||||
static {
|
||||
priorities.put(Location.SKETCHBOOK, 4);
|
||||
priorities.put(Location.CORE, 3);
|
||||
priorities.put(Location.REFERENCED_CORE, 2);
|
||||
priorities.put(Location.IDE_BUILTIN, 1);
|
||||
priorities.put(LOCATION_SKETCHBOOK, 4);
|
||||
priorities.put(LOCATION_CORE, 3);
|
||||
priorities.put(LOCATION_REF_CORE, 2);
|
||||
priorities.put(LOCATION_IDE, 1);
|
||||
}
|
||||
|
||||
private String arch;
|
||||
|
Loading…
x
Reference in New Issue
Block a user