Преглед изворни кода

Update Android Library build to latest gomombile and newer NDK

Rod Hynes пре 3 година
родитељ
комит
25505c8d48
2 измењених фајлова са 18 додато и 21 уклоњено
  1. 17 20
      MobileLibrary/Android/Dockerfile
  2. 1 1
      MobileLibrary/Android/make.bash

+ 17 - 20
MobileLibrary/Android/Dockerfile

@@ -27,41 +27,38 @@ RUN curl -L https://storage.googleapis.com/golang/$GOVERSION.linux-amd64.tar.gz
   && echo $GOVERSION > $GOROOT/VERSION
 
 # Setup Android Environment.
-ENV ANDROID_NDK_ROOT=/android-ndk ANDROID_HOME=/android-sdk-linux
+ENV ANDROID_NDK_ROOT=/android-ndk ANDROID_NDK_HOME=/android-ndk ANDROID_HOME=/android-sdk-linux
 
-# Setup Android NDK
+# Setup Android NDK.
 RUN cd /tmp \
-  && curl -L http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin -o /tmp/android-ndk.bin \
-  && chmod a+x /tmp/android-ndk.bin \
-  && /tmp/android-ndk.bin \
-  && rm /tmp/android-ndk.bin \
-  && ln -s $(find /tmp -type d -name 'android-ndk-*') /android-ndk
+  && curl -L https://dl.google.com/android/repository/android-ndk-r23b-linux.zip -o /tmp/android-ndk-r23b-linux.zip \
+  && cd /tmp \
+  && unzip android-ndk-r23b-linux.zip \
+  && mv /tmp/android-ndk-r23b /android-ndk
 
 # Setup Android SDK.
-RUN curl -L http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz -o /tmp/android-sdk.tgz \
+RUN curl -L https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz -o /tmp/android-sdk.tgz \
   && tar -C / -xzf /tmp/android-sdk.tgz \
   && rm /tmp/android-sdk.tgz \
   && (while true; do echo 'y'; sleep 2; done) | $ANDROID_HOME/tools/android update sdk --no-ui --filter platform,platform-tool,tool
 
-# Install Pinned Gomobile
-#  - Ordered last to allow use of previously cached layers when changing revisions
-ENV GOMOBILE_PINNED_REV=c4d780faeb85123ee32b88e84fd022739ed8c124
+# Install Pinned Gomobile.
+# The sed operation patches gomobile, editing a command that assumes modules
+ENV GOMOBILE_PINNED_REV=ce6a79cf6a13dd77095a6f8dbee5f39848fa7da1
 RUN mkdir -p $GOPATH/pkg/gomobile/dl \
   && cd $GOPATH/pkg/gomobile/dl \
-  && curl -O https://dl.google.com/go/mobile/gomobile-ndk-r10e-linux-x86_64.tar.gz \
-  && curl -O https://dl.google.com/go/mobile/gomobile-openal-soft-1.16.0.1.tar.gz \
   && mkdir -p $GOPATH/src/golang.org/x \
   && cd $GOPATH/src/golang.org/x \
   && git clone https://github.com/golang/mobile \
   && cd mobile \
   && git checkout -b pinned $GOMOBILE_PINNED_REV \
-  && git format-patch --stdout -1 e6f31964531b3d6b76d334ba0d313b64c9687146 | git apply \
-  && mv ./cmd/gomobile/build.go ./cmd/gomobile/build.go.orig \
-  && sed -e 's/"-tags="+strconv.Quote(strings.Join(ctx.BuildTags, ",")),/"-tags",strings.Join(ctx.BuildTags, " "),/g' ./cmd/gomobile/build.go.orig > ./cmd/gomobile/build.go \
-  && mv ./cmd/gomobile/build.go ./cmd/gomobile/build.go.orig \
-  && sed -e 's/"strconv"//g' ./cmd/gomobile/build.go.orig > ./cmd/gomobile/build.go \
-  && echo "master: $(git rev-parse master)\npinned: $(git rev-parse pinned)" | tee $GOROOT/MOBILE \
-  && GO111MODULE=off go install golang.org/x/mobile/cmd/gomobile \
+  && mv ./cmd/gomobile/init.go ./cmd/gomobile/init.go.orig \
+  && sed -e 's/golang.org\/x\/mobile\/cmd\/gobind@latest/golang.org\/x\/mobile\/cmd\/gobind/g' ./cmd/gomobile/init.go.orig > ./cmd/gomobile/init.go \
+  && echo "master: $(git rev-parse master)\npinned: $(git rev-parse master)" | tee $GOROOT/MOBILE \
+  && export GO111MODULE=off \
+  && go get golang.org/x/mod/modfile \
+  && go get golang.org/x/tools/go/packages\
+  && go install golang.org/x/mobile/cmd/gomobile \
   && gomobile init -v
 
 WORKDIR $GOPATH/src

+ 1 - 1
MobileLibrary/Android/make.bash

@@ -10,7 +10,7 @@ fi
 # $1, if specified, is go build tags
 if [ -z ${1+x} ]; then BUILD_TAGS=""; else BUILD_TAGS="$1"; fi
 
-# At this time, gomobile doesn't support modules
+# At this time, psiphon-tunnel-core doesn't support modules
 export GO111MODULE=off
 
 BUILDINFOFILE="psiphon-tunnel-core_buildinfo.txt"