From e1d25c96ee6afd87a34126f5f49e580db232b851 Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Tue, 15 Feb 2022 18:33:14 +0100 Subject: [PATCH] generate proto3 version of the linear solver proto in C# --- makefiles/Makefile.dotnet.mk | 13 +++++++++++++ ortools/linear_solver/linear_solver.proto | 2 +- tools/proto2_to_proto3.sed | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tools/proto2_to_proto3.sed diff --git a/makefiles/Makefile.dotnet.mk b/makefiles/Makefile.dotnet.mk index 7ddbe93495..75f0ce3f31 100644 --- a/makefiles/Makefile.dotnet.mk +++ b/makefiles/Makefile.dotnet.mk @@ -119,6 +119,19 @@ $(GEN_DIR)/ortools/constraint_solver/RoutingEnums.pb.cs: \ --csharp_opt=file_extension=.pb.cs \ $(SRC_DIR)$Sortools$Sconstraint_solver$Srouting_enums.proto + $(GEN_DIR)/ortools/linear_solver/linear_solver.proto: \ + $(SRC_DIR)/ortools/linear_solver/linear_solver.proto \ + | $(GEN_DIR)/ortools/linear_solver + $(SED) -f tools$Sproto2_to_proto3.sed $(SRC_DIR)/ortools/linear_solver/linear_solver.proto > $(GEN_DIR)/ortools/linear_solver/linear_solver.proto + +$(GEN_DIR)/ortools/linear_solver/LinearSolver.pb.cs: \ + $(GEN_DIR)/ortools/linear_solver/linear_solver.proto \ + | $(GEN_DIR)/ortools/linear_solver + $(PROTOC) --proto_path=$(GEN_DIR) --proto_path=$(SRC_DIR) \ + --csharp_out=$(GEN_PATH)$Sortools$Slinear_solver \ + --csharp_opt=file_extension=.pb.cs \ + $(GEN_DIR)$Sortools$Slinear_solver$Slinear_solver.proto + $(GEN_DIR)/ortools/sat/CpModel.pb.cs: \ $(SRC_DIR)/ortools/sat/cp_model.proto \ | $(GEN_DIR)/ortools/sat diff --git a/ortools/linear_solver/linear_solver.proto b/ortools/linear_solver/linear_solver.proto index f09659ee8d..13b86be5f2 100644 --- a/ortools/linear_solver/linear_solver.proto +++ b/ortools/linear_solver/linear_solver.proto @@ -419,8 +419,8 @@ message MPModelRequest { // program?). // This must remain consistent with MPSolver::OptimizationProblemType. enum SolverType { - GLOP_LINEAR_PROGRAMMING = 2; // Recommended default for LP models. CLP_LINEAR_PROGRAMMING = 0; + GLOP_LINEAR_PROGRAMMING = 2; // Recommended default for LP models. GLPK_LINEAR_PROGRAMMING = 1; GUROBI_LINEAR_PROGRAMMING = 6; // Commercial, needs a valid license. XPRESS_LINEAR_PROGRAMMING = 101; // Commercial, needs a valid license. NOLINT diff --git a/tools/proto2_to_proto3.sed b/tools/proto2_to_proto3.sed new file mode 100644 index 0000000000..cac4fd1bdc --- /dev/null +++ b/tools/proto2_to_proto3.sed @@ -0,0 +1,3 @@ +s| \[default = [^;]*\]||g +s|proto2|proto3|g +