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")
}