Skip to content

Commit a253288

Browse files
committed
Add optional branch parameter to install_package and install_library
This allows the user to select which branch of the Git repository they want to install. Closes #5
1 parent 010fda6 commit a253288

File tree

3 files changed

+47
-12
lines changed

3 files changed

+47
-12
lines changed

.travis.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ before_install:
5050
- install_package "https://github.com/SpenceKonde/ATTinyCore/archive/master.zip"
5151
# Test manual package install from Git repository clone
5252
- install_package "https://github.com/MCUdude/MightyCore.git"
53+
# Test manual package install from Git repository clone
54+
- install_package "https://github.com/JChristensen/mighty-1284p.git" "v1.6.3"
5355

5456
# Test library installation from repository (can't do this because there is no library in this repository)
5557
# - install_library
@@ -59,8 +61,12 @@ before_install:
5961
- install_library "https://github.com/brianc118/MPU9250/archive/master.zip" "MPU9250"
6062
# Test library install from git repo
6163
- install_library "https://github.com/sfrwmaker/WirelessOregonV2.git"
64+
# Test library install from git repo with branch
65+
- install_library "https://github.com/sde1000/NanodeUNIO.git" "master"
6266
# Test library install from git repo with rename
63-
- install_library "https://github.com/mikaelpatel/Arduino-Shell.git" "ArduinoShell"
67+
- install_library "https://github.com/mikaelpatel/Arduino-Shell.git" "" "ArduinoShell"
68+
# Test library install from git repo with branch and rename
69+
- install_library "https://github.com/Avamander/max7456.git" "master" "max_7456"
6470
# Test set_verbose_output_during_compilation.
6571
- set_verbose_output_during_compilation "$VERBOSE_COMPILATION"
6672

@@ -93,6 +99,8 @@ script:
9399
# Test board from hardware package manually installed by cloning Git repository
94100
# Test build_sketch with an IDE version range
95101
- build_sketch "${APPLICATION_FOLDER}/arduino/examples/01.Basics/BareMinimum/BareMinimum.ino" "MightyCore:avr:1284:pinout=standard,variant=modelP,BOD=2v7,LTO=Os,clock=16MHz_external" "false" "1.8.1" "1.8.2"
102+
# Test board from hardware package manually installed by cloning Git repository with non-default branch
103+
- build_sketch "${APPLICATION_FOLDER}/arduino/examples/01.Basics/BareMinimum/BareMinimum.ino" "mighty-1284p:avr:avr_developers" "false" "newest"
96104

