Brian Silverman | f7f267a | 2017-02-04 16:16:08 -0800 | [diff] [blame] | 1 | // There are two hal libraries that are built |
| 2 | // - desktop which is used by simulation (gcc/msvc) |
| 3 | // - athena which is used by the roborio (arm) |
| 4 | |
| 5 | plugins { |
| 6 | id 'cpp' |
| 7 | id 'maven-publish' |
| 8 | } |
| 9 | |
| 10 | defineWpiUtilProperties() |
| 11 | |
| 12 | debugStripSetup(project) |
| 13 | |
| 14 | model { |
| 15 | components { |
| 16 | HALAthena(NativeLibrarySpec) { |
| 17 | targetPlatform 'roborio-arm' |
| 18 | binaries.all { |
| 19 | tasks.withType(CppCompile) { |
| 20 | addNiLibraryLinks(linker, targetPlatform) |
| 21 | addWpiUtilLibraryLinks(it, linker, targetPlatform) |
| 22 | } |
| 23 | } |
| 24 | sources { |
| 25 | cpp { |
| 26 | source { |
| 27 | srcDirs = ["lib/athena", niLibraryHeadersRoot, "lib/shared"] |
| 28 | includes = ["**/*.cpp"] |
| 29 | } |
| 30 | exportedHeaders { |
| 31 | srcDirs = ["include", niLibraryHeadersRoot, wpiUtilInclude] |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | tasks { tasks -> |
| 38 | tasks.halZip.dependsOn tasks.HALAthenaSharedLibrary |
| 39 | tasks.athenaRuntimeZip.dependsOn tasks.HALAthenaSharedLibrary |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | task halZip(type: Zip) { |
| 44 | description = 'Zips the HAL' |
| 45 | group = 'WPILib' |
| 46 | baseName = 'hal' |
| 47 | destinationDir = project.buildDir |
| 48 | duplicatesStrategy = 'exclude' |
| 49 | |
| 50 | // Include the shared library file and header files from this project |
| 51 | model { |
| 52 | binaries { |
| 53 | withType(SharedLibraryBinarySpec) { spec -> |
| 54 | spec.headerDirs.each { |
| 55 | def normalizedIt = it.toString().replace('/', '\\') |
| 56 | def normalizedWPIUtil = wpiUtilInclude.toString().replace('/', '\\') |
| 57 | // exclude the wpiUtil library, and any NI libraries (NI libraries grabbed later) |
| 58 | if (normalizedIt != normalizedWPIUtil) { |
| 59 | from(it) { |
| 60 | into 'include' |
| 61 | // We don't want to include any of the .cpp files that are in some of the header directories |
| 62 | exclude '**/*.cpp' |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | from(spec.sharedLibraryFile) { |
| 67 | into 'lib' |
| 68 | } |
| 69 | from(new File(spec.sharedLibraryFile.absolutePath + ".debug")) { |
| 70 | into 'lib' |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | // Finally, include all of the shared library objects from the ni directory |
| 77 | from(project.file('../ni-libraries/lib')) { |
| 78 | into 'lib' |
| 79 | exclude 'genlinks' |
| 80 | exclude 'genlinks.bat' |
| 81 | exclude 'libwpi.so' |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | task athenaRuntimeZip(type: Zip) { |
| 86 | description = 'Zips the Athena Runtime libraries' |
| 87 | group = 'WPILib' |
| 88 | baseName = 'athena-runtime' |
| 89 | destinationDir = project.buildDir |
| 90 | duplicatesStrategy = 'exclude' |
| 91 | |
| 92 | // Include the static library file and header files from this project |
| 93 | model { |
| 94 | binaries { |
| 95 | withType(SharedLibraryBinarySpec) { spec -> |
| 96 | spec.headerDirs.each { |
| 97 | from(it) { |
| 98 | into 'include' |
| 99 | // We don't want to include any of the .cpp files that are in some of the header directories |
| 100 | exclude '**/*.cpp' |
| 101 | } |
| 102 | } |
| 103 | from(spec.sharedLibraryFile) { |
| 104 | into 'lib' |
| 105 | } |
| 106 | from(new File(spec.sharedLibraryFile.absolutePath + ".debug")) { |
| 107 | into 'lib' |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | defineNetworkTablesProperties() |
| 114 | dependsOn project(':').downloadNetworkTables |
| 115 | |
| 116 | from(project.file(netTablesInclude)) { |
| 117 | into 'include' |
| 118 | } |
| 119 | |
| 120 | from (file(netSharedLib)) { |
| 121 | into 'lib' |
| 122 | } |
| 123 | |
| 124 | from (file(netSharedLibDebug)) { |
| 125 | into 'lib' |
| 126 | } |
| 127 | |
| 128 | from (file(wpiUtilSharedLib)) { |
| 129 | into 'lib' |
| 130 | } |
| 131 | |
| 132 | from (file(wpiUtilSharedLibDebug)) { |
| 133 | into 'lib' |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | |
| 138 | publishing { |
| 139 | publications { |
| 140 | hal(MavenPublication) { |
| 141 | artifact halZip |
| 142 | |
| 143 | groupId 'edu.wpi.first.wpilib' |
| 144 | artifactId 'hal' |
| 145 | version WPILibVersion.version |
| 146 | } |
| 147 | athenaruntime(MavenPublication) { |
| 148 | artifact athenaRuntimeZip |
| 149 | |
| 150 | groupId 'edu.wpi.first.wpilib' |
| 151 | artifactId 'athena-runtime' |
| 152 | version WPILibVersion.version |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | setupWpilibRepo(it) |
| 157 | } |
| 158 | |
| 159 | build.dependsOn halZip |
| 160 | build.dependsOn athenaRuntimeZip |