diff --git a/.gitignore b/.gitignore index 64cba886ff..559647642a 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,7 @@ coverage .lock-wscript # Compiled binary addons (http://nodejs.org/api/addons.html) -build +/build # Dependency directory # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git diff --git a/.travis.yml b/.travis.yml index acffce841b..7b542d610a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,12 +22,15 @@ env: matrix: - TARGET_ARCH=x64 - TARGET_ARCH=x86 + - TARGET_ARCH=armv7hf matrix: fast_finish: true exclude: - os: osx env: TARGET_ARCH=x86 + - os: osx + env: TARGET_ARCH=armv7hf os: - linux @@ -41,7 +44,7 @@ before_install: fi install: - - travis_wait ./scripts/ci/install.sh -o $HOST_OS -r $TARGET_ARCH + - travis_wait 90 ./scripts/ci/install.sh -o $HOST_OS -r $TARGET_ARCH script: - ./scripts/ci/test.sh -o $HOST_OS -r $TARGET_ARCH diff --git a/Makefile b/Makefile index ef6f2ca465..fdc6c23068 100644 --- a/Makefile +++ b/Makefile @@ -75,7 +75,7 @@ else HOST_ARCH = x86 endif ifeq ($(shell uname -m),armv7l) - HOST_ARCH = armv7l + HOST_ARCH = armv7hf endif endif ifeq ($(shell uname -s),Darwin) diff --git a/scripts/build/architecture-convert.sh b/scripts/build/architecture-convert.sh index ba1e8ae7a8..0276b5e759 100755 --- a/scripts/build/architecture-convert.sh +++ b/scripts/build/architecture-convert.sh @@ -25,7 +25,7 @@ function usage() { echo "Options" echo "" echo " -r " - echo " -t " + echo " -t " exit 1 } @@ -51,7 +51,7 @@ if [ "$ARGV_TYPE" == "node" ]; then RESULT=ia32 elif [ "$ARGV_ARCHITECTURE" == "x64" ]; then RESULT=x64 - elif [ "$ARGV_ARCHITECTURE" == "armv7l" ]; then + elif [ "$ARGV_ARCHITECTURE" == "armv7hf" ]; then RESULT=arm fi elif [ "$ARGV_TYPE" == "debian" ]; then @@ -59,7 +59,7 @@ elif [ "$ARGV_TYPE" == "debian" ]; then RESULT=i386 elif [ "$ARGV_ARCHITECTURE" == "x64" ]; then RESULT=amd64 - elif [ "$ARGV_ARCHITECTURE" == "armv7l" ]; then + elif [ "$ARGV_ARCHITECTURE" == "armv7hf" ]; then RESULT=armhf fi elif [ "$ARGV_TYPE" == "redhat" ]; then @@ -67,6 +67,16 @@ elif [ "$ARGV_TYPE" == "redhat" ]; then RESULT=i386 elif [ "$ARGV_ARCHITECTURE" == "x64" ]; then RESULT='x86_64' + elif [ "$ARGV_ARCHITECTURE" == "armv7hf" ]; then + RESULT=armhf + fi +elif [ "$ARGV_TYPE" == "docker" ]; then + if [ "$ARGV_ARCHITECTURE" == "x64" ]; then + RESULT=x86_64 + elif [ "$ARGV_ARCHITECTURE" == "x86" ]; then + RESULT=i686 + elif [ "$ARGV_ARCHITECTURE" == "armv7hf" ]; then + RESULT=armv7hf fi else echo "Unsupported architecture type: $ARGV_TYPE" 1>&2 diff --git a/scripts/build/docker/Dockerfile-armv7hf b/scripts/build/docker/Dockerfile-armv7hf new file mode 100644 index 0000000000..1e59927196 --- /dev/null +++ b/scripts/build/docker/Dockerfile-armv7hf @@ -0,0 +1,56 @@ +FROM resin/armv7hf-debian-qemu:latest + + +RUN [ "cross-build-start" ] + + +# Setup APT sources + + + +RUN echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list + + +# Install dependencies +RUN apt-get update \ + && apt-get install -y \ + build-essential \ + curl \ + fuse \ + git \ + jq \ + libasound2 \ + libgconf-2-4 \ + libgtk2.0-0 \ + libx11-xcb1 \ + libnss3 \ + libxss1 \ + libxtst6 \ + libyaml-dev \ + python \ + python-pip \ + python-dev \ + python-software-properties \ + unzip \ + xvfb \ + zip + + + +# NodeJS +RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \ + && apt-get install -y nodejs + +# See https://github.com/mapbox/node-pre-gyp/issues/165 +RUN npm config set unsafe-perm=true + +RUN npm config set spin=false +RUN npm install -g uglify-es@3.0.3 electron-installer-debian@0.5.1 + +# Python +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt + + +RUN [ "cross-build-end" ] + diff --git a/scripts/build/docker/Dockerfile-i686 b/scripts/build/docker/Dockerfile-i686 index 8b28e60e99..8047a0e7e7 100644 --- a/scripts/build/docker/Dockerfile-i686 +++ b/scripts/build/docker/Dockerfile-i686 @@ -1,5 +1,7 @@ FROM erwinchang/ubuntu-12.04-32bit-build + + # Setup APT sources RUN sed s,ubuntu\.stu\.edu\.tw,archive.ubuntu.com, /etc/apt/sources.list > /tmp/sources.list \ @@ -7,6 +9,7 @@ RUN sed s,ubuntu\.stu\.edu\.tw,archive.ubuntu.com, /etc/apt/sources.list > /tmp/ + # Install dependencies RUN apt-get update \ && apt-get install -y \ @@ -32,11 +35,13 @@ RUN apt-get update \ zip \ rpm + # Install a C++11 compiler RUN add-apt-repository ppa:ubuntu-toolchain-r/test \ && apt-get update && apt-get install -y gcc-4.8 g++-4.8 \ && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50 + # NodeJS RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \ && apt-get install -y nodejs @@ -50,3 +55,5 @@ RUN npm install -g uglify-es@3.0.3 electron-installer-debian@0.5.1 electron-inst # Python COPY requirements.txt requirements.txt RUN pip install -r requirements.txt + + diff --git a/scripts/build/docker/Dockerfile-x86_64 b/scripts/build/docker/Dockerfile-x86_64 index ada56047f6..7df8f02007 100644 --- a/scripts/build/docker/Dockerfile-x86_64 +++ b/scripts/build/docker/Dockerfile-x86_64 @@ -1,11 +1,14 @@ FROM ubuntu:12.04 + + # Setup APT sources RUN echo "deb http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse" >> /etc/apt/sources.list + # Install dependencies RUN apt-get update \ && apt-get install -y \ @@ -31,11 +34,13 @@ RUN apt-get update \ zip \ rpm + # Install a C++11 compiler RUN add-apt-repository ppa:ubuntu-toolchain-r/test \ && apt-get update && apt-get install -y gcc-4.8 g++-4.8 \ && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50 + # NodeJS RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \ && apt-get install -y nodejs @@ -49,3 +54,5 @@ RUN npm install -g uglify-es@3.0.3 electron-installer-debian@0.5.1 electron-inst # Python COPY requirements.txt requirements.txt RUN pip install -r requirements.txt + + diff --git a/scripts/build/docker/Dockerfile.template b/scripts/build/docker/Dockerfile.template index 599e81935a..f02f64f713 100644 --- a/scripts/build/docker/Dockerfile.template +++ b/scripts/build/docker/Dockerfile.template @@ -1,5 +1,9 @@ FROM <%= image %> +<% if (architecture == 'armv7hf') { %> +RUN [ "cross-build-start" ] +<% } %> + # Setup APT sources <% if (architecture == 'i686') { %> RUN sed s,ubuntu\.stu\.edu\.tw,archive.ubuntu.com, /etc/apt/sources.list > /tmp/sources.list \ @@ -8,6 +12,9 @@ RUN sed s,ubuntu\.stu\.edu\.tw,archive.ubuntu.com, /etc/apt/sources.list > /tmp/ <% if (architecture == 'x86_64') { %> RUN echo "deb http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse" >> /etc/apt/sources.list <% } %> +<% if (architecture == 'armv7hf') { %> +RUN echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list +<% } %> # Install dependencies RUN apt-get update \ @@ -35,10 +42,12 @@ RUN apt-get update \ zip \ rpm +<% if (architecture != 'armv7hf') { %> # Install a C++11 compiler RUN add-apt-repository ppa:ubuntu-toolchain-r/test \ && apt-get update && apt-get install -y gcc-4.8 g++-4.8 \ && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50 +<% } %> # NodeJS RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \ @@ -53,3 +62,7 @@ RUN npm install -g uglify-es@3.0.3 electron-installer-debian@0.5.1 electron-inst # Python COPY requirements.txt requirements.txt RUN pip install -r requirements.txt + +<% if (architecture == 'armv7hf') { %> +RUN [ "cross-build-end" ] +<% } %> diff --git a/scripts/build/docker/compile-template.js b/scripts/build/docker/compile-template.js index 988bc7987f..cdfb1bf40c 100644 --- a/scripts/build/docker/compile-template.js +++ b/scripts/build/docker/compile-template.js @@ -36,6 +36,10 @@ _.each([ { architecture: 'x86_64', image: 'ubuntu:12.04' + }, + { + architecture: 'armv7hf', + image: 'resin/armv7hf-debian-qemu:latest' } ], (options) => { const result = _.template(template)(options); diff --git a/scripts/build/docker/run-command.sh b/scripts/build/docker/run-command.sh index dec3d0a0fc..25f9875bfe 100755 --- a/scripts/build/docker/run-command.sh +++ b/scripts/build/docker/run-command.sh @@ -54,16 +54,9 @@ then usage fi -if [ "$ARGV_ARCHITECTURE" == "x64" ]; then - DOCKERFILE="$HERE/Dockerfile-x86_64" -elif [ "$ARGV_ARCHITECTURE" == "x86" ]; then - DOCKERFILE="$HERE/Dockerfile-i686" -else - echo "Unsupported architecture: $ARGV_ARCHITECTURE" 1>&2 - exit 1 -fi - -IMAGE_ID="etcher-build-$ARGV_ARCHITECTURE" +DOCKER_ARCHITECTURE=$(./scripts/build/architecture-convert.sh -r "$ARGV_ARCHITECTURE" -t docker) +DOCKERFILE="$HERE/Dockerfile-$DOCKER_ARCHITECTURE" +IMAGE_ID="etcher-build-$DOCKER_ARCHITECTURE" docker build -f "$DOCKERFILE" -t "$IMAGE_ID" "$ARGV_SOURCE_CODE_DIRECTORY" @@ -91,6 +84,8 @@ docker run -t \ --env "TERM=xterm-256color" \ --env "TARGET_ARCH=$ARGV_ARCHITECTURE" \ ${DOCKER_ENVVARS[@]+"${DOCKER_ENVVARS[@]}"} \ + --entrypoint=qemu-arm-static \ + --env "QEMU_EXECVE=1" \ --privileged \ --cap-add SYS_ADMIN \ --device /dev/fuse:/dev/fuse:mrw \