blob: b8913fd454d37dc7cb5a8e121792dddb86b6fc70 [file] [log] [blame]
Brian Silverman890a32a2018-03-11 15:41:56 -07001import org.gradle.internal.os.OperatingSystem
2
3plugins {
4 id 'net.ltgt.errorprone' version '0.0.8'
5 id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '2.0'
6}
7
8allprojects {
9 repositories {
10 mavenCentral()
11 }
12}
13
14if (!hasProperty('releaseType')) {
15 WPILibVersion {
16 releaseType = 'dev'
17 }
18}
19
20ext.compilerPrefixToUse = project.hasProperty('compilerPrefix') ? project.compilerPrefix : 'arm-frc-linux-gnueabi-'
21
22ext.setupDefines = { project, binaries ->
23 binaries.all {
24 if (project.hasProperty('debug')) {
25 project.setupDebugDefines(cppCompiler, linker)
26 } else {
27 project.setupReleaseDefines(cppCompiler, linker)
28 }
29 }
30}
31
32apply from: "locations.gradle"
33
34ext.addUserLinks = { linker, targetPlatform, implLib ->
35 def libPattern = /.*((\\/|\\).*)+lib(?<libName>.+).(.+)$/
36 def libraryArgs = []
37 def libraryPath = file(driverLibraryLib).path
38
39 // adds all libraries found in the driver folder
40 def libraryTree = fileTree(libraryPath)
41 libraryTree.include '*.so'
42 libraryTree.include '*.a'
43
44 libraryTree.each { lib ->
45 def nameMatcher = (lib.path =~ libPattern)
46 if (nameMatcher[0].size() > 1) {
47 def name = nameMatcher.group('libName')
48 libraryArgs << '-l' + name
49 }
50 }
51
52 if (implLib) {
53 // adds all libraries found in the impl folder
54 def implLibraryPath = file(cppLibraryLib).path
55 def implLibraryTree = fileTree(implLibraryPath)
56 implLibraryTree.include '*.so'
57 implLibraryTree.include '*.a'
58
59 implLibraryTree.each { lib ->
60 def nameMatcher = (lib.path =~ libPattern)
61 if (nameMatcher[0].size() > 1) {
62 def name = nameMatcher.group('libName')
63 libraryArgs << '-l' + name
64 }
65 }
66 }
67
68 // Add all arguments
69 String architecture = targetPlatform.architecture
70 if (architecture.contains('arm')){
71 linker.args << '-L' + libraryPath
72 linker.args.addAll(libraryArgs)
73 }
74}
75
76apply from: "properties.gradle"
77apply from: "options.gradle"
78
79apply from: wpiDeps
80
81apply from: "cpp.gradle"
82
83// Empty task for build so that zips will be
84// built when running ./gradlew build
85task build
86
87apply from: "releases.gradle"
88
89task clean(type: Delete) {
90 description = "Deletes the build directory"
91 group = "Build"
92 delete buildDir
93}
94
95clean {
96 delete releaseDir
97}
98
99task wrapper(type: Wrapper) {
100 gradleVersion = '3.3'
101}