Remove generated google protobuf support (#7371)

It's not used anymore, and cleans up the build.
This commit is contained in:
Thad House
2024-11-08 18:29:30 -08:00
committed by GitHub
parent 811b130968
commit 3cc541f261
45 changed files with 0 additions and 342 deletions

3
.gitignore vendored
View File

@@ -255,6 +255,3 @@ bazel_auth.rc
# ctest
/Testing/
# protobuf
!wpiprotoplugin.jar

View File

@@ -293,8 +293,6 @@ if(WITH_NTCORE)
add_subdirectory(ntcore)
endif()
add_subdirectory(protoplugin)
if(WITH_WPIMATH)
if(WITH_JAVA)
set(WPIUNITS_DEP_REPLACE ${WPIUNITS_DEP_REPLACE_IMPL})

View File

@@ -21,7 +21,6 @@ plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
id 'com.diffplug.spotless' version '6.20.0' apply false
id 'com.github.spotbugs' version '6.0.2' apply false
id 'com.google.protobuf' version '0.9.3' apply false
}
wpilibVersioning.buildServerMode = project.hasProperty('buildServer')

View File

@@ -1,92 +0,0 @@
function(wpi_protobuf_generate)
set(_singleargs PROTOC_OUT_DIR PLUGIN DEPENDENCIES)
if(COMMAND target_sources)
list(APPEND _singleargs TARGET)
endif()
set(_multiargs PROTOS)
cmake_parse_arguments(
wpi_protobuf_generate
"${_options}"
"${_singleargs}"
"${_multiargs}"
"${ARGN}"
)
if(NOT wpi_protobuf_generate_PROTOS)
message(SEND_ERROR "Error: protobuf_generate called without any targets or source files")
return()
endif()
if(NOT wpi_protobuf_generate_TARGET)
message(SEND_ERROR "Error: wpi_protobuf_generate called without a target")
return()
endif()
if(NOT wpi_protobuf_generate_PROTOC_OUT_DIR)
message(SEND_ERROR "Error: protobuf_generate called without a protoc out directory")
return()
endif()
if(NOT wpi_protobuf_generate_PLUGIN)
message(SEND_ERROR "Error: wpi_protobuf_generate called without a plugin")
return()
endif()
set(_generate_extensions .pb.h .pb.cc)
# Create an include path for each file specified
foreach(_file ${wpi_protobuf_generate_PROTOS})
get_filename_component(_abs_file ${_file} ABSOLUTE)
get_filename_component(_abs_dir ${_abs_file} DIRECTORY)
list(FIND _protobuf_include_path ${_abs_dir} _contains_already)
if(${_contains_already} EQUAL -1)
list(APPEND _protobuf_include_path -I ${_abs_dir})
endif()
endforeach()
set(_generated_srcs_all)
foreach(_proto ${wpi_protobuf_generate_PROTOS})
get_filename_component(_abs_file ${_proto} ABSOLUTE)
get_filename_component(_abs_dir ${_abs_file} DIRECTORY)
get_filename_component(_basename ${_proto} NAME_WLE)
file(RELATIVE_PATH _rel_dir ${CMAKE_CURRENT_SOURCE_DIR} ${_abs_dir})
set(_possible_rel_dir)
set(_generated_srcs)
foreach(_ext ${_generate_extensions})
list(
APPEND
_generated_srcs
"${wpi_protobuf_generate_PROTOC_OUT_DIR}/${_possible_rel_dir}${_basename}${_ext}"
)
endforeach()
list(APPEND _generated_srcs_all ${_generated_srcs})
set(_comment "Running WPILib protocol buffer compiler on ${_proto}")
add_custom_command(
OUTPUT ${_generated_srcs}
COMMAND protobuf::protoc
ARGS
--cpp_out ${wpi_protobuf_generate_PROTOC_OUT_DIR} --wpilib_out
${wpi_protobuf_generate_PROTOC_OUT_DIR}
--plugin=protoc-gen-wpilib=${wpi_protobuf_generate_PLUGIN} ${_protobuf_include_path}
${_abs_file}
DEPENDS
${_abs_file}
protobuf::protoc
${wpi_protobuf_generate_DEPENDENCIES}
${wpi_protobuf_generate_PLUGIN}
COMMENT ${_comment}
VERBATIM
)
endforeach()
set_source_files_properties(${_generated_srcs_all} PROPERTIES GENERATED TRUE)
if(wpi_protobuf_generate_TARGET)
target_sources(${wpi_protobuf_generate_TARGET} PRIVATE ${_generated_srcs_all})
endif()
endfunction()

