Update scripts
This commit is contained in:
parent
06c1c209b9
commit
814780d55f
11
build.cmd
Normal file
11
build.cmd
Normal file
@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
::
|
||||
call gradlew %1 assembledebug --warning-mode all
|
||||
::
|
||||
call scripts\debug\win\hide-folders-from-notepad++.cmd
|
||||
::
|
||||
endlocal
|
||||
where update.cmd >NUL: 2>&1 || SET "PATH=%PATH%;%~dp0scripts\debug\win"
|
||||
::
|
||||
goto :eof
|
||||
9
clean.cmd
Normal file
9
clean.cmd
Normal file
@ -0,0 +1,9 @@
|
||||
@echo off
|
||||
::
|
||||
RD /S /Q ".gradle" 2>NUL:
|
||||
RD /S /Q ".kotlin" 2>NUL:
|
||||
RD /S /Q "app\build" 2>NUL:
|
||||
RD /S /Q "app\src\main\jniLibs" 2>NUL:
|
||||
RD /S /Q "build" 2>NUL:
|
||||
::
|
||||
goto :eof
|
||||
@ -1,112 +0,0 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
SET SCRIPT_PATH=%~dps0
|
||||
cd /d "%SCRIPT_PATH%"
|
||||
cls
|
||||
REM
|
||||
REM Script Consts.
|
||||
SET CLEANUP_BEFORE_BUILD=0
|
||||
REM
|
||||
REM Runtime Variables.
|
||||
IF NOT DEFINED ANDROID_SDK_ROOT SET "ANDROID_SDK_ROOT=%SCRIPT_PATH%..\syncthing-android-prereq"
|
||||
REM
|
||||
REM SET SYNCTHING_RELEASE_STORE_FILE="%userprofile%\.android\signing_key.jks"
|
||||
SET SYNCTHING_RELEASE_KEY_ALIAS=Syncthing-Fork
|
||||
SET BUILD_FLAVOUR_RELEASE=release
|
||||
SET BUILD_FLAVOUR_GPLAY=gplay
|
||||
title %SYNCTHING_RELEASE_KEY_ALIAS% - Build APK
|
||||
REM
|
||||
SET GIT_INSTALL_DIR=%ProgramFiles%\Git
|
||||
SET GIT_BIN="%GIT_INSTALL_DIR%\bin\git.exe"
|
||||
REM
|
||||
SET JAVA_HOME=%ProgramFiles%\Android\Android Studio\jbr
|
||||
SET PATH=%JAVA_HOME%\bin;"%GIT_INSTALL_DIR%\bin";%PATH%
|
||||
REM
|
||||
:checkPrerequisites
|
||||
echo [INFO] Checking prerequisites ...
|
||||
REM
|
||||
where java 2>&1 >NUL: || (echo [ERROR] Java is missing. Check env. & goto :eof)
|
||||
REM
|
||||
IF NOT EXIST "%ANDROID_SDK_ROOT%\.knownPackages" (echo [WARN] Android SDK missing. Trying to run 'python install_minimum_android_sdk_prerequisites.py' ... & call python install_minimum_android_sdk_prerequisites.py)
|
||||
REM
|
||||
echo [INFO] Checking if SyncthingNative was built before starting this script ...
|
||||
SET LIBCOUNT=
|
||||
for /f "tokens=*" %%A IN ('dir /s /a "%SCRIPT_PATH%app\src\main\jniLibs\*" 2^>NUL: ^| find /C "libsyncthingnative.so"') DO SET LIBCOUNT=%%A
|
||||
IF NOT "%LIBCOUNT%" == "4" echo [ERROR] SyncthingNative[s] "libsyncthingnative.so" are missing. Please run "gradlew buildNative" first. & goto :eos
|
||||
REM
|
||||
echo [INFO] Let's prepare a new "%SYNCTHING_RELEASE_KEY_ALIAS%" release.
|
||||
REM
|
||||
echo [INFO] Checking release prerequisites ...
|
||||
REM
|
||||
REM User has to enter the signing password if it is not filled in here.
|
||||
REM SET SIGNING_PASSWORD=
|
||||
IF DEFINED SIGNING_PASSWORD goto :absLint
|
||||
:enterSigningPassword
|
||||
setlocal DisableDelayedExpansion
|
||||
set "psCommand=powershell -Command "$pword = read-host 'Enter signing password' -AsSecureString ; ^
|
||||
$BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^
|
||||
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)""
|
||||
for /f "usebackq delims=" %%p in (`%psCommand%`) do SET SIGNING_PASSWORD=%%p
|
||||
setlocal EnableDelayedExpansion
|
||||
IF NOT DEFINED SIGNING_PASSWORD echo [ERROR] Signing password is required. Please retry. & goto :enterSigningPassword
|
||||
REM
|
||||
:absLint
|
||||
REM
|
||||
echo [INFO] Running lint before building ...
|
||||
REM
|
||||
call gradlew lint%BUILD_FLAVOUR_RELEASE% & SET RESULT=%ERRORLEVEL%
|
||||
IF NOT "!RESULT!" == "0" echo [ERROR] "gradlew lint%BUILD_FLAVOUR_RELEASE%" exited with code #%RESULT%. & goto :eos
|
||||
REM
|
||||
call gradlew lint%BUILD_FLAVOUR_GPLAY% & SET RESULT=%ERRORLEVEL%
|
||||
IF NOT "!RESULT!" == "0" echo [ERROR] "gradlew lint%BUILD_FLAVOUR_GPLAY%" exited with code #%RESULT%. & goto :eos
|
||||
REM
|
||||
REM Building APK
|
||||
REM
|
||||
call :buildApk %BUILD_FLAVOUR_RELEASE%
|
||||
call :buildApk %BUILD_FLAVOUR_GPLAY%
|
||||
REM
|
||||
IF "%CLEANUP_BEFORE_BUILD%" == "1" del /f "%SCRIPT_PATH%app\build\outputs\bundle\%BUILD_FLAVOUR_GPLAY%\app-%BUILD_FLAVOUR_GPLAY%.aab" 2> NUL:
|
||||
echo [INFO] Building Android BUNDLE variant "%BUILD_FLAVOUR_GPLAY%" ...
|
||||
call gradlew --quiet bundle%BUILD_FLAVOUR_GPLAY%
|
||||
SET RESULT=%ERRORLEVEL%
|
||||
IF NOT "%RESULT%" == "0" echo [ERROR] "gradlew bundle%BUILD_FLAVOUR_GPLAY%" exited with code #%RESULT%. & goto :eos
|
||||
REM
|
||||
:absPostBuildScript
|
||||
REM
|
||||
echo [INFO] Running OPTIONAL post build script ...
|
||||
call gradlew --quiet postBuildScript
|
||||
REM
|
||||
echo [INFO] Deleting unsupported play translations ...
|
||||
call gradlew --quiet deleteUnsupportedPlayTranslations
|
||||
SET RESULT=%ERRORLEVEL%
|
||||
IF NOT "%RESULT%" == "0" echo [ERROR] "gradlew deleteUnsupportedPlayTranslations" exited with code #%RESULT%. & goto :eos
|
||||
REM
|
||||
REM Copy build artifacts with correct file name to upload folder.
|
||||
call "%SCRIPT_PATH%postbuild_copy_apk.cmd"
|
||||
REM
|
||||
goto :eos
|
||||
:eos
|
||||
REM
|
||||
echo [INFO] End of Script.
|
||||
REM
|
||||
pause
|
||||
goto :eof
|
||||
|
||||
|
||||
:buildApk
|
||||
REM
|
||||
REM Syntax:
|
||||
REM call :buildApk [BUILD_TYPE]
|
||||
REM
|
||||
REM Variables.
|
||||
SET "BA_BUILD_TYPE=%1"
|
||||
IF NOT DEFINED BA_BUILD_TYPE echo [ERROR] buildApk: Parameter 1 BUILD_TYPE missing. & pause & goto :eof
|
||||
REM
|
||||
IF "%CLEANUP_BEFORE_BUILD%" == "1" del /f "%SCRIPT_PATH%app\build\outputs\apk\%BA_BUILD_TYPE%\app-%BA_BUILD_TYPE%.apk" 2> NUL:
|
||||
echo [INFO] Building Android APK variant "%BA_BUILD_TYPE%" ...
|
||||
call gradlew --quiet assemble%BA_BUILD_TYPE%
|
||||
SET RESULT=%ERRORLEVEL%
|
||||
IF NOT "%RESULT%" == "0" echo [ERROR] "gradlew assemble%BA_BUILD_TYPE%" exited with code #%RESULT%. & goto :eos
|
||||
type "app\build\intermediates\merged_manifests\%BA_BUILD_TYPE%\process%BA_BUILD_TYPE%Manifest\AndroidManifest.xml" | findstr /i "android:version"
|
||||
REM
|
||||
goto :eof
|
||||
@ -1,129 +0,0 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
SET SCRIPT_PATH=%~dps0
|
||||
cd /d "%SCRIPT_PATH%"
|
||||
title Update and Build SyncthingNative "libsyncthingnative.so"
|
||||
cls
|
||||
REM
|
||||
REM Script Consts.
|
||||
SET CLEAN_BEFORE_BUILD=1
|
||||
SET SKIP_CHECKOUT_SRC=0
|
||||
SET SYNCTHING_NATIVE_REQUIRED_VERSION=
|
||||
SET GRADLEW_PARAMS=-q
|
||||
REM
|
||||
REM Runtime Variables.
|
||||
IF NOT DEFINED ANDROID_HOME SET "ANDROID_HOME=%SCRIPT_PATH%..\syncthing-android-prereq"
|
||||
IF NOT DEFINED JAVA_HOME SET JAVA_HOME=%ProgramFiles%\Android\Android Studio\jbr
|
||||
REM
|
||||
:checkPrerequisites
|
||||
echo [INFO] Checking prerequisites ...
|
||||
REM
|
||||
SET GIT_BIN=
|
||||
FOR /F "tokens=*" %%A IN ('where git 2^> NUL:') DO SET GIT_BIN="%%A"
|
||||
IF NOT DEFINED GIT_BIN echo [ERROR] git not found. Install "Git for Windows" first and put it to the PATH env var. & pause & goto :checkPrerequisites
|
||||
IF NOT EXIST %GIT_BIN% echo [ERROR] git not found. Install "Git for Windows" first and put it to the PATH env var. & pause & goto :checkPrerequisites
|
||||
REM
|
||||
where /q java
|
||||
IF NOT "%ERRORLEVEL%" == "0" SET PATH=%PATH%;%JAVA_HOME%\bin
|
||||
where /q java
|
||||
IF NOT "%ERRORLEVEL%" == "0" echo [ERROR] java.exe not found on PATH env var. Download 'https://www.oracle.com/java/technologies/downloads/#java17' and run the installer & pause & goto :checkPrerequisites
|
||||
REM
|
||||
where /q python
|
||||
IF NOT "%ERRORLEVEL%" == "0" echo [ERROR] python.exe not found on PATH env var. Download 'https://www.python.org/ftp/python/3.9.6/python-3.9.6-amd64.exe' and run 'python-3.9.6-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0' & pause & goto :checkPrerequisites
|
||||
REM
|
||||
gradlew 2>&1 | find "ANDROID_SDK_ROOT" >NUL: && (echo [WARN] gradlew FAILED: Env var ANDROID_SDK_ROOT not set. Trying to run 'python install_minimum_android_sdk_prerequisites.py' ... & call python install_minimum_android_sdk_prerequisites.py)
|
||||
gradlew 2>&1 | find "ANDROID_SDK_ROOT" >NUL: && (echo [ERROR] gradlew FAILED: Env var ANDROID_SDK_ROOT not set, run 'python install_minimum_android_sdk_prerequisites.py' first. & pause & goto :checkPrerequisites)
|
||||
REM
|
||||
IF "%CLEAN_BEFORE_BUILD%" == "1" call :cleanBeforeBuild
|
||||
REM
|
||||
IF "%SKIP_CHECKOUT_SRC%" == "1" goto :afterCheckoutSrc
|
||||
REM
|
||||
echo [INFO] Fetching submodule "Syncthing" 1/2 ...
|
||||
md "%SCRIPT_PATH%syncthing\src\github.com\syncthing\syncthing" 2> NUL:
|
||||
git submodule init
|
||||
SET RESULT=%ERRORLEVEL%
|
||||
IF NOT "%RESULT%" == "0" echo [ERROR] git submodule init FAILED. & goto :eos
|
||||
REM
|
||||
echo [INFO] Fetching submodule "Syncthing" 2/2 ...
|
||||
git submodule update --init --recursive --quiet
|
||||
SET RESULT=%ERRORLEVEL%
|
||||
IF NOT "%RESULT%" == "0" echo [ERROR] git submodule update FAILED. & goto :eos
|
||||
REM
|
||||
cd /d "%SCRIPT_PATH%syncthing\src\github.com\syncthing\syncthing"
|
||||
echo [INFO] Fetching GitHub tags ...
|
||||
git fetch --quiet --all
|
||||
SET RESULT=%ERRORLEVEL%
|
||||
IF NOT "%RESULT%" == "0" echo [ERROR] git fetch FAILED. & goto :eos
|
||||
REM
|
||||
echo [INFO] Reading required SyncthingNative from build.gradle.kts ...
|
||||
IF NOT DEFINED SYNCTHING_NATIVE_REQUIRED_VERSION call :getRequiredSynchtingNativeVersion
|
||||
REM
|
||||
echo [INFO] Checking out syncthing_%SYNCTHING_NATIVE_REQUIRED_VERSION% ...
|
||||
git checkout %SYNCTHING_NATIVE_REQUIRED_VERSION% 2>&1 | find /i "HEAD is now at"
|
||||
SET RESULT=%ERRORLEVEL%
|
||||
IF NOT "%RESULT%" == "0" echo [ERROR] git checkout FAILED. & goto :eos
|
||||
REM
|
||||
:afterCheckoutSrc
|
||||
cd /d "%SCRIPT_PATH%"
|
||||
REM
|
||||
echo [INFO] Building submodule syncthing_%SYNCTHING_NATIVE_REQUIRED_VERSION% ...
|
||||
call gradlew %GRADLEW_PARAMS% buildNative
|
||||
SET RESULT=%ERRORLEVEL%
|
||||
IF NOT "%RESULT%" == "0" echo [ERROR] gradlew buildNative FAILED. & goto :eos
|
||||
REM
|
||||
echo [INFO] Reverting "go.mod", "go.sum" to checkout state ...
|
||||
cd /d "%SCRIPT_PATH%syncthing\src\github.com\syncthing\syncthing"
|
||||
git checkout -- go.mod
|
||||
git checkout -- go.sum
|
||||
cd /d "%SCRIPT_PATH%"
|
||||
REM
|
||||
echo [INFO] Checking if SyncthingNative was built successfully ...
|
||||
REM
|
||||
SET LIBCOUNT=
|
||||
for /f "tokens=*" %%A IN ('dir /s /a "%SCRIPT_PATH%app\src\main\jniLibs\*" 2^>NUL: ^| find /C "libsyncthingnative.so"') DO SET LIBCOUNT=%%A
|
||||
IF NOT "%LIBCOUNT%" == "4" echo [ERROR] SyncthingNative[s] "libsyncthingnative.so" are missing. You should fix that first. & goto :eos
|
||||
REM
|
||||
goto :eos
|
||||
|
||||
|
||||
:cleanBeforeBuild
|
||||
REM
|
||||
REM Syntax:
|
||||
REM call :cleanBeforeBuild
|
||||
REM
|
||||
echo [INFO] Performing cleanup ...
|
||||
rd /s /q "app\src\main\jniLibs" 2> NUL:
|
||||
IF NOT "%SKIP_CHECKOUT_SRC%" == "1" rd /s /q "syncthing\src\github.com\syncthing\syncthing" 2> NUL:
|
||||
REM
|
||||
goto :eof
|
||||
|
||||
|
||||
:getRequiredSynchtingNativeVersion
|
||||
REM
|
||||
REM Get "versionMajor"
|
||||
SET VERSION_MAJOR=
|
||||
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionMajor"') DO SET VERSION_MAJOR=%%A
|
||||
SET VERSION_MAJOR=%VERSION_MAJOR:"=%
|
||||
REM
|
||||
REM Get "versionMinor"
|
||||
SET VERSION_MINOR=
|
||||
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionMinor"') DO SET VERSION_MINOR=%%A
|
||||
SET VERSION_MINOR=%VERSION_MINOR:"=%
|
||||
REM
|
||||
REM Get "versionPatch"
|
||||
SET VERSION_PATCH=
|
||||
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionPatch"') DO SET VERSION_PATCH=%%A
|
||||
SET VERSION_PATCH=%VERSION_PATCH:"=%
|
||||
REM
|
||||
SET "SYNCTHING_NATIVE_REQUIRED_VERSION=v%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%"
|
||||
echo [INFO] SYNCTHING_NATIVE_REQUIRED_VERSION=[%SYNCTHING_NATIVE_REQUIRED_VERSION%]"
|
||||
REM
|
||||
goto :eof
|
||||
|
||||
|
||||
:eos
|
||||
REM
|
||||
echo [INFO] End of Script.
|
||||
REM
|
||||
pause
|
||||
goto :eof
|
||||
@ -1,14 +1,17 @@
|
||||
@echo off
|
||||
cd ..\..\..
|
||||
setlocal enabledelayedexpansion
|
||||
::
|
||||
attrib +h .git
|
||||
attrib +h .github
|
||||
attrib +h .gradle
|
||||
attrib +h .idea
|
||||
attrib +h .kotlin
|
||||
attrib +h app\build
|
||||
attrib +h build
|
||||
attrib +h syncthing\pkg
|
||||
timeout 3
|
||||
SET "SCRIPT_PATH=%~dp0"
|
||||
SET "PROJECT_ROOT=%SCRIPT_PATH%..\..\.."
|
||||
::
|
||||
attrib +h "%PROJECT_ROOT%\.git" >NUL:
|
||||
attrib +h "%PROJECT_ROOT%\.github" >NUL:
|
||||
attrib +h "%PROJECT_ROOT%\.gradle" >NUL:
|
||||
attrib +h "%PROJECT_ROOT%\.idea" >NUL:
|
||||
attrib +h "%PROJECT_ROOT%\.kotlin" >NUL:
|
||||
attrib +h "%PROJECT_ROOT%\app\build" >NUL:
|
||||
attrib +h "%PROJECT_ROOT%\build" >NUL:
|
||||
attrib +h "%PROJECT_ROOT%\syncthing\pkg" >NUL:
|
||||
attrib +h "%PROJECT_ROOT%\syncthing\src\github.com\syncthing\syncthing" >NUL:
|
||||
::
|
||||
goto :eof
|
||||
|
||||
8
scripts/debug/win/reinstall.cmd
Normal file
8
scripts/debug/win/reinstall.cmd
Normal file
@ -0,0 +1,8 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
::
|
||||
call uninstall.cmd
|
||||
::
|
||||
call update.cmd
|
||||
::
|
||||
goto :eof
|
||||
9
scripts/debug/win/restart.cmd
Normal file
9
scripts/debug/win/restart.cmd
Normal file
@ -0,0 +1,9 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
::
|
||||
SET "PACKAGE_NAME=com.github.catfriend1.syncthingandroid.debug"
|
||||
::
|
||||
adb shell am force-stop "%PACKAGE_NAME%"
|
||||
adb shell am start -n "%PACKAGE_NAME%/com.nutomic.syncthingandroid.activities.FirstStartActivity"
|
||||
::
|
||||
goto :eof
|
||||
7
scripts/debug/win/uninstall.cmd
Normal file
7
scripts/debug/win/uninstall.cmd
Normal file
@ -0,0 +1,7 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
::
|
||||
:: adb uninstall com.github.catfriend1.syncthingandroid
|
||||
adb uninstall "com.github.catfriend1.syncthingandroid.debug"
|
||||
::
|
||||
goto :eof
|
||||
11
scripts/debug/win/update.cmd
Normal file
11
scripts/debug/win/update.cmd
Normal file
@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
::
|
||||
SET "SCRIPT_PATH=%~dp0"
|
||||
SET "PROJECT_ROOT=%SCRIPT_PATH%..\..\.."
|
||||
SET "APK_FULLFN=%PROJECT_ROOT%\app\build\outputs\apk\debug\app-debug.apk"
|
||||
::
|
||||
dir "%APK_FULLFN%"
|
||||
adb install -r "%APK_FULLFN%"
|
||||
::
|
||||
goto :eof
|
||||
@ -1,153 +0,0 @@
|
||||
@echo off
|
||||
REM
|
||||
REM Purpose:
|
||||
REM Copy built APK's to match this style:
|
||||
REM [APPLICATION_ID]_v[VERSION_NAME]_[COMMIT_SHORT_HASH].apk
|
||||
REM Example:
|
||||
REM com.github.catfriend1.syncthingandroid_v1.0.0.1_7d59e75.apk
|
||||
REM
|
||||
title %~nx0
|
||||
setlocal enabledelayedexpansion
|
||||
REM
|
||||
REM Runtime variables.
|
||||
SET SCRIPT_PATH=%~dps0
|
||||
SET PACKAGE_SOURCE_CODE=1
|
||||
SET TEMP_OUTPUT_FOLDER=X:
|
||||
REM
|
||||
REM SET GIT_INSTALL_DIR=%ProgramFiles%\Git
|
||||
REM SET GIT_BIN="%GIT_INSTALL_DIR%\bin\git.exe"
|
||||
REM SET PATH=%PATH%;"%GIT_INSTALL_DIR%\bin"
|
||||
REM
|
||||
echo [INFO] *** postbuild_copy_apk BEGIN ***
|
||||
REM
|
||||
IF NOT DEFINED BUILD_FLAVOUR_GPLAY echo [ERROR] Env var BUILD_FLAVOUR_GPLAY not defined. & SET "BUILD_FLAVOUR_GPLAY=release"
|
||||
REM
|
||||
REM Get "applicationId"
|
||||
SET APPLICATION_ID=
|
||||
FOR /F "tokens=3 delims= " %%A IN ('type "%SCRIPT_PATH%app\build.gradle.kts" 2^>^&1 ^| findstr /c:"applicationId "') DO SET APPLICATION_ID=%%A
|
||||
SET APPLICATION_ID=%APPLICATION_ID:"=%
|
||||
echo [INFO] applicationId="%APPLICATION_ID%"
|
||||
REM
|
||||
REM Get "versionMajor"
|
||||
SET VERSION_MAJOR=
|
||||
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionMajor"') DO SET VERSION_MAJOR=%%A
|
||||
SET VERSION_MAJOR=%VERSION_MAJOR:"=%
|
||||
REM echo [INFO] versionMajor="%VERSION_MAJOR%"
|
||||
REM
|
||||
REM Get "versionMinor"
|
||||
SET VERSION_MINOR=
|
||||
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionMinor"') DO SET VERSION_MINOR=%%A
|
||||
SET VERSION_MINOR=%VERSION_MINOR:"=%
|
||||
REM echo [INFO] versionMinor="%VERSION_MINOR%"
|
||||
REM
|
||||
REM Get "versionPatch"
|
||||
SET VERSION_PATCH=
|
||||
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionPatch"') DO SET VERSION_PATCH=%%A
|
||||
SET VERSION_PATCH=%VERSION_PATCH:"=%
|
||||
REM echo [INFO] versionPatch="%VERSION_PATCH%"
|
||||
REM
|
||||
REM Get "versionWrapper"
|
||||
SET VERSION_WRAPPER=
|
||||
FOR /F "tokens=2 delims==) " %%A IN ('type "%SCRIPT_PATH%build.gradle.kts" 2^>^&1 ^| findstr "versionWrapper"') DO SET VERSION_WRAPPER=%%A
|
||||
SET VERSION_WRAPPER=%VERSION_WRAPPER:"=%
|
||||
REM echo [INFO] versionWrapper="%VERSION_WRAPPER%"
|
||||
REM
|
||||
SET VERSION_NAME=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%.%VERSION_WRAPPER%
|
||||
REM
|
||||
REM Get short hash of last commit.
|
||||
REM IF NOT EXIST %GIT_BIN% echo [ERROR] git.exe not found. & pause & goto :eof
|
||||
pushd %SCRIPT_PATH%
|
||||
SET COMMIT_LONG_HASH=
|
||||
FOR /F "tokens=1" %%A IN ('git rev-parse --verify HEAD 2^>NUL:') DO SET COMMIT_LONG_HASH=%%A
|
||||
REM
|
||||
SET COMMIT_SHORT_HASH=
|
||||
FOR /F "tokens=1" %%A IN ('git rev-parse --short --verify HEAD 2^>NUL:') DO SET COMMIT_SHORT_HASH=%%A
|
||||
popd
|
||||
echo [INFO] VERSION_NAME=[%VERSION_NAME%], commit=[%COMMIT_SHORT_HASH%]=[%COMMIT_LONG_HASH%].
|
||||
echo [INFO] Copying APK to same directory ...
|
||||
REM
|
||||
REM Copy APK to be ready for upload to the GitHub release page.
|
||||
SET APK_RELEASE_NEW_FILENAME=%APPLICATION_ID%_github_v%VERSION_NAME%_%COMMIT_SHORT_HASH%.apk
|
||||
call :copyIfExist %SCRIPT_PATH%app\build\outputs\apk\release\app-release.apk %SCRIPT_PATH%app\build\outputs\apk\release\%APK_RELEASE_NEW_FILENAME%
|
||||
REM
|
||||
SET APK_GPLAY_NEW_FILENAME=%APPLICATION_ID%_gplay_v%VERSION_NAME%_%COMMIT_SHORT_HASH%.apk
|
||||
IF NOT "%SKIP_RELEASE_BUILD%" == "1" call :copyIfExist %SCRIPT_PATH%app\build\outputs\apk\%BUILD_FLAVOUR_GPLAY%\app-%BUILD_FLAVOUR_GPLAY%.apk %SCRIPT_PATH%app\build\outputs\apk\%BUILD_FLAVOUR_GPLAY%\%APK_GPLAY_NEW_FILENAME%
|
||||
REM
|
||||
REM Copy both APK to temporary storage location if the storage is available.
|
||||
IF EXIST %TEMP_OUTPUT_FOLDER%\ (
|
||||
echo [INFO] Copying APK to [%TEMP_OUTPUT_FOLDER%] ...
|
||||
copy /y %SCRIPT_PATH%app\build\outputs\apk\release\%APK_RELEASE_NEW_FILENAME% %TEMP_OUTPUT_FOLDER%\ 2> NUL:
|
||||
IF NOT "%SKIP_RELEASE_BUILD%" == "1" copy /y %SCRIPT_PATH%app\build\outputs\apk\%BUILD_FLAVOUR_GPLAY%\%APK_GPLAY_NEW_FILENAME% %TEMP_OUTPUT_FOLDER%\ 2> NUL:
|
||||
)
|
||||
REM
|
||||
IF "%PACKAGE_SOURCE_CODE%" == "1" call :packageSourceCode
|
||||
REM
|
||||
echo [INFO] *** postbuild_copy_apk END ***
|
||||
REM timeout 3
|
||||
goto :eof
|
||||
|
||||
|
||||
:copyIfExist
|
||||
REM
|
||||
REM Syntax:
|
||||
REM call :copyIfExist [FULL_FN_ORIGINAL] [FILENAME_COPY_TARGET]
|
||||
REM IF EXIST %1 REN %1 %2 & goto :eof
|
||||
IF EXIST %1 copy /y %1 %2 & goto :eof
|
||||
echo [INFO] File not found: %1
|
||||
REM
|
||||
goto :eof
|
||||
|
||||
|
||||
:getFileSize
|
||||
REM
|
||||
REM Get file size to variable defined in parameter #2.
|
||||
SET %~2=%~z1
|
||||
REM
|
||||
goto :eof
|
||||
|
||||
|
||||
:packageSourceCode
|
||||
REM
|
||||
REM Syntax:
|
||||
REM call :packageSourceCode
|
||||
REM
|
||||
REM Global variables.
|
||||
REM [IN] COMMIT_LONG_HASH
|
||||
REM [IN] COMMIT_SHORT_HASH
|
||||
REM [IN] TEMP_OUTPUT_FOLDER
|
||||
REM [IN] VERSION_NAME
|
||||
REM
|
||||
REM Variables.
|
||||
SET TMP_DSC_ZIPFILE_FULLFN="%TEMP_OUTPUT_FOLDER%\%DATE:~-4%-%DATE:~-7,-5%-%DATE:~-10,-8%_com.github.catfriend1.syncthingandroid_v%VERSION_NAME%_%COMMIT_SHORT_HASH%.zip"
|
||||
SET TMP_DSC_SEVENZIP_EXE="%ProgramFiles%\7-Zip\7z.exe"
|
||||
REM
|
||||
REM Check prerequisites.
|
||||
where curl 1> NUL: 2>&1 || (echo [ERROR] curl not found on PATH. & goto :eof)
|
||||
IF NOT EXIST %TEMP_OUTPUT_FOLDER%\ echo [ERROR] TEMP_OUTPUT_FOLDER=[%TEMP_OUTPUT_FOLDER%] not found. & goto :eof
|
||||
IF NOT EXIST %TMP_DSC_SEVENZIP_EXE% echo [ERROR] TMP_DSC_SEVENZIP_EXE=[%TMP_DSC_SEVENZIP_EXE%] not found. & goto :eof
|
||||
REM
|
||||
REM Download source code for current build commit as ZIP.
|
||||
:packageSourceCodeRetry
|
||||
echo [INFO] Downloading source code ZIP from GitHub ...
|
||||
curl -s -k -L -o %TMP_DSC_ZIPFILE_FULLFN% "https://github.com/Catfriend1/syncthing-android/archive/%COMMIT_LONG_HASH%.zip"
|
||||
IF NOT EXIST %TMP_DSC_ZIPFILE_FULLFN% echo [ERROR] Download source code FAILED #1. & pause & goto :eof
|
||||
call :getFileSize %TMP_DSC_ZIPFILE_FULLFN% FILE_SIZE
|
||||
IF "%FILE_SIZE%" == "" echo [ERROR] Download source code FAILED #2. & pause & goto :eof
|
||||
IF %FILE_SIZE% LSS 23 echo [ERROR] Download source code FAILED #3. & DEL /F %TMP_DSC_ZIPFILE_FULLFN% & pause & goto :packageSourceCodeRetry
|
||||
REM
|
||||
REM Package built APKs into ZIP.
|
||||
echo [INFO] Adding built APKs to source code ZIP ...
|
||||
%TMP_DSC_SEVENZIP_EXE% -y -bso0 a %TMP_DSC_ZIPFILE_FULLFN% %TEMP_OUTPUT_FOLDER%\%APK_RELEASE_NEW_FILENAME%
|
||||
IF NOT "%SKIP_RELEASE_BUILD%" == "1" %TMP_DSC_SEVENZIP_EXE% -y -bso0 a %TMP_DSC_ZIPFILE_FULLFN% %TEMP_OUTPUT_FOLDER%\%APK_GPLAY_NEW_FILENAME%
|
||||
REM
|
||||
goto :eof
|
||||
|
||||
|
||||
:renIfExist
|
||||
REM
|
||||
REM Syntax:
|
||||
REM call :renIfExist [FULL_FN_ORIGINAL] [FILENAME_RENAMED]
|
||||
IF EXIST %1 REN %1 %2 & goto :eof
|
||||
echo [INFO] File not found: %1
|
||||
REM
|
||||
goto :eof
|
||||
@ -1,15 +1,17 @@
|
||||
#
|
||||
$stringToDelete = Read-Host "Please enter string to remove containing rows in xml files"
|
||||
$basePath = ($PSScriptRoot + "\..\app\src\main\res")
|
||||
#
|
||||
Get-ChildItem -Path $basePath -Recurse -Filter *.xml | ForEach-Object {
|
||||
$file = $_.FullName
|
||||
$lines = Get-Content $file
|
||||
$filteredLines = $lines | Where-Object { $_ -notmatch [regex]::Escape($stringToDelete) }
|
||||
if ($lines.Count -ne $filteredLines.Count) {
|
||||
Set-Content -Path $file -Value $filteredLines
|
||||
Write-Host "Processed: $file"
|
||||
}
|
||||
while ($true) {
|
||||
$stringToDelete = Read-Host "Please enter string to remove containing rows in xml files"
|
||||
$basePath = ($PSScriptRoot + "\..\app\src\main\res")
|
||||
#
|
||||
Get-ChildItem -Path $basePath -Recurse -Filter strings.xml | ForEach-Object {
|
||||
$file = $_.FullName
|
||||
$lines = Get-Content $file
|
||||
$filteredLines = $lines | Where-Object { $_ -notmatch [regex]::Escape($stringToDelete) }
|
||||
if ($lines.Count -ne $filteredLines.Count) {
|
||||
Set-Content -Path $file -Value $filteredLines
|
||||
Write-Host "Processed: $file"
|
||||
}
|
||||
}
|
||||
}
|
||||
#
|
||||
Exit 0
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
@echo off
|
||||
cls
|
||||
REM
|
||||
RD /S /Q "%~dps0..\app\src\main\jniLibs"
|
||||
REM
|
||||
echo Done.
|
||||
timeout 2
|
||||
Loading…
Reference in New Issue
Block a user