mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-14 11:29:26 +01:00
Explicitely store a layout type for a library
Previously, the useRecursion and srcFolders were filled on library creation, based on the existence of the src folder. Now, a layout variable is set, and the useRecursion() and getSrcFolder() methods change their return value based on the layout in use.
This commit is contained in:
parent
285a03a655
commit
a6013720e5
@ -23,10 +23,11 @@ public class Library {
|
|||||||
private String license;
|
private String license;
|
||||||
private List<String> architectures;
|
private List<String> architectures;
|
||||||
private File folder;
|
private File folder;
|
||||||
private File srcFolder;
|
|
||||||
private boolean useRecursion;
|
|
||||||
private boolean isLegacy;
|
private boolean isLegacy;
|
||||||
|
|
||||||
|
private enum LibraryLayout { FLAT, RECURSIVE };
|
||||||
|
private LibraryLayout layout;
|
||||||
|
|
||||||
private static final List<String> MANDATORY_PROPERTIES = Arrays
|
private static final List<String> MANDATORY_PROPERTIES = Arrays
|
||||||
.asList(new String[] { "name", "version", "author", "maintainer",
|
.asList(new String[] { "name", "version", "author", "maintainer",
|
||||||
"sentence", "paragraph", "url" });
|
"sentence", "paragraph", "url" });
|
||||||
@ -82,12 +83,12 @@ public class Library {
|
|||||||
throw new IOException("Missing '" + p + "' from library");
|
throw new IOException("Missing '" + p + "' from library");
|
||||||
|
|
||||||
// Check layout
|
// Check layout
|
||||||
boolean useRecursion;
|
LibraryLayout layout;
|
||||||
File srcFolder = new File(libFolder, "src");
|
File srcFolder = new File(libFolder, "src");
|
||||||
|
|
||||||
if (srcFolder.exists() && srcFolder.isDirectory()) {
|
if (srcFolder.exists() && srcFolder.isDirectory()) {
|
||||||
// Layout with a single "src" folder and recursive compilation
|
// Layout with a single "src" folder and recursive compilation
|
||||||
useRecursion = true;
|
layout = LibraryLayout.RECURSIVE;
|
||||||
|
|
||||||
File utilFolder = new File(libFolder, "utility");
|
File utilFolder = new File(libFolder, "utility");
|
||||||
if (utilFolder.exists() && utilFolder.isDirectory()) {
|
if (utilFolder.exists() && utilFolder.isDirectory()) {
|
||||||
@ -96,8 +97,7 @@ public class Library {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Layout with source code on library's root and "utility" folders
|
// Layout with source code on library's root and "utility" folders
|
||||||
srcFolder = libFolder;
|
layout = LibraryLayout.FLAT;
|
||||||
useRecursion = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn if root folder contains development leftovers
|
// Warn if root folder contains development leftovers
|
||||||
@ -134,7 +134,6 @@ public class Library {
|
|||||||
|
|
||||||
Library res = new Library();
|
Library res = new Library();
|
||||||
res.folder = libFolder;
|
res.folder = libFolder;
|
||||||
res.srcFolder = srcFolder;
|
|
||||||
res.name = properties.get("name").trim();
|
res.name = properties.get("name").trim();
|
||||||
res.version = properties.get("version").trim();
|
res.version = properties.get("version").trim();
|
||||||
res.author = properties.get("author").trim();
|
res.author = properties.get("author").trim();
|
||||||
@ -145,8 +144,8 @@ public class Library {
|
|||||||
res.category = category.trim();
|
res.category = category.trim();
|
||||||
res.license = license.trim();
|
res.license = license.trim();
|
||||||
res.architectures = archs;
|
res.architectures = archs;
|
||||||
res.useRecursion = useRecursion;
|
|
||||||
res.isLegacy = false;
|
res.isLegacy = false;
|
||||||
|
res.layout = layout;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,8 +153,7 @@ public class Library {
|
|||||||
// construct an old style library
|
// construct an old style library
|
||||||
Library res = new Library();
|
Library res = new Library();
|
||||||
res.folder = libFolder;
|
res.folder = libFolder;
|
||||||
res.srcFolder = libFolder;
|
res.layout = LibraryLayout.FLAT;
|
||||||
res.useRecursion = false;
|
|
||||||
res.name = libFolder.getName();
|
res.name = libFolder.getName();
|
||||||
res.architectures = Arrays.asList("*");
|
res.architectures = Arrays.asList("*");
|
||||||
res.isLegacy = true;
|
res.isLegacy = true;
|
||||||
@ -246,11 +244,18 @@ public class Library {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean useRecursion() {
|
public boolean useRecursion() {
|
||||||
return useRecursion;
|
return (layout == LibraryLayout.RECURSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getSrcFolder() {
|
public File getSrcFolder() {
|
||||||
return srcFolder;
|
switch (layout) {
|
||||||
|
case FLAT:
|
||||||
|
return folder;
|
||||||
|
case RECURSIVE:
|
||||||
|
return new File(folder, "src");
|
||||||
|
default:
|
||||||
|
return null; // Keep compiler happy :-(
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLegacy() {
|
public boolean isLegacy() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user