View File

@@ -1,20 +0,0 @@
project(protoplugin)
set(PROTO_JAR ${CMAKE_CURRENT_SOURCE_DIR}/binary/wpiprotoplugin.jar)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/binary/wpiprotoplugin.sh.in
${CMAKE_CURRENT_BINARY_DIR}/wpiprotoplugin.sh
@ONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/binary/wpiprotoplugin.bat.in
${CMAKE_CURRENT_BINARY_DIR}/wpiprotoplugin.bat
@ONLY
)
if(WIN32)
set(PROTOC_WPILIB_PLUGIN ${CMAKE_CURRENT_BINARY_DIR}/wpiprotoplugin.bat PARENT_SCOPE)
else()
set(PROTOC_WPILIB_PLUGIN ${CMAKE_CURRENT_BINARY_DIR}/wpiprotoplugin.sh PARENT_SCOPE)
endif()

View File

@@ -1,2 +0,0 @@
@ECHO OFF
"@Java_JAVA_EXECUTABLE@" -jar "@PROTO_JAR@" %*

View File

@@ -1,2 +0,0 @@
#!/bin/sh
exec "@Java_JAVA_EXECUTABLE@" -jar "@PROTO_JAR@" "$@"

View File

@@ -1,33 +0,0 @@
plugins {
id 'application'
id 'java'
id 'com.gradleup.shadow' version '8.3.0'
}
application {
mainClass = "org.wpilib.ProtoCDllGenerator"
}
repositories {
mavenCentral()
}
dependencies {
implementation "com.google.protobuf:protobuf-java:3.21.12"
}
java {
sourceCompatibility = 8
targetCompatibility = 8
}
def cshadow = project.tasks.register("copyShadow", Copy) {
from(tasks.shadowJar.archiveFile) {
rename {
"wpiprotoplugin.jar"
}
}
into layout.projectDirectory.dir("binary")
}
build.dependsOn cshadow

View File

@@ -1 +0,0 @@

View File