97105
# Installed library tests:
98106
# Test build_sketch without absolute path
@@ -104,8 +112,12 @@ script:
104112
- build_sketch "${SKETCHBOOK_FOLDER}/libraries/NewPing/examples/NewPingExample/NewPingExample.pde" "arduino:avr:uno" "false" "all"
105113
# Test library installed from .git
106114
- build_sketch "${SKETCHBOOK_FOLDER}/libraries/WirelessOregonV2/examples/OregonReceiver/OregonReceiver.ino" "arduino:avr:uno" "false" "newest"
115+
# Test library installed from .git with branch
116+
- build_sketch "${SKETCHBOOK_FOLDER}/libraries/NanodeUNIO/examples/NanodeUNIO_test/NanodeUNIO_test.ino" "arduino:avr:uno" "false" "newest"
107117
# Test library installed from .git with rename
108118
- build_sketch "${SKETCHBOOK_FOLDER}/libraries/ArduinoShell/examples/ShellBlink/ShellBlink.ino" "arduino:avr:uno" "false" "newest"
119+
# Test library installed from .git with branch and rename
120+
- build_sketch "${SKETCHBOOK_FOLDER}/libraries/max_7456/examples/HelloWorld/HelloWorld.ino" "arduino:avr:uno" "false" "newest"
109121
# Test library installed from Library Manager
110122
- build_sketch "${SKETCHBOOK_FOLDER}/libraries/Pushetta/examples/simple_notification/simple_notification.ino" "arduino:avr:uno" "false" "newest"
111123

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ Install a range of version(s) of the Arduino IDE.
5959
"Manually" install the hardware package from the current repository. Packages are installed to `$SKETCHBOOK_FOLDER/hardware. Assumes the hardware package is located in the root of the download or repository and has the correct folder structure.
6060

6161
##### `install_package packageURL`
62-
"Manually" install a hardware package. Packages are installed to `$SKETCHBOOK_FOLDER/hardware. Assumes the hardware package is located in the root of the download or repository and has the correct folder structure.
63-
- Parameter: **packageURL** - The URL of the hardware package download or Git repository. The protocol component of the URL (e.g. `http://`, `https://`) is required.
62+
"Manually" install a hardware package downloaded as a compressed file. Packages are installed to `$SKETCHBOOK_FOLDER/hardware. Assumes the hardware package is located in the root of the file and has the correct folder structure.
63+
- Parameter: **packageURL** - The URL of the hardware package download. The protocol component of the URL (e.g. `http://`, `https://`) is required.
64+
65+
##### `install_package packageURL [branchName]`
66+
"Manually" install a hardware package. Packages are installed to `$SKETCHBOOK_FOLDER/hardware. Assumes the hardware package is located in the root of the repository and has the correct folder structure.
67+
- Parameter: **packageURL** - The URL of the Git repository. The protocol component of the URL (e.g. `http://`, `https://`) is required.
68+
- Parameter(optional): **branchName** - Branch of the repository to install. If this argument is not specified or is left blank the default branch will be used.
6469

6570
##### `install_package packageID [packageURL]`
6671
Install a hardware package using the Arduino IDE (Boards Manager). Only the **Arduino AVR Boards** package is included with the Arduino IDE installation. Packages are installed to `$HOME/.arduino15/packages. You must call `install_ide` before this function. This feature is only available with Arduino IDE 1.6.4 and newer.
@@ -75,9 +80,15 @@ Install a library that is listed in the Arduino Library Manager index. The libra
7580
- Parameter: **libraryName** - The name of the library to install. You can specify a version separated from the name by a colon, e.g. "LiquidCrystal I2C:1.1.2". If no version is specified the most recent version will be installed. You can also specify comma-separated lists of library names.
7681

7782
##### `install_library libraryURL [newFolderName]`
78-
Install a library from a URL (either compressed file download or clone Git repository). The library is installed to the `libraries` subfolder of the sketchbook folder.
79-
- Parameter: **libraryURL** - The URL of the library download or library name in the Arduino Library Manager. The protocol component of the URL (e.g. `http://`, `https://`) is required. This can be any compressed file format or a .git file will cause that repository to be cloned. Assumes the library is located in the root of the file.
80-
- Parameter(optional): **newFolderName** - Folder name to rename the installed library folder to. This parameter is only used if the library identifier is a URL (installation from a compressed file or Git repository) This can be useful if the default folder name of the downloaded file is problematic. The Arduino IDE gives include file preference when the filename matches the library folder name. GitHub's "Download ZIP" file is given the folder name {repository name}-{branch name}. Library folder names that contain `-` or `.` are not compatible with Arduino IDE 1.5.6 and older, arduino will hang if it's started with a library using an invalid folder name installed.
83+
Download a library in a compressed file from a URL. The library is installed to the `libraries` subfolder of the sketchbook folder.
84+
- Parameter: **libraryURL** - The URL of the library download or library name in the Arduino Library Manager. The protocol component of the URL (e.g. `http://`, `https://`) is required. This can be any compressed file format. Assumes the library is located in the root of the file.
85+
- Parameter(optional): **newFolderName** - Folder name to rename the installed library folder to. This can be useful if the default folder name of the downloaded file is problematic. The Arduino IDE gives include file preference when the filename matches the library folder name. GitHub's "Download ZIP" file is given the folder name {repository name}-{branch name}. Library folder names that contain `-` or `.` are not compatible with Arduino IDE 1.5.6 and older, arduino will hang if it's started with a library using an invalid folder name installed.
86+
87+
##### `install_library libraryURL [branchName [newFolderName]]`
88+
Install a library by cloning a Git repository). The library is installed to the `libraries` subfolder of the sketchbook folder.
89+
- Parameter: **libraryURL** - The URL of the library download or library name in the Arduino Library Manager. The protocol component of the URL (e.g. `http://`, `https://`) is required. Assumes the library is located in the root of the repository.
90+
- Parameter(optional): **branchName** - Branch of the repository to install. If this argument is not specified or is left blank the default branch will be used.
91+
- Parameter(optional): **newFolderName** - Folder name to rename the installed library folder to. This can be useful if the default folder name of the downloaded file is problematic. The Arduino IDE gives include file preference when the filename matches the library folder name. Library folder names that contain `-` or `.` are not compatible with Arduino IDE 1.5.6 and older, arduino will hang if it's started with a library using an invalid folder name installed. If the `newFolderName` argument is specified the `branchName` argument must also be specified. If you don't want to specify a branch then use `""` for the `branchName` argument.
8192

