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

Created Windows cross-compile Dockerfile

Adam Pritchard 11 лет назад
Родитель
Сommit
dddb271b7e

+ 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 ./...

+ 30 - 0
ConsoleClient/Dockerfile

@@ -0,0 +1,30 @@
+# 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 \
+    gcc-mingw-w64-i686 upx
+
+# 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 && \
+  GOOS=windows GOARCH=386 CGO_ENABLED=1 CC_FOR_TARGET=/usr/bin/i686-w64-mingw32-gcc ./make.bash
+
+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`.

+ 22 - 0
ConsoleClient/make.bash

@@ -0,0 +1,22 @@
+#!/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 ./...
+
+echo 'Building windows-386 executable...'
+CGO_ENABLED=1 GOOS=windows GOARCH=386 \
+  go build -a -v -o psiphon-tunnel-core.exe
+upx --best psiphon-tunnel-core.exe
+
+mkdir -p windows_386
+mv -f psiphon-tunnel-core.exe windows_386/psiphon-tunnel-core.exe
+
+echo 'Windows executable can be found at: windows_386/psiphon-tunnel-core.exe'