diff --git a/README.md b/README.md index 937035cf7f..dd1890ff20 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cppSettings.gradle b/cppSettings.gradle index d1ca6a981f..a0197b2566 100644 --- a/cppSettings.gradle +++ b/cppSettings.gradle @@ -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 } } } } diff --git a/hal/build.gradle b/hal/build.gradle index 3300e5f4da..07d2d39b1d 100644 --- a/hal/build.gradle +++ b/hal/build.gradle @@ -14,7 +14,7 @@ debugStripSetup(project) model { components { HALAthena(NativeLibrarySpec) { - targetPlatform 'arm' + targetPlatform 'roborio-arm' binaries.all { tasks.withType(CppCompile) { addNiLibraryLinks(linker, targetPlatform) diff --git a/myRobotCpp/build.gradle b/myRobotCpp/build.gradle index 6b3b6de706..8e436e27e3 100644 --- a/myRobotCpp/build.gradle +++ b/myRobotCpp/build.gradle @@ -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) diff --git a/wpilibc/athena.gradle b/wpilibc/athena.gradle index 1aaa7521e5..17c04e24b5 100644 --- a/wpilibc/athena.gradle +++ b/wpilibc/athena.gradle @@ -9,7 +9,7 @@ def ntSourceDir = "$buildDir/ntSources" model { components { wpilibc(NativeLibrarySpec) { - targetPlatform 'arm' + targetPlatform 'roborio-arm' binaries.all { tasks.withType(CppCompile) { dependsOn generateCppVersion diff --git a/wpilibcIntegrationTests/build.gradle b/wpilibcIntegrationTests/build.gradle index 397e22f390..c37bbc7298 100644 --- a/wpilibcIntegrationTests/build.gradle +++ b/wpilibcIntegrationTests/build.gradle @@ -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" diff --git a/wpilibj/athena.gradle b/wpilibj/athena.gradle index 1fabe96b57..2f5dccdf17 100644 --- a/wpilibj/athena.gradle +++ b/wpilibj/athena.gradle @@ -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