diff --git a/.wpilib/wpilib_preferences.json b/.wpilib/wpilib_preferences.json index 0c8975e3f7..7e9049c2fb 100644 --- a/.wpilib/wpilib_preferences.json +++ b/.wpilib/wpilib_preferences.json @@ -1,6 +1,6 @@ -{ - "enableCppIntellisense": true, - "currentLanguage": "cpp", - "projectYear": "2019", - "teamNumber": 0 -} +{ + "enableCppIntellisense": true, + "currentLanguage": "cpp", + "projectYear": "2019", + "teamNumber": 0 +} diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 7bab0117e9..2270bacf24 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -1,9 +1,9 @@ -repositories { - maven { - url "https://plugins.gradle.org/m2/" - mavenLocal() - } -} -dependencies { - compile "edu.wpi.first:native-utils:2019.5.12" -} +repositories { + maven { + url "https://plugins.gradle.org/m2/" + mavenLocal() + } +} +dependencies { + compile "edu.wpi.first:native-utils:2019.5.12" +} diff --git a/buildSrc/src/main/groovy/MultiBuilds.groovy b/buildSrc/src/main/groovy/MultiBuilds.groovy index 8df7fc6d4c..1d5044d3bf 100644 --- a/buildSrc/src/main/groovy/MultiBuilds.groovy +++ b/buildSrc/src/main/groovy/MultiBuilds.groovy @@ -1,85 +1,85 @@ - -import org.gradle.api.GradleException; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.file.FileTree; -import org.gradle.api.tasks.compile.JavaCompile; -import org.gradle.language.base.internal.ProjectLayout; -import org.gradle.language.base.plugins.ComponentModelBasePlugin; -import org.gradle.language.nativeplatform.tasks.AbstractNativeSourceCompileTask; -import org.gradle.model.ModelMap; -import org.gradle.model.Mutate; -import org.gradle.nativeplatform.test.googletest.GoogleTestTestSuiteBinarySpec; -import org.gradle.model.RuleSource; -import org.gradle.model.Validate; -import org.gradle.nativeplatform.NativeExecutableBinarySpec -import org.gradle.nativeplatform.NativeBinarySpec; -import org.gradle.nativeplatform.NativeComponentSpec; -import org.gradle.nativeplatform.NativeLibrarySpec; -import org.gradle.nativeplatform.SharedLibraryBinarySpec; -import org.gradle.nativeplatform.StaticLibraryBinarySpec; -import org.gradle.nativeplatform.platform.internal.NativePlatformInternal; -import org.gradle.nativeplatform.toolchain.NativeToolChain; -import org.gradle.nativeplatform.toolchain.NativeToolChainRegistry; -import org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider; -import org.gradle.nativeplatform.toolchain.internal.ToolType; -import org.gradle.nativeplatform.toolchain.internal.gcc.AbstractGccCompatibleToolChain; -import org.gradle.nativeplatform.toolchain.internal.msvcpp.VisualCppToolChain; -import org.gradle.nativeplatform.toolchain.internal.tools.ToolRegistry; -import org.gradle.platform.base.BinarySpec; -import org.gradle.platform.base.ComponentSpec; -import org.gradle.platform.base.ComponentSpecContainer; -import org.gradle.platform.base.BinaryContainer; -import org.gradle.platform.base.ComponentType; -import org.gradle.platform.base.TypeBuilder; -import org.gradle.nativeplatform.tasks.ObjectFilesToBinary; -import groovy.transform.CompileStatic; -import groovy.transform.CompileDynamic -import org.gradle.nativeplatform.BuildTypeContainer - -@CompileStatic -class MultiBuilds implements Plugin { - @CompileStatic - public void apply(Project project) { - - } - - @CompileStatic - static class Rules extends RuleSource { - @CompileDynamic - private static void setBuildableFalseDynamically(NativeBinarySpec binary) { - binary.buildable = false - } - - @Mutate - @CompileStatic - void disableReleaseGoogleTest(BinaryContainer binaries, ProjectLayout projectLayout) { - def project = (Project) projectLayout.projectIdentifier - if (project.hasProperty('testRelease')) { - return - } - binaries.withType(GoogleTestTestSuiteBinarySpec) { oSpec -> - GoogleTestTestSuiteBinarySpec spec = (GoogleTestTestSuiteBinarySpec) oSpec - if (spec.buildType.name == 'release') { - Rules.setBuildableFalseDynamically(spec) - } - } - // def crossCompileConfigs = [] - // for (BuildConfig config : configs) { - // if (!BuildConfigRulesBase.isCrossCompile(config)) { - // continue - // } - // crossCompileConfigs << config.architecture - // } - // if (!crossCompileConfigs.empty) { - // binaries.withType(GoogleTestTestSuiteBinarySpec) { oSpec -> - // GoogleTestTestSuiteBinarySpec spec = (GoogleTestTestSuiteBinarySpec) oSpec - // if (crossCompileConfigs.contains(spec.targetPlatform.architecture.name)) { - // setBuildableFalseDynamically(spec) - // } - // } - // } - } - } -} + +import org.gradle.api.GradleException; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.Task; +import org.gradle.api.file.FileTree; +import org.gradle.api.tasks.compile.JavaCompile; +import org.gradle.language.base.internal.ProjectLayout; +import org.gradle.language.base.plugins.ComponentModelBasePlugin; +import org.gradle.language.nativeplatform.tasks.AbstractNativeSourceCompileTask; +import org.gradle.model.ModelMap; +import org.gradle.model.Mutate; +import org.gradle.nativeplatform.test.googletest.GoogleTestTestSuiteBinarySpec; +import org.gradle.model.RuleSource; +import org.gradle.model.Validate; +import org.gradle.nativeplatform.NativeExecutableBinarySpec +import org.gradle.nativeplatform.NativeBinarySpec; +import org.gradle.nativeplatform.NativeComponentSpec; +import org.gradle.nativeplatform.NativeLibrarySpec; +import org.gradle.nativeplatform.SharedLibraryBinarySpec; +import org.gradle.nativeplatform.StaticLibraryBinarySpec; +import org.gradle.nativeplatform.platform.internal.NativePlatformInternal; +import org.gradle.nativeplatform.toolchain.NativeToolChain; +import org.gradle.nativeplatform.toolchain.NativeToolChainRegistry; +import org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider; +import org.gradle.nativeplatform.toolchain.internal.ToolType; +import org.gradle.nativeplatform.toolchain.internal.gcc.AbstractGccCompatibleToolChain; +import org.gradle.nativeplatform.toolchain.internal.msvcpp.VisualCppToolChain; +import org.gradle.nativeplatform.toolchain.internal.tools.ToolRegistry; +import org.gradle.platform.base.BinarySpec; +import org.gradle.platform.base.ComponentSpec; +import org.gradle.platform.base.ComponentSpecContainer; +import org.gradle.platform.base.BinaryContainer; +import org.gradle.platform.base.ComponentType; +import org.gradle.platform.base.TypeBuilder; +import org.gradle.nativeplatform.tasks.ObjectFilesToBinary; +import groovy.transform.CompileStatic; +import groovy.transform.CompileDynamic +import org.gradle.nativeplatform.BuildTypeContainer + +@CompileStatic +class MultiBuilds implements Plugin { + @CompileStatic + public void apply(Project project) { + + } + + @CompileStatic + static class Rules extends RuleSource { + @CompileDynamic + private static void setBuildableFalseDynamically(NativeBinarySpec binary) { + binary.buildable = false + } + + @Mutate + @CompileStatic + void disableReleaseGoogleTest(BinaryContainer binaries, ProjectLayout projectLayout) { + def project = (Project) projectLayout.projectIdentifier + if (project.hasProperty('testRelease')) { + return + } + binaries.withType(GoogleTestTestSuiteBinarySpec) { oSpec -> + GoogleTestTestSuiteBinarySpec spec = (GoogleTestTestSuiteBinarySpec) oSpec + if (spec.buildType.name == 'release') { + Rules.setBuildableFalseDynamically(spec) + } + } + // def crossCompileConfigs = [] + // for (BuildConfig config : configs) { + // if (!BuildConfigRulesBase.isCrossCompile(config)) { + // continue + // } + // crossCompileConfigs << config.architecture + // } + // if (!crossCompileConfigs.empty) { + // binaries.withType(GoogleTestTestSuiteBinarySpec) { oSpec -> + // GoogleTestTestSuiteBinarySpec spec = (GoogleTestTestSuiteBinarySpec) oSpec + // if (crossCompileConfigs.contains(spec.targetPlatform.architecture.name)) { + // setBuildableFalseDynamically(spec) + // } + // } + // } + } + } +} diff --git a/cmake/toolchains/arm-frc-gnueabi.toolchain.cmake b/cmake/toolchains/arm-frc-gnueabi.toolchain.cmake index 6c7fd88892..960d29b256 100644 --- a/cmake/toolchains/arm-frc-gnueabi.toolchain.cmake +++ b/cmake/toolchains/arm-frc-gnueabi.toolchain.cmake @@ -1,5 +1,5 @@ - -set(GCC_COMPILER_VERSION "" CACHE STRING "GCC Compiler version") -set(GNU_MACHINE "arm-frc2019-linux-gnueabi" CACHE STRING "GNU compiler triple") -set(SOFTFP yes) -include("${CMAKE_CURRENT_LIST_DIR}/arm.toolchain.cmake") + +set(GCC_COMPILER_VERSION "" CACHE STRING "GCC Compiler version") +set(GNU_MACHINE "arm-frc2019-linux-gnueabi" CACHE STRING "GNU compiler triple") +set(SOFTFP yes) +include("${CMAKE_CURRENT_LIST_DIR}/arm.toolchain.cmake") diff --git a/cmake/toolchains/arm-pi-gnueabihf.toolchain.cmake b/cmake/toolchains/arm-pi-gnueabihf.toolchain.cmake index f0dd5ced09..0518cbb59a 100644 --- a/cmake/toolchains/arm-pi-gnueabihf.toolchain.cmake +++ b/cmake/toolchains/arm-pi-gnueabihf.toolchain.cmake @@ -1,98 +1,98 @@ -set(GCC_COMPILER_VERSION "" CACHE STRING "GCC Compiler version") -set(GNU_MACHINE "arm-raspbian9-linux-gnueabi" CACHE STRING "GNU compiler triple") - -if(COMMAND toolchain_save_config) - return() # prevent recursive call -endif() - -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_VERSION 1) -if(NOT DEFINED CMAKE_SYSTEM_PROCESSOR) - set(CMAKE_SYSTEM_PROCESSOR arm) -else() - #message("CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}") -endif() - -include("${CMAKE_CURRENT_LIST_DIR}/opencv/platforms/linux/gnu.toolchain.cmake") - -if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm AND NOT ARM_IGNORE_FP) - set(FLOAT_ABI_SUFFIX "") - if(NOT SOFTFP) - set(FLOAT_ABI_SUFFIX "hf") - endif() -endif() - -if(NOT "x${GCC_COMPILER_VERSION}" STREQUAL "x") - set(__GCC_VER_SUFFIX "-${GCC_COMPILER_VERSION}") -endif() - -if(NOT DEFINED CMAKE_C_COMPILER) - find_program(CMAKE_C_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-gcc${__GCC_VER_SUFFIX}) -else() - #message(WARNING "CMAKE_C_COMPILER=${CMAKE_C_COMPILER} is defined") -endif() -if(NOT DEFINED CMAKE_CXX_COMPILER) - find_program(CMAKE_CXX_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-g++${__GCC_VER_SUFFIX}) -else() - #message(WARNING "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} is defined") -endif() -if(NOT DEFINED CMAKE_LINKER) - find_program(CMAKE_LINKER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld) -else() - #message(WARNING "CMAKE_LINKER=${CMAKE_LINKER} is defined") -endif() -if(NOT DEFINED CMAKE_AR) - find_program(CMAKE_AR NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar) -else() - #message(WARNING "CMAKE_AR=${CMAKE_AR} is defined") -endif() - -if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE) - set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX}) -endif() - -if(NOT DEFINED CMAKE_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "") - set(CMAKE_C_FLAGS "" CACHE INTERNAL "") - set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "") - set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "") - set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "") - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi") - if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,nocopyreloc") - endif() - if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) - set(ARM_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") - elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) - set(ARM_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") - endif() - set(CMAKE_SHARED_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") - set(CMAKE_MODULE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") -else() - #message(WARNING "CMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}' is defined") -endif() - -if(USE_NEON) - message(WARNING "You use obsolete variable USE_NEON to enable NEON instruction set. Use -DENABLE_NEON=ON instead." ) - set(ENABLE_NEON TRUE) -elseif(USE_VFPV3) - message(WARNING "You use obsolete variable USE_VFPV3 to enable VFPV3 instruction set. Use -DENABLE_VFPV3=ON instead." ) - set(ENABLE_VFPV3 TRUE) -endif() - -set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${ARM_LINUX_SYSROOT}) - -if(EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) - set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CUDA_TOOLKIT_ROOT_DIR}) -endif() - -set(TOOLCHAIN_CONFIG_VARS ${TOOLCHAIN_CONFIG_VARS} - ARM_LINUX_SYSROOT - ENABLE_NEON - ENABLE_VFPV3 - CUDA_TOOLKIT_ROOT_DIR -) -toolchain_save_config() +set(GCC_COMPILER_VERSION "" CACHE STRING "GCC Compiler version") +set(GNU_MACHINE "arm-raspbian9-linux-gnueabi" CACHE STRING "GNU compiler triple") + +if(COMMAND toolchain_save_config) + return() # prevent recursive call +endif() + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_VERSION 1) +if(NOT DEFINED CMAKE_SYSTEM_PROCESSOR) + set(CMAKE_SYSTEM_PROCESSOR arm) +else() + #message("CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}") +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/opencv/platforms/linux/gnu.toolchain.cmake") + +if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm AND NOT ARM_IGNORE_FP) + set(FLOAT_ABI_SUFFIX "") + if(NOT SOFTFP) + set(FLOAT_ABI_SUFFIX "hf") + endif() +endif() + +if(NOT "x${GCC_COMPILER_VERSION}" STREQUAL "x") + set(__GCC_VER_SUFFIX "-${GCC_COMPILER_VERSION}") +endif() + +if(NOT DEFINED CMAKE_C_COMPILER) + find_program(CMAKE_C_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-gcc${__GCC_VER_SUFFIX}) +else() + #message(WARNING "CMAKE_C_COMPILER=${CMAKE_C_COMPILER} is defined") +endif() +if(NOT DEFINED CMAKE_CXX_COMPILER) + find_program(CMAKE_CXX_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-g++${__GCC_VER_SUFFIX}) +else() + #message(WARNING "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} is defined") +endif() +if(NOT DEFINED CMAKE_LINKER) + find_program(CMAKE_LINKER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld) +else() + #message(WARNING "CMAKE_LINKER=${CMAKE_LINKER} is defined") +endif() +if(NOT DEFINED CMAKE_AR) + find_program(CMAKE_AR NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar) +else() + #message(WARNING "CMAKE_AR=${CMAKE_AR} is defined") +endif() + +if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE) + set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX}) +endif() + +if(NOT DEFINED CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "") + set(CMAKE_C_FLAGS "" CACHE INTERNAL "") + set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "") + set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "") + set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "") + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi") + if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,nocopyreloc") + endif() + if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + set(ARM_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) + set(ARM_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") + endif() + set(CMAKE_SHARED_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_MODULE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") +else() + #message(WARNING "CMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}' is defined") +endif() + +if(USE_NEON) + message(WARNING "You use obsolete variable USE_NEON to enable NEON instruction set. Use -DENABLE_NEON=ON instead." ) + set(ENABLE_NEON TRUE) +elseif(USE_VFPV3) + message(WARNING "You use obsolete variable USE_VFPV3 to enable VFPV3 instruction set. Use -DENABLE_VFPV3=ON instead." ) + set(ENABLE_VFPV3 TRUE) +endif() + +set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${ARM_LINUX_SYSROOT}) + +if(EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CUDA_TOOLKIT_ROOT_DIR}) +endif() + +set(TOOLCHAIN_CONFIG_VARS ${TOOLCHAIN_CONFIG_VARS} + ARM_LINUX_SYSROOT + ENABLE_NEON + ENABLE_VFPV3 + CUDA_TOOLKIT_ROOT_DIR +) +toolchain_save_config() diff --git a/cmake/toolchains/arm.toolchain.cmake b/cmake/toolchains/arm.toolchain.cmake index 4d63360d51..184997fba5 100644 --- a/cmake/toolchains/arm.toolchain.cmake +++ b/cmake/toolchains/arm.toolchain.cmake @@ -1,97 +1,97 @@ -if(COMMAND toolchain_save_config) - return() # prevent recursive call -endif() - -set(CMAKE_SYSTEM_NAME Linux) -set(CMAKE_SYSTEM_VERSION 1) -if(NOT DEFINED CMAKE_SYSTEM_PROCESSOR) - set(CMAKE_SYSTEM_PROCESSOR arm) -else() - #message("CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}") -endif() - -include("${CMAKE_CURRENT_LIST_DIR}/gnu.toolchain.cmake") - -if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm AND NOT ARM_IGNORE_FP) - set(FLOAT_ABI_SUFFIX "") - if(NOT SOFTFP) - set(FLOAT_ABI_SUFFIX "hf") - endif() -endif() - -if(NOT "x${GCC_COMPILER_VERSION}" STREQUAL "x") - set(__GCC_VER_SUFFIX "-${GCC_COMPILER_VERSION}") -endif() - -if(NOT DEFINED CMAKE_C_COMPILER) - find_program(CMAKE_C_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-gcc${__GCC_VER_SUFFIX}) -else() - #message(WARNING "CMAKE_C_COMPILER=${CMAKE_C_COMPILER} is defined") -endif() -if(NOT DEFINED CMAKE_CXX_COMPILER) - find_program(CMAKE_CXX_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-g++${__GCC_VER_SUFFIX}) -else() - #message(WARNING "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} is defined") -endif() -if(NOT DEFINED CMAKE_LINKER) - find_program(CMAKE_LINKER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld) -else() - #message(WARNING "CMAKE_LINKER=${CMAKE_LINKER} is defined") -endif() -if(NOT DEFINED CMAKE_AR) - find_program(CMAKE_AR NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar) -else() - #message(WARNING "CMAKE_AR=${CMAKE_AR} is defined") -endif() - -if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE) - set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX}) -endif() - -if(NOT DEFINED CMAKE_CXX_FLAGS) - set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "") - set(CMAKE_C_FLAGS "" CACHE INTERNAL "") - set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "") - set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "") - set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "") - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi") - if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) - set(CMAKE_CXX_FLAGS "-mthumb ${CMAKE_CXX_FLAGS}") - set(CMAKE_C_FLAGS "-mthumb ${CMAKE_C_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,nocopyreloc") - endif() - if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) - set(ARM_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") - elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) - set(ARM_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") - endif() - set(CMAKE_SHARED_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") - set(CMAKE_MODULE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") -else() - #message(WARNING "CMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}' is defined") -endif() - -if(USE_NEON) - message(WARNING "You use obsolete variable USE_NEON to enable NEON instruction set. Use -DENABLE_NEON=ON instead." ) - set(ENABLE_NEON TRUE) -elseif(USE_VFPV3) - message(WARNING "You use obsolete variable USE_VFPV3 to enable VFPV3 instruction set. Use -DENABLE_VFPV3=ON instead." ) - set(ENABLE_VFPV3 TRUE) -endif() - -set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${ARM_LINUX_SYSROOT}) - -if(EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) - set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CUDA_TOOLKIT_ROOT_DIR}) -endif() - -set(TOOLCHAIN_CONFIG_VARS ${TOOLCHAIN_CONFIG_VARS} - ARM_LINUX_SYSROOT - ENABLE_NEON - ENABLE_VFPV3 - CUDA_TOOLKIT_ROOT_DIR -) -toolchain_save_config() +if(COMMAND toolchain_save_config) + return() # prevent recursive call +endif() + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_VERSION 1) +if(NOT DEFINED CMAKE_SYSTEM_PROCESSOR) + set(CMAKE_SYSTEM_PROCESSOR arm) +else() + #message("CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}") +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/gnu.toolchain.cmake") + +if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm AND NOT ARM_IGNORE_FP) + set(FLOAT_ABI_SUFFIX "") + if(NOT SOFTFP) + set(FLOAT_ABI_SUFFIX "hf") + endif() +endif() + +if(NOT "x${GCC_COMPILER_VERSION}" STREQUAL "x") + set(__GCC_VER_SUFFIX "-${GCC_COMPILER_VERSION}") +endif() + +if(NOT DEFINED CMAKE_C_COMPILER) + find_program(CMAKE_C_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-gcc${__GCC_VER_SUFFIX}) +else() + #message(WARNING "CMAKE_C_COMPILER=${CMAKE_C_COMPILER} is defined") +endif() +if(NOT DEFINED CMAKE_CXX_COMPILER) + find_program(CMAKE_CXX_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-g++${__GCC_VER_SUFFIX}) +else() + #message(WARNING "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} is defined") +endif() +if(NOT DEFINED CMAKE_LINKER) + find_program(CMAKE_LINKER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld) +else() + #message(WARNING "CMAKE_LINKER=${CMAKE_LINKER} is defined") +endif() +if(NOT DEFINED CMAKE_AR) + find_program(CMAKE_AR NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar) +else() + #message(WARNING "CMAKE_AR=${CMAKE_AR} is defined") +endif() + +if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE) + set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX}) +endif() + +if(NOT DEFINED CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "") + set(CMAKE_C_FLAGS "" CACHE INTERNAL "") + set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "") + set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "") + set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "") + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi") + if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + set(CMAKE_CXX_FLAGS "-mthumb ${CMAKE_CXX_FLAGS}") + set(CMAKE_C_FLAGS "-mthumb ${CMAKE_C_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,nocopyreloc") + endif() + if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + set(ARM_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) + set(ARM_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") + endif() + set(CMAKE_SHARED_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_MODULE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") +else() + #message(WARNING "CMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}' is defined") +endif() + +if(USE_NEON) + message(WARNING "You use obsolete variable USE_NEON to enable NEON instruction set. Use -DENABLE_NEON=ON instead." ) + set(ENABLE_NEON TRUE) +elseif(USE_VFPV3) + message(WARNING "You use obsolete variable USE_VFPV3 to enable VFPV3 instruction set. Use -DENABLE_VFPV3=ON instead." ) + set(ENABLE_VFPV3 TRUE) +endif() + +set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${ARM_LINUX_SYSROOT}) + +if(EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CUDA_TOOLKIT_ROOT_DIR}) +endif() + +set(TOOLCHAIN_CONFIG_VARS ${TOOLCHAIN_CONFIG_VARS} + ARM_LINUX_SYSROOT + ENABLE_NEON + ENABLE_VFPV3 + CUDA_TOOLKIT_ROOT_DIR +) +toolchain_save_config() diff --git a/cmake/toolchains/gnu.toolchain.cmake b/cmake/toolchains/gnu.toolchain.cmake index 189b718d42..cba08e7fbb 100644 --- a/cmake/toolchains/gnu.toolchain.cmake +++ b/cmake/toolchains/gnu.toolchain.cmake @@ -1,134 +1,134 @@ -cmake_minimum_required(VERSION 2.8) - -# load settings in case of "try compile" -set(TOOLCHAIN_CONFIG_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toolchain.config.cmake") -get_property(__IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE) -if(__IN_TRY_COMPILE) - include("${CMAKE_CURRENT_SOURCE_DIR}/../toolchain.config.cmake" OPTIONAL) # CMAKE_BINARY_DIR is different - macro(toolchain_save_config) - # nothing - endmacro() -else() - macro(toolchain_save_config) - set(__config "#message(\"Load TOOLCHAIN config...\")\n") - get_cmake_property(__variableNames VARIABLES) - set(__vars_list ${ARGN}) - list(APPEND __vars_list - ${TOOLCHAIN_CONFIG_VARS} - CMAKE_SYSTEM_NAME - CMAKE_SYSTEM_VERSION - CMAKE_SYSTEM_PROCESSOR - CMAKE_C_COMPILER - CMAKE_CXX_COMPILER - CMAKE_C_FLAGS - CMAKE_CXX_FLAGS - CMAKE_SHARED_LINKER_FLAGS - CMAKE_MODULE_LINKER_FLAGS - CMAKE_EXE_LINKER_FLAGS - CMAKE_SKIP_RPATH - CMAKE_FIND_ROOT_PATH - GCC_COMPILER_VERSION - ) - foreach(__var ${__variableNames}) - foreach(_v ${__vars_list}) - if("x${__var}" STREQUAL "x${_v}") - if(${__var} MATCHES " ") - set(__config "${__config}set(${__var} \"${${__var}}\")\n") - else() - set(__config "${__config}set(${__var} ${${__var}})\n") - endif() - endif() - endforeach() - endforeach() - if(EXISTS "${TOOLCHAIN_CONFIG_FILE}") - file(READ "${TOOLCHAIN_CONFIG_FILE}" __config_old) - endif() - if("${__config_old}" STREQUAL "${__config}") - # nothing - else() - #message("Update TOOLCHAIN config: ${__config}") - file(WRITE "${TOOLCHAIN_CONFIG_FILE}" "${__config}") - endif() - unset(__config) - unset(__config_old) - unset(__vars_list) - unset(__variableNames) - endmacro() -endif() # IN_TRY_COMPILE - -if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -endif() - -if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -endif() - -if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) -endif() - -if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -endif() - -macro(__cmake_find_root_save_and_reset) - foreach(v - CMAKE_FIND_ROOT_PATH_MODE_LIBRARY - CMAKE_FIND_ROOT_PATH_MODE_INCLUDE - CMAKE_FIND_ROOT_PATH_MODE_PACKAGE - CMAKE_FIND_ROOT_PATH_MODE_PROGRAM - ) - set(__save_${v} ${${v}}) - set(${v} NEVER) - endforeach() -endmacro() - -macro(__cmake_find_root_restore) - foreach(v - CMAKE_FIND_ROOT_PATH_MODE_LIBRARY - CMAKE_FIND_ROOT_PATH_MODE_INCLUDE - CMAKE_FIND_ROOT_PATH_MODE_PACKAGE - CMAKE_FIND_ROOT_PATH_MODE_PROGRAM - ) - set(${v} ${__save_${v}}) - unset(__save_${v}) - endforeach() -endmacro() - - -# macro to find programs on the host OS -macro(find_host_program) - __cmake_find_root_save_and_reset() - if(CMAKE_HOST_WIN32) - SET(WIN32 1) - SET(UNIX) - elseif(CMAKE_HOST_APPLE) - SET(APPLE 1) - SET(UNIX) - endif() - find_program(${ARGN}) - SET(WIN32) - SET(APPLE) - SET(UNIX 1) - __cmake_find_root_restore() -endmacro() - -# macro to find packages on the host OS -macro(find_host_package) - __cmake_find_root_save_and_reset() - if(CMAKE_HOST_WIN32) - SET(WIN32 1) - SET(UNIX) - elseif(CMAKE_HOST_APPLE) - SET(APPLE 1) - SET(UNIX) - endif() - find_package(${ARGN}) - SET(WIN32) - SET(APPLE) - SET(UNIX 1) - __cmake_find_root_restore() -endmacro() - -set(CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries.") +cmake_minimum_required(VERSION 2.8) + +# load settings in case of "try compile" +set(TOOLCHAIN_CONFIG_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toolchain.config.cmake") +get_property(__IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE) +if(__IN_TRY_COMPILE) + include("${CMAKE_CURRENT_SOURCE_DIR}/../toolchain.config.cmake" OPTIONAL) # CMAKE_BINARY_DIR is different + macro(toolchain_save_config) + # nothing + endmacro() +else() + macro(toolchain_save_config) + set(__config "#message(\"Load TOOLCHAIN config...\")\n") + get_cmake_property(__variableNames VARIABLES) + set(__vars_list ${ARGN}) + list(APPEND __vars_list + ${TOOLCHAIN_CONFIG_VARS} + CMAKE_SYSTEM_NAME + CMAKE_SYSTEM_VERSION + CMAKE_SYSTEM_PROCESSOR + CMAKE_C_COMPILER + CMAKE_CXX_COMPILER + CMAKE_C_FLAGS + CMAKE_CXX_FLAGS + CMAKE_SHARED_LINKER_FLAGS + CMAKE_MODULE_LINKER_FLAGS + CMAKE_EXE_LINKER_FLAGS + CMAKE_SKIP_RPATH + CMAKE_FIND_ROOT_PATH + GCC_COMPILER_VERSION + ) + foreach(__var ${__variableNames}) + foreach(_v ${__vars_list}) + if("x${__var}" STREQUAL "x${_v}") + if(${__var} MATCHES " ") + set(__config "${__config}set(${__var} \"${${__var}}\")\n") + else() + set(__config "${__config}set(${__var} ${${__var}})\n") + endif() + endif() + endforeach() + endforeach() + if(EXISTS "${TOOLCHAIN_CONFIG_FILE}") + file(READ "${TOOLCHAIN_CONFIG_FILE}" __config_old) + endif() + if("${__config_old}" STREQUAL "${__config}") + # nothing + else() + #message("Update TOOLCHAIN config: ${__config}") + file(WRITE "${TOOLCHAIN_CONFIG_FILE}" "${__config}") + endif() + unset(__config) + unset(__config_old) + unset(__vars_list) + unset(__variableNames) + endmacro() +endif() # IN_TRY_COMPILE + +if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +endif() + +if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +endif() + +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +endif() + +macro(__cmake_find_root_save_and_reset) + foreach(v + CMAKE_FIND_ROOT_PATH_MODE_LIBRARY + CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + CMAKE_FIND_ROOT_PATH_MODE_PACKAGE + CMAKE_FIND_ROOT_PATH_MODE_PROGRAM + ) + set(__save_${v} ${${v}}) + set(${v} NEVER) + endforeach() +endmacro() + +macro(__cmake_find_root_restore) + foreach(v + CMAKE_FIND_ROOT_PATH_MODE_LIBRARY + CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + CMAKE_FIND_ROOT_PATH_MODE_PACKAGE + CMAKE_FIND_ROOT_PATH_MODE_PROGRAM + ) + set(${v} ${__save_${v}}) + unset(__save_${v}) + endforeach() +endmacro() + + +# macro to find programs on the host OS +macro(find_host_program) + __cmake_find_root_save_and_reset() + if(CMAKE_HOST_WIN32) + SET(WIN32 1) + SET(UNIX) + elseif(CMAKE_HOST_APPLE) + SET(APPLE 1) + SET(UNIX) + endif() + find_program(${ARGN}) + SET(WIN32) + SET(APPLE) + SET(UNIX 1) + __cmake_find_root_restore() +endmacro() + +# macro to find packages on the host OS +macro(find_host_package) + __cmake_find_root_save_and_reset() + if(CMAKE_HOST_WIN32) + SET(WIN32 1) + SET(UNIX) + elseif(CMAKE_HOST_APPLE) + SET(APPLE 1) + SET(UNIX) + endif() + find_package(${ARGN}) + SET(WIN32) + SET(APPLE) + SET(UNIX 1) + __cmake_find_root_restore() +endmacro() + +set(CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries.") diff --git a/cscore/cscore-config.cmake.in b/cscore/cscore-config.cmake.in index 7894fbaece..da85e8b6ad 100644 --- a/cscore/cscore-config.cmake.in +++ b/cscore/cscore-config.cmake.in @@ -1,6 +1,6 @@ -include(CMakeFindDependencyMacro) -@FILENAME_DEP_REPLACE@ -@WPIUTIL_DEP_REPLACE@ -find_dependency(OpenCV) - -include(${SELF_DIR}/cscore.cmake) +include(CMakeFindDependencyMacro) +@FILENAME_DEP_REPLACE@ +@WPIUTIL_DEP_REPLACE@ +find_dependency(OpenCV) + +include(${SELF_DIR}/cscore.cmake) diff --git a/hal/src/generate/FRCNetComm.java.in b/hal/src/generate/FRCNetComm.java.in index af49407b2d..2c2f924e0a 100644 --- a/hal/src/generate/FRCNetComm.java.in +++ b/hal/src/generate/FRCNetComm.java.in @@ -1,33 +1,33 @@ -/* - * Autogenerated file! Do not manually edit this file. - */ - -package edu.wpi.first.hal; - -/** - * JNI wrapper for library FRC_NetworkCommunication
. - */ -@SuppressWarnings({"MethodName", "LineLength"}) -public class FRCNetComm { - /** - * Resource type from UsageReporting. - */ - @SuppressWarnings({"TypeName", "PMD.ConstantsInInterface"}) - public static final class tResourceType { - private tResourceType() { - } - -${usage_reporting_types} - } - - /** - * Instances from UsageReporting. - */ - @SuppressWarnings({"TypeName", "PMD.ConstantsInInterface"}) - public static final class tInstances { - private tInstances() { - } - -${usage_reporting_instances} - } -} +/* + * Autogenerated file! Do not manually edit this file. + */ + +package edu.wpi.first.hal; + +/** + * JNI wrapper for library FRC_NetworkCommunication
. + */ +@SuppressWarnings({"MethodName", "LineLength"}) +public class FRCNetComm { + /** + * Resource type from UsageReporting. + */ + @SuppressWarnings({"TypeName", "PMD.ConstantsInInterface"}) + public static final class tResourceType { + private tResourceType() { + } + +${usage_reporting_types} + } + + /** + * Instances from UsageReporting. + */ + @SuppressWarnings({"TypeName", "PMD.ConstantsInInterface"}) + public static final class tInstances { + private tInstances() { + } + +${usage_reporting_instances} + } +} diff --git a/hal/src/generate/FRCUsageReporting.h.in b/hal/src/generate/FRCUsageReporting.h.in index 7cf8128171..0ed3b33bbb 100644 --- a/hal/src/generate/FRCUsageReporting.h.in +++ b/hal/src/generate/FRCUsageReporting.h.in @@ -1,14 +1,14 @@ -#pragma once - -/* - * Autogenerated file! Do not manually edit this file. - */ - -namespace HALUsageReporting { - typedef enum { -${usage_reporting_types_cpp} - } tResourceType; - typedef enum { -${usage_reporting_instances_cpp} - } tInstances; -} +#pragma once + +/* + * Autogenerated file! Do not manually edit this file. + */ + +namespace HALUsageReporting { + typedef enum { +${usage_reporting_types_cpp} + } tResourceType; + typedef enum { +${usage_reporting_instances_cpp} + } tInstances; +} diff --git a/hal/src/generate/Instances.txt b/hal/src/generate/Instances.txt index 25fc463f7b..e7e9fea662 100644 --- a/hal/src/generate/Instances.txt +++ b/hal/src/generate/Instances.txt @@ -1,44 +1,44 @@ -kLanguage_LabVIEW = 1 -kLanguage_CPlusPlus = 2 -kLanguage_Java = 3 -kLanguage_Python = 4 -kLanguage_DotNet = 5 -kCANPlugin_BlackJagBridge = 1 -kCANPlugin_2CAN = 2 -kFramework_Iterative = 1 -kFramework_Simple = 2 -kFramework_CommandControl = 3 -kFramework_Timed = 4 -kFramework_ROS = 5 -kFramework_RobotBuilder = 6 -kRobotDrive_ArcadeStandard = 1 -kRobotDrive_ArcadeButtonSpin = 2 -kRobotDrive_ArcadeRatioCurve = 3 -kRobotDrive_Tank = 4 -kRobotDrive_MecanumPolar = 5 -kRobotDrive_MecanumCartesian = 6 -kRobotDrive2_DifferentialArcade = 7 -kRobotDrive2_DifferentialTank = 8 -kRobotDrive2_DifferentialCurvature = 9 -kRobotDrive2_MecanumCartesian = 10 -kRobotDrive2_MecanumPolar = 11 -kRobotDrive2_KilloughCartesian = 12 -kRobotDrive2_KilloughPolar = 13 -kDriverStationCIO_Analog = 1 -kDriverStationCIO_DigitalIn = 2 -kDriverStationCIO_DigitalOut = 3 -kDriverStationEIO_Acceleration = 1 -kDriverStationEIO_AnalogIn = 2 -kDriverStationEIO_AnalogOut = 3 -kDriverStationEIO_Button = 4 -kDriverStationEIO_LED = 5 -kDriverStationEIO_DigitalIn = 6 -kDriverStationEIO_DigitalOut = 7 -kDriverStationEIO_FixedDigitalOut = 8 -kDriverStationEIO_PWM = 9 -kDriverStationEIO_Encoder = 10 -kDriverStationEIO_TouchSlider = 11 -kADXL345_SPI = 1 -kADXL345_I2C = 2 -kCommand_Scheduler = 1 -kSmartDashboard_Instance = 1 +kLanguage_LabVIEW = 1 +kLanguage_CPlusPlus = 2 +kLanguage_Java = 3 +kLanguage_Python = 4 +kLanguage_DotNet = 5 +kCANPlugin_BlackJagBridge = 1 +kCANPlugin_2CAN = 2 +kFramework_Iterative = 1 +kFramework_Simple = 2 +kFramework_CommandControl = 3 +kFramework_Timed = 4 +kFramework_ROS = 5 +kFramework_RobotBuilder = 6 +kRobotDrive_ArcadeStandard = 1 +kRobotDrive_ArcadeButtonSpin = 2 +kRobotDrive_ArcadeRatioCurve = 3 +kRobotDrive_Tank = 4 +kRobotDrive_MecanumPolar = 5 +kRobotDrive_MecanumCartesian = 6 +kRobotDrive2_DifferentialArcade = 7 +kRobotDrive2_DifferentialTank = 8 +kRobotDrive2_DifferentialCurvature = 9 +kRobotDrive2_MecanumCartesian = 10 +kRobotDrive2_MecanumPolar = 11 +kRobotDrive2_KilloughCartesian = 12 +kRobotDrive2_KilloughPolar = 13 +kDriverStationCIO_Analog = 1 +kDriverStationCIO_DigitalIn = 2 +kDriverStationCIO_DigitalOut = 3 +kDriverStationEIO_Acceleration = 1 +kDriverStationEIO_AnalogIn = 2 +kDriverStationEIO_AnalogOut = 3 +kDriverStationEIO_Button = 4 +kDriverStationEIO_LED = 5 +kDriverStationEIO_DigitalIn = 6 +kDriverStationEIO_DigitalOut = 7 +kDriverStationEIO_FixedDigitalOut = 8 +kDriverStationEIO_PWM = 9 +kDriverStationEIO_Encoder = 10 +kDriverStationEIO_TouchSlider = 11 +kADXL345_SPI = 1 +kADXL345_I2C = 2 +kCommand_Scheduler = 1 +kSmartDashboard_Instance = 1 diff --git a/hal/src/generate/ResourceType.txt b/hal/src/generate/ResourceType.txt index b8699b098c..1c9068af1a 100644 --- a/hal/src/generate/ResourceType.txt +++ b/hal/src/generate/ResourceType.txt @@ -1,85 +1,85 @@ -kResourceType_Controller = 0 -kResourceType_Module = 1 -kResourceType_Language = 2 -kResourceType_CANPlugin = 3 -kResourceType_Accelerometer = 4 -kResourceType_ADXL345 = 5 -kResourceType_AnalogChannel = 6 -kResourceType_AnalogTrigger = 7 -kResourceType_AnalogTriggerOutput = 8 -kResourceType_CANJaguar = 9 -kResourceType_Compressor = 10 -kResourceType_Counter = 11 -kResourceType_Dashboard = 12 -kResourceType_DigitalInput = 13 -kResourceType_DigitalOutput = 14 -kResourceType_DriverStationCIO = 15 -kResourceType_DriverStationEIO = 16 -kResourceType_DriverStationLCD = 17 -kResourceType_Encoder = 18 -kResourceType_GearTooth = 19 -kResourceType_Gyro = 20 -kResourceType_I2C = 21 -kResourceType_Framework = 22 -kResourceType_Jaguar = 23 -kResourceType_Joystick = 24 -kResourceType_Kinect = 25 -kResourceType_KinectStick = 26 -kResourceType_PIDController = 27 -kResourceType_Preferences = 28 -kResourceType_PWM = 29 -kResourceType_Relay = 30 -kResourceType_RobotDrive = 31 -kResourceType_SerialPort = 32 -kResourceType_Servo = 33 -kResourceType_Solenoid = 34 -kResourceType_SPI = 35 -kResourceType_Task = 36 -kResourceType_Ultrasonic = 37 -kResourceType_Victor = 38 -kResourceType_Button = 39 -kResourceType_Command = 40 -kResourceType_AxisCamera = 41 -kResourceType_PCVideoServer = 42 -kResourceType_SmartDashboard = 43 -kResourceType_Talon = 44 -kResourceType_HiTechnicColorSensor = 45 -kResourceType_HiTechnicAccel = 46 -kResourceType_HiTechnicCompass = 47 -kResourceType_SRF08 = 48 -kResourceType_AnalogOutput = 49 -kResourceType_VictorSP = 50 -kResourceType_PWMTalonSRX = 51 -kResourceType_CANTalonSRX = 52 -kResourceType_ADXL362 = 53 -kResourceType_ADXRS450 = 54 -kResourceType_RevSPARK = 55 -kResourceType_MindsensorsSD540 = 56 -kResourceType_DigitalGlitchFilter = 57 -kResourceType_ADIS16448 = 58 -kResourceType_PDP = 59 -kResourceType_PCM = 60 -kResourceType_PigeonIMU = 61 -kResourceType_NidecBrushless = 62 -kResourceType_CANifier = 63 -kResourceType_CTRE_future0 = 64 -kResourceType_CTRE_future1 = 65 -kResourceType_CTRE_future2 = 66 -kResourceType_CTRE_future3 = 67 -kResourceType_CTRE_future4 = 68 -kResourceType_CTRE_future5 = 69 -kResourceType_CTRE_future6 = 70 -kResourceType_LinearFilter = 71 -kResourceType_XboxController = 72 -kResourceType_UsbCamera = 73 -kResourceType_NavX = 74 -kResourceType_Pixy = 75 -kResourceType_Pixy2 = 76 -kResourceType_ScanseSweep = 77 -kResourceType_Shuffleboard = 78 -kResourceType_CAN = 79 -kResourceType_DigilentDMC60 = 80 -kResourceType_PWMVictorSPX = 81 -kResourceType_RevSparkMaxPWM = 82 -kResourceType_RevSparkMaxCAN = 83 -kResourceType_ADIS16470 = 84 +kResourceType_Controller = 0 +kResourceType_Module = 1 +kResourceType_Language = 2 +kResourceType_CANPlugin = 3 +kResourceType_Accelerometer = 4 +kResourceType_ADXL345 = 5 +kResourceType_AnalogChannel = 6 +kResourceType_AnalogTrigger = 7 +kResourceType_AnalogTriggerOutput = 8 +kResourceType_CANJaguar = 9 +kResourceType_Compressor = 10 +kResourceType_Counter = 11 +kResourceType_Dashboard = 12 +kResourceType_DigitalInput = 13 +kResourceType_DigitalOutput = 14 +kResourceType_DriverStationCIO = 15 +kResourceType_DriverStationEIO = 16 +kResourceType_DriverStationLCD = 17 +kResourceType_Encoder = 18 +kResourceType_GearTooth = 19 +kResourceType_Gyro = 20 +kResourceType_I2C = 21 +kResourceType_Framework = 22 +kResourceType_Jaguar = 23 +kResourceType_Joystick = 24 +kResourceType_Kinect = 25 +kResourceType_KinectStick = 26 +kResourceType_PIDController = 27 +kResourceType_Preferences = 28 +kResourceType_PWM = 29 +kResourceType_Relay = 30 +kResourceType_RobotDrive = 31 +kResourceType_SerialPort = 32 +kResourceType_Servo = 33 +kResourceType_Solenoid = 34 +kResourceType_SPI = 35 +kResourceType_Task = 36 +kResourceType_Ultrasonic = 37 +kResourceType_Victor = 38 +kResourceType_Button = 39 +kResourceType_Command = 40 +kResourceType_AxisCamera = 41 +kResourceType_PCVideoServer = 42 +kResourceType_SmartDashboard = 43 +kResourceType_Talon = 44 +kResourceType_HiTechnicColorSensor = 45 +kResourceType_HiTechnicAccel = 46 +kResourceType_HiTechnicCompass = 47 +kResourceType_SRF08 = 48 +kResourceType_AnalogOutput = 49 +kResourceType_VictorSP = 50 +kResourceType_PWMTalonSRX = 51 +kResourceType_CANTalonSRX = 52 +kResourceType_ADXL362 = 53 +kResourceType_ADXRS450 = 54 +kResourceType_RevSPARK = 55 +kResourceType_MindsensorsSD540 = 56 +kResourceType_DigitalGlitchFilter = 57 +kResourceType_ADIS16448 = 58 +kResourceType_PDP = 59 +kResourceType_PCM = 60 +kResourceType_PigeonIMU = 61 +kResourceType_NidecBrushless = 62 +kResourceType_CANifier = 63 +kResourceType_CTRE_future0 = 64 +kResourceType_CTRE_future1 = 65 +kResourceType_CTRE_future2 = 66 +kResourceType_CTRE_future3 = 67 +kResourceType_CTRE_future4 = 68 +kResourceType_CTRE_future5 = 69 +kResourceType_CTRE_future6 = 70 +kResourceType_LinearFilter = 71 +kResourceType_XboxController = 72 +kResourceType_UsbCamera = 73 +kResourceType_NavX = 74 +kResourceType_Pixy = 75 +kResourceType_Pixy2 = 76 +kResourceType_ScanseSweep = 77 +kResourceType_Shuffleboard = 78 +kResourceType_CAN = 79 +kResourceType_DigilentDMC60 = 80 +kResourceType_PWMVictorSPX = 81 +kResourceType_RevSparkMaxPWM = 82 +kResourceType_RevSparkMaxCAN = 83 +kResourceType_ADIS16470 = 84 diff --git a/hal/src/main/native/include/hal/CANAPITypes.h b/hal/src/main/native/include/hal/CANAPITypes.h index dd075cab09..06f13ae439 100644 --- a/hal/src/main/native/include/hal/CANAPITypes.h +++ b/hal/src/main/native/include/hal/CANAPITypes.h @@ -1,60 +1,60 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include "hal/Types.h" - -/** - * @defgroup hal_canapi CAN API Functions - * @ingroup hal_capi - * @{ - */ - -// clang-format off -/** - * The CAN device type. - * - * Teams should use HAL_CAN_Dev_kMiscellaneous - */ -HAL_ENUM(HAL_CANDeviceType) { - HAL_CAN_Dev_kBroadcast = 0, - HAL_CAN_Dev_kRobotController = 1, - HAL_CAN_Dev_kMotorController = 2, - HAL_CAN_Dev_kRelayController = 3, - HAL_CAN_Dev_kGyroSensor = 4, - HAL_CAN_Dev_kAccelerometer = 5, - HAL_CAN_Dev_kUltrasonicSensor = 6, - HAL_CAN_Dev_kGearToothSensor = 7, - HAL_CAN_Dev_kPowerDistribution = 8, - HAL_CAN_Dev_kPneumatics = 9, - HAL_CAN_Dev_kMiscellaneous = 10, - HAL_CAN_Dev_kFirmwareUpdate = 31 -}; - -/** - * The CAN manufacturer ID. - * - * Teams should use HAL_CAN_Man_kTeamUse. - */ -HAL_ENUM(HAL_CANManufacturer) { - HAL_CAN_Man_kBroadcast = 0, - HAL_CAN_Man_kNI = 1, - HAL_CAN_Man_kLM = 2, - HAL_CAN_Man_kDEKA = 3, - HAL_CAN_Man_kCTRE = 4, - HAL_CAN_Man_kREV = 5, - HAL_CAN_Man_kGrapple = 6, - HAL_CAN_Man_kMS = 7, - HAL_CAN_Man_kTeamUse = 8, - HAL_CAN_Man_kKauaiLabs = 9, - HAL_CAN_Man_kCopperforge = 10 -}; -// clang-format on -/** @} */ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#pragma once + +#include + +#include "hal/Types.h" + +/** + * @defgroup hal_canapi CAN API Functions + * @ingroup hal_capi + * @{ + */ + +// clang-format off +/** + * The CAN device type. + * + * Teams should use HAL_CAN_Dev_kMiscellaneous + */ +HAL_ENUM(HAL_CANDeviceType) { + HAL_CAN_Dev_kBroadcast = 0, + HAL_CAN_Dev_kRobotController = 1, + HAL_CAN_Dev_kMotorController = 2, + HAL_CAN_Dev_kRelayController = 3, + HAL_CAN_Dev_kGyroSensor = 4, + HAL_CAN_Dev_kAccelerometer = 5, + HAL_CAN_Dev_kUltrasonicSensor = 6, + HAL_CAN_Dev_kGearToothSensor = 7, + HAL_CAN_Dev_kPowerDistribution = 8, + HAL_CAN_Dev_kPneumatics = 9, + HAL_CAN_Dev_kMiscellaneous = 10, + HAL_CAN_Dev_kFirmwareUpdate = 31 +}; + +/** + * The CAN manufacturer ID. + * + * Teams should use HAL_CAN_Man_kTeamUse. + */ +HAL_ENUM(HAL_CANManufacturer) { + HAL_CAN_Man_kBroadcast = 0, + HAL_CAN_Man_kNI = 1, + HAL_CAN_Man_kLM = 2, + HAL_CAN_Man_kDEKA = 3, + HAL_CAN_Man_kCTRE = 4, + HAL_CAN_Man_kREV = 5, + HAL_CAN_Man_kGrapple = 6, + HAL_CAN_Man_kMS = 7, + HAL_CAN_Man_kTeamUse = 8, + HAL_CAN_Man_kKauaiLabs = 9, + HAL_CAN_Man_kCopperforge = 10 +}; +// clang-format on +/** @} */ diff --git a/hal/src/main/native/include/hal/HALBase.h b/hal/src/main/native/include/hal/HALBase.h index fd22c0c8b4..c1a46d2885 100644 --- a/hal/src/main/native/include/hal/HALBase.h +++ b/hal/src/main/native/include/hal/HALBase.h @@ -1,182 +1,182 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -#pragma once - -#include - -#include "hal/Types.h" - -/** - * @defgroup hal_capi WPILib HAL API - * Hardware Abstraction Layer to hardware or simulator - * @{ - */ - -// clang-format off -HAL_ENUM(HAL_RuntimeType) { HAL_Athena, HAL_Mock }; -// clang-format on - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Gets the error message for a specific status code. - * - * @param code the status code - * @return the error message for the code. This does not need to be freed. - */ -const char* HAL_GetErrorMessage(int32_t code); - -/** - * Returns the FPGA Version number. - * - * For now, expect this to be competition year. - * - * @return FPGA Version number. - */ -int32_t HAL_GetFPGAVersion(int32_t* status); - -/** - * Returns the FPGA Revision number. - * - * The format of the revision is 3 numbers. - * The 12 most significant bits are the Major Revision. - * the next 8 bits are the Minor Revision. - * The 12 least significant bits are the Build Number. - * - * @return FPGA Revision number. - */ -int64_t HAL_GetFPGARevision(int32_t* status); - -HAL_RuntimeType HAL_GetRuntimeType(void); - -/** - * Gets the state of the "USER" button on the roboRIO. - * - * @return true if the button is currently pressed down - */ -HAL_Bool HAL_GetFPGAButton(int32_t* status); - -/** - * Gets if the system outputs are currently active - * - * @return true if the system outputs are active, false if disabled - */ -HAL_Bool HAL_GetSystemActive(int32_t* status); - -/** - * Gets if the system is in a browned out state. - * - * @return true if the system is in a low voltage brown out, false otherwise - */ -HAL_Bool HAL_GetBrownedOut(int32_t* status); - -/** - * The base HAL initialize function. Useful if you need to ensure the DS and - * base HAL functions (the ones above this declaration in HAL.h) are properly - * initialized. For normal programs and executables, please use HAL_Initialize. - * - * This is mainly expected to be use from libraries that are expected to be used - * from LabVIEW, as it handles its own initialization for objects. - */ -void HAL_BaseInitialize(int32_t* status); - -#ifndef HAL_USE_LABVIEW - -/** - * Gets a port handle for a specific channel. - * - * The created handle does not need to be freed. - * - * @param channel the channel number - * @return the created port - */ -HAL_PortHandle HAL_GetPort(int32_t channel); - -/** - * Gets a port handle for a specific channel and module. - * - * This is expected to be used for PCMs, as the roboRIO does not work with - * modules anymore. - * - * The created handle does not need to be freed. - * - * @param module the module number - * @param channel the channel number - * @return the created port - */ -HAL_PortHandle HAL_GetPortWithModule(int32_t module, int32_t channel); - -/** - * Reads the microsecond-resolution timer on the FPGA. - * - * @return The current time in microseconds according to the FPGA (since FPGA - * reset). - */ -uint64_t HAL_GetFPGATime(int32_t* status); - -/** - * Call this to start up HAL. This is required for robot programs. - * - * This must be called before any other HAL functions. Failure to do so will - * result in undefined behavior, and likely segmentation faults. This means that - * any statically initialized variables in a program MUST call this function in - * their constructors if they want to use other HAL calls. - * - * The common parameters are 500 for timeout and 0 for mode. - * - * This function is safe to call from any thread, and as many times as you wish. - * It internally guards from any reentrancy. - * - * The applicable modes are: - * 0: Try to kill an existing HAL from another program, if not successful, - * error. - * 1: Force kill a HAL from another program. - * 2: Just warn if another hal exists and cannot be killed. Will likely result - * in undefined behavior. - * - * @param timeout the initialization timeout (ms) - * @param mode the initialization mode (see remarks) - * @return true if initialization was successful, otherwise false. - */ -HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode); - -// ifdef's definition is to allow for default parameters in C++. -#ifdef __cplusplus -/** - * Reports a hardware usage to the HAL. - * - * @param resource the used resource - * @param instanceNumber the instance of the resource - * @param context a user specified context index - * @param feature a user specified feature string - * @return the index of the added value in NetComm - */ -int64_t HAL_Report(int32_t resource, int32_t instanceNumber, - int32_t context = 0, const char* feature = nullptr); -#else - -/** - * Reports a hardware usage to the HAL. - * - * @param resource the used resource - * @param instanceNumber the instance of the resource - * @param context a user specified context index - * @param feature a user specified feature string - * @return the index of the added value in NetComm - */ -int64_t HAL_Report(int32_t resource, int32_t instanceNumber, int32_t context, - const char* feature); -#endif - -#endif // HAL_USE_LABVIEW -#ifdef __cplusplus -} // extern "C" -#endif -/** @} */ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#pragma once + +#include + +#include "hal/Types.h" + +/** + * @defgroup hal_capi WPILib HAL API + * Hardware Abstraction Layer to hardware or simulator + * @{ + */ + +// clang-format off +HAL_ENUM(HAL_RuntimeType) { HAL_Athena, HAL_Mock }; +// clang-format on + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Gets the error message for a specific status code. + * + * @param code the status code + * @return the error message for the code. This does not need to be freed. + */ +const char* HAL_GetErrorMessage(int32_t code); + +/** + * Returns the FPGA Version number. + * + * For now, expect this to be competition year. + * + * @return FPGA Version number. + */ +int32_t HAL_GetFPGAVersion(int32_t* status); + +/** + * Returns the FPGA Revision number. + * + * The format of the revision is 3 numbers. + * The 12 most significant bits are the Major Revision. + * the next 8 bits are the Minor Revision. + * The 12 least significant bits are the Build Number. + * + * @return FPGA Revision number. + */ +int64_t HAL_GetFPGARevision(int32_t* status); + +HAL_RuntimeType HAL_GetRuntimeType(void); + +/** + * Gets the state of the "USER" button on the roboRIO. + * + * @return true if the button is currently pressed down + */ +HAL_Bool HAL_GetFPGAButton(int32_t* status); + +/** + * Gets if the system outputs are currently active + * + * @return true if the system outputs are active, false if disabled + */ +HAL_Bool HAL_GetSystemActive(int32_t* status); + +/** + * Gets if the system is in a browned out state. + * + * @return true if the system is in a low voltage brown out, false otherwise + */ +HAL_Bool HAL_GetBrownedOut(int32_t* status); + +/** + * The base HAL initialize function. Useful if you need to ensure the DS and + * base HAL functions (the ones above this declaration in HAL.h) are properly + * initialized. For normal programs and executables, please use HAL_Initialize. + * + * This is mainly expected to be use from libraries that are expected to be used + * from LabVIEW, as it handles its own initialization for objects. + */ +void HAL_BaseInitialize(int32_t* status); + +#ifndef HAL_USE_LABVIEW + +/** + * Gets a port handle for a specific channel. + * + * The created handle does not need to be freed. + * + * @param channel the channel number + * @return the created port + */ +HAL_PortHandle HAL_GetPort(int32_t channel); + +/** + * Gets a port handle for a specific channel and module. + * + * This is expected to be used for PCMs, as the roboRIO does not work with + * modules anymore. + * + * The created handle does not need to be freed. + * + * @param module the module number + * @param channel the channel number + * @return the created port + */ +HAL_PortHandle HAL_GetPortWithModule(int32_t module, int32_t channel); + +/** + * Reads the microsecond-resolution timer on the FPGA. + * + * @return The current time in microseconds according to the FPGA (since FPGA + * reset). + */ +uint64_t HAL_GetFPGATime(int32_t* status); + +/** + * Call this to start up HAL. This is required for robot programs. + * + * This must be called before any other HAL functions. Failure to do so will + * result in undefined behavior, and likely segmentation faults. This means that + * any statically initialized variables in a program MUST call this function in + * their constructors if they want to use other HAL calls. + * + * The common parameters are 500 for timeout and 0 for mode. + * + * This function is safe to call from any thread, and as many times as you wish. + * It internally guards from any reentrancy. + * + * The applicable modes are: + * 0: Try to kill an existing HAL from another program, if not successful, + * error. + * 1: Force kill a HAL from another program. + * 2: Just warn if another hal exists and cannot be killed. Will likely result + * in undefined behavior. + * + * @param timeout the initialization timeout (ms) + * @param mode the initialization mode (see remarks) + * @return true if initialization was successful, otherwise false. + */ +HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode); + +// ifdef's definition is to allow for default parameters in C++. +#ifdef __cplusplus +/** + * Reports a hardware usage to the HAL. + * + * @param resource the used resource + * @param instanceNumber the instance of the resource + * @param context a user specified context index + * @param feature a user specified feature string + * @return the index of the added value in NetComm + */ +int64_t HAL_Report(int32_t resource, int32_t instanceNumber, + int32_t context = 0, const char* feature = nullptr); +#else + +/** + * Reports a hardware usage to the HAL. + * + * @param resource the used resource + * @param instanceNumber the instance of the resource + * @param context a user specified context index + * @param feature a user specified feature string + * @return the index of the added value in NetComm + */ +int64_t HAL_Report(int32_t resource, int32_t instanceNumber, int32_t context, + const char* feature); +#endif + +#endif // HAL_USE_LABVIEW +#ifdef __cplusplus +} // extern "C" +#endif +/** @} */ diff --git a/ntcore/ntcore-config.cmake.in b/ntcore/ntcore-config.cmake.in index 1e950e90ce..fb677b351f 100644 --- a/ntcore/ntcore-config.cmake.in +++ b/ntcore/ntcore-config.cmake.in @@ -1,5 +1,5 @@ -include(CMakeFindDependencyMacro) -@FILENAME_DEP_REPLACE@ -@WPIUTIL_DEP_REPLACE@ - -include(${SELF_DIR}/ntcore.cmake) +include(CMakeFindDependencyMacro) +@FILENAME_DEP_REPLACE@ +@WPIUTIL_DEP_REPLACE@ + +include(${SELF_DIR}/ntcore.cmake) diff --git a/shared/nilibraries.gradle b/shared/nilibraries.gradle index 49e99b0d51..efb9cfc8f0 100644 --- a/shared/nilibraries.gradle +++ b/shared/nilibraries.gradle @@ -1,10 +1,10 @@ -model { - binaries { - all { - if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { - nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared') - } - - } - } -} +model { + binaries { + all { + if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { + nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared') + } + + } + } +} diff --git a/wpilib-config.cmake.in b/wpilib-config.cmake.in index 2c15dfe090..f3033888f3 100644 --- a/wpilib-config.cmake.in +++ b/wpilib-config.cmake.in @@ -1,11 +1,11 @@ -include(CMakeFindDependencyMacro) -@FILENAME_DEP_REPLACE@ -set(THREADS_PREFER_PTHREAD_FLAG ON) -find_dependency(Threads) -@LIBUV_VCPKG_REPLACE@ -@WPIUTIL_DEP_REPLACE@ -@NTCORE_DEP_REPLACE@ -@CSCORE_DEP_REPLACE@ -@CAMERASERVER_DEP_REPLACE@ -@HAL_DEP_REPLACE@ -@WPILIBC_DEP_REPLACE@ +include(CMakeFindDependencyMacro) +@FILENAME_DEP_REPLACE@ +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_dependency(Threads) +@LIBUV_VCPKG_REPLACE@ +@WPIUTIL_DEP_REPLACE@ +@NTCORE_DEP_REPLACE@ +@CSCORE_DEP_REPLACE@ +@CAMERASERVER_DEP_REPLACE@ +@HAL_DEP_REPLACE@ +@WPILIBC_DEP_REPLACE@ diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/emptyclass/ReplaceMeEmptyClass.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/emptyclass/ReplaceMeEmptyClass.java index 94983484e5..e2d866e7ae 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/emptyclass/ReplaceMeEmptyClass.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/commands/emptyclass/ReplaceMeEmptyClass.java @@ -1,14 +1,14 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 FIRST. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package edu.wpi.first.wpilibj.commands.emptyclass; - -/** - * Add your docs here. - */ -public class ReplaceMeEmptyClass { -} +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package edu.wpi.first.wpilibj.commands.emptyclass; + +/** + * Add your docs here. + */ +public class ReplaceMeEmptyClass { +} diff --git a/wpiutil/src/main/native/include/wpi/Compiler.h b/wpiutil/src/main/native/include/wpi/Compiler.h index 81b2fae0b0..736166396b 100644 --- a/wpiutil/src/main/native/include/wpi/Compiler.h +++ b/wpiutil/src/main/native/include/wpi/Compiler.h @@ -117,10 +117,10 @@ #ifndef LLVM_NODISCARD #if __cplusplus > 201402L && __has_cpp_attribute(nodiscard) #define LLVM_NODISCARD [[nodiscard]] -// Detect MSVC directly, since __cplusplus still defaults to old version -#elif _MSVC_LANG >= 201703L -#define LLVM_NODISCARD [[nodiscard]] -#elif _MSC_VER +// Detect MSVC directly, since __cplusplus still defaults to old version +#elif _MSVC_LANG >= 201703L +#define LLVM_NODISCARD [[nodiscard]] +#elif _MSC_VER #define LLVM_NODISCARD #elif !__cplusplus // Workaround for llvm.org/PR23435, since clang 3.6 and below emit a spurious @@ -241,10 +241,10 @@ #ifndef LLVM_FALLTHROUGH #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough) #define LLVM_FALLTHROUGH [[fallthrough]] -// Detect MSVC directly, since __cplusplus still defaults to old version -#elif _MSVC_LANG >= 201703L -#define LLVM_FALLTHROUGH [[fallthrough]] -#elif _MSC_VER +// Detect MSVC directly, since __cplusplus still defaults to old version +#elif _MSVC_LANG >= 201703L +#define LLVM_FALLTHROUGH [[fallthrough]] +#elif _MSC_VER #define LLVM_FALLTHROUGH #elif __has_cpp_attribute(gnu::fallthrough) #define LLVM_FALLTHROUGH [[gnu::fallthrough]] diff --git a/wpiutil/src/main/native/include/wpi/json.h b/wpiutil/src/main/native/include/wpi/json.h index 1a8146ad2b..a27f84342d 100644 --- a/wpiutil/src/main/native/include/wpi/json.h +++ b/wpiutil/src/main/native/include/wpi/json.h @@ -2962,13 +2962,13 @@ class json { std::allocator alloc; - using AllocatorTraits = std::allocator_traits>; - - auto deleter = [&](T * object) - { - AllocatorTraits::deallocate(alloc, object, 1); - }; - std::unique_ptr object(AllocatorTraits::allocate(alloc, 1), deleter); + using AllocatorTraits = std::allocator_traits>; + + auto deleter = [&](T * object) + { + AllocatorTraits::deallocate(alloc, object, 1); + }; + std::unique_ptr object(AllocatorTraits::allocate(alloc, 1), deleter); AllocatorTraits::construct(alloc, object.get(), std::forward(args)...); assert(object != nullptr); return object.release(); @@ -5320,7 +5320,7 @@ class json if (is_string()) { std::allocator alloc; - std::allocator_traits::destroy(alloc, m_value.string); + std::allocator_traits::destroy(alloc, m_value.string); std::allocator_traits::deallocate(alloc, m_value.string, 1); m_value.string = nullptr; } @@ -5424,7 +5424,7 @@ class json if (is_string()) { std::allocator alloc; - std::allocator_traits::destroy(alloc, m_value.string); + std::allocator_traits::destroy(alloc, m_value.string); std::allocator_traits::deallocate(alloc, m_value.string, 1); m_value.string = nullptr; } diff --git a/wpiutil/wpiutil-config.cmake.in b/wpiutil/wpiutil-config.cmake.in index 5d71bc1923..08fbffb551 100644 --- a/wpiutil/wpiutil-config.cmake.in +++ b/wpiutil/wpiutil-config.cmake.in @@ -1,7 +1,7 @@ -include(CMakeFindDependencyMacro) -@FILENAME_DEP_REPLACE@ -set(THREADS_PREFER_PTHREAD_FLAG ON) -find_dependency(Threads) -@LIBUV_VCPKG_REPLACE@ - -include(${SELF_DIR}/wpiutil.cmake) +include(CMakeFindDependencyMacro) +@FILENAME_DEP_REPLACE@ +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_dependency(Threads) +@LIBUV_VCPKG_REPLACE@ + +include(${SELF_DIR}/wpiutil.cmake)