Skip to content

Commit

Permalink
Merge pull request #14 from Team612/dev-windows
Browse files Browse the repository at this point in the history
Dev windows
  • Loading branch information
Ahmad-Bamba authored Feb 2, 2017
2 parents d20073d + d235e3c commit f0a207d
Show file tree
Hide file tree
Showing 9 changed files with 261 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ FRCUserProgram

#CTRE
CTRE/

#Other binaries
bin/*
14 changes: 14 additions & 0 deletions Makefile.win
Original file line number Diff line number Diff line change
@@ -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
65 changes: 36 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,47 @@ 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

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:

Expand All @@ -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
22 changes: 22 additions & 0 deletions batch/.compiler-download.bat
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions batch/.get-ctre.bat
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions batch/.wpilib-download.bat
Original file line number Diff line number Diff line change
@@ -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
64 changes: 64 additions & 0 deletions batch/build.bat
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions batch/deploy.bat
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion script/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f0a207d

Please sign in to comment.