blob: 6277667ce9837b567b812276cf40a4526ed7af0c [file] [log] [blame]
John Park7eb90422018-01-27 12:04:57 -08001apply plugin: 'maven-publish'
2apply plugin: 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin'
3
4if (!hasProperty('releaseType')) {
5 WPILibVersion {
6 releaseType = 'dev'
7 }
8}
9
10def pubVersion = ''
11if (project.hasProperty("publishVersion")) {
12 pubVersion = project.publishVersion
13} else {
14 pubVersion = WPILibVersion.version
15}
16
17def baseArtifactId = 'wpilibc'
18def artifactGroupId = 'edu.wpi.first.wpilibc'
19
20def outputsFolder = file("$project.buildDir/outputs")
21
22task cppSourcesZip(type: Zip) {
23 destinationDir = outputsFolder
24 baseName = 'wpilibc'
25 classifier = "sources"
26
27 from(licenseFile) {
28 into '/'
29 }
30
31 from('src/main/native/cpp') {
32 into '/'
33 }
34}
35
36task cppHeadersZip(type: Zip) {
37 destinationDir = outputsFolder
38 baseName = 'wpilibc'
39 classifier = "headers"
40
41 from(licenseFile) {
42 into '/'
43 }
44
45 from('src/main/native/include') {
46 into '/'
47 }
48}
49
50build.dependsOn cppHeadersZip
51build.dependsOn cppSourcesZip
52
53def linkFile = project.file("${buildDir}/libwpi.so")
54
55task linkScriptZip(type: Zip) {
56 destinationDir = outputsFolder
57 baseName = 'wpilibclinkscript-classifier'
58 classifier = "linuxathena"
59
60 from(licenseFile) {
61 into '/'
62 }
63 from (linkFile) {
64 into '/linux/athena/shared'
65 }
66}
67
68build.dependsOn linkScriptZip
69
70model {
71 publishing {
72 def wpilibCTaskList = createComponentZipTasks($.components, 'wpilibc', 'zipcpp', Zip, project, includeStandardZipFormat)
73 def allTask
74 if (!project.hasProperty('jenkinsBuild')) {
75 allTask = createAllCombined(wpilibCTaskList, 'wpilibc', 'zipcpp', Zip, project)
76 }
77
78 $.components.each {
79 if (it in NativeLibrarySpec && it.name == 'wpilibc') {
80 def libSpec = it
81 tasks.create('generateWpilibLinkScript', Task) {
82 build.dependsOn it
83 linkScriptZip.dependsOn it
84 libSpec.binaries.each {
85 if (getClassifier(it) == 'linuxathena' && it in SharedLibraryBinarySpec) {
86 dependsOn it.buildTask
87 }
88 }
89
90 outputs.file linkFile
91 outputs.upToDateWhen { false }
92
93 doLast {
94 def libs = []
95 libSpec.binaries.each {
96 if (getClassifier(it) == 'linuxathena' && it in SharedLibraryBinarySpec) {
97 it.libs.each {
98 it.linkFiles.each {
99 libs.add it.name
100 }
101
102 }
103 libs.add it.sharedLibraryFile.name
104 }
105 }
106
107 linkFile.withWriter { out ->
108 out.println '/* GNU ld script */'
109 out.println 'OUTPUT_FORMAT(elf32-littlearm)'
110 out.print 'GROUP ( AS_NEEDED ( '
111 libs.each {
112 out.print it
113 out.print ' '
114 }
115 out.println ') )'
116 }
117 }
118 }
119 }
120 }
121
122
123
124 publications {
125 cpp(MavenPublication) {
126 wpilibCTaskList.each {
127 artifact it
128 }
129 if (!project.hasProperty('jenkinsBuild')) {
130 artifact allTask
131 }
132 artifact cppHeadersZip
133 artifact cppSourcesZip
134
135 artifactId = baseArtifactId
136 groupId artifactGroupId
137 version pubVersion
138 }
139 linkscripts(MavenPublication) {
140 artifact linkScriptZip
141
142 artifactId = "${baseArtifactId}-linkscripts"
143 groupId artifactGroupId
144 version pubVersion
145 }
146 }
147 }
148}