Brian Silverman | 890a32a | 2018-03-11 15:41:56 -0700 | [diff] [blame] | 1 | import org.gradle.internal.os.OperatingSystem |
| 2 | |
| 3 | plugins { |
| 4 | id 'net.ltgt.errorprone' version '0.0.8' |
| 5 | id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '2.0' |
| 6 | } |
| 7 | |
| 8 | allprojects { |
| 9 | repositories { |
| 10 | mavenCentral() |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | if (!hasProperty('releaseType')) { |
| 15 | WPILibVersion { |
| 16 | releaseType = 'dev' |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | ext.compilerPrefixToUse = project.hasProperty('compilerPrefix') ? project.compilerPrefix : 'arm-frc-linux-gnueabi-' |
| 21 | |
| 22 | ext.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 | |
| 32 | apply from: "locations.gradle" |
| 33 | |
| 34 | ext.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 | |
| 76 | apply from: "properties.gradle" |
| 77 | apply from: "options.gradle" |
| 78 | |
| 79 | apply from: wpiDeps |
| 80 | |
| 81 | apply from: "cpp.gradle" |
| 82 | |
| 83 | // Empty task for build so that zips will be |
| 84 | // built when running ./gradlew build |
| 85 | task build |
| 86 | |
| 87 | apply from: "releases.gradle" |
| 88 | |
| 89 | task clean(type: Delete) { |
| 90 | description = "Deletes the build directory" |
| 91 | group = "Build" |
| 92 | delete buildDir |
| 93 | } |
| 94 | |
| 95 | clean { |
| 96 | delete releaseDir |
| 97 | } |
| 98 | |
| 99 | task wrapper(type: Wrapper) { |
| 100 | gradleVersion = '3.3' |
| 101 | } |