@@ -1,76 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib;
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import com.google.protobuf.DescriptorProtos.FileDescriptorProto;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.DescriptorValidationException;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.Descriptors.FieldDescriptor.Type;
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest;
public final class ProtoCDllGenerator {
private ProtoCDllGenerator() {
}
public static void main(String[] args) throws IOException, DescriptorValidationException {
CodeGeneratorRequest request = CodeGeneratorRequest.parseFrom(System.in);
Map<String, Descriptors.FileDescriptor> descriptors = new HashMap<>();
Descriptors.FileDescriptor[] tmpArray = new Descriptors.FileDescriptor[0];
for (FileDescriptorProto proto : request.getProtoFileList()) {
// Make array of file descriptors that exists
Descriptors.FileDescriptor[] depArray = descriptors.values().toArray(tmpArray);
Descriptors.FileDescriptor desc = Descriptors.FileDescriptor.buildFrom(proto, depArray);
descriptors.put(proto.getName(), desc);
}
// Filter to generated descriptors
CodeGeneratorResponse.Builder response = CodeGeneratorResponse.newBuilder();
for (String genFile : request.getFileToGenerateList()) {
Descriptors.FileDescriptor desc = descriptors.get(genFile);
for (Descriptor msg : desc.getMessageTypes()) {
for (FieldDescriptor field : msg.getFields()) {
if (field.getType() == Type.MESSAGE && !field.isRepeated()) {
// If we have a nested non repeated field, we need a custom accessor
String type = field.getMessageType().getFullName();
type = "::" + type.replaceAll("\\.", "::");
// Add definition
response.addFileBuilder()
.setName(desc.getName().replace("proto", "pb.h"))
.setInsertionPoint("class_scope:" + msg.getFullName())
.setContent("// Custom WPILib Accessor\n"
+ "bool wpi_has_" + field.getName() + "() const;\n"
+ "const " + type + "& wpi_" + field.getName() + "() const;\n");
// Add implementation. As were in the cc file for the proto
// we can just call straight through to the inline definitions
response.addFileBuilder()
.setName(desc.getName().replace("proto", "pb.cc"))
.setInsertionPoint("namespace_scope")
.setContent("// Custom WPILib Accessor\n"
+ "bool " + msg.getName() + "::wpi_has_" + field.getName() + "() const { return has_"
+ field.getName() + "(); }\n"
+ "const " + type + "& " + msg.getName() + "::wpi_" + field.getName() + "() const { return "
+ field.getName() + "(); }\n");
}
}
}
}
response.build().writeTo(System.out);
}
}

View File

@@ -1,7 +1,6 @@
apply plugin: 'maven-publish'
apply plugin: 'java-library'
apply plugin: 'jacoco'
apply plugin: 'com.google.protobuf'
def baseArtifactId = project.baseId
def artifactGroupId = project.groupId
@@ -143,35 +142,3 @@ jacocoTestReport {
html.required = true
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.21.12'
}
plugins {
wpilib {
path = rootProject.file("protoplugin/binary/wpiprotoplugin.jar")
}
}
generateProtoTasks {
all().configureEach { task ->
if (project.hasProperty('skipproto')) {
task.builtins {
cpp {}
remove java
}
return
}
task.inputs.file(rootProject.file("protoplugin/binary/wpiprotoplugin.jar"))
task.plugins {
wpilib {
outputSubDir = 'cpp'
}
}
task.builtins {
cpp {}
remove java
}
}
}
}

View File

@@ -43,9 +43,6 @@ model {
it.buildable = false
return
}
it.tasks.withType(CppCompile) {
it.dependsOn generateProto
}
if (project.hasProperty('extraSetup')) {
extraSetup(it)
}

View File

@@ -67,9 +67,6 @@ model {
if (!project.hasProperty('noWpiutil')) {
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
}
it.tasks.withType(CppCompile) {
it.dependsOn generateProto
}
if (project.hasProperty('splitSetup')) {
splitSetup(it)
}
@@ -223,9 +220,6 @@ model {
nativeUtils.useRequiredLibrary(it, 'ni_link_libraries', 'ni_runtime_libraries')
}
}
it.tasks.withType(CppCompile) {
it.dependsOn generateProto
}
if (project.hasProperty('exeSplitSetup')) {
exeSplitSetup(it)
}
@@ -279,9 +273,6 @@ model {
nativeUtils.useRequiredLibrary(it, 'ni_link_libraries', 'ni_runtime_libraries')
}
}
it.tasks.withType(CppCompile) {
it.dependsOn generateProto
}
if (project.hasProperty('exeSplitSetup')) {
exeSplitSetup(it)
}

View File

