Skip to content

Commit

Permalink
added windows script, needs work
Browse files Browse the repository at this point in the history
  • Loading branch information
chanonly123 committed Feb 3, 2025
1 parent 2a36036 commit 3d0b0d2
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
[![](https://markdown-videos-api.jorgenkh.no/youtube/3ZiBKfGdLjs)](https://youtu.be/3ZiBKfGdLjs)

### Requirements
- Macos
- JUCE directory in `/Users/<username>/JUCE/` (JUCE VERSION 8.0.2 [download](https://juce.com/download/))
- Xcode `xcodebuild -version`
- Cocoapods (`brew install cocoapods`). `pod --version` should work.
- Gradle (`brew install gradle`) `gradle --version` should work.
- Android Studio (for Android)
- JUCE directory in `/Users/<username>/JUCE/` or `C:\JUCE\` (JUCE VERSION 8.0.2 [download](https://juce.com/download/))
- Xcode `xcodebuild -version` (for iOS)
- Cocoapods (`brew install cocoapods`). `pod --version` should work. (for iOS)
- Gradle (`brew install gradle`) `gradle --version` should work. (for Android)
- `flutter` and `dart` (to generate cpp to dart bindings)

### Regenerate Projucer generated projects
- open `juce_lib/juce_lib.jucer` using Projucer and hit (command+P to regenerate)
Expand Down
86 changes: 86 additions & 0 deletions win_android_build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,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

0 comments on commit 3d0b0d2

Please sign in to comment.