Skip to content
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

Add basic support for arduino-cli detection #44

Open
wants to merge 3 commits into
base: release-1.1-dev
Choose a base branch
from
Open
Changes from all commits
Commits
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
48 changes: 36 additions & 12 deletions Arduino/System/PackagePathIndex.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function(InitializeArduinoPackagePathList)

if (${CMAKE_HOST_APPLE})

set(install_search_paths "$ENV{HOME}/Applications" /Applications
set(install_search_paths "$ENV{HOME}/Applications"
"$ENV{HOME}/Library/Arduino15" /Applications
/Developer/Applications /sw /opt/local)
set(install_path_suffixes Arduino.app/Contents/Java
Arduino.app/Contents/Resources/Java)
Expand Down Expand Up @@ -57,6 +58,8 @@ function(InitializeArduinoPackagePathList)
DIRECTORY)
list(APPEND install_search_paths "${_install_path}")
endif()
elseif(EXISTS "$ENV{HOME}/.arduino15/inventory.yaml")
list(APPEND install_search_paths "$ENV{HOME}/.arduino15")
endif()
endif()

Expand All @@ -76,17 +79,21 @@ function(InitializeArduinoPackagePathList)

set(Prog86Path "ProgramFiles(x86)")
set(install_search_paths "$ENV{${Prog86Path}}/Arduino"
"$ENV{ProgramFiles}/Arduino")
"$ENV{ProgramFiles}/Arduino"
"$ENV{LOCALAPPDATA}/Arduino15")
set(install_path_suffixes "")

file(GLOB package_search_paths "$ENV{LOCALAPPDATA}/Arduino15")
set(package_path_suffixes "")

set(_reg_software "HKEY_LOCAL_MACHINE\\SOFTWARE")
set(_reg_software "HKEY_CURRENT_USER\\SOFTWARE")
set(_reg_win "${_reg_software}\\Microsoft\\Windows\\CurrentVersion")
set(_reg_explorer "${_reg_win}\\Explorer")
get_filename_component(_reg_documents
"[${_reg_explorer}\\User Shell Folders;Personal]" ABSOLUTE)

file(GLOB sketchbook_search_paths "$ENV{LOCALAPPDATA}/Arduino15"
"[${_reg_explorer}\\User Shell Folders;Personal]/ArduinoData")
"${_reg_documents}/ArduinoData")
set(sketchbook_path_suffixes "")
else()

Expand All @@ -97,7 +104,7 @@ function(InitializeArduinoPackagePathList)

# Search for Arduino install path
find_path(ARDUINO_INSTALL_PATH
NAMES lib/version.txt
NAMES lib/version.txt inventory.yaml
PATH_SUFFIXES ${install_path_suffixes}
HINTS ${install_search_paths}
NO_DEFAULT_PATH
Expand All @@ -110,13 +117,18 @@ function(InitializeArduinoPackagePathList)
"Use -DARDUINO_INSTALL_PATH=<path> to manually specify the path (OR)\n"
"Use -DARDUINO_BOARD_MANAGER_URL=<board_url> to try downloading\n")
elseif(ARDUINO_INSTALL_PATH AND NOT "${ARDUINO_ENABLE_PACKAGE_MANAGER}"
AND "${ARDUINO_BOARD_MANAGER_URL}" STREQUAL "")
message("${ARDUINO_INSTALL_PATH}")
file(READ "${ARDUINO_INSTALL_PATH}/lib/version.txt" _version)
string(REGEX MATCH "[0-9]+\\.[0-9]" _ard_version "${_version}")
if (_version AND "${_ard_version}" VERSION_LESS "1.5")
message(WARNING "${ARDUINO_INSTALL_PATH} may be unsupported version "
"${_version}. Please install newer version!")
AND "${ARDUINO_BOARD_MANAGER_URL}" STREQUAL "")
if (EXISTS "${ARDUINO_INSTALL_PATH}/lib/version.txt")
message("${ARDUINO_INSTALL_PATH}")
file(READ "${ARDUINO_INSTALL_PATH}/lib/version.txt" _version)
string(REGEX MATCH "[0-9]+\\.[0-9]" _ard_version "${_version}")
message("${_ard_version}")
if (_version AND "${_ard_version}" VERSION_LESS "1.5")
message(WARNING "${ARDUINO_INSTALL_PATH} may be unsupported version "
"${_version}. Please install newer version!")
endif()
elseif(EXISTS "${ARDUINO_INSTALL_PATH}/inventory.yaml")
message("arduino-cli found at ${ARDUINO_INSTALL_PATH}")
endif()
endif()

Expand Down Expand Up @@ -150,6 +162,18 @@ function(InitializeArduinoPackagePathList)
endif()
# message("ARDUINO_SKETCHBOOK_PATH:${ARDUINO_SKETCHBOOK_PATH}")

# support arduino-cli package downloads on Windows. Sketchbook path will be
# not found if IDE is not installed, so use the Documents/Arduino as
# additional library lookup paths. This is the expected location when running
# arduino-cli lib install <library>.
if (NOT ARDUINO_SKETCHBOOK_PATH AND _reg_documents)
file(GLOB _reg_doc_lib "${_reg_documents}/Arduino")
if (_reg_doc_lib)
set(ARDUINO_SKETCHBOOK_PATH "${_reg_doc_lib}"
CACHE PATH "Path to Arduino Libraries")
endif()
endif()

# Arduino local package management path
if (NOT ARDUINO_PACKAGE_MANAGER_PATH)
set(ARDUINO_PACKAGE_MANAGER_PATH
Expand Down