diff --git a/myRobot/build.gradle b/myRobot/build.gradle new file mode 100644 index 0000000000..941f6f71f4 --- /dev/null +++ b/myRobot/build.gradle @@ -0,0 +1,70 @@ +apply plugin: 'java' +apply plugin: 'application' +apply plugin: 'com.github.johnrengelman.shadow' + +evaluationDependsOn(':wpilibj') + +mainClassName = 'edu.wpi.first.wpilibj.RobotBase' + +buildscript { + repositories { jcenter() } + dependencies { + classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3' + } +} + +def wpilibj = project(':wpilibj') + +dependencies { + compile wpilibj + compile files(wpilibj.sourceSets.test.output.classesDir) + compile 'edu.wpi.first.wpilib.networktables.java:NetworkTables:+:arm' +} + +def nativeDirectory = "$buildDir/output" + +clean { + delete nativeDirectory +} + +task copyRobotLibraries(type: Copy) { + description = 'Copies all native libraries to an easy to find folder' + group = 'WPILib' + dependsOn shadowJar + dependsOn ':hal:build' + dependsOn ':wpilibj:build' + + from (shadowJar) + + project(':wpilibj').model { + binaries { + withType(SharedLibraryBinarySpec) { spec -> + from(spec.sharedLibraryFile) + } + } + } + + project(':hal').model { + binaries { + withType(SharedLibraryBinarySpec) { spec -> + from(spec.sharedLibraryFile) + } + } + } + + defineNetworkTablesProperties() + defineWpiUtilProperties() + + from file(netSharedLib) + + from file(wpiUtilSharedLib) + + into nativeDirectory +} + + +build.dependsOn copyRobotLibraries + +jar { + manifest { attributes 'Robot-Class': 'MyRobot' } +} diff --git a/myRobot/src/main/java/MyRobot.java b/myRobot/src/main/java/MyRobot.java new file mode 100644 index 0000000000..9743ff1454 --- /dev/null +++ b/myRobot/src/main/java/MyRobot.java @@ -0,0 +1,54 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +import edu.wpi.first.wpilibj.IterativeRobot; + +@SuppressWarnings("all") +public class MyRobot extends IterativeRobot { + /** + * This function is run when the robot is first started up and should be + * used for any initialization code. + */ + @Override + public void robotInit() {} + + /** + * This function is run once each time the robot enters autonomous mode + */ + @Override + public void autonomousInit() {} + + /** + * This function is called periodically during autonomous + */ + @Override + public void autonomousPeriodic() {} + + /** + * This function is called once each time the robot enters tele-operated mode + */ + @Override + public void teleopInit() {} + + /** + * This function is called periodically during operator control + */ + @Override + public void teleopPeriodic() {} + + /** + * This function is called periodically during test mode + */ + @Override + public void testPeriodic() {} + + /** + * This function is called periodically during all modes + */ + @Override + public void robotPeriodic() {} +} diff --git a/myRobotCpp/build.gradle b/myRobotCpp/build.gradle new file mode 100644 index 0000000000..c37e170270 --- /dev/null +++ b/myRobotCpp/build.gradle @@ -0,0 +1,42 @@ +apply plugin: 'cpp' + +defineNetworkTablesProperties() +defineWpiUtilProperties() + +ext.shared = "${project(':wpilibc').projectDir.getAbsolutePath()}/shared" +ext.athena = "${project(':wpilibc').projectDir.getAbsolutePath()}/athena" +ext.hal = project(':hal').projectDir.getAbsolutePath() + +model { + components { + myRobotcpp(NativeExecutableSpec) { + targetPlatform 'arm' + binaries.all { + tasks.withType(CppCompile) { + addNiLibraryLinks(linker, targetPlatform) + addStaticNetworkTablesLibraryLinks(it, linker, targetPlatform) + } + + cppCompiler.args '-pthread', '-Wno-unused-variable' + linker.args '-pthread', '-Wno-unused-variable', '-Wl,-rpath,/opt/GenICam_v2_3/bin/Linux_armv7-a' + } + sources { + cpp { + source { + srcDir 'src' + include '**/*.cpp' + } + exportedHeaders { + srcDirs = ['include', + "${project.athena}/include", "${project.shared}/include", + "${project.hal}/include/HAL", netTablesInclude, wpiUtilInclude] + include '**/*.h' + } + + lib project: ':wpilibc', library: 'wpilibc', linkage: 'static' + lib project: ':hal', library: 'HALAthena', linkage: 'static' + } + } + } + } +} diff --git a/myRobotCpp/src/MyRobot.cpp b/myRobotCpp/src/MyRobot.cpp new file mode 100644 index 0000000000..19fc40d5aa --- /dev/null +++ b/myRobotCpp/src/MyRobot.cpp @@ -0,0 +1,48 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2016. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "WPILib.h" + +class MyRobot : public IterativeRobot { + /** + * This function is run when the robot is first started up and should be + * used for any initialization code. + */ + void RobotInit() override {} + + /** + * This function is run once each time the robot enters autonomous mode + */ + void AutonomousInit() override {} + + /** + * This function is called periodically during autonomous + */ + void AutonomousPeriodic() override {} + + /** + * This function is called once each time the robot enters tele-operated mode + */ + void TeleopInit() override {} + + /** + * This function is called periodically during operator control + */ + void TeleopPeriodic() override {} + + /** + * This function is called periodically during test mode + */ + void TestPeriodic() override {} + + /** + * This function is called periodically during all modes + */ + void RobotPeriodic() override {} +}; + +START_ROBOT_CLASS(MyRobot) diff --git a/settings.gradle b/settings.gradle index 9c570c463a..b92a97b0d2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,7 +2,9 @@ include 'hal', 'wpilibc', 'wpilibcIntegrationTests', 'wpilibj', - 'wpilibjIntegrationTests' + 'wpilibjIntegrationTests', + 'myRobot', + 'myRobotCpp' if (hasProperty("makeSim")){ include 'simulation',