Unverified Commit 310faf7f authored by Terry Ellison's avatar Terry Ellison Committed by GitHub
Browse files

Merge pull request #2886 from nodemcu/dev

Next master drop
parents 68c425c0 a08e74d9
......@@ -36,10 +36,19 @@
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#ifdef _MSC_VER
#include "getopt.h" /* local copy from MingW project */
#include <io.h>
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
typedef ptrdiff_t off_t;
#else
#include <unistd.h>
#include <fcntl.h>
#include <getopt.h>
#include <sys/mman.h>
#endif
#include <fcntl.h>
#include <errno.h>
#include "spiffs.h"
#define NO_CPU_ESP8266_INCLUDE
......@@ -261,6 +270,9 @@ int main (int argc, char *argv[])
die("Need a filename");
}
#ifdef _MSC_VER
_set_fmode( _O_BINARY ); //change default open mode to binary rather than text
#endif
int fd;
if (create)
......@@ -326,7 +338,20 @@ int main (int argc, char *argv[])
if (sz & (0x1000 -1))
die ("file size not multiple of erase block size");
flash = mmap (0, sz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
#ifdef _MSC_VER
//We don't have a mmap(), so we simply allocate a file buffer we write out
//at the end of the program. This also means that we need to let the program
//end normally (i.e. not via Ctrl-C) or else that final write will not happen.
//If you are in interactive mode, there is not a command for 'exit', however
//EOF may be used to end the interactive loop by pressing Ctrl-Z, return.
flash = (uint8_t*)malloc( sz );
if ( lseek( fd, 0, SEEK_SET ) == -1 )
die( "lseek" );
if ( read( fd, flash, sz ) != sz )
die( "write" );
#else
flash = mmap( 0, sz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
#endif
if (!flash)
die ("mmap");
......@@ -392,7 +417,13 @@ int main (int argc, char *argv[])
else if (strncmp (line, "import ", 7) == 0)
{
char *src = 0, *dst = 0;
#ifdef _MSC_VER
src = (char*)malloc(260 + 1); //MAX_PATH
dst = (char*)malloc( 260 + 1 );
if (sscanf (line +7, " %260s %260s", src, dst) != 2)
#else
if (sscanf (line +7, " %ms %ms", &src, &dst) != 2)
#endif
{
fprintf (stderr, "SYNTAX ERROR: %s\n", line);
retcode = 1;
......@@ -405,7 +436,13 @@ int main (int argc, char *argv[])
else if (strncmp (line, "export ", 7) == 0)
{
char *src = 0, *dst = 0;
#ifdef _MSC_VER
src = (char*)malloc( 260 + 1 ); //MAX_PATH
dst = (char*)malloc( 260 + 1 );
if ( sscanf( line + 7, " %260s %260s", src, dst ) != 2 )
#else
if (sscanf (line + 7, " %ms %ms", &src, &dst) != 2)
#endif
{
fprintf (stderr, "SYNTAX ERROR: %s\n", line);
retcode = 1;
......@@ -450,7 +487,15 @@ int main (int argc, char *argv[])
}
SPIFFS_unmount (&fs);
#ifdef _MSC_VER
if ( lseek( fd, 0, SEEK_SET ) == -1 )
die( "lseek" );
if ( write( fd, flash, sz ) != sz )
die( "write" );
free( flash );
#else
munmap (flash, sz);
#endif
close (fd);
return retcode;
}
......@@ -10,7 +10,7 @@ typedef uint16_t u16_t;
typedef int8_t s8_t;
typedef uint8_t u8_t;
#ifndef __CYGWIN__
#if !defined(__CYGWIN__) && !defined(_MSC_VER)
typedef long long ptrdiff_t;
#define offsetof(type, member) __builtin_offsetof (type, member)
#endif
#!/bin/sh
set -e
echo "Running ci build for linux"
(
cd "$TRAVIS_BUILD_DIR" || exit
export BUILD_DATE=$(date +%Y%m%d)
# build integer firmware
make EXTRA_CCFLAGS="-DLUA_NUMBER_INTEGRAL -DBUILD_DATE='\"'$BUILD_DATE'\"'"
cd bin/ || exit
file_name_integer="nodemcu_integer_${TRAVIS_TAG}.bin"
srec_cat -output ${file_name_integer} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000
cd ../ || exit
# build float firmware
make clean
make EXTRA_CCFLAGS="-DBUILD_DATE='\"'$BUILD_DATE'\"'" all
cd bin/ || exit
file_name_float="nodemcu_float_${TRAVIS_TAG}.bin"
srec_cat -output ${file_name_float} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000
)
#!/bin/sh
set -e
echo "Running ci build for windows msbuild (supports only hosttools)"
(
cd "$TRAVIS_BUILD_DIR"/msvc || exit
export PATH=$MSBUILD_PATH:$PATH
msbuild.exe hosttools.sln
)
#!/bin/bash
# Downloads and installs a self-contained Lua and LuaRocks.
# Supports Linux, macOS and MSYS2.
# Copyright (c) 2015-2019 Pierre Chapuis, MIT Licensed.
# Latest stable version available at: https://loadk.com/localua.sh
# Maintained at: https://github.com/oploadk/localua
DEFAULT_LUA_V="5.3.5"
DEFAULT_LR_V="3.0.4"
usage () {
>&2 echo -e "USAGE: $0 output-dir [lua-version] [luarocks-version]\n"
>&2 echo -n "The first optional argument is the Lua version, "
>&2 echo -n "the second one is the LuaRocks version. "
>&2 echo -e "Defaults are Lua $DEFAULT_LUA_V and LuaRocks $DEFAULT_LR_V.\n"
>&2 echo -n "You can set a custom build directory with environment "
>&2 echo -e "variable LOCALUA_BUILD_DIRECTORY (not useful in general).\n"
>&2 echo -e "You can set a custom makefile target with LOCALUA_TARGET.\n"
>&2 echo -e "You can disable LUA_COMPAT by setting LOCALUA_NO_COMPAT.\n"
>&2 echo -e "You can skip luarocks by setting LOCALUA_NO_LUAROCKS."
exit 1
}
# Set output directory, Lua version and LuaRocks version
ODIR="$1"
[ -z "$ODIR" ] && usage
LUA_V="$2"
[ -z "$LUA_V" ] && LUA_V="$DEFAULT_LUA_V"
LUA_SHORTV="$(echo $LUA_V | cut -c 1-3)"
LR_V="$3"
[ -z "$LR_V" ] && LR_V="$DEFAULT_LR_V"
# Set build directory
BDIR="$LOCALUA_BUILD_DIRECTORY"
[ -z "$BDIR" ] && BDIR="$(mktemp -d /tmp/localua-XXXXXX)"
# Create output directory and get absolute path
mkdir -p "$ODIR"
>/dev/null pushd "$ODIR"
ODIR="$(pwd)"
>/dev/null popd
# Download, unpack and build Lua and LuaRocks
if [ -z "$LOCALUA_TARGET" ]; then
case "$(uname)" in
Linux)
LOCALUA_TARGET="linux";;
Darwin)
LOCALUA_TARGET="macosx";;
MSYS*)
LOCALUA_TARGET="msys";;
*)
LOCALUA_TARGET="posix";;
esac
fi
pushd "$BDIR"
wget "http://www.lua.org/ftp/lua-${LUA_V}.tar.gz"
tar xf "lua-${LUA_V}.tar.gz"
pushd "lua-${LUA_V}"
sed 's#"/usr/local/"#"'"$ODIR"'/"#' "src/luaconf.h" > "$BDIR/t"
mv "$BDIR/t" "src/luaconf.h"
if [ ! -z "$LOCALUA_NO_COMPAT" ]; then
sed 's#-DLUA_COMPAT_5_2##' "src/Makefile" > "$BDIR/t"
sed 's#-DLUA_COMPAT_ALL##' "$BDIR/t" > "src/Makefile"
fi
if [ "$LOCALUA_TARGET" = "msys" ]; then
>> "src/Makefile" echo
>> "src/Makefile" echo 'msys:' >> "src/Makefile"
>> "src/Makefile" echo -ne "\t"
>> "src/Makefile" echo '$(MAKE) "LUA_A=lua53.dll" "LUA_T=lua.exe" \'
>> "src/Makefile" echo -ne "\t"
>> "src/Makefile" echo '"AR=$(CC) -shared -Wl,--out-implib,liblua.dll.a -o" "RANLIB=strip --strip-unneeded" \'
>> "src/Makefile" echo -ne "\t"
>> "src/Makefile" echo '"SYSCFLAGS=-DLUA_BUILD_AS_DLL -DLUA_USE_POSIX -DLUA_USE_DLOPEN" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe'
>> "src/Makefile" echo -ne "\t"
>> "src/Makefile" echo '$(MAKE) "LUAC_T=luac.exe" luac.exe'
make -C src "$LOCALUA_TARGET" || exit 1
make \
TO_BIN="lua.exe luac.exe lua53.dll" \
TO_LIB="liblua.a liblua.dll.a" \
INSTALL_TOP="$ODIR" install || exit 1
else
make "$LOCALUA_TARGET" || exit 1
make INSTALL_TOP="$ODIR" install || exit 1
fi
popd
if [ -z "$LOCALUA_NO_LUAROCKS" ]; then
wget "http://luarocks.org/releases/luarocks-${LR_V}.tar.gz"
tar xf "luarocks-${LR_V}.tar.gz"
pushd "luarocks-${LR_V}"
./configure --with-lua="$ODIR" --prefix="$ODIR" \
--lua-version="$LUA_SHORTV" \
--sysconfdir="$ODIR/luarocks" --force-config
make bootstrap
popd
fi
popd
# Cleanup
rm -rf "$BDIR"
......@@ -29,8 +29,4 @@ cd "$TRAVIS_BUILD_DIR"/ld || exit
cd "$TRAVIS_BUILD_DIR" || exit
make clean
make
LUA_FILES=`find lua_modules lua_examples -iname "*.lua"`
echo checking $LUA_FILES
./luac.cross -p $LUA_FILES
)
#!/bin/bash
set -e
echo "Installing Lua 5.3, LuaRocks and Luacheck"
(
cd "$TRAVIS_BUILD_DIR" || exit
bash tools/travis/localua.sh cache/localua || exit
cache/localua/bin/luarocks install luacheck || exit
)
(
echo "Static analysys of:"
find lua_modules lua_examples -iname "*.lua" -print0 | xargs -0 echo
)
(find lua_modules lua_examples -iname "*.lua" -print0 | xargs -0 cache/localua/bin/luacheck --config tools/luacheck_config.lua) || exit
#!/usr/bin/env bash
USER_MODULES_H=app/include/user_modules.h
COMMIT_ID="$(git rev-parse HEAD)"
BRANCH="$(git rev-parse --abbrev-ref HEAD | sed -E 's/[\/\\]+/_/g')"
RELEASE="$(git describe --tags --long | sed -E 's/(.*)-(.*)-.*/\1 +\2/g' | sed 's/ +0$//')"
RELEASE_DTS=$(TZ=UTC git show --quiet --date=format-local:"%Y%m%d%H%M" --format="%cd" HEAD)
BUILD_DATE="$(date "+%Y-%m-%d %H:%M")"
MODULES=$(awk '/^[ \t]*#define LUA_USE_MODULES/{modules=modules sep tolower(substr($2,17));sep=","}END{if(length(modules)==0)modules="-";print modules}' $USER_MODULES_H | tr -d '\r')
# create temp buildinfo
TEMPFILE=/tmp/buildinfo.h
cat > $TEMPFILE << EndOfMessage
#ifndef __BUILDINFO_H__
#define __BUILDINFO_H__
#include "user_config.h"
#define BUILDINFO_STR_HELPER(x) #x
#define BUILDINFO_TO_STR(x) BUILDINFO_STR_HELPER(x)
#ifdef LUA_FLASH_STORE
#define BUILDINFO_LFS LUA_FLASH_STORE
#else
#define BUILDINFO_LFS 0
#endif
#ifdef CLIENT_SSL_ENABLE
#define BUILDINFO_SSL true
#define BUILDINFO_SSL_STR "true"
#else
#define BUILDINFO_SSL false
#define BUILDINFO_SSL_STR "false"
#endif
#ifdef LUA_NUMBER_INTEGRAL
#define BUILDINFO_BUILD_TYPE "integer"
#else
#define BUILDINFO_BUILD_TYPE "float"
#endif
#define USER_PROLOG "$USER_PROLOG"
#define BUILDINFO_BRANCH "$BRANCH"
#define BUILDINFO_COMMIT_ID "$COMMIT_ID"
#define BUILDINFO_RELEASE "$RELEASE"
#define BUILDINFO_RELEASE_DTS "$RELEASE_DTS"
#define BUILDINFO_MODULES "$MODULES"
#define BUILDINFO_BUILD_DATE "$BUILD_DATE"
#define NODE_VERSION_LONG \\
USER_PROLOG "\n" \\
"\tbranch: " BUILDINFO_BRANCH "\n" \\
"\tcommit: " BUILDINFO_COMMIT_ID "\n" \\
"\trelease: " BUILDINFO_RELEASE "\n" \\
"\trelease DTS: " BUILDINFO_RELEASE_DTS "\n" \\
"\tSSL: " BUILDINFO_SSL_STR "\n" \\
"\tbuild type: " BUILDINFO_BUILD_TYPE "\n" \\
"\tLFS: " BUILDINFO_TO_STR(BUILDINFO_LFS) "\n" \\
"\tmodules: " BUILDINFO_MODULES "\n"
EndOfMessage
echo "#endif /* __BUILDINFO_H__ */" >> $TEMPFILE
diff -q $TEMPFILE app/include/buildinfo.h || cp $TEMPFILE app/include/buildinfo.h
rm $TEMPFILE
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