Browse Source

support build on BSD, save build hash in versioning and small fix

master
Jaromil 3 years ago
parent
commit
5e4d33e9ba
  1. 6
      build/embed-lualibs
  2. 8
      build/linux.mk
  3. 3
      src/Makefile
  4. 2
      src/cli.c
  5. 2
      src/lua/zenroom_common.lua
  6. 2
      src/lua_functions.c

6
build/embed-lualibs

@ -49,7 +49,11 @@ for i in ${(f)libs}; do
print >> ${dst}
print "// $i" >> ${dst}
xxd -i ${n} >> ${dst}
sed -i 's/^unsigned/const unsigned/' ${dst}
if [[ "`uname`" =~ "BSD" ]]; then
sed -i "" 's/^unsigned/const unsigned/' ${dst}
else
sed -i 's/^unsigned/const unsigned/' ${dst}
fi
print >> ${dst}
popd
rm -rf $tmp

8
build/linux.mk

@ -15,6 +15,14 @@ musl-system: apply-patches lua53 embed-lua milagro
CC=${gcc} AR="${ar}" CFLAGS="${cflags}" LDFLAGS="${ldflags}" LDADD="${ldadd}" \
make -C src musl
bsd: cflags := -O3 ${cflags_protection} -fPIE -fPIC -DARCH_BSD
bsd: ldadd += -lm
bsd: apply-patches lua53 milagro embed-lua
CC=${gcc} AR="${ar}" CFLAGS="${cflags}" LDFLAGS="${ldflags}" LDADD="${ldadd}" \
make -C src linux
@cp -v src/zenroom build/zenroom
linux: cflags := -O3 ${cflags_protection} -fPIE -fPIC
linux: apply-patches lua53 milagro embed-lua
CC=${gcc} AR="${ar}" CFLAGS="${cflags}" LDFLAGS="${ldflags}" LDADD="${ldadd}" \

3
src/Makefile

@ -16,11 +16,12 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
ZENROOM_VERSION := 1.0.0
CC?=gcc
VERSION := $(shell cat ../VERSION)
ARCH := $(shell uname -m)
BRANCH := $(shell git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
HASH := $(shell git rev-parse --short HEAD)
VERSION := ${ZENROOM_VERSION}+${HASH}
CFLAGS += -I. -I../lib/lua53/src -I../lib/milagro-crypto-c/include -Wall -Wextra
SOURCES := \
cli.o jutils.o zenroom.o zen_error.o \

2
src/cli.c

@ -300,7 +300,7 @@ int main(int argc, char **argv) {
else return EXIT_SUCCESS;
#endif
#if (defined(ARCH_WIN) || defined(DISABLE_FORK)) || defined(ARCH_CORTEX)
#if (defined(ARCH_WIN) || defined(DISABLE_FORK)) || defined(ARCH_CORTEX) || defined(ARCH_BSD)
if(zencode)
if( zen_exec_zencode(Z, script) ) return EXIT_FAILURE;
else

2
src/lua/zenroom_common.lua

@ -236,7 +236,7 @@ function set_rule(text)
local res = false
local rule = strtok(text) -- TODO: optimise in C (see zenroom_common)
if rule[2] == 'check' and rule[3] == 'version' and rule[4] then
if not SEMVER then SEMVER = require('semver') end
SEMVER = require_once('semver')
local ver = SEMVER(rule[4])
if ver == VERSION then
act("Zencode version match: "..VERSION.original)

2
src/lua_functions.c

@ -46,7 +46,7 @@ int zen_setenv(lua_State *L, char *key, char *val) {
warning(L, "setenv: NULL string detected");
return 1; }
if(val[0]=='\0') {
warning(L, "setenv: empty string detected");
warning(L, "setenv: empty value for key: %s", key);
return 1; }
lua_pushstring(L, val);
lua_setglobal(L, key);

Loading…
Cancel
Save