@@ -43,10 +43,6 @@ cppHeadersZip {
from('src/main/native/thirdparty/gcem/include') {
into '/'
}
from("$buildDir/generated/source/proto/main/cpp") {
into '/wpimath/protobuf'
include '*.h'
}
from("src/generated/main/native/cpp/wpimath/protobuf") {
into '/wpimath/protobuf'
include '**/*.h'
@@ -56,8 +52,6 @@ cppHeadersZip {
}
}
cppHeadersZip.dependsOn generateProto
model {
components {
all {

View File

@@ -288,7 +288,5 @@ class WPILIB_DLLEXPORT ArmFeedforward {
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/controller/proto/ArmFeedforwardProto.h"
#endif
#include "frc/controller/struct/ArmFeedforwardStruct.h"

View File

@@ -99,7 +99,5 @@ class WPILIB_DLLEXPORT DifferentialDriveFeedforward {
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/controller/proto/DifferentialDriveFeedforwardProto.h"
#endif
#include "frc/controller/struct/DifferentialDriveFeedforwardStruct.h"

View File

@@ -21,7 +21,5 @@ struct DifferentialDriveWheelVoltages {
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/controller/proto/DifferentialDriveWheelVoltagesProto.h"
#endif
#include "frc/controller/struct/DifferentialDriveWheelVoltagesStruct.h"

View File

@@ -262,7 +262,5 @@ class ElevatorFeedforward {
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/controller/proto/ElevatorFeedforwardProto.h"
#endif
#include "frc/controller/struct/ElevatorFeedforwardStruct.h"

View File

@@ -210,7 +210,5 @@ class WPILIB_DLLEXPORT Ellipse2d {
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/Ellipse2dProto.h"
#endif
#include "frc/geometry/struct/Ellipse2dStruct.h"

View File

@@ -259,9 +259,7 @@ void from_json(const wpi::json& json, Pose2d& pose);
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/Pose2dProto.h"
#endif
#include "frc/geometry/struct/Pose2dStruct.h"
#include "frc/geometry/Transform2d.h"

View File

@@ -236,9 +236,7 @@ void from_json(const wpi::json& json, Pose3d& pose);
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/Pose3dProto.h"
#endif
#include "frc/geometry/struct/Pose3dStruct.h"
#include "frc/geometry/Transform3d.h"

View File

@@ -335,7 +335,5 @@ void from_json(const wpi::json& json, Quaternion& quaternion);
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/QuaternionProto.h"
#endif
#include "frc/geometry/struct/QuaternionStruct.h"

View File

@@ -206,7 +206,5 @@ class WPILIB_DLLEXPORT Rectangle2d {
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/Rectangle2dProto.h"
#endif
#include "frc/geometry/struct/Rectangle2dStruct.h"

View File

@@ -205,7 +205,5 @@ void from_json(const wpi::json& json, Rotation2d& rotation);
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/Rotation2dProto.h"
#endif
#include "frc/geometry/struct/Rotation2dStruct.h"

View File

@@ -412,7 +412,5 @@ void from_json(const wpi::json& json, Rotation3d& rotation);
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/Rotation3dProto.h"
#endif
#include "frc/geometry/struct/Rotation3dStruct.h"

View File

@@ -155,7 +155,5 @@ constexpr Transform2d Transform2d::operator+(const Transform2d& other) const {
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/Transform2dProto.h"
#endif
#include "frc/geometry/struct/Transform2dStruct.h"

View File

@@ -163,7 +163,5 @@ constexpr Transform3d Transform3d::operator+(const Transform3d& other) const {
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/Transform3dProto.h"
#endif
#include "frc/geometry/struct/Transform3dStruct.h"

View File

@@ -271,7 +271,5 @@ void from_json(const wpi::json& json, Translation2d& state);
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/Translation2dProto.h"
#endif
#include "frc/geometry/struct/Translation2dStruct.h"

View File

@@ -236,7 +236,5 @@ void from_json(const wpi::json& json, Translation3d& state);
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/Translation3dProto.h"
#endif
#include "frc/geometry/struct/Translation3dStruct.h"

View File

@@ -60,7 +60,5 @@ struct WPILIB_DLLEXPORT Twist2d {
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/Twist2dProto.h"
#endif
#include "frc/geometry/struct/Twist2dStruct.h"

View File

@@ -79,7 +79,5 @@ struct WPILIB_DLLEXPORT Twist3d {
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/geometry/proto/Twist3dProto.h"
#endif
#include "frc/geometry/struct/Twist3dStruct.h"

View File

@@ -279,7 +279,5 @@ struct WPILIB_DLLEXPORT ChassisSpeeds {
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/kinematics/proto/ChassisSpeedsProto.h"
#endif
#include "frc/kinematics/struct/ChassisSpeedsStruct.h"

View File

@@ -104,7 +104,5 @@ class WPILIB_DLLEXPORT DifferentialDriveKinematics
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/kinematics/proto/DifferentialDriveKinematicsProto.h"
#endif
#include "frc/kinematics/struct/DifferentialDriveKinematicsStruct.h"

View File

@@ -42,7 +42,5 @@ struct WPILIB_DLLEXPORT DifferentialDriveWheelPositions {
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/kinematics/proto/DifferentialDriveWheelPositionsProto.h"
#endif
#include "frc/kinematics/struct/DifferentialDriveWheelPositionsStruct.h"

View File

@@ -122,7 +122,5 @@ struct WPILIB_DLLEXPORT DifferentialDriveWheelSpeeds {
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/kinematics/proto/DifferentialDriveWheelSpeedsProto.h"
#endif
#include "frc/kinematics/struct/DifferentialDriveWheelSpeedsStruct.h"

View File

@@ -200,7 +200,5 @@ class WPILIB_DLLEXPORT MecanumDriveKinematics
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/kinematics/proto/MecanumDriveKinematicsProto.h"
#endif
#include "frc/kinematics/struct/MecanumDriveKinematicsStruct.h"

View File

@@ -53,7 +53,5 @@ struct WPILIB_DLLEXPORT MecanumDriveWheelPositions {
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/kinematics/proto/MecanumDriveWheelPositionsProto.h"
#endif
#include "frc/kinematics/struct/MecanumDriveWheelPositionsStruct.h"

View File

@@ -144,7 +144,5 @@ struct WPILIB_DLLEXPORT MecanumDriveWheelSpeeds {
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/kinematics/proto/MecanumDriveWheelSpeedsProto.h"
#endif
#include "frc/kinematics/struct/MecanumDriveWheelSpeedsStruct.h"

View File

@@ -45,7 +45,5 @@ struct WPILIB_DLLEXPORT SwerveModulePosition {
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/kinematics/proto/SwerveModulePositionProto.h"
#endif
#include "frc/kinematics/struct/SwerveModulePositionStruct.h"

View File

@@ -86,7 +86,5 @@ struct WPILIB_DLLEXPORT SwerveModuleState {
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/kinematics/proto/SwerveModuleStateProto.h"
#endif
#include "frc/kinematics/struct/SwerveModuleStateStruct.h"

View File

@@ -147,7 +147,5 @@ class WPILIB_DLLEXPORT CubicHermiteSpline : public Spline<3> {
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/spline/proto/CubicHermiteSplineProto.h"
#endif
#include "frc/spline/struct/CubicHermiteSplineStruct.h"

View File

@@ -154,7 +154,5 @@ class WPILIB_DLLEXPORT QuinticHermiteSpline : public Spline<5> {
};
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/spline/proto/QuinticHermiteSplineProto.h"
#endif
#include "frc/spline/struct/QuinticHermiteSplineStruct.h"

View File

@@ -272,7 +272,5 @@ void from_json(const wpi::json& json, Trajectory::State& state);
} // namespace frc
#ifndef NO_PROTOBUF
#include "frc/trajectory/proto/TrajectoryProto.h"
#include "frc/trajectory/proto/TrajectoryStateProto.h"
#endif

View File

@@ -1,7 +1,6 @@
apply from: "${rootDir}/shared/resources.gradle"
ext {
skipproto = true
noWpiutil = true
skipJniSymbols = [
'Java_edu_wpi_first_util_CombinedRuntimeLoader_setDllDirectory'