Skip to content

Use arduino-cli to manage libraries (WIP) #9643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
aa50ec3
fixed some trivial warnings
cmaglie Nov 21, 2019
4b20898
Added arduino-cli 0.6.0 to the build
cmaglie Jan 18, 2019
53140ca
GRPC binding to arduino-cli (EXPERIMENTAL)
cmaglie May 21, 2019
44b763d
Added arduino-cli daemon startup and some basic control code
cmaglie Nov 21, 2019
921a4c5
Added more GRPC commands
cmaglie Nov 28, 2019
20cfded
Rename ContributeLibrary and ContributeLibraryReleases
cmaglie Feb 28, 2020
0ef0056
GRPC: removed limit to max message size
cmaglie Nov 28, 2019
2d193e8
GRPC: Added lib index update command with progress wrapper
cmaglie Nov 28, 2019
de45d7f
Library manager through arduino-cli (WIP, part 1)
cmaglie Nov 28, 2019
f82b8b9
Added GRPC libraryList command
cmaglie Dec 5, 2019
9177254
Using Collection instead of List on some Library types
cmaglie Dec 5, 2019
7a40d00
Installed libraries are now detected via GPRC calls
cmaglie Dec 5, 2019
fb1c188
Removed the, now useless, library folder handling
cmaglie Dec 5, 2019
8d3d244
Removed the now useless UserLibraryFolder
cmaglie Dec 5, 2019
2fbd8fb
Removed, no more needed, LibraryInstaller::updateIndex method
cmaglie Dec 6, 2019
efb3a9a
Removed no more needed LibraryInstaller (it's now done via GRPC)
cmaglie Dec 6, 2019
bc01f7a
Use Library.RealName for installed libraries
cmaglie Dec 7, 2019
6d22212
Removed no more needed UserLibrary constructor/parser
cmaglie Dec 7, 2019
ec6d135
Small update to ProgressWrapper
cmaglie Dec 7, 2019
deee8fa
Updated arduino-cli to 0.7.2
cmaglie Jan 22, 2020
c3212f8
Updated GRPC/arduino-cli to version 0.7.2
cmaglie Jan 20, 2020
37204da
Updated arduino-cli to 0.8.0
cmaglie Feb 18, 2020
f844057
Update GRPC/arduino-cli to 0.8.0
cmaglie Feb 18, 2020
eb75932
Using enumerations for LibraryLocation
cmaglie Feb 18, 2020
a9e9b35
Added paths to grpc lib in build.xml
cmaglie Feb 19, 2020
14ff582
Added missing fields in ContributedLibrary
cmaglie Mar 2, 2020
5ea000c
Fixed 'Installed' drop-down menu condition in library manager
cmaglie Mar 2, 2020
c0c75a9
LibManager: avoid throwing an exception to allow correct error handling
facchinm Mar 9, 2020
6ae06b1
INITIAL: integrate compile with arduino-cli
facchinm Mar 9, 2020
b57fced
Using GRPC enumerations for LibraryLayout
cmaglie Mar 2, 2020
49551b2
Updated cli java bindings
cmaglie Mar 12, 2020
cb0152d
compile/verify now uses arduino-cli daemon
cmaglie Mar 12, 2020
a98396e
Removed testing/debugging leftvoers
cmaglie Mar 12, 2020
25310d2
Slightly simplified loop
cmaglie Mar 12, 2020
e5c7351
Updated java bindings
cmaglie Mar 17, 2020
bad9811
Compiler now read progress through GRPC
cmaglie Mar 17, 2020
d3494dc
Setting are applied automatically when preferences dialog is closed
cmaglie Apr 15, 2020
c612b7f
Added method to extract Proxy URI from configuration
cmaglie Apr 16, 2020
7520805
Proxy configuration is now properly handled
cmaglie Apr 16, 2020
61a2f4a
Updated arduino-cli and java bindings to 0.11.0
cmaglie Jun 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ hardware/arduino/bootloaders/caterina_LUFA/Caterina.lss
hardware/arduino/bootloaders/caterina_LUFA/Caterina.elf
hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep
hardware/arduino/bootloaders/caterina_LUFA/.dep/
build/arduino-cli*.tar.gz
build/*.zip
build/*.tar.bz2
build/windows/work/
Expand Down
2 changes: 2 additions & 0 deletions app/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@
<classpathentry kind="lib" path="lib/jtouchbar-1.0.0.jar"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.8.1.jar"/>
<classpathentry kind="lib" path="lib/jssc-2.8.0-arduino4.jar"/>
<classpathentry kind="lib" path="lib/grpc-core-1.20.0.jar"/>
<classpathentry kind="lib" path="lib/grpc/protobuf-java-3.11.4.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
3 changes: 3 additions & 0 deletions app/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
<fileset dir="lib/grpc">
<include name="*.jar"/>
</fileset>
<pathelement path="${env.JAVA_HOME}/lib/tools.jar"/>
<pathelement path="../arduino-core/arduino-core.jar"/>
</path>
Expand Down
Binary file added app/lib/grpc-core-1.20.0.jar
Binary file not shown.
Binary file added app/lib/grpc/protobuf-java-3.11.4.jar
Binary file not shown.
14 changes: 7 additions & 7 deletions app/src/cc/arduino/contributions/ContributionsSelfCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
package cc.arduino.contributions;

import cc.arduino.UpdatableBoardsLibsFakeURLsHandler;
import cc.arduino.contributions.libraries.LibraryInstaller;
import cc.arduino.cli.ArduinoCoreInstance;
import cc.arduino.contributions.libraries.filters.UpdatableLibraryPredicate;
import cc.arduino.contributions.packages.ContributionInstaller;
import cc.arduino.contributions.packages.filters.UpdatablePlatformPredicate;
Expand All @@ -53,19 +53,19 @@ public class ContributionsSelfCheck extends TimerTask implements NotificationPop
private final Base base;
private final HyperlinkListener hyperlinkListener;
private final ContributionInstaller contributionInstaller;
private final LibraryInstaller libraryInstaller;
private final ArduinoCoreInstance core;
private final ProgressListener progressListener;
private final String boardsManagerURL = "http://boardsmanager/DropdownUpdatableCoresItem";
private final String libraryManagerURL = "http://librarymanager/DropdownUpdatableLibrariesItem";

private volatile boolean cancelled;
private volatile NotificationPopup notificationPopup;

public ContributionsSelfCheck(Base base, HyperlinkListener hyperlinkListener, ContributionInstaller contributionInstaller, LibraryInstaller libraryInstaller) {
public ContributionsSelfCheck(Base base, HyperlinkListener hyperlinkListener, ContributionInstaller contributionInstaller, ArduinoCoreInstance core) {
this.base = base;
this.hyperlinkListener = hyperlinkListener;
this.contributionInstaller = contributionInstaller;
this.libraryInstaller = libraryInstaller;
this.core = core;
this.progressListener = new NoopProgressListener();
this.cancelled = false;
}
Expand Down Expand Up @@ -176,13 +176,13 @@ public void onOptionalButton2Callback() {
goToManager(libraryManagerURL);
}

static boolean checkForUpdatablePlatforms() {
boolean checkForUpdatablePlatforms() {
return BaseNoGui.indexer.getPackages().stream()
.flatMap(pack -> pack.getPlatforms().stream())
.anyMatch(new UpdatablePlatformPredicate());
}

static boolean checkForUpdatableLibraries() {
boolean checkForUpdatableLibraries() {
return BaseNoGui.librariesIndexer.getIndex().getLibraries().stream()
.anyMatch(new UpdatableLibraryPredicate());
}
Expand All @@ -201,7 +201,7 @@ private void updateLibrariesIndex() {
return;
}
try {
libraryInstaller.updateIndex(progressListener);
core.updateLibrariesIndex(progressListener);
} catch (Exception e) {
// ignore
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ public int compare(UserLibrary o1, UserLibrary o2) {
if (o2.getTypes().isEmpty()) {
return -1;
}
if (!o1.getTypes().get(0).equals(o2.getTypes().get(0))) {
return o1.getTypes().get(0).compareTo(o2.getTypes().get(0));
String t1 = o1.getTypes().iterator().next();
String t2 = o2.getTypes().iterator().next();
if (!t1.equals(t2)) {
return t1.compareTo(t2);
}
return o1.getName().compareTo(o2.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@

package cc.arduino.contributions.libraries.filters;

import java.util.List;
import java.util.function.Predicate;

import cc.arduino.contributions.VersionComparator;
import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
import cc.arduino.contributions.libraries.LibrariesIndexer;
import processing.app.BaseNoGui;

Expand All @@ -51,12 +50,10 @@ public UpdatableLibraryPredicate(LibrariesIndexer indexer) {

@Override
public boolean test(ContributedLibrary lib) {
if (!lib.isLibraryInstalled()) {
if (!lib.getInstalled().isPresent()) {
return false;
}
String libraryName = lib.getName();
List<ContributedLibrary> libraries = librariesIndexer.getIndex().find(libraryName);
ContributedLibrary latest = libraries.stream().reduce(VersionComparator::max).get();
ContributedLibraryRelease latest = lib.getLatest().get(); // it must be present
return !latest.isLibraryInstalled();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@

package cc.arduino.contributions.libraries.ui;

import cc.arduino.contributions.libraries.ContributedLibraryRelease;
import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.libraries.ContributedLibraryReleases;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class ContributedLibraryReleasesComparator implements Comparator<ContributedLibraryReleases> {
public class ContributedLibraryComparatorWithTypePriority implements Comparator<ContributedLibrary> {

private final String firstType;

public ContributedLibraryReleasesComparator(String firstType) {
public ContributedLibraryComparatorWithTypePriority(String firstType) {
this.firstType = firstType;
}

@Override
public int compare(ContributedLibraryReleases o1, ContributedLibraryReleases o2) {
ContributedLibrary lib1 = o1.getLatest();
ContributedLibrary lib2 = o2.getLatest();
public int compare(ContributedLibrary o1, ContributedLibrary o2) {
ContributedLibraryRelease lib1 = o1.getLatest().get();
ContributedLibraryRelease lib2 = o2.getLatest().get();

List<String> types1 = lib1.getTypes();
List<String> types2 = lib2.getTypes();
Expand All @@ -66,7 +66,7 @@ public int compare(ContributedLibraryReleases o1, ContributedLibraryReleases o2)
return compareName(lib1, lib2);
}

private int compareName(ContributedLibrary lib1, ContributedLibrary lib2) {
private int compareName(ContributedLibraryRelease lib1, ContributedLibraryRelease lib2) {
return lib1.getName().compareToIgnoreCase(lib2.getName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

import java.awt.Color;
import java.awt.Component;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -44,51 +46,51 @@
import cc.arduino.contributions.DownloadableContributionVersionComparator;
import cc.arduino.contributions.VersionComparator;
import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
import cc.arduino.contributions.ui.InstallerTableCell;
import cc.arduino.utils.ReverseComparator;

@SuppressWarnings("serial")
public class ContributedLibraryTableCellEditor extends InstallerTableCell {

private ContributedLibraryReleases editorValue;
private ContributedLibrary editorLibrary;
private ContributedLibraryTableCellJPanel editorCell;

@Override
public Object getCellEditorValue() {
return editorValue;
return editorLibrary;
}

@Override
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row,
int column) {
editorValue = (ContributedLibraryReleases) value;
editorLibrary = (ContributedLibrary) value;

editorCell = new ContributedLibraryTableCellJPanel(table, value, true);
editorCell.installButton
.addActionListener(e -> onInstall(editorValue.getSelected(),
editorValue.getInstalled()));
.addActionListener(e -> onInstall(editorLibrary.getSelected().get(),
editorLibrary.getInstalled()));
editorCell.downgradeButton.addActionListener(e -> {
JComboBox chooser = editorCell.downgradeChooser;
ContributedLibrary lib = (ContributedLibrary) chooser.getSelectedItem();
onInstall(lib, editorValue.getInstalled());
ContributedLibraryRelease lib = (ContributedLibraryRelease) chooser.getSelectedItem();
onInstall(lib, editorLibrary.getInstalled());
});
editorCell.versionToInstallChooser.addActionListener(e -> {
editorValue.select((ContributedLibrary) editorCell.versionToInstallChooser.getSelectedItem());
editorLibrary.select((ContributedLibraryRelease) editorCell.versionToInstallChooser.getSelectedItem());
if (editorCell.versionToInstallChooser.getSelectedIndex() != 0) {
InstallerTableCell.dropdownSelected(true);
}
});

setEnabled(true);

final Optional<ContributedLibrary> mayInstalled = editorValue.getInstalled();
final Optional<ContributedLibraryRelease> mayInstalled = editorLibrary.getInstalled();

List<ContributedLibrary> releases = editorValue.getReleases();
List<ContributedLibrary> notInstalled = new LinkedList<>(releases);
Collection<ContributedLibraryRelease> releases = editorLibrary.getReleases();
List<ContributedLibraryRelease> notInstalled = new ArrayList<>(releases);
if (mayInstalled.isPresent()) {
notInstalled.remove(editorValue.getInstalled().get());
notInstalled.remove(mayInstalled.get());
}

Collections.sort(notInstalled, new ReverseComparator<>(
Expand All @@ -97,8 +99,8 @@ public Component getTableCellEditorComponent(JTable table, Object value,
editorCell.downgradeChooser.removeAllItems();
editorCell.downgradeChooser.addItem(tr("Select version"));

final List<ContributedLibrary> notInstalledPrevious = new LinkedList<>();
final List<ContributedLibrary> notInstalledNewer = new LinkedList<>();
final List<ContributedLibraryRelease> notInstalledPrevious = new LinkedList<>();
final List<ContributedLibraryRelease> notInstalledNewer = new LinkedList<>();

notInstalled.stream().forEach(input -> {
if (!mayInstalled.isPresent()
Expand Down Expand Up @@ -139,12 +141,12 @@ public void setStatus(String status) {
editorCell.statusLabel.setText(status);
}

protected void onRemove(ContributedLibrary selected) {
protected void onRemove(ContributedLibraryRelease selected) {
// Empty
}

protected void onInstall(ContributedLibrary selected,
Optional<ContributedLibrary> mayInstalled) {
protected void onInstall(ContributedLibraryRelease selected,
Optional<ContributedLibraryRelease> mayInstalled) {
// Empty
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import javax.swing.text.html.StyleSheet;

import cc.arduino.contributions.DownloadableContributionVersionComparator;
import cc.arduino.contributions.libraries.ContributedLibraryRelease;
import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
import cc.arduino.contributions.ui.InstallerTableCell;
import processing.app.Base;
import processing.app.PreferencesData;
Expand Down Expand Up @@ -119,15 +119,15 @@ public ContributedLibraryTableCellJPanel(JTable parentTable, Object value,

add(Box.createVerticalStrut(15));

ContributedLibraryReleases releases = (ContributedLibraryReleases) value;
ContributedLibrary releases = (ContributedLibrary) value;

// FIXME: happens on macosx, don't know why
if (releases == null)
return;

ContributedLibrary selected = releases.getSelected();
ContributedLibraryRelease selected = releases.getSelected().get();
titledBorder.setTitle(selected.getName());
Optional<ContributedLibrary> mayInstalled = releases.getInstalled();
Optional<ContributedLibraryRelease> mayInstalled = releases.getInstalled();

boolean installable, upgradable;
if (!mayInstalled.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@

package cc.arduino.contributions.libraries.ui;

import cc.arduino.contributions.libraries.ContributedLibraryReleases;
import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.ui.DropdownItem;

import java.util.function.Predicate;

import static processing.app.I18n.tr;

public class DropdownAllLibraries implements DropdownItem<ContributedLibraryReleases> {
public class DropdownAllLibraries implements DropdownItem<ContributedLibrary> {

public String toString() {
return tr("All");
}

@Override
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
public Predicate<ContributedLibrary> getFilterPredicate() {
return x -> true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@

import java.util.function.Predicate;

import cc.arduino.contributions.libraries.ContributedLibraryReleases;
import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.ui.DropdownItem;

public class DropdownInstalledLibraryItem implements DropdownItem<ContributedLibraryReleases> {
public class DropdownInstalledLibraryItem implements DropdownItem<ContributedLibrary> {

public String toString() {
return tr("Installed");
}

@Override
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
return new Predicate<ContributedLibraryReleases>() {
public Predicate<ContributedLibrary> getFilterPredicate() {
return new Predicate<ContributedLibrary>() {
@Override
public boolean test(ContributedLibraryReleases t) {
public boolean test(ContributedLibrary t) {
return t.getInstalled().isPresent();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@

package cc.arduino.contributions.libraries.ui;

import cc.arduino.contributions.libraries.ContributedLibraryRelease;
import cc.arduino.contributions.libraries.ContributedLibrary;
import cc.arduino.contributions.libraries.ContributedLibraryReleases;
import cc.arduino.contributions.ui.DropdownItem;

import java.util.function.Predicate;

import static processing.app.I18n.tr;

public class DropdownLibraryOfCategoryItem implements DropdownItem<ContributedLibraryReleases> {
public class DropdownLibraryOfCategoryItem implements DropdownItem<ContributedLibrary> {

private final String category;

Expand All @@ -50,11 +50,11 @@ public String toString() {
}

@Override
public Predicate<ContributedLibraryReleases> getFilterPredicate() {
return new Predicate<ContributedLibraryReleases>() {
public Predicate<ContributedLibrary> getFilterPredicate() {
return new Predicate<ContributedLibrary>() {
@Override
public boolean test(ContributedLibraryReleases rel) {
ContributedLibrary lib = rel.getLatest();
public boolean test(ContributedLibrary rel) {
ContributedLibraryRelease lib = rel.getLatest().get();
return category.equals(lib.getCategory());
}
};
Expand Down
Loading