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

Use local go-mobile as Go mobile in builds

Rod Hynes 3 лет назад
Родитель
Сommit
036ca94162

+ 5 - 10
MobileLibrary/Android/Dockerfile

@@ -41,21 +41,16 @@ RUN curl -L https://dl.google.com/android/repository/commandlinetools-linux-8092
   && yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses \
   && $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-${ANDROID_PLATFORM_VERSION}" "ndk;${ANDROID_NDK_VERSION}"
 
-# Install Pinned Gomobile.
+# Install Gomobile from source at MobileLibrary/go-mobile
 # 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 \
-  && 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 \
+RUN mkdir -p $GOPATH/src/golang.org/x
+COPY go-mobile $GOPATH/src/golang.org/x/mobile
+RUN cd $GOPATH/src/golang.org/x/mobile \
   && 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/sync/errgroup \
   && go get golang.org/x/tools/go/packages \
   && go install golang.org/x/mobile/cmd/gomobile \
   && gomobile init -v

+ 1 - 1
MobileLibrary/Android/README.md

@@ -40,7 +40,7 @@ Note that you may need to use `sudo docker` below, depending on your OS.
 
 ##### Create the build image:
 
-1. While in the `MobileLibrary/Android` directory, run the command: `docker build --no-cache=true -t psiandroid .`
+1. While in the `MobileLibrary/Android` directory, run the command: `docker build --no-cache=true -t psiandroid -f Dockerfile ..`
 
 2. Once completed, verify that you see an image named `psiandroid` when running: `docker images`
 

+ 6 - 5
MobileLibrary/iOS/build-psiphon-framework.sh

@@ -114,16 +114,17 @@ fi
 # Get and install gomobile, using our pinned revision
 #
 
-go get -u golang.org/x/mobile/cmd/gomobile
-cd "${GOPATH}"/src/golang.org/x/mobile/cmd/gomobile
-git checkout master
-git checkout -b pinned ${GOMOBILE_PINNED_REV}
+mkdir -p "${GOPATH}/src/golang.org/x"
+cp -R "${GOPATH}/src/github.com/Psiphon-Labs/psiphon-tunnel-core/MobileLibrary/go-mobile" "${GOPATH}/src/golang.org/x/mobile"
+cd "${GOPATH}/src/golang.org/x/mobile/cmd/gomobile"
 
 # Patch gomobile to edit a command that assumes modules
 mv init.go init.go.orig
 sed -e 's/golang.org\/x\/mobile\/cmd\/gobind@latest/golang.org\/x\/mobile\/cmd\/gobind/g' init.go.orig > init.go
 
-
+go get golang.org/x/mod/modfile
+go get golang.org/x/sync/errgroup
+go get golang.org/x/tools/go/packages
 go install
 "${GOPATH}"/bin/gomobile init -v -x
 if [[ $? != 0 ]]; then