Utiliser des arguments de compilation
Compiler arguments allow us to change the behavior of our compiler. This includes making warnings into errors, ignoring certain warnings and choosing optimization level. When compiling code a variety of flags are already included by default which can be found here. Normally it could be proposed that the solution is to pass them in as flags when compiling our code but this doesn’t work in GradleRIO. Instead modify the build.gradle.
Avertissement
Modifier les arguments est dangereux et peut causer un comportement inattendu.
C++
Plateformes
Different compilers and different platforms use a variety of different flags. Therefore to avoid breaking different platforms with compiler flags configure all flags per platform. The platforms that are supported are listed here
Configuration pour une plateforme
nativeUtils.platformConfigs.named('windowsx86-64').configure {
it.cppCompiler.args.add("/utf-8")
}
native-utils est utilisé pour configurer la plateforme, dans ce cas, windowsx86-64. Cela peut être remplacé par n’importe quelle plateforme répertoriée dans la section précédente. Ensuite, des arguments, tels que /utf-8, sont ajoutés au compilateur C++.
Java
Compiler arguments can also be configured for Java. We do this by adding arguments in the JavaCompile task.
// Configure string concat to always inline compile
tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
}
JVM Arguments
Along with being able to configure compiler arguments Java also allows us to configure runtime options for the JVM. We do this by editing the frcJava artifact’s arguments.
frcJava(getArtifactClass('FRCJavaArtifact')) {
jvmArgs.add("-XX:+DisableExplicitGC")
}
Deleting Unused Deploy Files
By default the src/main/deploy directory in your project is transferred to the roboRIO when code is deployed. It is initiated by this section of the build.gradle file.
32 // Static files artifact
33 frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) {
34 files = project.fileTree('src/main/deploy')
35 directory = '/home/lvuser/deploy'
36 deleteOldFiles = false // Change to true to delete files on roboRIO that no
37 // longer exist in deploy directory of this project
38 }
This will overwrite any duplicate files found in the /home/lvuser/deploy directory on the RIO and copy over any additional not present there. If deleteOldFiles is false it will not remove any files no longer present in the project deploy directory. Changing it to true helps prevent programs like Choreo and PathPlanner from getting confused by files that were deleted locally but still exist on the roboRIO.
If you want to manage the roboRIO files directly, the FTP documentation provides one method to do so.