blob: 0c047e84d7ffa001a75ad2009e0b7d607f5738c5 [file] [log] [blame]
Brian Silverman41cdd3e2019-01-19 19:48:58 -08001plugins {
2 id 'java'
3 id 'application'
4 id 'cpp'
5 id 'visual-studio'
6}
7
8apply plugin: 'edu.wpi.first.NativeUtils'
9
10apply from: '../shared/config.gradle'
11
12ext {
13 sharedCvConfigs = [myRobotCpp: []]
14 staticCvConfigs = [myRobotCppStatic: []]
15 useJava = true
16 useCpp = true
17 skipDev = true
18}
19
20ext {
21 chipObjectComponents = ['myRobotCpp', 'myRobotCppStatic']
22 netCommComponents = ['myRobotCpp', 'myRobotCppStatic']
23 useNiJava = true
24}
25
26apply from: "${rootDir}/shared/nilibraries.gradle"
27
28apply from: "${rootDir}/shared/opencv.gradle"
29
30mainClassName = 'Main'
31
32apply plugin: 'com.github.johnrengelman.shadow'
33
34repositories {
35 mavenCentral()
36}
37
38dependencies {
39 compile project(':wpilibj')
40 compile project(':hal')
41 compile project(':wpiutil')
42 compile project(':ntcore')
43 compile project(':cscore')
44 compile project(':cameraserver')
45}
46
47jar {
48 manifest { attributes 'Robot-Class': 'MyRobot' }
49}
50
51model {
52 components {
53 myRobotCpp(NativeExecutableSpec) {
54 targetBuildTypes 'debug'
55 baseName = 'FRCUserProgram'
56 sources {
57 cpp {
58 source {
59 srcDirs = ['src/main/native/cpp']
60 includes = ['**/*.cpp']
61 }
62 exportedHeaders {
63 srcDirs = ['src/main/native/include']
64 includes = ['**/*.h']
65 }
66 }
67 }
68 binaries.all { binary ->
69 lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
70 lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
71 lib project: ':cscore', library: 'cscore', linkage: 'shared'
72 project(':hal').addHalDependency(binary, 'shared')
73 lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
74 lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
75 }
76 }
77 myRobotCppStatic(NativeExecutableSpec) {
78 targetBuildTypes 'debug'
79 baseName = 'FRCUserProgram'
80 sources {
81 cpp {
82 source {
83 srcDirs = ['src/main/native/cpp']
84 includes = ['**/*.cpp']
85 }
86 exportedHeaders {
87 srcDirs = ['src/main/native/include']
88 includes = ['**/*.h']
89 }
90 }
91 }
92 binaries.all { binary ->
93 lib project: ':wpilibc', library: 'wpilibc', linkage: 'static'
94 lib project: ':ntcore', library: 'ntcore', linkage: 'static'
95 lib project: ':cscore', library: 'cscore', linkage: 'static'
96 project(':hal').addHalDependency(binary, 'static')
97 lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
98 lib project: ':cameraserver', library: 'cameraserver', linkage: 'static'
99 }
100 }
101 }
102 tasks {
103 def c = $.components
104 project.tasks.create('runCpp', Exec) {
105 group = 'WPILib'
106 description = "Run the myRobotCpp executable"
107 def found = false
108 def systemArch = getCurrentArch()
109 c.each {
110 if (it in NativeExecutableSpec && it.name == "myRobotCpp") {
111 it.binaries.each {
112 if (!found) {
113 def arch = it.targetPlatform.architecture.name
114 if (arch == systemArch) {
115 dependsOn it.tasks.install
116 commandLine it.tasks.install.runScriptFile.get().asFile.toString()
117 def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib'
118 run.dependsOn it.tasks.install
119 run.systemProperty 'java.library.path', filePath
120 run.environment 'LD_LIBRARY_PATH', filePath
121 run.workingDir filePath
122
123 found = true
124 }
125 }
126 }
127 }
128 }
129 }
130 installAthena(Task) {
131 $.binaries.each {
132 if (it in NativeExecutableBinarySpec && it.targetPlatform.architecture.name == 'athena' && it.component.name == 'myRobotCpp') {
133 dependsOn it.tasks.install
134 }
135 }
136 }
137 installAthenaStatic(Task) {
138 $.binaries.each {
139 if (it in NativeExecutableBinarySpec && it.targetPlatform.architecture.name == 'athena' && it.component.name == 'myRobotCppStatic') {
140 dependsOn it.tasks.install
141 }
142 }
143 }
144 }
145}