Brian Silverman | 890a32a | 2018-03-11 15:41:56 -0700 | [diff] [blame] | 1 | defineWpiUtilProperties() |
| 2 | if (wpiDeps == "wpi-dependencies-2018.gradle"){defineNIProperties()} |
| 3 | defineHALProperties() |
| 4 | defineNetworkTablesProperties() |
| 5 | defineWpiLibProperties() |
| 6 | //defineCsCoreProperties() |
| 7 | |
| 8 | def cppSetupModel = { project -> |
| 9 | project.model { |
| 10 | components { |
| 11 | CTRE_Phoenix(NativeLibrarySpec) { |
| 12 | targetPlatform 'arm' |
| 13 | setupDefines(project, binaries) |
| 14 | |
| 15 | binaries.all { |
| 16 | tasks.withType(CppCompile) { |
| 17 | cppCompiler.args << "-DNAMESPACED_WPILIB" << "-Werror" << "-Wall" |
| 18 | addUserLinks(linker, targetPlatform, false) |
| 19 | addHalLibraryLinks(it, linker, targetPlatform) |
| 20 | addWpiUtilLibraryLinks(it, linker, targetPlatform) |
| 21 | addNetworkTablesLibraryLinks(it, linker, targetPlatform) |
| 22 | addWpilibLibraryLinks(it, linker, targetPlatform) |
| 23 | // addCsCoreLibraryLinks(it, linker, targetPlatform) |
| 24 | if (wpiDeps == "wpi-dependencies-2018.gradle"){addNILibraryLinks(it, linker, targetPlatform)} |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | sources { |
| 29 | cpp { |
| 30 | source { |
| 31 | srcDirs = [cppSrc, cppLibrarySrc] |
| 32 | includes = ["**/*.cpp"] |
| 33 | } |
| 34 | exportedHeaders { |
| 35 | srcDirs = [cppInclude, driverLibraryInclude, cppLibraryInclude, wpilibInclude, halInclude, wpiUtilInclude, netTablesInclude, NIInclude] |
| 36 | includes = ['**/*.h'] |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | ext.mergeStaticSetup = { pjt -> |
| 46 | if (combineStaticLibs) { |
| 47 | pjt.tasks.whenObjectAdded { task -> |
| 48 | def name = task.name.toLowerCase() |
| 49 | if (name.contains('create') && name.contains('staticlibrary')) { |
| 50 | def libraryPath = task.outputFile.parent |
| 51 | def library = file(task.outputFile.absolutePath) |
| 52 | project(':arm:driver').model { |
| 53 | binaries { |
| 54 | withType(StaticLibraryBinarySpec) { binary -> |
| 55 | ext.driverLibrary = new File(binary.staticLibraryFile.absolutePath) |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | task.doLast { |
| 60 | library.renameTo(file("${library}.m")) |
| 61 | copy { |
| 62 | from driverLibrary |
| 63 | into libraryPath |
| 64 | } |
| 65 | |
| 66 | ByteArrayOutputStream mriFile = new ByteArrayOutputStream() |
| 67 | mriFile << "create lib${libraryName}.a\n" |
| 68 | mriFile << "addlib lib${libraryName}.a.m\n" |
| 69 | mriFile << "addlib lib${libraryName}Driver.a\n" |
| 70 | mriFile << "save\n" |
| 71 | mriFile << "end\n" |
| 72 | |
| 73 | def stdIn = new ByteArrayInputStream(mriFile.buf) |
| 74 | |
| 75 | exec { |
| 76 | standardInput = stdIn |
| 77 | workingDir = libraryPath |
| 78 | commandLine "${compilerPrefixToUse}ar", '-M' |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | project(':arm:cpp') { |
| 87 | apply plugin: 'cpp' |
| 88 | |
| 89 | apply from: "${rootDir}/toolchains/arm.gradle" |
| 90 | |
| 91 | apply from: "${rootDir}/java/java.gradle" |
| 92 | |
| 93 | cppSetupModel(project) |
| 94 | |
| 95 | project.debugStripSetup() |
| 96 | mergeStaticSetup(project) |
| 97 | } |