probonopd / go-appimage

Go implementation of AppImage tools
MIT License
818 stars 71 forks source link

Only use one build machine for all architectures #5

Open probonopd opened 5 years ago

probonopd commented 5 years ago

With the cross-compiler built into Go, it should be possible to only use one build machine for all architectures, hence saving Travis CI resources.

However, as long as we are using come C (currently for the calculation of the ELF size), we need to install a C crosscompiler toolchain, and this is where the usual Linux complexity begins.

dist: xenial
language: go

go:
- "1.13"

git:
  depth: 1

script:
  - sudo apt-get -y update
  - sudo apt-get -y install gcc-multilib g++-multilib gcc-arm-linux-gnueabi gcc-aarch64-linux-gnu psmisc dbus-x11
  - if [ $(go env GOHOSTARCH) == "amd64" ] ; then wget -c -q https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz ; fi
  - if [ $(go env GOHOSTARCH) == "arm64" ] ; then wget -c -q https://github.com/upx/upx/releases/download/v3.95/upx-3.95-arm64_linux.tar.xz ; fi
  - tar xf upx-*_linux.tar.xz
  - export PATH=$(readlink -f upx-*_linux/):$PATH
  - export GO111MODULE=off # Needed?
  - go get github.com/probonopd/appimage/src/appimagetool
  - env CGO_ENABLED=1 GOOS=linux GOARCH=386 go build -trimpath -ldflags="-s -w" github.com/probonopd/appimage/src/appimaged
  - upx -9 appimagetool
  - mv ./appimagetool ./appimagetool-386
  - go build -trimpath -ldflags="-s -w" appimagetool.go
  - upx -9 appimagetool
  - mv ./appimagetool ./appimagetool-amd64
  - env CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm32 go build -trimpath -ldflags="-s -w" github.com/probonopd/appimage/src/appimaged
  - upx -9 appimagetool
  - mv ./appimagetool ./appimagetool-arm32
  - env CC=aarch64-linux-gnu CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="-s -w" github.com/probonopd/appimage/src/appimaged
  - upx -9 appimagetool
  - mv ./appimagetool ./appimagetool-arm64
  - go get github.com/probonopd/appimage/src/zsyncmake
  - env CGO_ENABLED=1 GOOS=linux GOARCH=386 go build -trimpath -ldflags="-s -w" github.com/probonopd/appimage/src/appimaged
  - upx -9 zsyncmake
  - mv ./zsyncmake ./zsyncmake-386
  - go build -trimpath -ldflags="-s -w" zsyncmake.go
  - upx -9 zsyncmake
  - mv ./zsyncmake ./zsyncmake-amd64
  - env CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm32 go build -trimpath -ldflags="-s -w" github.com/probonopd/appimage/src/appimaged
  - upx -9 zsyncmake
  - mv ./zsyncmake ./zsyncmake-arm32
  - env CC=aarch64-linux-gnu CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="-s -w" github.com/probonopd/appimage/src/appimaged
  - upx -9 zsyncmake
  - mv ./zsyncmake ./zsyncmake-arm64
  - go get github.com/probonopd/appimage/src/appimaged
  - env CGO_ENABLED=1 GOOS=linux GOARCH=386 go build -trimpath -ldflags="-s -w" github.com/probonopd/appimage/src/appimaged
  - upx -9 appimaged
  - mv ./appimaged ./appimaged-386
  - go build -trimpath -ldflags="-s -w" appimaged.go
  - upx -9 appimaged
  - mv ./appimaged ./appimaged-amd64
  - env CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm32 go build -trimpath -ldflags="-s -w" github.com/probonopd/appimage/src/appimaged
  - upx -9 appimaged
  - mv ./appimaged ./appimaged-arm32
  - env CC=aarch64-linux-gnu CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="-s -w" github.com/probonopd/appimage/src/appimaged
  - upx -9 appimaged
  - mv ./appimaged ./appimaged-arm64
  # Test run
  - ./appimaged-amd64 &
  - sleep 10
  - killall appimaged

after_success:
  - wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
  - bash upload.sh *.386 *amd64 *arm32 *arm64

branches:
  except:
    - # Do not build tags that we create when we upload to GitHub Releases
    - /^(?i:continuous)/

#cache:
#  directories:
#    - $HOME/gopath/src
The following packages have unmet dependencies:
 gcc-aarch64-linux-gnu : Depends: gcc-5-aarch64-linux-gnu (>= 5.3.1-3~)
 gcc-arm-linux-gnueabi : Depends: gcc-5-arm-linux-gnueabi (>= 5.3.1-3~)
E: Unable to correct problems, you have held broken packages.

We should definitely revisit this once we do not use any C anymore.

probonopd commented 5 years ago

Blocked by #6