diff --git a/.travis.yml b/.travis.yml index e25f7c6d3a7..ce8c5869642 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,19 +11,22 @@ cache: - cache before_install: - cat build.config -- export X_EMAIL=$(grep -E 'email=(.*)' build.config | cut -c 7-) -- export X_BRANCH=$(grep -E 'branch=(.*)' build.config | cut -c 8-) -- export X_MODULES=$(grep -E 'modules=(.*)' build.config | cut -c 9-) -- export X_U8G_FONTS=$(grep -E 'u8g-fonts=(.*)' build.config | cut -c 11-) -- export X_U8G_DISPLAY_I2C=$(grep -E 'u8g-display-i2c=(.*)' build.config | cut -c 17-) -- export X_U8G_DISPLAY_SPI=$(grep -E 'u8g-display-spi=(.*)' build.config | cut -c 17-) -- export X_UCG_DISPLAY_SPI=$(grep -E 'ucg-display-spi=(.*)' build.config | cut -c 17-) -- export X_SSL_ENABLED=$(grep -E 'ssl-enabled=(.*)' build.config | cut -c 13-) -- export X_DEBUG_ENABLED=$(grep -E 'debug-enabled=(.*)' build.config | cut -c 15-) -- export X_FATFS_ENABLED=$(grep -E 'fatfs-enabled=(.*)' build.config | cut -c 15-) -# count ',' in the string and add +1 -- export X_NUMBER_OF_MODULES=$((`echo $X_MODULES | tr -d -c ',' | wc -m`+1)) -- env | grep 'X_' + +- export X_EMAIL=$(grep -E '^email=' build.config | cut -f 2- -d '=') +- export X_BRANCH=$(grep -E '^branch=' build.config | cut -f 2- -d '=') +- export X_MODULES=$(grep -E '^modules=' build.config | cut -f 2- -d '=') +- export X_U8G_FONTS=$(grep -E '^u8g-fonts=' build.config | cut -f 2- -d '=') +- export X_U8G_DISPLAY_I2C=$(grep -E '^u8g-display-i2c=' build.config | cut -f 2- -d '=') +- export X_U8G_DISPLAY_SPI=$(grep -E '^u8g-display-spi=' build.config | cut -f 2- -d '=') +- export X_UCG_DISPLAY_SPI=$(grep -E '^ucg-display-spi=' build.config | cut -f 2- -d '=') +- export X_LUA_FLASH_STORE=$(grep -E '^lfs-size=' build.config | cut -f 2- -d '=') +- export X_SPIFFS_FIXED_LOCATION=$(grep -E '^spiffs-base=' build.config | cut -f 2- -d '=') +- export X_SPIFFS_MAX_FILESYSTEM_SIZE=$(grep -E '^spiffs-size=' build.config | cut -f 2- -d '=') +- export X_SSL_ENABLED=$(grep -E '^ssl-enabled=' build.config | cut -f 2- -d '=') +- export X_DEBUG_ENABLED=$(grep -E '^debug-enabled=' build.config | cut -f 2- -d '=') +- export X_FATFS_ENABLED=$(grep -E '^fatfs-enabled=' build.config | cut -f 2- -d '=') +- export X_NUMBER_OF_MODULES=$(echo $X_MODULES | awk -F\, '{print NF}') +- export -p | grep " X_" - wget -d -v -O/dev/null --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused --no-check-certificate 'https://nodemcu-build.com/hook.php?event=start&recipient='${X_EMAIL//+/%2B} - git clone --depth=1 --branch=$X_BRANCH git://github.com/nodemcu/nodemcu-firmware.git nodemcu-firmware @@ -33,12 +36,8 @@ before_install: # replace modules in user_modules.h by the selected ones - bash $TRAVIS_BUILD_DIR/set-modules.sh -# comment the SSL flag in user_config.h if not enabled -- bash $TRAVIS_BUILD_DIR/set-ssl.sh -# set the NODE_DEBUG and COAP_DEBUG flags in user_config.h -- bash $TRAVIS_BUILD_DIR/set-debug.sh -# set the BUILD_FATFS flag in user_config.h -- bash $TRAVIS_BUILD_DIR/set-fatfs.sh +# set defines in user_config.h according to X_* variables +- bash $TRAVIS_BUILD_DIR/set-config.sh # replace fonts in u8g_config.h by the selected ones - bash $TRAVIS_BUILD_DIR/set-fonts.sh # set I2C/SPI displays in u8g_config.h and ucg_config.h @@ -101,3 +100,4 @@ branches: only: - builds - master + diff --git a/build.config b/build.config index cc7ed1a5a69..8b89bd1ac5c 100644 --- a/build.config +++ b/build.config @@ -2,8 +2,12 @@ email=suvft@rkpvgr.pbz branch=dev modules=node,file,gpio,wifi,net,tmr,uart,mqtt,spi,http,ucg,u8g ssl-enabled=true -debug-enabled=false +debug-enabled=true +fatfs-enabled=true u8g-fonts=font_6x10,font_chikita u8g-display-i2c=uc1611_dogm240_i2c u8g-display-spi=pcf8812_96x65_hw_spi ucg-display-spi=seps225_16x128x128_uvis_hw_spi, ucg_dev_seps225_16x128x128_univision, ucg_ext_seps225_16 +lfs-size=0x20000 +spiffs-base=0 +spiffs-size=0x200000 diff --git a/set-config.sh b/set-config.sh new file mode 100755 index 00000000000..fda89235c1f --- /dev/null +++ b/set-config.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# +# user_config.h has a number of defines the are replaced according to their +# corresponding env X_???? variable. +# +# Define Uncomment if param Set to param +# LUA_FLASH_STORE >0 Y +# SPIFFS_FIXED_LOCATION >0 Y +# SPIFFS_MAX_FILESYSTEM_SIZE >0 Y +# BUILD_FATFS "true" +# DEVELOP_VERSION "true" +# SSL_ENABLED "true" +# +set -e + +# What is carried in the following variables is the sed replacement expression. +# It makes all #defines commented by default. +declare lfs="// #\\1" +declare spiffs_base="// #\\1" +declare spiffs_size="// #\\1" +declare fatfs="// #\\1" +declare debug="// #\\1" +declare ssl="// #\\1" + +#if env var exists and is not "0" +if [ ! -z "${X_LUA_FLASH_STORE}" ] && [ "${X_LUA_FLASH_STORE}" != "0" ]; then + printf "Enabling LFS, size = %s\\n" "${X_LUA_FLASH_STORE}" + lfs="#\\1 ${X_LUA_FLASH_STORE}" +fi + +if [ ! -z "${X_SPIFFS_FIXED_LOCATION}" ] && [ "${X_SPIFFS_FIXED_LOCATION}" != "0" ]; then + printf "SPIFFS location offset = %s\\n" "${X_SPIFFS_FIXED_LOCATION}" + spiffs_base="#\\1 ${X_SPIFFS_FIXED_LOCATION}" +fi + +if [ ! -z "${X_SPIFFS_MAX_FILESYSTEM_SIZE}" ] && [ "${X_SPIFFS_MAX_FILESYSTEM_SIZE}" != "0" ]; then + printf "SPIFFS size = %s\\n" "${X_SPIFFS_MAX_FILESYSTEM_SIZE}" + spiffs_size="#\\1 ${X_SPIFFS_MAX_FILESYSTEM_SIZE}" +fi + +if [ "${X_DEBUG_ENABLED}" == "true" ]; then + echo "Enabling debug mode" + debug="#\\1" +fi + +if [ "${X_FATFS_ENABLED}" == "true" ]; then + echo "Enabling FatFS" + fatfs="#\\1" +fi + +if [ "${X_SSL_ENABLED}" == "true" ]; then + echo "Enabling SSL" + ssl="#\\1" +fi + +# There's no option for sed in-place editing that works on both Unix and macOS +# -> pipe to new file, then rename it +sed -e "s!^.*\\(define *LUA_FLASH_STORE\\).*!$lfs!" \ + -e "s!^.*\\(define *SPIFFS_FIXED_LOCATION\\).*!$spiffs_base!" \ + -e "s!^.*\\(define *SPIFFS_MAX_FILESYSTEM_SIZE\\).*!$spiffs_size!" \ + -e "s!^.*\\(define *BUILD_FATFS\\).*!$fatfs!" \ + -e "s!^.*\\(define *CLIENT_SSL_ENABLE\\).*!$ssl!" \ + -e "s!^.*\\(define *DEVELOP_VERSION\\).*!$debug!" \ + user_config.h > user_config.h.new; + +mv user_config.h.new user_config.h; diff --git a/set-debug.sh b/set-debug.sh deleted file mode 100755 index f8f3beaab26..00000000000 --- a/set-debug.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -set -e - -echo "Debug enabled: " ${X_DEBUG_ENABLED}; - -if [ "${X_DEBUG_ENABLED}" == "true" ]; then - echo "Enabling debug mode in user_config.h" - # http://stackoverflow.com/q/18272379/131929 - awk 'NR==4{print "#define NODE_DEBUG\n#define COAP_DEBUG\n"}1' user_config.h > user_config.h.tmp && mv user_config.h.tmp user_config.h; -fi diff --git a/set-fatfs.sh b/set-fatfs.sh deleted file mode 100755 index f282a54246e..00000000000 --- a/set-fatfs.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -e - -echo "FatFs enabled:" "${X_FATFS_ENABLED}"; - -if [ "${X_FATFS_ENABLED}" = "true" ]; then - echo "Enabling FatFs in user_config.h" - sed -e 's/\/\/ *#define BUILD_FATFS/#define BUILD_FATFS/g' user_config.h > user_config.h.tmp; -else - echo "Disabling FatFs in user_config.h" - sed -e 's/#define BUILD_FATFS/\/\/#define BUILD_FATFS/g' user_config.h > user_config.h.tmp; -fi -mv user_config.h.tmp user_config.h; diff --git a/set-ssl.sh b/set-ssl.sh deleted file mode 100755 index 629979cf52a..00000000000 --- a/set-ssl.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -e - -echo "SSL enabled:" "${X_SSL_ENABLED}"; - -if [ "${X_SSL_ENABLED}" = "true" ]; then - echo "Enabling SSL in user_config.h" - sed -e 's/\/\/ *#define CLIENT_SSL_ENABLE/#define CLIENT_SSL_ENABLE/g' user_config.h > user_config.h.tmp; -else - echo "Disabling SSL in user_config.h" - sed -e 's/#define CLIENT_SSL_ENABLE/\/\/ #define CLIENT_SSL_ENABLE/g' user_config.h > user_config.h.tmp; -fi -mv user_config.h.tmp user_config.h;