Commit bc2667e9 authored by Adrien Oliva's avatar Adrien Oliva

build(release): Prepare PlatformIO release

Signed-off-by: Adrien Oliva's avatarAdrien Oliva <olivaa+gitlab@yapbreak.fr>
parent a4a57346
Pipeline #386 passed with stages
in 1 minute and 2 seconds
......@@ -102,3 +102,5 @@ platformio.ini
buttontest
library.properties
library.json
*.pc
before_script:
- ./autogen.sh
- curl -o libardsim-last.tar.gz https://ci.yapbreak.fr/job/libraries/job/LibArdsim/lastSuccessfulBuild/artifact/libardsim-last.tar.gz
- tar xzf libardsim-last.tar.gz
- (cd libardsim-*/ && ./configure --prefix=/tmp/libardsim && make && make install)
- rm -rf libardsim-*
- ./bootstrap.sh
stages:
- build
- test
- deploy
build:
stage: build
script:
- ./configure
- PKG_CONFIG_PATH=/tmp/libardsim/lib/pkgconfig ./configure
- make
- make firmware
check:
stage: test
script:
- ./configure --enable-coverage
- make clean
- PKG_CONFIG_PATH=/tmp/libardsim/lib/pkgconfig ./configure --enable-coverage
- make coverage | tail -10
distribute:
stage: deploy
script:
- ./configure
- make dist
artifacts:
paths:
- libbutton-*.tar.gz
expire_in: 1 week
except:
- tags
distribute-release:
stage: deploy
script:
- ./configure
- make dist
artifacts:
paths:
- libbutton-*.tar.gz
only:
- tags
......@@ -3,6 +3,7 @@ ACLOCAL_AMFLAGS = -I m4
include Makefile.common
SOURCE_DIR = src
SOURCE_DIR += doc
if ARDSIM
SOURCE_DIR += simulation
endif
......@@ -17,6 +18,12 @@ ALLPHONY = coverage doc
doc:
@(cd doc && $(MAKE) $@)
if ARDSIM
else
install:
@(echo "Please install libArdsim")
endif
if COVERAGE
if LCOV
......@@ -127,3 +134,5 @@ ALLPHONY += firmware
ALLPHONY += upload
.PHONY: $(ALLPHONY)
dist_data_DATA = examples/simple.cpp
......@@ -15,5 +15,3 @@ AM_CXXFLAGS += -I$(top_builddir)/src
AM_CXXFLAGS += -include $(top_builddir)/src/config.h
AM_CXXFLAGS += $(ARDSIM_CFLAGS)
AM_LDFLAGS += -L$(top_builddir)
......@@ -149,11 +149,10 @@ PKG_CHECK_MODULES([CPPUTEST], [cpputest], [have_cpputest=yes], [have_cpputest=no
AM_CONDITIONAL([CPPUTEST], [test "x${have_cpputest}" = "xyes"])
AS_IF([test "x$have_cpputest" = "xno"],
[AC_MSG_WARN([Please install CppUTest package to get support of unit tests.])])
PKG_CHECK_MODULES([ARDSIM], [ardsim >= 0.0.4], [have_ardsim=yes], [have_ardsim=no])
PKG_CHECK_MODULES([ARDSIM], [ardsim >= 0.0.5], [have_ardsim=yes], [have_ardsim=no])
AM_CONDITIONAL([ARDSIM], [test "x${have_ardsim}" = "xyes"])
AS_IF([test "x$have_ardsim" = "xno"],
[AC_MSG_WARN([Please install Ardsim library from https://gitlab.yapbreak.fr/libraries/libardsim])],
[AC_DEFINE([HAVE_ARDSIM], [1], [Define if Arduino simulator is available])])
[AC_MSG_ERROR([Please install Ardsim library from https://gitlab.yapbreak.fr/libraries/libardsim])])
# Check coverage tools
AC_CHECK_PROG([gcovr], [gcovr], [yes])
......@@ -175,10 +174,12 @@ AM_CONDITIONAL(DOXYGEN, [test "x${doxygen}" = "xyes"])
# Generate files
AC_CONFIG_FILES([platformio.ini
library.properties
library.json
Makefile
utests/Makefile
utests/fixtures/Makefile
src/Makefile
src/button.pc
simulation/Makefile
doc/Makefile
doc/Doxyfile
......
......@@ -114,7 +114,7 @@ WARN_LOGFILE =
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = @abs_top_srcdir@/src @abs_top_srcdir@/examples
INPUT = @abs_top_srcdir@/src
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.c \
*.cpp \
......
......@@ -15,3 +15,5 @@ else
doc:
@(echo "Please install doxygen to get actual documentation")
endif
dist_data_DATA = img/button.png
......@@ -35,7 +35,7 @@ void doubleclick(void *arg)
* @brief Arduino function to setup and initialize everything.
*/
// cppcheck-suppress unusedFunction
void setup() {
extern "C" void setup() {
Serial.begin(115200);
my_button.on_single_click(click, NULL);
......@@ -48,7 +48,7 @@ void setup() {
/**
* @brief Arduino function called in the main loop.
*/
void loop() {
extern "C" void loop() {
my_button.loop();
}
/// [Click]
{
"name": "@PACKAGE_NAME@",
"keywords": "simple,button,yapbreak",
"description": "Button library for any board Arduino framework compatible.",
"version": "@PACKAGE_VERSION@",
"authors": {
"name": "YapBreak",
"url": "https://gitlab.yapbreak.fr/olivaa",
"email": "@PACKAGE_BUGREPORT@"
},
"downloadUrl": "https://ci.yapbreak.fr/job/release_manager/job/@PACKAGE_NAME@/lastSuccessfulBuild/artifact/@PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz",
"frameworks": "arduino",
"platforms": "*",
"license": "WTF-PL",
"homepage": "@PACKAGE_URL@",
"examples": [
"examples/*.c",
"examples/*.cpp"
],
"export": {
"include": [
"src/*.h",
"src/*.cpp"
]
}
}
; PlatformIO Project Configuration File
[platformio]
src_dir = simulation
lib_dir = .
include_dir =
[env:witty]
platform = espressif8266
board = nodemcuv2
framework = arduino
build_flags = -DTESTFIRMWARE
[env:uno]
platform = atmelavr
board = uno
framework = arduino
build_flags = -DTESTFIRMWARE
#ifndef ARDUINO_H_ERPC3NVU
#define ARDUINO_H_ERPC3NVU
#ifdef HAVE_ARDSIM
#include <ardsim.h>
#else
#include "utests/fixtures/Arduino.h"
#endif
#endif /* end of include guard: ARDUINO_H_ERPC3NVU */
......@@ -4,8 +4,8 @@ include $(top_srcdir)/Makefile.common
bin_PROGRAMS = buttontest
buttontest_CFLAGS = -DTESTFIRMWARE $(AM_CFLAGS)
buttontest_CXXFLAGS = -DTESTFIRMWARE $(AM_CXXFLAGS)
buttontest_SOURCES = ../src/test.cpp
buttontest_CFLAGS = -DSIMULATE $(AM_CFLAGS)
buttontest_CXXFLAGS = -DSIMULATE $(AM_CXXFLAGS)
buttontest_SOURCES = test.cpp
buttontest_SOURCES += simulate.cpp
buttontest_LDADD = $(top_builddir)/src/libbutton.la $(ARDSIM_LIBS)
#include "Arduino.h"
#include "button.h"
#include <time.h>
#ifdef SIMULATE
#include <Arduino.h>
#include <stdio.h>
extern "C" void setup();
extern "C" void loop();
int main(int argc, const char *argv[])
{
(void) argc;
(void) argv;
return ardsim_run();
}
#endif
#if defined(TESTFIRMWARE)
#include <Arduino.h>
#include "button.h"
......@@ -57,5 +55,3 @@ extern "C" void setup() {
extern "C" void loop() {
my_button.loop();
}
#endif
......@@ -7,3 +7,8 @@ libbutton_la_SOURCES = button.h
libbutton_la_SOURCES += button.cpp
include_HEADERS = button.h
libdir = $(prefix)/lib/yapiot/
includedir = $(prefix)/include/yapiot/libbutton
libledextradir = $(prefix)/lib/pkgconfig
libledextra_DATA = button.pc
prefix=@prefix@
exec_prefix=@prefix@
libdir=@libdir@/yapiot
includedir=@includedir@/yapiot/@PACKAGE_NAME@
Name: @PACKAGE_NAME@
Description: Arduino simple button library
URL: @PACKAGE_URL@
Version: @VERSION@
Requires:
Libs: -L${libdir} -lbutton @ARDSIM_LIBS@
Cflags: -I${includedir} @ARDSIM_CFLAGS@
......@@ -6,20 +6,12 @@ SUBDIRS = fixtures
TESTS = ut_button.xtest
noinst_PROGRAMS = $(TESTS)
check_PROGRAMS = $(TESTS)
lib_LTLIBRARIES = libbutton_utests.la
libbutton_utests_la_CFLAGS = $(TESTCFLAGS)
libbutton_utests_la_CXXFLAGS = $(TESTCXXFLAGS)
libbutton_utests_la_SOURCES = ../src/button.h
libbutton_utests_la_SOURCES += ../src/button.cpp
ut_button_xtest_SOURCES = ut_button.h
ut_button_xtest_SOURCES += main.cpp
ut_button_xtest_CFLAGS = $(TESTCFLAGS)
ut_button_xtest_CXXFLAGS = $(TESTCXXFLAGS)
ut_button_xtest_LDFLAGS = $(TESTLDFLAGS)
ut_button_xtest_LDADD = $(top_builddir)/utests/libbutton_utests.la
ut_button_xtest_LDADD = $(top_builddir)/src/libbutton.la
ut_button_xtest_LDADD += $(top_builddir)/utests/fixtures/libfixtures.la
......@@ -2,7 +2,7 @@
#include <sstream>
#include <string>
#include <iomanip>
#include "Arduino.h"
#include "ArduinoFixtures.h"
#include <CppUTest/TestHarness.h>
fixtures *fixtures::s_fixtures;
......@@ -15,7 +15,7 @@ void fixtures::registerInstance(fixtures &f)
s_fixtures = &f;
}
void analogWrite(uint8_t pin, uint8_t value)
void analogWrite(uint8_t pin, int value)
{
fixtures *f = fixtures::getInstance();
BYTES_EQUAL(OUTPUT, f->get_actual_pin_mode(pin));
......
#ifndef ARDUINO_H_NID3LW9T
#define ARDUINO_H_NID3LW9T
#ifdef __cplusplus
#ifndef ARDUINO_FIXTURES_H_NID3LW9T
#define ARDUINO_FIXTURES_H_NID3LW9T
#include <map>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
extern "C"
{
#endif
#include <stdint.h>
#include "config.h"
/* Arduino fixtures */
/********************
* Arduino wiring *
********************/
void analogWrite(uint8_t pin, uint8_t value);
void digitalWrite(uint8_t pin, uint8_t value);
int digitalRead(uint8_t pin);
#define LOW 25
#define HIGH 90
#define OUTPUT ('O')
#define INPUT ('I')
#define NOTSET ('X')
#define UNDEFINED (0xffff)
void pinMode(uint8_t pin, uint8_t mode);
/********************
* Arduino timing *
********************/
unsigned long millis();
unsigned long micros();
#ifdef __cplusplus
};
#include <Arduino.h>
/*******************
* Test fixtures *
*******************/
#define NOTSET ('X')
#define UNDEFINED (0xffff)
struct pin_attribute_t
{
......@@ -107,6 +81,86 @@ class fixtures
void check() const;
};
#endif
class memory : public Print {
public:
memory()
: Print()
, m_str()
{
m_null = fopen("/dev/null", "w");
}
memory(const memory &o)
{
(void) o;
m_null = fopen("/dev/null", "w");
}
~memory()
{
fclose(m_null);
}
size_t print(const std::string &str) override
{ m_str << str; return str.size(); }
size_t print(const char c_str[]) override
{ m_str << c_str; return strlen(c_str); }
size_t print(char c) override
{ m_str << c; return 1; }
size_t print(unsigned char c, int base = DEC) override
{ (void) base; m_str << static_cast<unsigned long>(c); return fprintf(m_null, "%u", c); }
size_t print(int i, int base = DEC) override
{ (void) base; m_str << i; return fprintf(m_null, "%d", i); }
size_t print(unsigned int i, int base = DEC) override
{ (void) base; m_str << i; return fprintf(m_null, "%u", i); }
size_t print(long i, int base = DEC) override
{ (void) base; m_str << i; return fprintf(m_null, "%ld", i); }
size_t print(unsigned long i, int base = DEC) override
{ (void) base; m_str << i; return fprintf(m_null, "%lu", i); }
size_t print(double d, int floating = 2) override
{ (void) floating; m_str << d; return fprintf(m_null, "%f", d); }
size_t print(const Printable &p) override
{ return p.printTo(*this); };
size_t println(const std::string &str) override
{ size_t l = print(str); m_str << "\n"; return l + 1; }
size_t println(const char c_str[]) override
{ size_t l = print(c_str); m_str << "\n"; return l + 1; }
size_t println(char c) override
{ size_t l = print(c); m_str << "\n"; return l + 1; }
size_t println(unsigned char c, int base = DEC) override
{ size_t l = print(c, base); m_str << "\n"; return l + 1; }
size_t println(int c, int base = DEC) override
{ size_t l = print(c, base); m_str << "\n"; return l + 1; }
size_t println(unsigned int c, int base = DEC) override
{ size_t l = print(c, base); m_str << "\n"; return l + 1; }
size_t println(long c, int base = DEC) override
{ size_t l = print(c, base); m_str << "\n"; return l + 1; }
size_t println(unsigned long c, int base = DEC) override
{ size_t l = print(c, base); m_str << "\n"; return l + 1; }
size_t println(double d, int floating = 2) override
{ size_t l = print(d, floating); m_str << "\n"; return l + 1; }
size_t println(const Printable &p) override
{ size_t l = print(p); m_str << "\n"; return l + 1; }
size_t println() override
{ m_str << "\n"; return 1; };
void clear()
{
m_str.clear();
}
std::string getcontent() const
{
return m_str.str();
}
memory &operator=(const memory &) = delete;
private:
std::stringstream m_str;
FILE *m_null;
};
#endif /* end of include guard: ARDUINO_H_NID3LW9T */
......@@ -2,9 +2,9 @@ ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
include $(top_srcdir)/utests/Makefile.test.common
noinst_LTLIBRARIES = libfixtures.la
libfixtures_la_SOURCES = Arduino.h
libfixtures_la_SOURCES += Arduino.cpp
check_LTLIBRARIES = libfixtures.la
libfixtures_la_SOURCES = ArduinoFixtures.cpp
libfixtures_la_SOURCES += ArduinoFixtures.h
libfixtures_la_CFLAGS = $(TESTCFLAGS)
libfixtures_la_CXXFLAGS = $(TESTCXXFLAGS)
libfixtures_la_LDFLAGS = $(TESTLDFLAGS)
......
......@@ -3,7 +3,7 @@
#include <CppUTest/TestHarness.h>
#include "button.h"
#include "Arduino.h"
#include "ArduinoFixtures.h"
TEST_GROUP(basic)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment