Initial commit

This commit is contained in:
Austen Adler 2015-01-04 20:17:07 -05:00
commit 0342e80ff5
5 changed files with 115 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.vagrant
build
wpilib
src
config/host

20
README.md Normal file
View File

@ -0,0 +1,20 @@
# FRC C++ Vagrantfile
This project uses [Vagrant](https://www.vagrantup.com/) and creates a virtual machine to compile and build WPILib C++ code for FRC. The goal is to make and deploy code without requiring Eclipse. This is not an official method of making or deploying code, so use with caution.
### Installation
- Install the [latest version of Vagrant](https://www.vagrantup.com/downloads.html). For Ubuntu users, apt-get doesn't work because the version of Vagrant in the repositories is too old.
- Clone the repository: `git clone git@github.com:stonewareslord/frc-cpp-vagrantfile.git`
- Edit the rRIO host address in `config/host`
- Copy source code to `src/`
- Start the virtual machine: `vagrant up`
- The first time the machine is started, your computer must be connected to the internet. It will probably take a few minutes.
- Once provisioning completes, log into the machine with `vagrant ssh`
### Usage
- `build` - compiles the source code in `src` to `build/FRCUserProgram`. If there are errors in the source, they will be displayed and `FRCUserProgram` will be deleted.
- `putkey` (optional) - Sends the public key to the roboRIO for passwordless deploying.
- `deploy` - Uploads `FRCUserProgram` to the roboRIO. This will prompt for a password if putkey was not run (the default password is blank).
### Issues
- There is no way to automate updating wpilib
- sftp is used to deploy instead of ftp

71
Vagrantfile vendored Normal file
View File

@ -0,0 +1,71 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "ubuntu/trusty64"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline <<-SHELL
# sudo apt-get install apache2
# SHELL
config.vm.provision :shell, path: "bootstrap.sh"
end

17
bootstrap.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
# Download wpilib from github if the folder doesn't already exist
(test -d /vagrant/wpilib||(mkdir /vagrant/wpilib;curl -L https://github.com/stonewareslord/wpilib/tarball/master | tar -xzC /vagrant/wpilib --strip-components=1))&
# Create the build folder if it doesn't already exist
mkdir -p /vagrant/build
# Install the frc toolchain
add-apt-repository -y ppa:byteit101/frc-toolchain
apt-get update
apt-get install -y frc-toolchain
# Compiles code in the /vagrant/src folder
echo 'echo "Starting build";test -f /vagrant/build/FRCUserProgram&&rm /vagrant/build/FRCUserProgram;arm-frc-linux-gnueabi-g++ -std=c++1y -I/vagrant/wpilib/include "-I/vagrant/src" -O0 -g3 -Wall -c -fmessage-length=0 -o /vagrant/build/Robot.o /vagrant/src/Robot.cpp&&arm-frc-linux-gnueabi-g++ -L/vagrant/wpilib/lib -Wl,-rpath,/opt/GenICam_v2_3/bin/Linux_armv7-a -o /vagrant/build/FRCUserProgram /vagrant/build/Robot.o -lwpi;rm /vagrant/build/Robot.o;echo "Done"' > /usr/local/bin/build
# Uploads the code to the rRIO based on /vagrant/config/host file
echo "cat /vagrant/FRCUserProgram | ssh \`cat /vagrant/config/host|head -n 1\` 'cat > /home/lvuser/FRCUserProgram2&&rm /home/lvuser/FRCUserProgram;mv /home/lvuser/FRCUserProgram2 /home/lvuser/FRCUserProgram&&. /etc/profile.d/natinst-path.sh;chmod a+x /home/lvuser/FRCUserProgram;/usr/local/frc/bin/frcKillRobot.sh -t -r'||echo 'You probably haven\'t succesfully built yet. Run build to compile the program''" > /usr/local/bin/deploy
# Creates ssh key if it doesn't exist and cats the public key to the rRIO
echo "test -d ~/.ssh||mkdir ~/.ssh;test -f ~/.ssh/id_rsa||ssh-keygen -t rsa -f ~/.ssh/id_rsa -b 4096 -q -N '';cat ~/.ssh/id_rsa.pub|ssh \`cat /vagrant/config/host|head -n 1\` 'cat >> ~/.ssh/authorized_keys'" > /usr/local/bin/putkey
chmod +x /usr/local/bin/build /usr/local/bin/deploy /usr/local/bin/putkey
echo "Done provisioning. Run vagrant ssh to connect to the virtual machine."

2
config/host Normal file
View File

@ -0,0 +1,2 @@
admin@roboRIO-xxxx.local
The line above should be the address to connect to. The default is admin@roboRIO-xxxx.local where xxxx is your team number