diff --git a/cscore/build.gradle b/cscore/build.gradle index 3769628e60..c7bad1c77d 100644 --- a/cscore/build.gradle +++ b/cscore/build.gradle @@ -5,6 +5,10 @@ ext { devMain = 'edu.wpi.cscore.DevMain' } +if (OperatingSystem.current().isMacOsX()) { + apply plugin: 'objective-cpp' +} + apply from: "${rootDir}/shared/jni/setupBuild.gradle" ext { @@ -15,6 +19,21 @@ ext { staticCvConfigs = [cscoreJNI: []] useJava = true useCpp = true + splitSetup = { + if (it.targetPlatform.operatingSystem.name == 'osx') { + it.sources { + macObjCpp(ObjectiveCppSourceSet) { + source { + srcDirs = ['src/main/native/objcpp'] + include '**/*.mm' + } + exportedHeaders { + srcDirs 'src/main/native/include' + } + } + } + } + } } def examplesMap = [:]; diff --git a/cscore/src/main/native/objcpp/objcpptemp.mm b/cscore/src/main/native/objcpp/objcpptemp.mm new file mode 100644 index 0000000000..27aaaff17f --- /dev/null +++ b/cscore/src/main/native/objcpp/objcpptemp.mm @@ -0,0 +1,12 @@ +#import + +@interface XYZPerson : NSObject +- (void)sayHello; +@end + + +@implementation XYZPerson +- (void)sayHello { + NSLog(@"Hello, World!"); +} +@end diff --git a/shared/config.gradle b/shared/config.gradle index 14597ab690..0bb9cb50b7 100644 --- a/shared/config.gradle +++ b/shared/config.gradle @@ -21,8 +21,10 @@ def macCompilerArgs = ['-std=c++14', '-Wall', '-Wextra', '-Werror', '-pedantic-e '-Wno-unused-const-variable', '-pthread'] def macCCompilerArgs = ['-Wall', '-Wextra', '-Werror', '-pedantic-errors', '-fPIC', '-g', '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-unused-private-field'] +def macObjCLinkerArgs = ['-std=c++14', '-stdlib=libc++','-fobjc-arc', '-g', '-fPIC', '-Wall', '-Wextra', '-Werror'] def macReleaseCompilerArgs = ['-O2'] def macDebugCompilerArgs = ['-O0'] +def macLinkerArgs = ['-framework', 'CoreFoundation', '-framework', 'AVFoundation', '-framework', 'Foundation', '-framework', 'CoreMedia', '-framework', 'CoreVideo'] def mac32BitArg = '-m32' def buildAll = project.hasProperty('buildAll') @@ -158,6 +160,8 @@ if (!project.hasProperty('onlyAthena')) { CCompilerArgs = macCCompilerArgs debugCompilerArgs = macDebugCompilerArgs releaseCompilerArgs = macReleaseCompilerArgs + objCppCompilerArgs = macObjCLinkerArgs + linkerArgs = macLinkerArgs releaseStripBinaries = true compilerFamily = 'Clang' detectPlatform = mac64PlatformDetect