kanflo / opendps

Give your DPS5005 the upgrade it deserves
MIT License
895 stars 124 forks source link

Let travis build binaries #154

Closed danielkucera closed 5 years ago

danielkucera commented 5 years ago

You can use travis to build binaries. The result will look like this: https://github.com/danielkucera/opendps/releases All you need to do is add project to travis and set GITHUB_OAUTH_TOKEN variable by this guide: https://docs.travis-ci.com/user/deployment/pages/#setting-the-github-token Release is built with each tag

JackNewman12 commented 5 years ago

Beat me to it. This looks good.

There are a few things to consider:

danielkucera commented 5 years ago

Don't merge it yet, I broke original build_binaries.sh script

danielkucera commented 5 years ago

But for the other images you just need to edit original build.sh to build all needed variants and copy them to /output

danielkucera commented 5 years ago

From my side it's ready

Xenoamor commented 5 years ago

I think the opendps output files should be renamed to the model that they were built for. Something like opendps_dps5005.bin

kanflo commented 5 years ago

I agree with @Xenoamor regarding the naming. Could you please change this @danielkucera?

danielkucera commented 5 years ago

I was trying to be nice and change the output file name in Makefile but following doesn't work for some reason:

BINARY = opendps_$(MODEL)

It ends with:

make: Leaving directory '/home/opendps/code/opendps'
make: Entering directory '/home/opendps/code/opendps'
make: *** No rule to make target 'opendps_DPS5005.elf', needed by 'elf'.  Stop.
make: Leaving directory '/home/opendps/code/opendps'

Can you guys help?

Xenoamor commented 5 years ago

Looks like the build system expected BINARY to match the directory name. Perhaps changing the build script to this? I haven't tested this mind

#!/bin/bash

set -eEuo pipefail
umask 022

sudo mkdir -p /home/opendps/code
sudo cp -R /parent/{*,.git*} /home/opendps/code
sudo chown -R opendps:opendps /home/opendps

cd /home/opendps/code
git submodule init
git submodule update
make -j -C libopencm3
make -C opendps fonts "$@"
make -C dpsboot elf bin "$@"

cp -f /home/opendps/code/dpsboot/dpsboot.elf /output/
cp -f /home/opendps/code/dpsboot/dpsboot.bin /output/

make -C opendps elf bin "$@" MODEL=DPS5015
cp -f /home/opendps/code/opendps/opendps.elf /output/opendps_DPS5015.elf
cp -f /home/opendps/code/opendps/opendps.bin /output/opendps_DPS5015.bin

make -C opendps elf bin "$@" MODEL=DPS5005
cp -f /home/opendps/code/opendps/opendps.elf /output/opendps_DPS5005.elf
cp -f /home/opendps/code/opendps/opendps.bin /output/opendps_DPS5005.bin

make -C opendps elf bin "$@" MODEL=DPS3005
cp -f /home/opendps/code/opendps/opendps.elf /output/opendps_DPS3005.elf
cp -f /home/opendps/code/opendps/opendps.bin /output/opendps_DPS3005.bin
danielkucera commented 5 years ago

I was aiming more towards:

make -C opendps elf bin "$@" MODEL=DPS5015
make -C opendps elf bin "$@" MODEL=DPS5005
make -C opendps elf bin "$@" MODEL=DPS3005

cp -f /home/opendps/code/opendps/*.elf /output/
cp -f /home/opendps/code/opendps/*.bin /output/

Do you have an idea how to adjust the build system?

Xenoamor commented 5 years ago

Change line 52 of libopencm3.rules.mk to: OBJS += opendps.o

EDIT: Nope that breaks dpsboot. It is definitely this line causing issues though

Xenoamor commented 5 years ago

The following patch resolves it:

diff --git a/dpsboot/Makefile b/dpsboot/Makefile
index e355c81..af31f1f 100644
--- a/dpsboot/Makefile
+++ b/dpsboot/Makefile
@@ -9,6 +9,7 @@ CFLAGS = -I. -I../opendps -DGIT_VERSION=\"$(GIT_VERSION)\" -DCONFIG_PAST_NO_GC -
 #CFLAGS += -flto

 OBJS = \
+   dpsboot.o \
    common.o \
    hw.o

diff --git a/libopencm3.rules.mk b/libopencm3.rules.mk
index 60d6ce8..47e3860 100644
--- a/libopencm3.rules.mk
+++ b/libopencm3.rules.mk
@@ -46,12 +46,6 @@ OPT      := -Os
 CSTD       ?= -std=c99

-###############################################################################
-# Source files
-
-OBJS       += $(BINARY).o
-
-
 ifeq ($(strip $(OPENCM3_DIR)),)
 # user has not specified the library path, so we try to detect it

diff --git a/opendps/Makefile b/opendps/Makefile
index 02af4da..1a8ba5a 100644
--- a/opendps/Makefile
+++ b/opendps/Makefile
@@ -1,5 +1,3 @@
-BINARY = opendps
-
 # Build with commandline interface rather than serial interface
 COMMANDLINE := 0

@@ -24,6 +22,9 @@ WIFI := 1
 # Print debug information on the serial output
 DEBUG ?= 0

+# Set the output binary filenames
+BINARY := opendps_$(MODEL)
+
 # Font file
 METER_FONT_FILE ?= gfx/Ubuntu-C.ttf
 METER_FONT_SMALL_SIZE ?= 18
@@ -71,6 +72,7 @@ CFLAGS += \
 LDSCRIPT = stm32f100_app.ld

 OBJS = \
+    opendps.o \
     flashlock.o \
     bootcom.o \
     crc16.o \
danielkucera commented 5 years ago

@Xenoamor I didn't want to touch libopencm3.rules.mk so I did it in a different way. Anyway it was a good school of make. Now there is still one problem outstanding - it doesn't rebuild after changing model parameter.

Xenoamor commented 5 years ago

I'm almost certain that the libopencm3.rules.mk is incorrect as it stands. It should only be used to describe how to build a project and not what sourcefiles are in it.

You'll need to touch the dps-model.h file to trigger a rebuild I believe

danielkucera commented 5 years ago

@Xenoamor yes, touch works. Let's leave the decision to @kanflo whether to edit libopencm3.rules.mk or my workaround. Btw different solution for model config could be using dps-model-$MODEL.c with const parameter definitions and then link only the correct file.

kanflo commented 5 years ago

As libopencm3.rules.mk is a part of this git, please feel free to modify it as needed @danielkucera.

danielkucera commented 5 years ago

done

Xenoamor commented 5 years ago

Sods law that this has just came out: https://github.com/features/actions