Update build scripts

This commit is contained in:
世界 2021-01-17 00:25:30 +08:00
parent 41584af04b
commit d69ea8934f
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
23 changed files with 199 additions and 361 deletions

View File

@ -63,22 +63,10 @@ Consider using a Linux VM or dual booting.**
It is recommended to use [AndroidStudio](https://developer.android.com/studio) to install. [here is how to install AndroidStudio](https://developer.android.com/studio/install).
2. Install golang ( >= 1.15.4 ), and add GOPATH to the PATH variable.
It is recommended to use gvm for the installation. if you are using the system package manager, don't forget to add environment variable.
(Run one command at a time)
2. Install golang ( >= 1.15.5 ).
```shell
apt install -y bison gcc make
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source "$HOME/.bashrc"
gvm install go1.15.4 -B
gvm use go1.15.4 --default
apt install -y golang
```
3. Install rust and its stdlib for android abis, add environment variables for it.
@ -86,18 +74,18 @@ gvm use go1.15.4 --default
It is recommended to use the official script, otherwise you may not find rustup.
```shell
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
echo "source \$HOME/.cargo/env" >> $HOME/.bashrc && source $HOME/.cargo/env
cd ss-rust/src/main/rust/shadowsocks-rust
rustup target install armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android
```
4. Build native dependencies: `bin/native_libs.sh`
5. Build external libraries and native code: `bin/update_libs.sh`
4. Build native dependencies: `./run init libs`
5. Build external libraries and native code: `./run libs update`
6. Fill out `TELEGRAM_APP_ID` and `TELEGRAM_APP_HASH` in `local.properties`
7. Replace TMessagesProj/google-services.json if you want fcm to work.
8. Replace release.keystore with yours and fill out `ALIAS_NAME`, `KEYSTORE_PASS` and `ALIAS_PASS` in `local.properties`
8. Replace release.keystore with yours and fill out `ALIAS_NAME`, `KEYSTORE_PASS` and `ALIAS_PASS` in `local.properties` if you want a non-debug build.
`./gradlew assemble<Full/Mini><Debug/Release/ReleaseNoGcm>`

View File

@ -110,6 +110,32 @@ dependencies {
}
def keystorePwd = null
def alias = null
def pwd = null
Properties properties
if (project.rootProject.file('local.properties').exists()) {
properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
} else {
def base64 = System.getenv("LOCAL_PROPERTIES")
if (base64 != null && !base64.isBlank()) {
properties = new Properties()
properties.load(new ByteArrayInputStream(Base64.decoder.decode(base64)))
}
}
if (properties != null) {
keystorePwd = properties.getProperty("KEYSTORE_PASS")
alias = properties.getProperty("ALIAS_NAME")
pwd = properties.getProperty("ALIAS_PASS")
}
keystorePwd = keystorePwd ?: System.getenv("KEYSTORE_PASS")
alias = alias ?: System.getenv("ALIAS_NAME")
pwd = pwd ?: System.getenv("ALIAS_PASS")
android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
@ -125,20 +151,18 @@ android {
versionName verName
versionCode verCode
def appId = null
def appHash = null
def appId = "1391584"
def appHash = "355c91550b0d658cfb7ff89dcf91a08c"
//obtain your own keys at https://core.telegram.org/api/obtaining_api_id
if (project.rootProject.file('local.properties').exists()) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
appId = properties.getProperty("TELEGRAM_APP_ID") ?: System.getenv("TELEGRAM_APP_ID")
appHash = properties.getProperty("TELEGRAM_APP_HASH") ?: System.getenv("TELEGRAM_APP_HASH")
if (properties != null) {
appId = properties.getProperty("TELEGRAM_APP_ID") ?: System.getenv("TELEGRAM_APP_ID") ?: appId
appHash = properties.getProperty("TELEGRAM_APP_HASH") ?: System.getenv("TELEGRAM_APP_HASH") ?: appHash
}
buildConfigField 'int', 'APP_ID', appId != null ? appId : "1391584"
buildConfigField 'String', 'APP_HASH', "\"" + (appHash != null ? appHash : "355c91550b0d658cfb7ff89dcf91a08c") + "\""
buildConfigField 'int', 'APP_ID', appId
buildConfigField 'String', 'APP_HASH', "\"" + appHash + "\""
externalNativeBuild {
cmake {
@ -197,40 +221,12 @@ android {
}
signingConfigs {
def keystorePwd = null
def alias = null
def pwd = null
Properties properties
if (project.rootProject.file('local.properties').exists()) {
properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
} else {
def base64 = System.getenv("LOCAL_PROPERTIES")
if (base64 != null && !base64.isBlank()) {
properties = new Properties()
properties.load(new ByteArrayInputStream(Base64.decoder.decode(base64)))
}
}
if (properties != null) {
keystorePwd = properties.getProperty("KEYSTORE_PASS")
alias = properties.getProperty("ALIAS_NAME")
pwd = properties.getProperty("ALIAS_PASS")
}
keystorePwd = keystorePwd ?: System.getenv("KEYSTORE_PASS")
alias = alias ?: System.getenv("ALIAS_NAME")
pwd = pwd ?: System.getenv("ALIAS_PASS")
release {
storeFile project.file('release.keystore')
storePassword keystorePwd
keyAlias alias
keyPassword pwd
}
}
buildTypes {
@ -240,7 +236,7 @@ android {
jniDebuggable false
multiDexEnabled true
zipAlignEnabled true
signingConfig signingConfigs.release
signingConfig keystorePwd == null ? signingConfigs.debug : signingConfigs.release
}
releaseNoGcm {

13
bin/app/init.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
function flavor() {
for f in "$@"; do
./gradlew TMessagesProj:assemble${1}Release || exit 1
./gradlew TMessagesProj:assemble${1}ReleaseNoGcm || exit 1
done
}
flavor Full
flavor FullAppleEmoji
flavor Mini
flavor MiniAppletEmoji

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
if [ ! -x "$(command -v ghr)" ]; then

7
bin/init/action.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source "bin/init/env.sh"
cat > local.properties << EOF
ndk.dir=$NDK
EOF

20
bin/init/debian.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
function sudodo() {
sudo $@ || $@
}
sudodo apt-get install bison gcc make curl ninja-build -y
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source $HOME/.gvm/scripts/gvm
gvm install go1.15.6 -B
gvm use go1.15.6 --default
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
echo "source \$HOME/.cargo/env" >> $HOME/.bashrc && source $HOME/.cargo/env
git submodule update --init --recursive
cd ss-rust/src/main/rust/shadowsocks-rust
rustup target install armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android

17
bin/init/env.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
if [ -z "$ANDROID_HOME" ]; then
if [ -d "$HOME/Android/Sdk" ]; then
export ANDROID_HOME="$HOME/Android/Sdk"
fi
fi
if [ -f "$ANDROID_HOME/ndk-bundle/source.properties" ]; then
export NDK=$ANDROID_HOME/ndk-bundle
else
export NDK=$ANDROID_HOME/ndk/21.3.6528147
fi
export ANDROID_NDK_HOME=$NDK
export PROJECT=$(realpath .)

25
bin/init/libs.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
source "bin/init/env.sh"
export NINJA_PATH="$(command -v ninja)"
export PATH=$(echo "$ANDROID_HOME"/cmake/*/bin):$PATH
cd TMessagesProj/jni || exit 1
git submodule update --init --recursive
cd ffmpeg
git reset --hard
git clean -fdx
cd ..
./build_ffmpeg_clang.sh || exit 1
./patch_ffmpeg.sh || exit 1
cd boringssl
git reset --hard
git clean -fdx
cd ..
./patch_boringssl.sh || exit 1
./build_boringssl.sh

View File

@ -1,15 +0,0 @@
#!/bin/bash
function assemble() {
./gradlew TMessagesProj:assembleRelease \
TMessagesProj:assembleReleaseNoGcm
return $?
}
#./gradlew TMessagesProj:assembleRelease \
# TMessagesProj:assembleReleaseNoGcm
assemble

3
bin/kts/README.md Normal file
View File

@ -0,0 +1,3 @@
# kts scripts
Create run configure without build before launch

View File

@ -1,7 +1,7 @@
import java.io.File
import kotlin.system.exitProcess
val projectRoot = File("..")
val projectRoot = File("../..")
val webpSources = File(projectRoot, "TMessagesProj/jni/libwebp/Android.mk")
.readLines()

19
bin/libs/native.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
source "bin/init/env.sh"
./gradlew TMessagesProj:stripFullFossDebugSymbols || exit 1
OUT=TMessagesProj/build/intermediates/stripped_native_libs/fullFoss/out/lib
DIR=TMessagesProj/src/main/libs
rm -rf $DIR/armeabi-v7a
mkdir -p $DIR/armeabi-v7a
cp $OUT/armeabi-v7a/libtmessages*.so $DIR/armeabi-v7a
rm -rf $DIR/arm64-v8a
mkdir -p $DIR/arm64-v8a
cp $OUT/arm64-v8a/libtmessages*.so $DIR/arm64-v8a
rm -rf $DIR/x86
mkdir -p $DIR/x86
cp $OUT/x86/libtmessages*.so $DIR/x86
rm -rf $DIR/x86_64
mkdir -p $DIR/x86_64
cp $OUT/x86_64/libtmessages*.so $DIR/x86_64

6
bin/libs/ss.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
source "bin/init/env.sh"
./gradlew ss-rust:assembleRelease || exit 1
cp ss-rust/build/outputs/aar/* TMessagesProj/libs

6
bin/libs/ssr.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
source "bin/init/env.sh"
./gradlew ssr-libev:assembleRelease || exit 1
cp ssr-libev/build/outputs/aar/* TMessagesProj/libs

6
bin/libs/update.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
bin/libs/ss.sh || exit 1
bin/libs/ssr.sh || exit 1
bin/libs/v2ray.sh || exit 1
bin/libs/native.sh || exit 1

27
bin/libs/v2ray.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
V2RAY_CORE_VERSION="4.34.0"
source "bin/init/env.sh"
v2rayCore="$(go env GOPATH)/src/v2ray.com/core"
if [ ! -d "$v2rayCore" ]; then
mkdir -p "$v2rayCore"
git clone https://github.com/v2fly/v2ray-core.git "$v2rayCore" -b "v$V2RAY_CORE_VERSION" --depth 1
cd "$v2rayCore"
else
cd "$v2rayCore"
git fetch origin "v$V2RAY_CORE_VERSION" && git reset "v$V2RAY_CORE_VERSION" --hard || git clone https://github.com/v2fly/v2ray-core.git "$v2rayCore" -b "v$V2RAY_CORE_VERSION" --depth 1
fi
export PATH="$PATH/$(go env $GOPATH/bin)"
go mod download -x
cd "$PROJECT/TMessagesProj/libs"
go get -v golang.org/x/mobile/cmd/...
go get -d github.com/2dust/AndroidLibV2rayLite
gomobile init
gomobile bind -v -ldflags='-s -w' github.com/2dust/AndroidLibV2rayLite || exit 1
rm *-sources.jar

View File

@ -1,92 +0,0 @@
#!/bin/bash
if [ ! -x "$(command -v go)" ]; then
# if [ ! -x "$(command -v gvm)" ]; then
#
# apt install -y bison binutils gcc make
#
# bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
#
# source "$HOME/.bashrc"
#
# fi
#
# gvm install go1.15.5 -B
# gvm use go1.15.5 --default
echo "install golang please!"
exit 1
fi
if [ ! -x "$(command -v ninja)" ]; then
# apt install -y ninja-build
echo "install ninja-build please!"
exit 1
fi
if [ ! -x "$(command -v cmake)" ]; then
# apt install -y cmake
echo "install cmake please!"
exit 1
fi
if [ -z "$ANDROID_HOME" ]; then
if [ -d "$HOME/Android/Sdk" ]; then
export ANDROID_HOME=$HOME/Android/Sdk
else
echo "E: ANDROID_HOME not found."
exit 1
fi
fi
if [ -f "$ANDROID_HOME/ndk-bundle/source.properties" ]; then
export NDK=$ANDROID_HOME/ndk-bundle
else
export NDK=$ANDROID_HOME/ndk/21.3.6528147
fi
export NINJA_PATH="$(command -v ninja)"
export PATH=$(echo "$ANDROID_HOME"/cmake/*/bin):$PATH
cd TMessagesProj/jni || exit 1
git submodule update --init --recursive
cd ffmpeg
git reset --hard
git clean -fdx
cd ..
./build_ffmpeg_clang.sh
./patch_ffmpeg.sh
cd boringssl
git reset --hard
git clean -fdx
cd ..
./patch_boringssl.sh
./build_boringssl.sh

View File

@ -1,93 +0,0 @@
#!/bin/bash
V2RAY_CORE_VERSION="4.34.0"
if [ ! -x "$(command -v go)" ]; then
# if [ ! -x "$(command -v gvm)" ]; then
#
# apt install -y bison gcc make
# bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
# source "$HOME/.bashrc"
#
# fi
#
# gvm install go1.15.5 -B
# gvm use go1.15.5 --default
echo "install golang please!"
exit 1
fi
if [ ! -x "$(command -v rustc)" ]; then
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# echo "source \$HOME/.cargo/env" >> $HOME/.bashrc && source $HOME/.cargo/env
# rustup target install armv7-linux-androideabi aarch64-linux-android i686-linux-android x86_64-linux-android
echo "install rust please!"
exit 1
fi
if [ -z "$ANDROID_HOME" ]; then
if [ -d "$HOME/Android/Sdk" ]; then
export ANDROID_HOME="$HOME/Android/Sdk"
fi
fi
if [ ! -f "$ANDROID_HOME/ndk-bundle/source.properties" ]; then
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/21.3.6528147
fi
rm -rf TMessagesProj/libs/*.aar
./gradlew ss-rust:assembleRelease --stacktrace &&
cp ss-rust/build/outputs/aar/* TMessagesProj/libs &&
./gradlew ssr-libev:assembleRelease &&
cp ssr-libev/build/outputs/aar/* TMessagesProj/libs &&
cd TMessagesProj/libs &&
go get -v golang.org/x/mobile/cmd/... || exit 1
v2rayCore="$(go env GOPATH)/src/v2ray.com/core"
if [ ! -d "$v2rayCore" ]; then
mkdir -p "$v2rayCore"
git clone https://github.com/v2fly/v2ray-core.git "$v2rayCore" -b "v$V2RAY_CORE_VERSION"
cd "$v2rayCore"
else
cd "$v2rayCore"
git fetch origin "v$V2RAY_CORE_VERSION" && git reset "v$V2RAY_CORE_VERSION" --hard || git clone https://github.com/v2fly/v2ray-core.git "$v2rayCore" -b "v$V2RAY_CORE_VERSION"
fi
go mod download
cd "$OLDPWD"
go get -d github.com/2dust/AndroidLibV2rayLite &&
gomobile init &&
gomobile bind -v -ldflags='-s -w' github.com/2dust/AndroidLibV2rayLite &&
rm *-sources.jar &&
cd ../.. &&
./gradlew TMessagesProj:stripFullFossDebugSymbols &&
OUT=TMessagesProj/build/intermediates/stripped_native_libs/fullFoss/out/lib &&
DIR=TMessagesProj/src/main/libs &&
rm -rf $DIR/armeabi-v7a &&
mkdir -p $DIR/armeabi-v7a &&
cp $OUT/armeabi-v7a/libtmessages*.so $DIR/armeabi-v7a &&
rm -rf $DIR/arm64-v8a &&
mkdir -p $DIR/arm64-v8a &&
cp $OUT/arm64-v8a/libtmessages*.so $DIR/arm64-v8a &&
rm -rf $DIR/x86 &&
mkdir -p $DIR/x86 &&
cp $OUT/x86/libtmessages*.so $DIR/x86 &&
rm -rf $DIR/x86_64 &&
mkdir -p $DIR/x86_64 &&
cp $OUT/x86_64/libtmessages*.so $DIR/x86_64

View File

@ -1,34 +0,0 @@
#!/bin/bash
./gradlew TMessagesProj:assembleFullRelease \
TMessagesProj:assembleFullReleaseNoGcm || exit 1
trap 'kill $(jobs -p)' SIGINT
function upload() {
for apk in $outPath/*.apk; do
echo ">> Uploading $apk"
curl https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument \
-X POST \
-F chat_id="$TELEGRAM_CHANNEL" \
-F document="@$apk" \
--silent --show-error --fail >/dev/null &
done
for job in $(jobs -p); do
wait $job
done
}
outPath="TMessagesProj/build/outputs/apk/full/release"
upload
outPath="TMessagesProj/build/outputs/apk/full/releaseNoGcm"
upload

View File

@ -1,29 +0,0 @@
#!/bin/bash
./gradlew TMessagesProj:assembleFullRelease || exit 1
trap 'kill $(jobs -p)' SIGINT
function upload() {
for apk in $outPath/*arm64*.apk; do
echo ">> Uploading $apk"
curl https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument \
-X POST \
-F chat_id="$TELEGRAM_CHANNEL" \
-F document="@$apk" \
--silent --show-error --fail >/dev/null &
done
for job in $(jobs -p); do
wait $job
done
}
outPath="TMessagesProj/build/outputs/apk/full/release"
upload

View File

@ -1,39 +0,0 @@
#!/bin/bash
trap 'kill $(jobs -p)' SIGINT
function upload() {
for apk in $outPath/*.apk; do
echo ">> Uploading $apk"
curl https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument \
-X POST \
-F chat_id="$TELEGRAM_CHANNEL" \
-F document="@$apk" \
--silent --show-error --fail >/dev/null &
done
for job in $(jobs -p); do
wait $job
done
}
outPath="TMessagesProj/build/outputs/apk/full/release"
upload
outPath="TMessagesProj/build/outputs/apk/full/releaseNoGcm"
upload
outPath="TMessagesProj/build/outputs/apk/mini/release"
upload
outPath="TMessagesProj/build/outputs/apk/mini/releaseNoGcm"
upload

7
run Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
TARGET="bin"
for e in $@; do
TARGET="$TARGET/$e"
done
exec ${TARGET}.sh