Skip to content

Fix regression in handling of spaces in dependent library names #223

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

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Support for mock EEPROM (but only if board supports it)
- Add stubs for `Client.h`, `IPAddress.h`, `Printable.h`, `Server.h`, and `Udp.h`
- `Wire` now has a mock support for the master role
- Sample project for `BusIO` to show problem finding header file

### Changed
- Move repository from https://github.com/ianfixes/arduino_ci to https://github.com/Arduino-CI/arduino_ci
Expand Down
12 changes: 12 additions & 0 deletions SampleProjects/BusIO/.arduino-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
unittest:
platforms:
- mega2560
libraries:
- "Adafruit BusIO"
# - "Adafruit_BusIO" <= This works if you have the library pre-installed

compile:
platforms:
- mega2560
libraries:
- "Adafruit BusIO"
1 change: 1 addition & 0 deletions SampleProjects/BusIO/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.bundle
2 changes: 2 additions & 0 deletions SampleProjects/BusIO/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source 'https://rubygems.org'
gem 'arduino_ci', path: '../../'
4 changes: 4 additions & 0 deletions SampleProjects/BusIO/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# BusIO

This is an example of a library that depends on Adafruit BusIO.
It is provided to help reproduce #192.
39 changes: 39 additions & 0 deletions SampleProjects/BusIO/examples/spi_readwrite/spi_readwrite.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <Adafruit_SPIDevice.h>

#define SPIDEVICE_CS 10
Adafruit_SPIDevice spi_dev = Adafruit_SPIDevice(SPIDEVICE_CS);


void setup() {
while (!Serial) { delay(10); }
Serial.begin(115200);
Serial.println("SPI device read and write test");

if (!spi_dev.begin()) {
Serial.println("Could not initialize SPI device");
while (1);
}

uint8_t buffer[32];

// Try to read 32 bytes
spi_dev.read(buffer, 32);
Serial.print("Read: ");
for (uint8_t i=0; i<32; i++) {
Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
}
Serial.println();

// read a register by writing first, then reading
buffer[0] = 0x8F; // we'll reuse the same buffer
spi_dev.write_then_read(buffer, 1, buffer, 2, false);
Serial.print("Write then Read: ");
for (uint8_t i=0; i<2; i++) {
Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
}
Serial.println();
}

void loop() {

}
10 changes: 10 additions & 0 deletions SampleProjects/BusIO/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name=BusIO
version=0.1.0
author=James Foster <[email protected]>
maintainer=James Foster <[email protected]>
sentence=Sample BusIO library to validate import of Adafruit BusIO
paragraph=Sample BusIO library to validate import of Adafruit BusIO
category=Other
url=https://github.com/Arduino-CI/arduino_ci/SampleProjects/BusIO
architectures=avr,esp8266
includes=BusIO.h
9 changes: 9 additions & 0 deletions SampleProjects/BusIO/src/BusIO.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <Adafruit_SPIDevice.h>
#include <Arduino.h>

class BusIO {
public:
BusIO() {}
~BusIO() {}
int answer() { return 42; }
};
17 changes: 17 additions & 0 deletions SampleProjects/BusIO/test/busio.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
bundle config --local path vendor/bundle
bundle install
bundle exec arduino_ci.rb --skip-examples-compilation
*/

#include <Arduino.h>
#include <ArduinoUnitTests.h>
#include <BusIO.h>

unittest(busio_answer) {
// token test
BusIO busIO;
assertEqual(42, busIO.answer());
}

unittest_main()
15 changes: 12 additions & 3 deletions cpp/arduino/Wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class TwoWire : public ObservableDataStream {
// https://www.arduino.cc/en/Reference/WireRequestFrom
// Used by the master to request bytes from a slave device. The bytes may then
// be retrieved with the available() and read() functions.
uint8_t requestFrom(uint8_t address, size_t quantity, bool stop) {
uint8_t requestFrom(uint8_t address, uint8_t quantity, uint32_t _iaddress, uint8_t _isize, uint8_t stop) {
assert(_didBegin);
assert(address > 0 && address < SLAVE_COUNT);
assert(quantity <= BUFFER_LENGTH);
Expand All @@ -131,11 +131,20 @@ class TwoWire : public ObservableDataStream {
return 0;
}
}

uint8_t requestFrom(uint8_t address, uint8_t quantity, uint8_t stop) {
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint32_t)0, (uint8_t)0, (uint8_t)stop);
}

uint8_t requestFrom(uint8_t address, uint8_t quantity) {
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true);
}

uint8_t requestFrom(int address, int quantity) {
return requestFrom((uint8_t)address, (size_t)quantity, true);
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)true);
}
uint8_t requestFrom(int address, int quantity, int stop) {
return requestFrom((uint8_t)address, (size_t)quantity, (bool)stop);
return requestFrom((uint8_t)address, (uint8_t)quantity, (uint8_t)stop);
}

// https://www.arduino.cc/en/Reference/WireWrite
Expand Down
7 changes: 6 additions & 1 deletion lib/arduino_ci/cpp_library.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,12 @@ def arduino_library_src_dirs(aux_libraries)
# Pull in all possible places that headers could live, according to the spec:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification

aux_libraries.map { |d| self.class.new(@arduino_lib_dir + d, @arduino_lib_dir, @exclude_dirs).header_dirs }.flatten.uniq
aux_libraries.map do |d|
# library manager coerces spaces in package names to underscores
# see https://github.com/ianfixes/arduino_ci/issues/132#issuecomment-518857059
legal_dir = d.tr(" ", "_")
self.class.new(@arduino_lib_dir + legal_dir, @arduino_lib_dir, @exclude_dirs).header_dirs
end.flatten.uniq
end

# GCC command line arguments for including aux libraries
Expand Down