Skip to content
Permalink
Browse files

Update Makefile to add hacks to fix esqlite

  • Loading branch information...
ConnorRigby committed Mar 12, 2019
1 parent 40bbc67 commit 26116726f63e511ba6a23df972aa4ad264081e7f
Showing with 61 additions and 18 deletions.
  1. +11 −8 .circleci/config.yml
  2. +49 −9 Makefile
  3. +1 −1 mix.exs
@@ -66,9 +66,9 @@ build_firmware_steps: &build_firmware_steps
echo $MIX_ENV > MIX_ENV
cp mix.lock MIX_LOCK
- restore_cache:
key: v8-fbos-{{ checksum "MIX_TARGET" }}-{{ checksum "MIX_ENV" }}-dependency-cache-{{ checksum "MIX_LOCK" }}
key: v9-fbos-{{ checksum "MIX_TARGET" }}-{{ checksum "MIX_ENV" }}-dependency-cache-{{ checksum "MIX_LOCK" }}
- restore_cache:
key: v8-fbos-host-test-dependency-cache-{{ checksum "mix.lock.host" }}
key: v9-fbos-host-test-dependency-cache-{{ checksum "mix.lock" }}
- <<: *install_elixir
- <<: *install_hex_archives
- run:
@@ -85,7 +85,7 @@ build_firmware_steps: &build_firmware_steps
command: |
cp _build/${MIX_TARGET}_${MIX_ENV}/nerves/images/farmbot.fw /nerves/deploy/system/artifacts/farmbot-${MIX_TARGET}-$(cat VERSION).fw
- save_cache:
key: v8-fbos-{{ checksum "MIX_TARGET" }}-{{ checksum "MIX_ENV" }}-dependency-cache-{{ checksum "MIX_LOCK" }}
key: v9-fbos-{{ checksum "MIX_TARGET" }}-{{ checksum "MIX_ENV" }}-dependency-cache-{{ checksum "MIX_LOCK" }}
paths:
- _build/
- deps/
@@ -106,7 +106,7 @@ deploy_nerves_hub_firmware_steps: &deploy_nerves_hub_firmware_steps
echo $MIX_ENV > MIX_ENV
cp mix.lock MIX_LOCK
- restore_cache:
key: v8-fbos-{{ checksum "MIX_TARGET" }}-{{ checksum "MIX_ENV" }}-dependency-cache-{{ checksum "MIX_LOCK" }}
key: v9-fbos-{{ checksum "MIX_TARGET" }}-{{ checksum "MIX_ENV" }}-dependency-cache-{{ checksum "MIX_LOCK" }}
- restore_cache:
key: nerves/deploy/system-{{ checksum "MIX_TARGET" }}-{{ .Branch }}-{{ .Revision }}-{{ .Environment.CIRCLE_TAG }}
- <<: *install_elixir
@@ -134,7 +134,7 @@ jobs:
- checkout
- run: git submodule update --init --recursive
- restore_cache:
key: v8-fbos-host-test-dependency-cache-{{ checksum "mix.lock.host" }}
key: v9-fbos-host-test-dependency-cache-{{ checksum "mix.lock" }}
- <<: *install_elixir
- <<: *install_hex_archives
- run:
@@ -143,7 +143,7 @@ jobs:
mix deps.get
mix compile
- save_cache:
key: v8-fbos-host-test-dependency-cache-{{ checksum "mix.lock.host" }}
key: v9-fbos-host-test-dependency-cache-{{ checksum "mix.lock" }}
paths:
- _build/host_test
- deps
@@ -267,8 +267,8 @@ jobs:
echo $MIX_ENV > MIX_ENV
- restore_cache:
key: nerves/deploy/system-{{ checksum "MIX_TARGET_RPI3" }}-{{ .Branch }}-{{ .Revision }}-{{ .Environment.CIRCLE_TAG }}
- restore_cache:
key: nerves/deploy/system-{{ checksum "MIX_TARGET_RPI" }}-{{ .Branch }}-{{ .Revision }}-{{ .Environment.CIRCLE_TAG }}
# - restore_cache:
# key: nerves/deploy/system-{{ checksum "MIX_TARGET_RPI" }}-{{ .Branch }}-{{ .Revision }}-{{ .Environment.CIRCLE_TAG }}
- <<: *install_elixir
- <<: *install_hex_archives
- <<: *install_ghr
@@ -285,6 +285,7 @@ jobs:
mv /nerves/deploy/system/artifacts/farmbot-rpi3-$(cat VERSION).fw /tmp/farmbot-rpi3-$(cat VERSION).fw
fwup -S -s $NERVES_FW_PRIV_KEY -i /tmp/farmbot-rpi3-$(cat VERSION).fw -o /nerves/deploy/system/artifacts/farmbot-rpi3-$(cat VERSION)-beta.fw
fwup -a -t complete -i /nerves/deploy/system/artifacts/farmbot-rpi3-$(cat VERSION)-beta.fw -d /nerves/deploy/system/artifacts/farmbot-rpi3-$(cat VERSION)-beta.img
sha256sum /nerves/deploy/system/artifacts/farmbot-rpi3-$(cat VERSION)-beta.img > /nerves/deploy/system/artifacts/farmbot-rpi3-$(cat VERSION)-beta.sha256
# - run:
# name: Sign rpi Firmware
# command: |
@@ -339,6 +340,8 @@ jobs:
mv /nerves/deploy/system/artifacts/farmbot-rpi3-$(cat VERSION).fw /tmp/farmbot-rpi3-$(cat VERSION).fw
fwup -S -s $NERVES_FW_PRIV_KEY -i /tmp/farmbot-rpi3-$(cat VERSION).fw -o /nerves/deploy/system/artifacts/farmbot-rpi3-$(cat VERSION).fw
fwup -a -t complete -i /nerves/deploy/system/artifacts/farmbot-rpi3-$(cat VERSION).fw -d /nerves/deploy/system/artifacts/farmbot-rpi3-$(cat VERSION).img
sha256sum /nerves/deploy/system/artifacts/farmbot-rpi3-$(cat VERSION).img > /nerves/deploy/system/artifacts/farmbot-rpi3-$(cat VERSION).sha256
# - run:
# name: Sign rpi Firmware and create image
# command: |
@@ -3,40 +3,80 @@ CLEAN :=

