Skip to content

Commit

Permalink
ci: build for all platforms on travis-ci
Browse files Browse the repository at this point in the history
- use multiarch/crossbuild Docker image to build for all targets
- remove Appveyor builds
- Makefile refactoring and cleanup
- generate a file with sha256 and size of the archive
- update Github releases deploy key
  • Loading branch information
igrr committed Oct 15, 2017
1 parent 1bd2729 commit 6b22471
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 127 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
esptool
esptool.exe
build/
build/
*/*.o
*.o
*.zip
*.tar.gz
esptool-*
70 changes: 58 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,73 @@
language: cpp
language: c
sudo: required
services:
- docker

matrix:
include:
- os: linux
sudo: false
compiler: gcc
env: PLATFORM=linux64
- os: osx
compiler: clang
env: PLATFORM=osx
script: make dist
- env:
- TARGET_OS=linux64
- CROSS_TRIPLE=x86_64-linux-gnu
- env:
- TARGET_OS=linux32
- CROSS_TRIPLE=x86_64-linux-gnu
- env:
- TARGET_OS=linux-armhf
- CROSS_TRIPLE=x86_64-linux-gnu
- env:
- TARGET_OS=win32
- CROSS_TRIPLE=i686-w64-mingw32
# Unfortunately multiarch/crossbuild doesn't come with 'zip',
# so we build a tgz archive in the container, and re-package it later in the script.
- EXTRA_ARGS='-e ARCHIVE=tar'
- env:
- TARGET_OS=osx
- CROSS_TRIPLE=x86_64-apple-darwin

script:
- export VER=$(git describe)
- echo ${VER}

- >-
docker run --rm
-v $PWD:/workdir
-e TARGET_OS=${TARGET_OS}
-e CROSS_TRIPLE=${CROSS_TRIPLE}
${EXTRA_ARGS}
multiarch/crossbuild
make clean dist
# for windows, prepare zip archive
- |
if [ $TARGET_OS = "win32" ]; then
rm -f esptool-${VER}-win32.tar.gz
zip -r esptool-${VER}-win32.zip esptool-${VER}-win32/
fi
# Diagnostics
- file esptool-${VER}-${TARGET_OS}/*
- ls -l esptool-${VER}-${TARGET_OS}/*

# Prepare a file with size and sha256
- export DIST_NAME=$(ls -1 esptool-${VER}-${TARGET_OS}.*)
- DIST_SIZE=$(wc -c <${DIST_NAME} 2>/dev/null | tr -d ' ')
- DIST_SHA256=$(shasum -a 256 ${DIST_NAME} | cut -d ' ' -f1)
- echo ${DIST_NAME} ${DIST_SIZE} ${DIST_SHA256} >esptool-${VER}-${TARGET_OS}.sha256.txt

notifications:
email:
recipients:
- igrokhotkov@gmail.com
on_success: change
on_failure: change

deploy:
provider: releases
skip_cleanup: true
file_glob: true
api_key:
secure: Lg/Po5YFRcnrpqjgrdHcyGdxhRe8iB01Og8hvTmhhDxew1mpVHCfcZxO1VMpBxWnLS3ud4UdMjC3RBpcCWTvt0w9g35Vt9cj7XgnBEBHrBBA5DL+E5cAj/5Sf63pztc85m/kB0WODNG2NQiTpjonszrFHpmWdmXp3mqP95mZVBw=
file: esptool-$TRAVIS_TAG-$PLATFORM.tar.gz
secure: "SsAnTtkjpHq2OQCnfZskdUY2R3lIRgl4iuVbKtMsGBS7YYZvpv8l+TdCcPXGaOXDRymJnWiNZs2/wJU1haVhwnDkp46Suo3m9OKQ40K4YQ6rpXBM5/f2ahdSKhNxR7lbVaAZnJWXO3PgGTM73F+d619oj5GGF/1SbCQ1thSRMQs="
file: esptool-$TRAVIS_TAG-$TARGET_OS.*
on:
repo: igrr/esptool-ck
tags: true
all_branches: true
110 changes: 64 additions & 46 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,46 +1,61 @@
CFLAGS += -std=gnu99 -Os -Wall
CXXFLAGS += -std=c++11 -Os -Wall


# OS detection. Not used in CI builds
ifndef TARGET_OS
ifeq ($(OS),Windows_NT)
TARGET_OS := WINDOWS
DIST_SUFFIX := windows
ARCHIVE_CMD := 7z a
ARCHIVE_EXTENSION := zip
TARGET_OS := win32
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
TARGET_OS := LINUX
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),x86_64)
DIST_SUFFIX := linux64
endif
ifeq ($(UNAME_M),i686)
DIST_SUFFIX := linux32
endif
ifeq ($(UNAME_M),armv6l)
DIST_SUFFIX := linux-armhf
endif
endif
ifeq ($(UNAME_S),Darwin)
TARGET_OS := OSX
DIST_SUFFIX := osx
endif
ifeq ($(UNAME_S),FreeBSD)
TARGET_OS := FREEBSD
DIST_SUFFIX := freebsd
endif
ARCHIVE_CMD := tar czf
ARCHIVE_EXTENSION := tar.gz
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),x86_64)
TARGET_OS := linux64
endif
ifeq ($(UNAME_M),i686)
TARGET_OS := linux32
endif
ifeq ($(UNAME_M),armv6l)
TARGET_OS := linux-armhf
endif
endif
ifeq ($(UNAME_S),Darwin)
TARGET_OS := osx
endif
ifeq ($(UNAME_S),FreeBSD)
TARGET_OS := freebsd
endif
endif
endif # TARGET_OS

VERSION ?= $(shell git describe --always)
# OS-specific settings and build flags
ifeq ($(TARGET_OS),win32)
ARCHIVE ?= zip
TARGET := esptool.exe
TARGET_LDFLAGS = -Wl,-static -static-libgcc
else
ARCHIVE ?= tar
TARGET := esptool
endif

ifeq ($(TARGET_OS),osx)
TARGET_CFLAGS = -mmacosx-version-min=10.6 -arch i386 -arch x86_64
TARGET_CXXFLAGS = -mmacosx-version-min=10.6 -arch i386 -arch x86_64
TARGET_LDFLAGS = -mmacosx-version-min=10.6 -arch i386 -arch x86_64
endif

MODULES := infohelper elf binimage argparse serialport espcomm
# Packaging into archive (for 'dist' target)
ifeq ($(ARCHIVE), zip)
ARCHIVE_CMD := zip -r
ARCHIVE_EXTENSION := zip
endif
ifeq ($(ARCHIVE), tar)
ARCHIVE_CMD := tar czf
ARCHIVE_EXTENSION := tar.gz
endif

VERSION ?= $(shell git describe --always)

-include local/Makefile.local.$(TARGET_OS)
MODULES := infohelper elf binimage argparse serialport espcomm

OBJECTS := \
OBJECTS := \
argparse/argparse.o \
argparse/argparse_binimagecmd.o \
argparse/argparse_commcmd.o \
Expand All @@ -55,23 +70,23 @@ OBJECTS := \
serialport/serialport.o \
main.o

INCLUDES := $(addprefix -I,$(MODULES))
INCLUDES := $(addprefix -I,$(MODULES))

CFLAGS += $(TARGET_CFLAGS)
CXXFLAGS += $(TARGET_CXXFLAGS)
LDFLAGS += $(TARGET_LDFLAGS)
CPPFLAGS += $(INCLUDES) $(SDK_INCLUDES) -D$(TARGET_OS) -DVERSION=\"$(VERSION)\"
override CFLAGS := -std=gnu99 -Os -Wall $(TARGET_CFLAGS) $(CFLAGS)
override CXXFLAGS := -std=c++11 -Os -Wall $(TARGET_CXXFLAGS) ($CXXFLAGS)
override LDFLAGS := $(TARGET_LDFLAGS) $(LDFLAGS)
override CPPFLAGS := $(INCLUDES) $(SDK_INCLUDES) -DVERSION=\"$(VERSION)\" $(CPPFLAGS)

DIST_NAME := esptool-$(VERSION)-$(DIST_SUFFIX)
DIST_NAME := esptool-$(VERSION)-$(TARGET_OS)
DIST_DIR := $(DIST_NAME)
DIST_ARCHIVE := $(DIST_NAME).$(ARCHIVE_EXTENSION)


.PHONY: all checkdirs clean dist

all: $(TARGET)

dist: $(TARGET) $(DIST_DIR)
dist: $(DIST_ARCHIVE)

$(DIST_ARCHIVE): $(TARGET) $(DIST_DIR)
cp $(TARGET) $(DIST_DIR)/
$(ARCHIVE_CMD) $(DIST_ARCHIVE) $(DIST_DIR)

Expand All @@ -88,4 +103,7 @@ $(DIST_DIR):
clean:
@rm -f $(OBJECTS)
@rm -f $(TARGET)
@rm -rf esptool-*
@rm -rf $(DIST_DIR)
@rm -f $(DIST_ARCHIVE)

.PHONY: all clean dist
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Esptool reads the compiled program in ELF format, extracts code and data sections, and either dumps a section to a file or assembles the firmware file from several segments. Esptool also communicates with the ESP8266 bootloader to upload firmware files to flash. Esptool can automatically put the board into UART bootloader mode using a variety of methods.

Linux|Windows
----- | ------
[![Linux build status](http://img.shields.io/travis/igrr/esptool-ck.svg)](https://travis-ci.org/igrr/esptool-ck) | [![Windows build status](http://img.shields.io/appveyor/ci/igrr/esptool-ck.svg)](https://ci.appveyor.com/project/igrr/esptool-ck)
Build status
------------
[![Build status](http://img.shields.io/travis/igrr/esptool-ck.svg)](https://travis-ci.org/igrr/esptool-ck)


Usage
Expand Down
40 changes: 0 additions & 40 deletions appveyor.yml

This file was deleted.

5 changes: 0 additions & 5 deletions local/Makefile.local.FREEBSD

This file was deleted.

5 changes: 0 additions & 5 deletions local/Makefile.local.LINUX

This file was deleted.

9 changes: 0 additions & 9 deletions local/Makefile.local.OSX

This file was deleted.

5 changes: 0 additions & 5 deletions local/Makefile.local.WINDOWS

This file was deleted.

2 changes: 1 addition & 1 deletion serialport/serialport.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <unistd.h>

#if defined (_WIN32)
#include <Windows.h>
#include <windows.h>
#else
#include <sys/types.h>
#include <sys/stat.h>
Expand Down

0 comments on commit 6b22471

Please sign in to comment.