Windows support included

This commit is contained in:
Eric Ratliff
2026-01-21 08:00:25 -06:00
parent 81452a8670
commit 63827dba58
15 changed files with 1342 additions and 0 deletions

160
ftc-new-project.bat Normal file
View File

@@ -0,0 +1,160 @@
@echo off
REM FTC Project Generator for Windows
REM Copyright (c) 2026 Nexus Workshops LLC
REM Licensed under MIT License
setlocal enabledelayedexpansion
REM Set default values
set "DEFAULT_FTC_VERSION=v10.1.1"
set "FTC_VERSION=%DEFAULT_FTC_VERSION%"
if not defined FTC_SDK_DIR set "FTC_SDK_DIR=%USERPROFILE%\ftc-sdk"
REM Get script directory
set "SCRIPT_DIR=%~dp0"
set "WINDOWS_DIR=%SCRIPT_DIR%windows"
REM Parse command line arguments
set "PROJECT_NAME="
set "SHOW_HELP=0"
:parse_args
if "%~1"=="" goto args_done
if /i "%~1"=="-h" set "SHOW_HELP=1" & goto next_arg
if /i "%~1"=="--help" set "SHOW_HELP=1" & goto next_arg
if /i "%~1"=="-v" set "FTC_VERSION=%~2" & shift & goto next_arg
if /i "%~1"=="--version" set "FTC_VERSION=%~2" & shift & goto next_arg
if /i "%~1"=="-d" set "FTC_SDK_DIR=%~2" & shift & goto next_arg
if /i "%~1"=="--sdk-dir" set "FTC_SDK_DIR=%~2" & shift & goto next_arg
if "%PROJECT_NAME%"=="" set "PROJECT_NAME=%~1"
:next_arg
shift
goto parse_args
:args_done
REM Show help if requested
if %SHOW_HELP%==1 (
call "%WINDOWS_DIR%\show-usage.bat"
exit /b 0
)
REM Validate project name
if "%PROJECT_NAME%"=="" (
echo Error: Project name required
echo Usage: %~nx0 ^<project-name^> [options]
echo Run '%~nx0 --help' for more info
exit /b 1
)
set "PROJECT_DIR=%CD%\%PROJECT_NAME%"
echo ============================================
echo FTC Project Generator
echo ============================================
echo Project: %PROJECT_NAME%
echo SDK Dir: %FTC_SDK_DIR%
echo SDK Version: %FTC_VERSION%
echo Target: %PROJECT_DIR%
echo.
REM Step 1: Check/setup FTC SDK
echo ^>^>^> Checking FTC SDK...
if exist "%FTC_SDK_DIR%" (
echo SDK directory exists, checking version...
cd /d "%FTC_SDK_DIR%"
if exist ".git" (
REM Check current version
for /f "delims=" %%i in ('git describe --tags --exact-match 2^>nul') do set "CURRENT_TAG=%%i"
if "!CURRENT_TAG!"=="" set "CURRENT_TAG=none"
if "!CURRENT_TAG!"=="%FTC_VERSION%" (
echo + SDK already at version %FTC_VERSION%
) else (
echo Current version: !CURRENT_TAG!
echo Fetching and checking out %FTC_VERSION%...
git fetch --tags
git checkout "%FTC_VERSION%"
if errorlevel 1 (
echo Error: Failed to checkout version %FTC_VERSION%
exit /b 1
)
echo + Updated to %FTC_VERSION%
)
) else (
echo Warning: SDK directory exists but is not a git repo
echo Using existing directory anyway...
)
) else (
echo Cloning FTC SDK %FTC_VERSION%...
echo This will take a minute (SDK is ~200MB)...
git clone --depth 1 --branch "%FTC_VERSION%" https://github.com/FIRST-Tech-Challenge/FtcRobotController.git "%FTC_SDK_DIR%"
if errorlevel 1 (
echo Error: Failed to clone FTC SDK
echo Check your internet connection or try a different version tag
exit /b 1
)
echo + Cloned FTC SDK %FTC_VERSION% to %FTC_SDK_DIR%
)
REM Step 2: Create project structure
echo.
echo ^>^>^> Creating project: %PROJECT_NAME%
if exist "%PROJECT_DIR%" (
echo Error: Project directory already exists: %PROJECT_DIR%
exit /b 1
)
mkdir "%PROJECT_DIR%"
cd /d "%PROJECT_DIR%"
REM Create directory structure
mkdir src\main\java\robot\subsystems 2>nul
mkdir src\main\java\robot\hardware 2>nul
mkdir src\main\java\robot\opmodes 2>nul
mkdir src\test\java\robot\subsystems 2>nul
mkdir src\test\java\robot\hardware 2>nul
REM Step 3: Generate build files
echo Generating build configuration...
call "%WINDOWS_DIR%\generate-build-gradle.bat" "%PROJECT_DIR%"
call "%WINDOWS_DIR%\generate-settings-gradle.bat" "%PROJECT_DIR%" "%FTC_SDK_DIR%"
REM Step 4: Create Gradle wrapper files
echo Setting up Gradle wrapper...
call "%WINDOWS_DIR%\create-gradle-wrapper.bat" "%PROJECT_DIR%"
REM Step 5: Generate source files
echo Generating example source files...
call "%WINDOWS_DIR%\generate-pose2d.bat" "%PROJECT_DIR%"
call "%WINDOWS_DIR%\generate-drive-subsystem.bat" "%PROJECT_DIR%"
call "%WINDOWS_DIR%\generate-mecanum-drive.bat" "%PROJECT_DIR%"
call "%WINDOWS_DIR%\generate-teleop.bat" "%PROJECT_DIR%"
call "%WINDOWS_DIR%\generate-drive-test.bat" "%PROJECT_DIR%"
REM Step 6: Generate helper scripts
echo Creating helper scripts...
call "%WINDOWS_DIR%\generate-build-script.bat" "%PROJECT_DIR%"
call "%WINDOWS_DIR%\generate-deploy-script.bat" "%PROJECT_DIR%"
REM Step 7: Create project files
echo Creating project files...
call "%WINDOWS_DIR%\generate-gitignore.bat" "%PROJECT_DIR%"
call "%WINDOWS_DIR%\generate-readme.bat" "%PROJECT_DIR%" "%PROJECT_NAME%"
REM Step 8: Initialize Git repository
echo.
echo ^>^>^> Initializing Git repository...
git init >nul 2>&1
git add . >nul 2>&1
git commit -m "Initial commit from FTC Project Generator" >nul 2>&1
echo + Git repository initialized
REM Final success message
call "%WINDOWS_DIR%\show-success.bat" "%PROJECT_NAME%" "%PROJECT_DIR%" "%FTC_SDK_DIR%" "%FTC_VERSION%"
endlocal
exit /b 0