diff --git a/.gitignore b/.gitignore index 6949ecb..6d0c09b 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ FRCUserProgram #CTRE CTRE/ + +#Other binaries +bin/* diff --git a/Makefile.win b/Makefile.win new file mode 100644 index 0000000..cbd964e --- /dev/null +++ b/Makefile.win @@ -0,0 +1,14 @@ +all: + start batch\build.bat + +deploy: + start batch\deploy.bat + +update: + del CTRE /Q + del wpilib /Q + start batch\.get-ctre.bat + start batch\.wpilib-download.bat + +clean: + del .build\cmake_install.cmake .build\CMakeCache.txt .build\FRCUserProgram .build\Makefile /Q diff --git a/README.md b/README.md index f3c9a8b..cba67ef 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,13 @@ Status: Operational! (Report bugs as Issues) ### Instructions -1. Download source code and add files to your repository +1. Install system dependencies -1. Write code in src/ +1. Download the zip package (located in releases) + +1. Add code to a new folder called src + +1. (Windows only) Add the binaries folder to your System PATH ## Dependencies @@ -20,23 +24,33 @@ General: * CMake - * FRC Toolchain + * FRC C++ Toolchain + +Cygwin: + + * cmake + + * make + + * unzip + + * wget + + * openssh Windows: - * Cygwin - cmake, make, unzip, wget, openssh + * NMake (Visual Studio) ## User guide -### Linux +### Linux/Cygwin How to build code: -1. Open a terminal and `cd` into your code base - -1. Make sure the code you want to compile is in src/ and `.build.sh` and `Makefile` are in the directory above src/ +1. Make sure the code you want to compile is in src/ and the `Makefile` is in the directory above src/ -1. Type `make`into the terminal +1. Type `make` into the terminal How to deploy code: @@ -52,39 +66,32 @@ How to deploy code: 1. Write your team number in the TEAM_NAME file. Make sure it is only one line and contains no extra spaces. -After this is done, simply type `make deploy`to deploy +After this is done, simply type `make deploy` to deploy ### Windows How to build code: -1. Open Cygwin and type `cd c:/` - -1. Use `ls` to list your directory and `cd` to find the directory your code base is in +1. Make sure the code you want to compile is in src/ and the `Makefile` are in the directory above src/ -1. Make sure the code you want to compile is in src/ and `.build.sh` and `Makefile` are in the directory above src/ - -1. Type `make`into Cygwin +1. Type `nmake /F Makefile.win` into cmd How to deploy code: -**FIRST TIME ONLY** - -1. Type `ssh-keygen -t rsa` into the terminal - -1. Enter file in which to save the key (/home/demo/.ssh/id_rsa): `roborio` - -1. Enter passphrase (empty for no passphrase): [leave blank] - -1. After the output, connect to the robot and type `ssh-copy-id -i roborio lvuser@roborio-[TEAM]-frc.local`. Be sure to replace [TEAM] with your number - -1. Write your team number in the TEAM_NAME file. Make sure it is only one line and contains no extra spaces. - -After this is done, simply type `make deploy`to deploy +1. type `nmake /F Makefile.win deploy` ### Commands +**Linux/Cygwin** + make - build code make update - manually update WPILib make clean - clean output files make deploy - deploy to robot + +**Windows** + + nmake /F Makefile.win - build code + nmake /F Makefile.win update - manually update WPILib + nmake /F Makefile.win clean - manually update WPILib + nmake /F Makefile.win deploy - deploy to robot diff --git a/batch/.compiler-download.bat b/batch/.compiler-download.bat new file mode 100644 index 0000000..d8dd5c7 --- /dev/null +++ b/batch/.compiler-download.bat @@ -0,0 +1,22 @@ +@echo off + +REM Doesn't actually download compiler because on windows its a nice installer already. + +for %%x in (arm-frc-linux-gnueabi-g++.exe) do (SET FOUND=%%~$PATH:x) +if defined FOUND ( + ECHO ^.compiler-download.bat: Valid FRC Compiler found in PATH! + GOTO end +) else ( + GOTO no-compiler +) + +:no-compiler +ECHO ^.compiler-download.bat: Valid FRC Compiler not found in PATH! +ECHO ^.compiler-download.bat: Please download the FRC Compiler from: http://first.wpi.edu/FRC/roborio/toolchains/ +ECHO. 1>Error.txt +GOTO end + +ECHO .compiler-download.bat: Exiting... +GOTO end + +:end diff --git a/batch/.get-ctre.bat b/batch/.get-ctre.bat new file mode 100644 index 0000000..085c3f4 --- /dev/null +++ b/batch/.get-ctre.bat @@ -0,0 +1,43 @@ +@echo off + +ECHO ^.get-ctre^.bat: Downloading CTRE^.^.^. + +if defined ProgramFiles(x86) ( + for %%x in (wget64.exe) do (SET WGET=%%~$PATH:x) + if defined WGET ( + wget64.exe -r -nd --progress=bar http://www.ctr-electronics.com//downloads/lib/CTRE_FRCLibs_NON-WINDOWS.zip + GOTO get-ctre + ) else ( + ECHO ^.get-ctre^.bat: Please download wget64 and add it to the PATH + GOTO error + ) +) else ( + REM assuming 32 bit + for %%x in (wget.exe) do (SET WGET=%%~$PATH:x) + if defined WGET ( + wget.exe -r -nd --progress=bar http://www.ctr-electronics.com//downloads/lib/CTRE_FRCLibs_NON-WINDOWS.zip + GOTO get-ctre + ) else ( + ECHO ^.get-ctre^.bat: Please download wget ^(32 bit^)^. Add it to the PATH + GOTO error + ) +) + +REM if there was no error, unzip +REM lol downloading the non-windows even though this is windows +:get-ctre +mkdir ctre_full +CD ctre_full +unzip ..\CTRE_FRCLibs_NON-WINDOWS.zip +ECHO ^.get-ctre^.bat: Cleaning up^.^.^. +CD .. +ECHO D | xcopy ctre_full\cpp CTRE /s/e +rmdir ctre_full\ /S /Q +del CTRE_FRCLibs_NON-WINDOWS^.zip /Q +GOTO end + +:error +ECHO. 1>CTRE^.txt +GOTO end + +:end diff --git a/batch/.wpilib-download.bat b/batch/.wpilib-download.bat new file mode 100644 index 0000000..553174d --- /dev/null +++ b/batch/.wpilib-download.bat @@ -0,0 +1,47 @@ +@echo off + +REM This scripts downloads the latest version of wpilib. +REM It does not check for the latest version +REM To ensure the installation of the latest version, run nmake -f Makefile.win update + +if defined ProgramFiles(x86) ( + for %%x in (wget64.exe) do (SET WGET=%%~$PATH:x) + if defined WGET ( + wget64.exe http://first.wpi.edu/FRC/roborio/release/eclipse/plugins/edu.wpi.first.wpilib.plugins.cpp_2017.1.1.jar + GOTO wpilib-download + ) else ( + ECHO ^.wpilib-download^.bat: Please download wget64^. Add it to the PATH + GOTO error + ) +) else ( + REM assuming 32 bit + for %%x in (wget.exe) do (SET WGET=%%~$PATH:x) + if defined WGET ( + wget.exe http://first.wpi.edu/FRC/roborio/release/eclipse/plugins/edu.wpi.first.wpilib.plugins.cpp_2017.1.1.jar + GOTO wpilib-download + ) else ( + ECHO ^.wpilib-download.bat: Please download wget ^(32 bit^)^. Add it to the PATH + GOTO error + ) +) + +REM if there was no error, unzip +:wpilib-download +mkdir wpilib +CD wpilib +unzip ..\edu.wpi.first.wpilib.plugins.cpp_2017.1.1.jar +rmdir edu /S /Q +rmdir META-INF /S /Q +rmdir plugin.xml /S /Q +unzip resources\cpp.zip +ECHO ^.wpilib-download.bat: Cleaning up... +rmdir resources\ /S /Q +CD .. +del edu.wpi.first.wpilib.plugins.cpp_2017.1.1.jar +GOTO end + +:error +ECHO. 1>wpilib.txt +GOTO end + +:end diff --git a/batch/build.bat b/batch/build.bat new file mode 100644 index 0000000..e19ec76 --- /dev/null +++ b/batch/build.bat @@ -0,0 +1,64 @@ +call batch\.compiler-download.bat + +REM Exit if FRC C++ Toolchain not found +if exist Error.txt ( + ECHO batch\build.bat: Compiler not found + ECHO batch\build.bat: Exiting... + del Error.txt /Q + GOTO error +) + +ECHO build.bat: Checking internet... + +Ping www.google.com -n 2 -w 1000 +if errorlevel 1 ( + ECHO build.bat: Offline +) else ( + ECHO build.bat: Online + if not exist CTRE call batch\.get-ctre.bat + if exist CTRE.txt ( + del CTRE.txt /Q + GOTO error + ) + if not exist wpilib call batch\.wpilib-download.bat + if exist wpilib.txt ( + del wpilib.txt /Q + GOTO error + ) + REM exit early if unable to get required materials +) + +CD .build + +del CMakeCache.txt cmake_install.cmake Makefile +rmdir CMakeFiles\ /S /Q + +ECHO build.bat: Generating Makefiles... +cmake .. -G "NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=arm.cmake -DCMAKE_TOOLCHAIN_FILE=robot.cmake + +nmake + +ECHO build.bat: Deleting CMakeFiles... +rmdir CMakeFiles\ /S /Q + +ECHO build.sh: Re-naming outfile... +if exist FRCUserProgram del FRCUserProgram /Q +move FRC FRCUserProgram + +if exist FRCUserProgram ( + ECHO Build successfully! + CD .. + PAUSE + GOTO end +) else ( + ECHO Build failed! + CD .. + PAUSE + GOTO error +) + +:end +EXIT + +:error +EXIT /b 1 diff --git a/batch/deploy.bat b/batch/deploy.bat new file mode 100644 index 0000000..11e418a --- /dev/null +++ b/batch/deploy.bat @@ -0,0 +1,31 @@ +@echo off + +if exist .build\FRCUserProgram ( + ECHO deploy.bat: Deploying robot code... + GOTO checkwinscp +) else ( + ECHO deploy.bat: Valid FRCUserProgram not found! + GOTO noscp +) + +:checkwinscp +for %%x in (winscp.exe) do (SET WINSCP=%%~$PATH:x) +if defined WINSCP GOTO deploy + +:deploy +ECHO Enter roborio ip address +SET /p ADDRESS=Usually roborio-TEAM-frc.local, 10.TE.AM.X, or 172.22.11.2 for Static USB: +winscp lvuser@%ADDRESS% /upload .build\FRCUserProgram +ECHO deploy.bat: deployed successfully! +PAUSE +GOTO end + +:noscp +REM only runs if winscp isn't found in the path +ECHO .deploy.bat: It looks like WinSCP has not been added to your PATH +ECHO .deploy.bat: Deploying to the robot from FRC++ Build Tools requires WinSCP +ECHO .deploy.bat: If you do not have the intention of deploying using WinSCP, simply copy FRCUserProgram in the .build folder to /home/lvuser on the roborio with your method of choice. +GOTO end + +:end +EXIT diff --git a/script/build.sh b/script/build.sh index a56a4a2..f9a9c98 100755 --- a/script/build.sh +++ b/script/build.sh @@ -74,7 +74,7 @@ fi # Delete cmake files to keep Eclipse working echo "build.sh: Deleting CMakeFiles..." -#rm -rf CMakeFiles/ +rm -rf CMakeFiles/ echo "build.sh: Re-naming outfile..." rm FRCUserProgram