import edu.wpi.first.nativeutils.NativeUtils buildscript { repositories { mavenLocal() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath 'gradle.plugin.edu.wpi.first:native-utils:1.3.0' classpath 'gradle.plugin.edu.wpi.first.wpilib.versioning:wpilib-version-plugin:2.0' } } ext.getClassifier = { binary-> return NativeUtils.getClassifier(binary) } ext.getPlatformPath = { binary-> return NativeUtils.getPlatformPath(binary) } apply plugin: 'cpp' apply plugin: 'google-test' apply plugin: 'visual-studio' apply plugin: 'edu.wpi.first.NativeUtils' apply plugin: 'java' apply from: 'config.gradle' sourceSets { dev } task run(type: JavaExec) { classpath = sourceSets.dev.runtimeClasspath main = 'edu.wpi.first.wpiutil.DevMain' } build.dependsOn devClasses dependencies { testCompile 'junit:junit:4.12' devCompile sourceSets.main.output } model { // Exports config is a utility to enable exporting all symbols in a C++ library on windows to a DLL. // This removes the need for DllExport on a library. However, the gradle C++ builder has a bug // where some extra symbols are added that cannot be resolved at link time. This configuration // lets you specify specific symbols to exlude from exporting. exportsConfigs { wpiutil(ExportsConfig) { x86ExcludeSymbols = [ '_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', '_TI3?AVout_of_range' ] x64ExcludeSymbols = [ '_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', '_TI5?AVfailure', '_CT??_R0?AVout_of_range', '_CTA3?AVout_of_range', '_TI3?AVout_of_range' ] } } components { wpiutil(NativeLibrarySpec) { sources { cpp { source { srcDirs 'src/main/native/cpp' include '**/*.cpp' } exportedHeaders { srcDirs 'src/main/native/include' } } } } // By default, a development executable will be generated. This is to help the case of // testing specific functionality of the library. if (!project.hasProperty('skipDevExe')) { wpiutilDev(NativeExecutableSpec) { sources { cpp { source { srcDirs 'src/dev/native/cpp' include '**/*.cpp' lib library: "wpiutil" } exportedHeaders { srcDirs 'src/dev/native/include' } } } } } // The TestingBase library is a workaround for an issue with the GoogleTest plugin. // The plugin by default will rebuild the entire test source set, which increases // build time. By testing an empty library, and then just linking the already built component // into the test, we save the extra build wpiutilTestingBase(NativeLibrarySpec) { } } testSuites { wpiutilTestingBaseTest { sources { cpp { source { srcDirs 'src/test/native/cpp' include '**/*.cpp' } exportedHeaders { srcDirs 'src/test/native/include', 'src/main/native/cpp' } } } } } binaries { withType(GoogleTestTestSuiteBinarySpec) { if (it.component.testedComponent.name.contains('TestingBase') && !project.hasProperty('onlyAthena')) { lib project: ':gmock', library: 'gmock', linkage: 'static' lib library: 'wpiutil', linkage: 'shared' } else { it.buildable = false } } } tasks { def c = $.components project.tasks.create('runCpp', Exec) { def found = false c.each { if (it in NativeExecutableSpec && it.name == 'wpiutilDev') { it.binaries.each { if (!found) { def arch = it.targetPlatform.architecture.name if (arch == 'x86-64' || arch == 'x86') { dependsOn it.tasks.install commandLine it.tasks.install.runScript found = true } } } } } } } } apply from: 'publish.gradle' task wrapper(type: Wrapper) { gradleVersion = '4.1' }