-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwin_android_build.bat
86 lines (72 loc) · 2.13 KB
/
win_android_build.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
@echo off
setlocal enabledelayedexpansion
:: Set variables
set libname=juce_lib
set flutter_app=flutter_app
set flutter_wrapper_package=juce_mix_player_package
:: Check for options
if "%1"=="-debug" (
set debug=true
) else if "%1"=="-release" (
set debug=false
) else (
echo Usage: command -debug/release -clean
exit /b 1
)
:: Get the root directory
set root_dir=%cd%
:: Generate Dart files from native header
:: Check if flutter is installed and available
where flutter >nul 2>nul
if %errorlevel% neq 0 (
echo 🔴 Flutter command not found! Please install Flutter and ensure it is in your PATH.
) else (
cd %flutter_wrapper_package%
flutter pub get
dart run ffigen
)
:: Go to the Gradle project
cd %root_dir%
cd %libname%\Builds\Android\lib
:: Clean build directory
if "%2"=="-clean" (
echo ✅ cleaning build directory
gradle clean
rmdir /s /q build
) else (
echo ✅ using cached build directory
)
:: Convert to SHARED library for Android (not working)
powershell -Command "(Get-Content CMakeLists.txt) -replace '^STATIC$', 'SHARED' | Set-Content CMakeLists_new.txt"
move /y CMakeLists_new.txt CMakeLists.txt
:: Gradle build
if %debug%==true (
gradle assembleDebug --debug
) else (
gradle assembleRelease
)
echo ✅ Build Success [debug %debug%] ✅
:: Return to root directory
cd %root_dir%
:: Find build output directory
if %debug%==true (
for /f "delims=" %%i in ('dir /s /b *\%libname%\*\cxx\Debug\*\obj') do set libDirectory=%%i
) else (
for /f "delims=" %%i in ('dir /s /b *\%libname%\*\stripped_native_libs\release_Release\*\lib') do set libDirectory=%%i
)
if not defined libDirectory (
echo 🔴 build output binary directory not found!
exit /b 1
) else (
echo ✅ build directory found [%libDirectory%]
)
:: Copy to flutter project
if exist "%flutter_app%\android\app\src\main" (
rmdir /s /q "%flutter_app%\android\app\src\main\jniLibs"
xcopy /e /i /h /y %libDirectory% "%flutter_app%\android\app\src\main\jniLibs\"
echo ✅ Copy to [%flutter_app%] project Success ✅
) else (
echo 🔴 [%flutter_app%\android\app\src\main] not found
exit /b 1
)
endlocal