PREFIX = $(MIX_COMPILE_PATH)/../priv
BUILD = $(MIX_COMPILE_PATH)/../obj

# Set Erlang-specific compile and linker flags
ERL_CFLAGS ?= -I$(ERL_EI_INCLUDE_DIR)
ERL_LDFLAGS ?= -L$(ERL_EI_LIBDIR)

NIF_LDFLAGS += -fPIC -shared
NIF_CFLAGS ?= -fPIC -O2 -Wall
ERL_LDFLAGS ?= -L$(ERL_EI_LIBDIR) -lei

NIF=
CFLAGS += -fPIC --std=c11
LDFLAGS += -fPIC -shared

ifeq ($(ERL_EI_INCLUDE_DIR),)
$(warning ERL_EI_INCLUDE_DIR not set. Invoke via mix)
endif

ESQLITE_SRC = $(MIX_DEPS_PATH)/esqlite/c_src
ESQLITE_BUILD = $(MIX_BUILD_PATH)/lib/esqlite/obj
ESQLITE_PREFIX = $(MIX_BUILD_PATH)/lib/esqlite/priv

.PHONY: fbos_arduino_firmware fbos_clean_arduino_firmware all clean

all: $(PREFIX) $(BUILD) $(PREFIX)/build_calendar.so
SQLITE_CFLAGS := -DSQLITE_THREADSAFE=1 \
-DSQLITE_USE_URI \
-DSQLITE_ENABLE_FTS3 \
-DSQLITE_ENABLE_FTS3_PARENTHESIS

all: $(PREFIX) \
$(BUILD) \
$(PREFIX)/build_calendar.so \
$(ESQLITE_BUILD) \
$(ESQLITE_PREFIX) \
$(ESQLITE_PREFIX)/esqlite3_nif.so

clean:
$(RM) $(PREFIX)/*.so
$(RM) $(ESQLITE_PREFIX)/*.so

## ARDUINO FIRMWARE

fbos_arduino_firmware:
cd c_src/farmbot-arduino-firmware && make all BUILD_DIR=$(PWD)/_build FBARDUINO_FIRMWARE_SRC_DIR=$(PWD)/c_src/farmbot-arduino-firmware/src BIN_DIR=$(PWD)/priv

fbos_clean_arduino_firmware:
cd c_src/farmbot-arduino-firmware && make clean BUILD_DIR=$(PWD)/_build FBARDUINO_FIRMWARE_SRC_DIR=$(PWD)/c_src/farmbot-arduino-firmware/src BIN_DIR=$(PWD)/priv

## ESQLITE NIF HACK

$(ESQLITE_PREFIX)/esqlite3_nif.so: $(ESQLITE_BUILD)/sqlite3.o $(ESQLITE_BUILD)/queue.o $(ESQLITE_BUILD)/esqlite3_nif.o
$(CC) -o $@ $(ERL_LDFLAGS) $(LDFLAGS) $^

$(ESQLITE_BUILD)/esqlite3_nif.o: $(ESQLITE_SRC)/esqlite3_nif.c
$(CC) -c $(ERL_CFLAGS) $(CFLAGS) $(SQLITE_CFLAGS) -o $@ $<

$(ESQLITE_BUILD)/queue.o: $(ESQLITE_SRC)/queue.c
$(CC) -c $(ERL_CFLAGS) $(CFLAGS) $(SQLITE_CFLAGS) -o $@ $<

$(ESQLITE_BUILD)/sqlite3.o: $(ESQLITE_SRC)/sqlite3.c
$(CC) -c $(CFLAGS) $(SQLITE_CFLAGS) -o $@ $<

## BUILD CALENDAR NIF

$(PREFIX)/build_calendar.so: $(BUILD)/build_calendar.o
$(CC) $(ERL_LDFLAGS) $(NIF_LDFLAGS) -o $@ $<
$(CC) -o $@ $(ERL_LDFLAGS) $(LDFLAGS) $^

$(BUILD)/build_calendar.o: c_src/build_calendar/build_calendar.c
$(CC) -c $(ERL_CFLAGS) $(NIF_CFLAGS) -o $@ $<
$(CC) -c $(ERL_CFLAGS) $(CFLAGS) -o $@ $<

## DIRECTORIES

$(PREFIX):
mkdir -p $(PREFIX)

$(BUILD):
mkdir -p $(BUILD)
mkdir -p $(BUILD)

$(ESQLITE_BUILD):
mkdir -p $(ESQLITE_BUILD)

$(ESQLITE_PREFIX):
mkdir -p $(ESQLITE_PREFIX)
@@ -34,7 +34,7 @@ defmodule Farmbot.Mixfile do
branch: branch(),
arduino_commit: arduino_commit(),
archives: [nerves_bootstrap: "~> 1.2"],
build_embedded: true,
build_embedded: false,
start_permanent: Mix.env() == :prod,
config_path: "config/config.exs",
elixirc_paths: elixirc_paths(Mix.env(), Mix.target()),

0 comments on commit 2611672

Please sign in to comment.
You can’t perform that action at this time.