8293
##### `set_verbose_output_during_compilation verboseOutputDuringCompilation`
8394
Turn on/off arduino verbose output during compilation. This will show all the commands arduino runs during the process rather than just the compiler output. This is usually not very useful output and only clutters up the log.

arduino-ci-script.sh

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,15 @@ function install_package()
377377

378378
if [[ "$packageURL" =~ \.git$ ]]; then
379379
# Clone the repository
380+
local -r branchName="$2"
381+
380382
cd "${ARDUINO_CI_SCRIPT_SKETCHBOOK_FOLDER}/hardware"
381-
git clone --quiet "$packageURL"
382383

384+
if [[ "$branchName" == "" ]]; then
385+
git clone --quiet "$packageURL"
386+
else
387+
git clone --quiet --branch "$branchName" "$packageURL"
388+
fi
383389
else
384390
cd "$ARDUINO_CI_SCRIPT_TEMPORARY_FOLDER"
385391

@@ -452,7 +458,6 @@ function install_library()
452458
set -o errexit
453459

454460
local -r libraryIdentifier="$1"
455-
local -r newFolderName="$2"
456461

457462
# Create the libraries folder if it doesn't already exist
458463
create_folder "${ARDUINO_CI_SCRIPT_SKETCHBOOK_FOLDER}/libraries"
@@ -463,16 +468,23 @@ function install_library()
463468
# Note: this assumes the library is in the root of the file
464469
if [[ "$libraryIdentifier" =~ \.git$ ]]; then
465470
# Clone the repository
471+
local -r branchName="$2"
472+
local -r newFolderName="$3"
473+
466474
cd "${ARDUINO_CI_SCRIPT_SKETCHBOOK_FOLDER}/libraries"
467-
if [[ "$newFolderName" == "" ]]; then
475+
476+
if [[ "$branchName" == "" && "$newFolderName" == "" ]]; then
477+
git clone --quiet "$libraryIdentifier"
478+
elif [[ "$branchName" == "" ]]; then
468479
git clone --quiet "$libraryIdentifier"
480+
elif [[ "$newFolderName" == "" ]]; then
481+
git clone --quiet --branch "$branchName" "$libraryIdentifier"
469482
else
470-
git clone --quiet "$libraryIdentifier" "$newFolderName"
483+
git clone --quiet --branch "$branchName" "$libraryIdentifier" "$newFolderName"
471484
fi
472-
473485
else
474486
# Assume it's a compressed file
475-
487+
local -r newFolderName="$2"
476488
# Download the file to the temporary folder
477489
cd "$ARDUINO_CI_SCRIPT_TEMPORARY_FOLDER"
478490
# Clean up the temporary folder

0 commit comments

Comments
 (0)