sevenx_engine 0.2.11

Engine de jogos 2D/3D completa com suporte Android, física, áudio, partículas, tilemap, UI, eventos e sistema 3D avançado com PBR.
Documentation
# Script de Build Android Completo - SevenX Engine
# Automatiza todo o processo de build para Android

Write-Host "🤖 SevenX Engine - Build Android Completo" -ForegroundColor Cyan
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host ""

# Verifica se cargo-apk está instalado
Write-Host "📦 Verificando cargo-apk..." -ForegroundColor Yellow
if (!(Get-Command cargo-apk -ErrorAction SilentlyContinue)) {
    Write-Host "❌ cargo-apk não encontrado!" -ForegroundColor Red
    Write-Host "Instalando cargo-apk..." -ForegroundColor Yellow
    cargo install cargo-apk
    
    if ($LASTEXITCODE -ne 0) {
        Write-Host "❌ Falha ao instalar cargo-apk" -ForegroundColor Red
        exit 1
    }
}
Write-Host "✅ cargo-apk encontrado" -ForegroundColor Green
Write-Host ""

# Verifica targets Android
Write-Host "🎯 Verificando targets Android..." -ForegroundColor Yellow
$targets = @("aarch64-linux-android", "armv7-linux-androideabi")

foreach ($target in $targets) {
    $installed = rustup target list --installed | Select-String $target
    if (!$installed) {
        Write-Host "Instalando target $target..." -ForegroundColor Yellow
        rustup target add $target
        
        if ($LASTEXITCODE -ne 0) {
            Write-Host "❌ Falha ao instalar target $target" -ForegroundColor Red
            exit 1
        }
    }
    Write-Host "✅ Target $target instalado" -ForegroundColor Green
}
Write-Host ""

# Verifica NDK
Write-Host "🔧 Verificando Android NDK..." -ForegroundColor Yellow
if (!$env:ANDROID_NDK_ROOT) {
    Write-Host "⚠️  ANDROID_NDK_ROOT não configurado" -ForegroundColor Yellow
    Write-Host "Tentando detectar NDK automaticamente..." -ForegroundColor Yellow
    
    $possiblePaths = @(
        "$env:ANDROID_HOME\ndk",
        "$env:LOCALAPPDATA\Android\Sdk\ndk",
        "C:\Android\sdk\ndk"
    )
    
    foreach ($path in $possiblePaths) {
        if (Test-Path $path) {
            $ndkVersions = Get-ChildItem $path -Directory | Sort-Object Name -Descending
            if ($ndkVersions.Count -gt 0) {
                $env:ANDROID_NDK_ROOT = $ndkVersions[0].FullName
                Write-Host "✅ NDK encontrado: $env:ANDROID_NDK_ROOT" -ForegroundColor Green
                break
            }
        }
    }
    
    if (!$env:ANDROID_NDK_ROOT) {
        Write-Host "❌ NDK não encontrado!" -ForegroundColor Red
        Write-Host "Por favor, instale o Android NDK e configure ANDROID_NDK_ROOT" -ForegroundColor Red
        exit 1
    }
} else {
    Write-Host "✅ NDK configurado: $env:ANDROID_NDK_ROOT" -ForegroundColor Green
}
Write-Host ""

# Menu de opções
Write-Host "📱 Escolha o que deseja buildar:" -ForegroundColor Cyan
Write-Host "1. android_test (exemplo básico)" -ForegroundColor White
Write-Host "2. android_complete (demo completa)" -ForegroundColor White
Write-Host "3. Ambos" -ForegroundColor White
Write-Host "4. Apenas verificar configuração" -ForegroundColor White
Write-Host ""

$choice = Read-Host "Digite sua escolha (1-4)"

function Build-AndroidExample {
    param (
        [string]$ExampleName,
        [string]$DisplayName
    )
    
    Write-Host ""
    Write-Host "🔨 Buildando $DisplayName..." -ForegroundColor Cyan
    Write-Host "=========================================" -ForegroundColor Cyan
    
    # Build para ARM64 (dispositivos modernos)
    Write-Host "📱 Build ARM64..." -ForegroundColor Yellow
    cargo apk build --example $ExampleName --target aarch64-linux-android --release
    
    if ($LASTEXITCODE -eq 0) {
        Write-Host "✅ Build ARM64 concluído!" -ForegroundColor Green
    } else {
        Write-Host "❌ Falha no build ARM64" -ForegroundColor Red
        return $false
    }
    
    # Build para ARMv7 (dispositivos antigos)
    Write-Host "📱 Build ARMv7..." -ForegroundColor Yellow
    cargo apk build --example $ExampleName --target armv7-linux-androideabi --release
    
    if ($LASTEXITCODE -eq 0) {
        Write-Host "✅ Build ARMv7 concluído!" -ForegroundColor Green
    } else {
        Write-Host "⚠️  Build ARMv7 falhou (opcional)" -ForegroundColor Yellow
    }
    
    Write-Host ""
    Write-Host "📦 APKs gerados:" -ForegroundColor Green
    Write-Host "  ARM64: target\aarch64-linux-android\release\examples\$ExampleName.apk" -ForegroundColor White
    Write-Host "  ARMv7: target\armv7-linux-androideabi\release\examples\$ExampleName.apk" -ForegroundColor White
    
    return $true
}

switch ($choice) {
    "1" {
        Build-AndroidExample "android_test" "Android Test"
    }
    "2" {
        Build-AndroidExample "android_complete" "Android Complete Demo"
    }
    "3" {
        $success1 = Build-AndroidExample "android_test" "Android Test"
        $success2 = Build-AndroidExample "android_complete" "Android Complete Demo"
        
        if ($success1 -and $success2) {
            Write-Host ""
            Write-Host "🎉 Todos os builds concluídos com sucesso!" -ForegroundColor Green
        }
    }
    "4" {
        Write-Host ""
        Write-Host "✅ Configuração verificada com sucesso!" -ForegroundColor Green
        Write-Host "Você está pronto para buildar para Android!" -ForegroundColor Green
    }
    default {
        Write-Host "❌ Opção inválida!" -ForegroundColor Red
        exit 1
    }
}

Write-Host ""
Write-Host "=========================================" -ForegroundColor Cyan
Write-Host "📱 Como instalar no dispositivo:" -ForegroundColor Cyan
Write-Host ""
Write-Host "1. Conecte seu dispositivo Android via USB" -ForegroundColor White
Write-Host "2. Ative 'Depuração USB' nas opções de desenvolvedor" -ForegroundColor White
Write-Host "3. Execute:" -ForegroundColor White
Write-Host "   adb install target\aarch64-linux-android\release\examples\android_test.apk" -ForegroundColor Yellow
Write-Host ""
Write-Host "Ou use:" -ForegroundColor White
Write-Host "   cargo apk run --example android_test --target aarch64-linux-android" -ForegroundColor Yellow
Write-Host ""
Write-Host "✅ Build Android completo!" -ForegroundColor Green