Fix RoboRIO Cross-Toolchain GCC Status (#405)

* Dedicated RoboRIO Toolchain, allow Toolchain Path to change

* Add cCompiler Tool to correctly discover RoboRIO GCC on Mac

* Add @333fred requests for GString and ToolChainPath

* Add Toolchain Path option to README
This commit is contained in:
Jaci R
2016-12-22 11:56:28 +08:00
committed by Fred Silberberg
parent fddb6cd9d8
commit a42ec08d16
7 changed files with 30 additions and 39 deletions

View File

@@ -47,6 +47,12 @@ To build a specific subproject, such as WPILibC, you must access the subproject
./gradlew :wpilibc:build
```
If you have installed the FRC Toolchain to a directory other than the default, or if the Toolchain location is not on your System PATH, you can pass the `toolChainPath` property to specify where it is located. Example:
```bash
./gradlew build -PtoolChainPath=some/path/to/frc/toolchain/bin
```
If you also want simulation to be built, add -PmakeSim. This requires gazebo_transport. We have tested on 14.04 and 15.05, but any correct install of Gazebo should work, even on Windows if you build Gazebo from source. Correct means CMake needs to be able to find gazebo-config.cmake. See [The Gazebo website](https://gazebosim.org/) for installation instructions.
```bash

View File

@@ -72,6 +72,10 @@ task clean(type: Delete) {
delete buildDir
}
if (!hasProperty("toolChainPath")) {
ext.toolChainPath = null
}
subprojects {
ext.defineWpiUtilProperties = {
ext.wpiUtil = wpiUtilUnzipLocation
@@ -165,8 +169,11 @@ subprojects {
}
// Adds a custom toolchain for our compiler prefix and options
toolChains {
gcc(Gcc) {
target('arm') {
roborioGcc(Gcc) {
if (toolChainPath != null)
path toolChainPath
target('roborio-arm') {
cCompiler.executable = compilerPrefix + cCompiler.executable
cppCompiler.executable = compilerPrefix + cppCompiler.executable
linker.executable = compilerPrefix + linker.executable
assembler.executable = compilerPrefix + assembler.executable
@@ -188,37 +195,10 @@ subprojects {
staticLibArchiver.executable = compilerPrefix + staticLibArchiver.executable
}
}
// Workaround for OS X. Macs for some reason want to use Xcode's gcc
// (which just wraps Clang), so we have to explicitly make it so
// that trying to compile with Clang will call gcc instead
macGcc(Clang) {
target('arm') {
cppCompiler.executable = compilerPrefix + 'g++'
linker.executable = compilerPrefix + 'g++'
assembler.executable = compilerPrefix + 'gcc'
// Gradle auto-adds the -m32 argument to the linker and compiler. Our compiler only supports
// arm, and doesn't understand this flag, so it is removed from both
cppCompiler.withArguments { args ->
args << '-std=c++1y' << '-Wformat=2' << '-Wall' << '-Wextra' << '-Werror' << '-pedantic'
args << '-Wno-psabi' << '-Wno-unused-parameter' << '-fPIC' << '-Og' << '-g3' << '-rdynamic'
//TODO: When the compiler allows us to actually call deprecated functions from within
// deprecated function, remove this line (this will cause calling deprecated functions
// to be treated as a warning rather than an error).
args << '-Wno-error=deprecated-declarations'
args.remove('-m32')
}
linker.withArguments { args ->
args << '-rdynamic'
args.remove('-m32')
}
staticLibArchiver.executable = compilerPrefix + 'ar'
}
}
}
// The only platform is arm linux
platforms {
arm {
'roborio-arm' {
architecture 'arm'
operatingSystem 'linux'
}
@@ -228,6 +208,11 @@ subprojects {
ext.niLibraryHeadersRoot = "${rootDir}/ni-libraries/include"
ext.niLibraryHeadersChipObject = "${rootDir}/ni-libraries/include/FRC_FPGA_ChipObject"
ext.binTool = { tool ->
if (toolChainPath != null) return "${toolChainPath}/${compilerPrefix}${tool}"
return "${compilerPrefix}${tool}"
}
// This task adds the appropriate linker flags for the NI libraries
ext.addNiLibraryLinks = { linker, targetPlatform ->
String architecture = targetPlatform.architecture
@@ -246,9 +231,9 @@ subprojects {
def library = task.outputFile.absolutePath
def debugLibrary = task.outputFile.absolutePath + ".debug"
task.doLast {
exec { commandLine "${compilerPrefix}objcopy", '--only-keep-debug', library, debugLibrary }
exec { commandLine "${compilerPrefix}strip", '-g', library }
exec { commandLine "${compilerPrefix}objcopy", "--add-gnu-debuglink=$debugLibrary", library }
exec { commandLine binTool('objcopy'), '--only-keep-debug', library, debugLibrary }
exec { commandLine binTool('strip'), '-g', library }
exec { commandLine binTool('objcopy'), "--add-gnu-debuglink=$debugLibrary", library }
}
}
}

View File

@@ -14,7 +14,7 @@ debugStripSetup(project)
model {
components {
HALAthena(NativeLibrarySpec) {
targetPlatform 'arm'
targetPlatform 'roborio-arm'
binaries.all {
tasks.withType(CppCompile) {
addNiLibraryLinks(linker, targetPlatform)

View File

@@ -10,7 +10,7 @@ ext.hal = project(':hal').projectDir.getAbsolutePath()
model {
components {
myRobotcpp(NativeExecutableSpec) {
targetPlatform 'arm'
targetPlatform 'roborio-arm'
binaries.all {
tasks.withType(CppCompile) {
addNiLibraryLinks(linker, targetPlatform)

View File

@@ -9,7 +9,7 @@ def ntSourceDir = "$buildDir/ntSources"
model {
components {
wpilibc(NativeLibrarySpec) {
targetPlatform 'arm'
targetPlatform 'roborio-arm'
binaries.all {
tasks.withType(CppCompile) {
dependsOn generateCppVersion

View File

@@ -11,7 +11,7 @@ ext.hal = project(':hal').projectDir.getAbsolutePath()
model {
components {
FRCUserProgram(NativeExecutableSpec) {
targetPlatform 'arm'
targetPlatform 'roborio-arm'
binaries.all {
tasks.withType(CppCompile) {
cppCompiler.args "-DNAMESPACED_WPILIB"

View File

@@ -30,7 +30,7 @@ defineWpiUtilProperties()
model {
components {
wpilibJavaJNI(NativeLibrarySpec) {
targetPlatform 'arm'
targetPlatform 'roborio-arm'
binaries.all {
tasks.withType(CppCompile) {
dependsOn jniHeaders
@@ -197,7 +197,7 @@ task checkJNISymbols() {
doLast {
defineCrossCompilerProperties()
exec {
commandLine "${compilerPrefix}nm", lib
commandLine binTool('nm'), lib
standardOutput = nmOutput
}
// Remove '\r' so we can check for full string contents