Просмотр исходного кода

Merge pull request #55 from adam-p/master

Cross-compile improvements
Rod Hynes 11 лет назад
Родитель
Сommit
1c6ee7ee12

+ 5 - 3
AndroidLibrary/Dockerfile

@@ -1,10 +1,12 @@
 # Dockerfile to build an image with the local version of psiphon-tunnel-core.
 #
-#  > docker build -t psigobuild $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/AndroidApp
-#  > docker run -it --rm -v $GOPATH/src:/src psigobuild
+# See README.md for usage instructions.
 
+# TODO: Switch to debian:testing
 FROM ubuntu:12.04
 
+ENV GOVERSION=go1.4
+
 # Install system-level dependencies.
 ENV DEBIAN_FRONTEND=noninteractive
 RUN echo "debconf shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections && \
@@ -54,7 +56,7 @@ ENV GOROOT=/go \
   GOPATH=/
 ENV PATH=$PATH:$GOROOT/bin
 RUN echo "INSTALLING GO" && \
-  curl -L https://github.com/golang/go/archive/master.zip -o /tmp/go.zip && \
+  curl -L https://github.com/golang/go/archive/$GOVERSION.zip -o /tmp/go.zip && \
   unzip /tmp/go.zip && \
   rm /tmp/go.zip && \
   mv /go-master $GOROOT && \

+ 6 - 4
AndroidLibrary/README.md

@@ -48,20 +48,22 @@ Follow Go Android documentation:
 
 ### Building with Docker
 
+Note that you may need to use `sudo docker` below, depending on your OS.
+
 Create the build image:
 
 ```bash
 # While in the same directory as the Dockerfile...
-$ sudo docker build -t psibuild .
+$ docker build --no-cache=true -t psigoandroid .
 # That will take a long time to complete.
-# After it's done, you'll have an image called "psibuild". Check with...
-$ sudo docker images
+# After it's done, you'll have an image called "psigoandroid". Check with...
+$ docker images
 ```
 
 To do the build:
 
 ```bash
-$ sudo docker run -v $GOPATH/src:/src psibuild /bin/bash -c 'cd /src/github.com/Psiphon-Labs/psiphon-tunnel-core/AndroidLibrary && ./make.bash'
+$ docker run --rm -v $GOPATH/src:/src psigoandroid /bin/bash -c 'cd /src/github.com/Psiphon-Labs/psiphon-tunnel-core/AndroidLibrary && ./make.bash'
 ```
 
 When that command completes, the compiled library will be located at `libs/armeabi-v7a/libgojni.so`.

+ 0 - 2
AndroidLibrary/make.bash

@@ -7,8 +7,6 @@ if [ ! -f make.bash ]; then
   exit 1
 fi
 
-ANDROID_APP=$PWD
-
 # Make sure we have our dependencies
 echo 'go-getting dependencies...'
 go get -d -v ./...

+ 37 - 0
ConsoleClient/Dockerfile

@@ -0,0 +1,37 @@
+# Dockerfile to build an image with the local version of psiphon-tunnel-core.
+#
+# See README.md for usage instructions.
+
+FROM debian:testing
+
+ENV GOVERSION=go1.4
+
+# Install system-level dependencies.
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get update && \
+  apt-get -y install build-essential python-software-properties bzip2 unzip curl \
+    git subversion mercurial bzr \
+    upx gcc-mingw-w64-i686 gcc-mingw-w64-x86-64
+
+# Install Go.
+ENV GOROOT=/go \
+  GOPATH=/
+ENV PATH=$PATH:$GOROOT/bin
+RUN echo "INSTALLING GO" && \
+  curl -L https://github.com/golang/go/archive/$GOVERSION.zip -o /tmp/go.zip && \
+  unzip /tmp/go.zip && \
+  rm /tmp/go.zip && \
+  mv /go-$GOVERSION $GOROOT && \
+  echo $GOVERSION > $GOROOT/VERSION && \
+  cd $GOROOT/src && \
+  ./all.bash
+
+ENV CGO_ENABLED=1
+RUN go get github.com/mitchellh/gox && \
+  go get github.com/inconshreveable/gonative && \
+  mkdir -p /usr/local/gonative && \
+  cd /usr/local/gonative && \
+  gonative build
+ENV PATH=/usr/local/gonative/go/bin:$PATH
+
+WORKDIR $GOPATH/src

+ 24 - 0
ConsoleClient/README.md

@@ -0,0 +1,24 @@
+Psiphon Console Client README
+================================================================================
+
+### Building with Docker
+
+Note that you may need to use `sudo docker` below, depending on your OS.
+
+Create the build image:
+
+```bash
+# While in the same directory as the Dockerfile...
+$ docker build --no-cache=true -t psigoconsole .
+# That will take a long time to complete.
+# After it's done, you'll have an image called "psigoconsole". Check with...
+$ docker images
+```
+
+To do the build:
+
+```bash
+$ docker run --rm -v $GOPATH/src:/src psigoconsole /bin/bash -c 'cd /src/github.com/Psiphon-Labs/psiphon-tunnel-core/ConsoleClient && ./make.bash'
+```
+
+When that command completes, the compiled library will be located at `windows_386/psiphon-tunnel-core.exe`.

+ 28 - 0
ConsoleClient/make.bash

@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+
+set -e
+
+if [ ! -f make.bash ]; then
+  echo 'make.bash must be run from $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/ConsoleClient'
+  exit 1
+fi
+
+# Make sure we have our dependencies
+echo 'go-getting dependencies...'
+go get -d -v ./...
+
+CGO_ENABLED=1
+
+echo 'Building windows-386...'
+CC=/usr/bin/i686-w64-mingw32-gcc \
+  gox -verbose -osarch windows/386 -output windows_386_psiphon-tunnel-core
+upx --best windows_386_psiphon-tunnel-core.exe
+
+echo 'Building windows-amd64...'
+CC=/usr/bin/x86_64-w64-mingw32-gcc \
+  gox -verbose -osarch windows/amd64 -output windows_amd64_psiphon-tunnel-core
+upx --best windows_amd64_psiphon-tunnel-core.exe
+
+echo 'Building linux-amd64...'
+gox -verbose -osarch linux/amd64 -output linux_amd64_psiphon-tunnel-core
+upx --best linux_amd64_psiphon-tunnel-core