Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

Commit

Permalink
Add new ARM Toolchain, add toolchainpath to README (#42)
Browse files Browse the repository at this point in the history
Matches ntcore #165
  • Loading branch information
ThadHouse authored and PeterJohnson committed Jan 5, 2017
1 parent a3adb38 commit a72f8f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 33 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -68,6 +68,12 @@ BUILD FAILED
Total time: 2.441 secs
```

If you have the Toolchain installed somewhere not on the System PATH, you can use the `toolChainPath` property to specify where the bin location of the toolchain is installed to, for example:

```bash
./gradlew :arm:build -PtoolChainPath=some/path/to/my/toolchain/bin
```

## Testing
By default, tests will be built for the x86 and x64 versions of CameraServer, and will be run during any execution of the `build` or `publish` tasks. To skip building and running the tests, use the `-PwithoutTests` command line flag when running Gradle.

Expand Down
46 changes: 13 additions & 33 deletions toolchains/arm.gradle
Expand Up @@ -2,6 +2,7 @@ ext.isArm = true
ext.buildPlatform = 'arm'

def compilerPrefix = project.hasProperty('compilerPrefix') ? project.compilerPrefix : 'arm-frc-linux-gnueabi-'
def toolChainPath = project.hasProperty('toolChainPath') ? project.toolChainPath : null
model {
platforms {
arm {
Expand All @@ -10,10 +11,12 @@ model {
}
}
toolChains {
gcc(Gcc) {
armGcc(Gcc) {
if (toolChainPath != null) path(toolChainPath)
target("arm") {
// We use a custom-built cross compiler with the prefix arm-frc-linux-gnueabi-<util name>
// If this ever changes, the prefix will need to be changed here
cCompiler.executable = compilerPrefix + cCompiler.executable
cppCompiler.executable = compilerPrefix + cppCompiler.executable
linker.executable = compilerPrefix + linker.executable
assembler.executable = compilerPrefix + assembler.executable
Expand All @@ -35,37 +38,14 @@ model {
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') {
// We use a custom-built cross compiler with the prefix arm-frc-linux-gnueabi-<util name>
// If this ever changes, the prefix will need to be changed here
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' << '-O0' << '-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' << '-pthread'
args.remove('-m32')
}
linker.withArguments { args ->
args << '-rdynamic' << '-pthread'
args.remove('-m32')
}
staticLibArchiver.executable = compilerPrefix + 'ar'
}
}
}
}

ext.binTools = { tool ->
if (toolChainPath != null) return "${toolChainPath}/${compilerPrefix}${tool}"
return "${compilerPrefix}${tool}"
}

ext.setupReleaseDefines = { cppCompiler, linker ->
cppCompiler.args '-O2', '-g'
}
Expand All @@ -84,9 +64,9 @@ ext.debugStripSetup = {
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 binTools('objcopy'), '--only-keep-debug', library, debugLibrary }
exec { commandLine binTools('strip'), '-g', library }
exec { commandLine binTools('objcopy'), "--add-gnu-debuglink=$debugLibrary", library }
}
}
}
Expand All @@ -100,7 +80,7 @@ ext.checkNativeSymbols = { getSymbolFunc ->
task.doLast {
def nmOutput = new ByteArrayOutputStream()
exec {
commandLine "${compilerPrefix}nm", library
commandLine binTools('nm'), library
standardOutput nmOutput
}
// Remove '\r' so we can check for full string contents
Expand Down

0 comments on commit a72f8f3

Please sign in to comment.