Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/dotnet.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if(NOT TARGET ${PROJECT_NAMESPACE}::ortools)
endif()

# Will need swig
set(SWIG_SOURCE_FILE_EXTENSIONS ".i" ".swig")
set(CMAKE_SWIG_FLAGS)
find_package(SWIG REQUIRED)
include(UseSWIG)
Expand Down
1 change: 1 addition & 0 deletions cmake/java.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if(NOT TARGET ${PROJECT_NAMESPACE}::ortools)
endif()

# Will need swig
set(SWIG_SOURCE_FILE_EXTENSIONS ".i" ".swig")
set(CMAKE_SWIG_FLAGS)
find_package(SWIG REQUIRED)
include(UseSWIG)
Expand Down
1 change: 1 addition & 0 deletions cmake/python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if(NOT TARGET ${PROJECT_NAMESPACE}::ortools)
endif()

# Will need swig
set(SWIG_SOURCE_FILE_EXTENSIONS ".i" ".swig")
set(CMAKE_SWIG_FLAGS)
find_package(SWIG REQUIRED)
include(UseSWIG)
Expand Down
2 changes: 1 addition & 1 deletion ortools/algorithms/java/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load("//bazel:swig_java.bzl", "ortools_java_wrap_cc")

ortools_java_wrap_cc(
name = "knapsacksolver",
src = "knapsack_solver.i",
src = "knapsack_solver.swig",
module = "operations_research_algorithms",
package = "com.google.ortools.algorithms",
swig_includes = [
Expand Down
10 changes: 5 additions & 5 deletions ortools/algorithms/java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set_property(SOURCE knapsack_solver.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE knapsack_solver.i PROPERTY SWIG_MODULE_NAME main)
set_property(SOURCE knapsack_solver.i PROPERTY COMPILE_DEFINITIONS
set_property(SOURCE knapsack_solver.swig PROPERTY CPLUSPLUS ON)
set_property(SOURCE knapsack_solver.swig PROPERTY SWIG_MODULE_NAME main)
set_property(SOURCE knapsack_solver.swig PROPERTY COMPILE_DEFINITIONS
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT=)
set_property(SOURCE knapsack_solver.i PROPERTY COMPILE_OPTIONS
set_property(SOURCE knapsack_solver.swig PROPERTY COMPILE_OPTIONS
-package ${JAVA_PACKAGE}.algorithms)
swig_add_library(jnialgorithms
TYPE OBJECT
LANGUAGE java
OUTPUT_DIR ${JAVA_PROJECT_DIR}/${JAVA_SRC_PATH}/algorithms
SOURCES knapsack_solver.i)
SOURCES knapsack_solver.swig)

target_include_directories(jnialgorithms PRIVATE ${JNI_INCLUDE_DIRS})
set_target_properties(jnialgorithms PROPERTIES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
%include "enums.swg"

%include "ortools/base/base.i"
%import "ortools/util/java/vector.i"
%import "ortools/util/java/vector.swig"

%{
#include "ortools/algorithms/knapsack_solver.h"
Expand Down
2 changes: 1 addition & 1 deletion ortools/base/python-swig.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

// Static part of SWIG-generated C++ wrapper for Python (_module_name.cc).
//
// This file should only be included in base.i inside Python-specific part:
// This file should only be included in base.swig inside Python-specific part:
// #ifdef SWIGPYTHON
// %{
// #include "ortools/base/swig/python-swig.cc"
Expand Down
10 changes: 5 additions & 5 deletions ortools/constraint_solver/java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set_property(SOURCE constraint_solver.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE constraint_solver.i PROPERTY SWIG_MODULE_NAME Globals)
set_property(SOURCE constraint_solver.i PROPERTY COMPILE_DEFINITIONS
set_property(SOURCE constraint_solver.swig PROPERTY CPLUSPLUS ON)
set_property(SOURCE constraint_solver.swig PROPERTY SWIG_MODULE_NAME Globals)
set_property(SOURCE constraint_solver.swig PROPERTY COMPILE_DEFINITIONS
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT=)
set_property(SOURCE constraint_solver.i PROPERTY COMPILE_OPTIONS
set_property(SOURCE constraint_solver.swig PROPERTY COMPILE_OPTIONS
-package ${JAVA_PACKAGE}.constraintsolver)
swig_add_library(jniconstraint_solver
TYPE OBJECT
LANGUAGE java
OUTPUT_DIR ${JAVA_PROJECT_DIR}/${JAVA_SRC_PATH}/constraintsolver
SOURCES constraint_solver.i)
SOURCES constraint_solver.swig)

target_include_directories(jniconstraint_solver PRIVATE ${JNI_INCLUDE_DIRS})
set_target_properties(jniconstraint_solver PROPERTIES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
%include "exception.i"

%include "ortools/base/base.i"
%include "ortools/util/java/absl_string_view.i"
%include "ortools/util/java/tuple_set.i"
%include "ortools/util/java/vector.i"
%include "ortools/util/java/absl_string_view.swig"
%include "ortools/util/java/tuple_set.swig"
%include "ortools/util/java/vector.swig"
%include "ortools/util/java/proto.i"

// Make the SWIG-generated constructor public.
Expand Down Expand Up @@ -82,7 +82,7 @@ class GlobalRefGuard {
%}

// ############ BEGIN DUPLICATED CODE BLOCK ############
// IMPORTANT: keep this code block in sync with the .i
// IMPORTANT: keep this code block in sync with the .swig
// files in ../python and ../csharp.

// Protect from failure.
Expand Down
10 changes: 5 additions & 5 deletions ortools/constraint_solver/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ target_link_libraries(constraint_solver_pybind11 PRIVATE
add_library(${PROJECT_NAMESPACE}::constraint_solver_pybind11 ALIAS constraint_solver_pybind11)

# legacy pywrapcp
set_property(SOURCE constraint_solver.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE constraint_solver.i PROPERTY SWIG_MODULE_NAME pywrapcp)
set_property(SOURCE constraint_solver.i PROPERTY COMPILE_DEFINITIONS
set_property(SOURCE constraint_solver.swig PROPERTY CPLUSPLUS ON)
set_property(SOURCE constraint_solver.swig PROPERTY SWIG_MODULE_NAME pywrapcp)
set_property(SOURCE constraint_solver.swig PROPERTY COMPILE_DEFINITIONS
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT=)
set_property(SOURCE constraint_solver.i PROPERTY COMPILE_OPTIONS -nofastunpack)
set_property(SOURCE constraint_solver.swig PROPERTY COMPILE_OPTIONS -nofastunpack)
swig_add_library(pywrapcp
TYPE MODULE
LANGUAGE python
OUTPUT_DIR ${PYTHON_PROJECT_DIR}/constraint_solver
SOURCES constraint_solver.i)
SOURCES constraint_solver.swig)

target_include_directories(pywrapcp PRIVATE ${Python3_INCLUDE_DIRS})
set_property(TARGET pywrapcp PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// This .i file exposes the code declared in ../constraint_solver.h and
// This .swig file exposes the code declared in ../constraint_solver.h and
// ../constraint_solveri.h.
//
// It is particularly complex for a swig file, mostly because it contains a
Expand All @@ -35,12 +35,12 @@
%include "ortools/util/python/proto.i"

// PY_CONVERT_HELPER_* macros.
%include "ortools/constraint_solver/python/constraint_solver_helpers.i"
%include "ortools/constraint_solver/python/constraint_solver_helpers.swig"

%include "ortools/util/python/functions.i"
%include "ortools/util/python/vector.i"
%include "ortools/util/python/functions.swig"
%include "ortools/util/python/vector.swig"

%include "ortools/constraint_solver/python/pywrapcp_util.i"
%include "ortools/constraint_solver/python/pywrapcp_util.swig"

// We *do* need to use SWIGTYPE_... type names directly, because the
// (recommended replacement) $descriptor macro fails, as of 2019-07, with
Expand Down Expand Up @@ -103,7 +103,7 @@ struct FailureProtect {

// ============= Type conversions ==============

// See ./constraint_solver_helpers.i
// See ./constraint_solver_helpers.swig
PY_CONVERT_HELPER_PTR(Constraint);
PY_CONVERT_HELPER_PTR(Decision);
PY_CONVERT_HELPER_PTR(DecisionBuilder);
Expand Down Expand Up @@ -131,7 +131,7 @@ PY_CONVERT(LocalSearchFilter);
PY_CONVERT(LocalSearchFilterManager);

// Support passing std::function<void(Solver*)> as argument.
// See ../utils/python/functions.i, from which this was copied and adapted.
// See ../utils/python/functions.swig, from which this was copied and adapted.

%{
static void PyFunctionSolverToVoid(PyObject* pyfunc,
Expand Down Expand Up @@ -647,10 +647,10 @@ PY_STRINGIFY_DEBUGSTRING(Decision);
}

// ############ BEGIN DUPLICATED CODE BLOCK ############
// IMPORTANT: keep this code block in sync with the .i
// IMPORTANT: keep this code block in sync with the .swig
// files in ../java and ../csharp.
// TODO(user): extract this duplicated code into a common, multi-language
// .i file with SWIG_exception.
// .swig file with SWIG_exception.

// Protect from failure.
// TODO(user): document this further.
Expand Down Expand Up @@ -1911,7 +1911,7 @@ RENAME_ASSIGNMENT_CONTAINER(

} // namespace operations_research

// ================= constraint_solver.i API =====================
// ================= constraint_solver.swig API =====================

namespace operations_research {

Expand Down
2 changes: 1 addition & 1 deletion ortools/constraint_solver/python/constraint_solver_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -5715,7 +5715,7 @@ static const char* __doc_operations_research_Solver_SetUseFastLocalSearch =
R"doc(enabled for metaheuristics. Disables/enables fast local search.)doc";

static const char* __doc_operations_research_Solver_ShouldFail =
R"doc(See http://cs/file:constraint_solver.i%20ShouldFail.)doc";
R"doc(See http://cs/file:constraint_solver.swig%20ShouldFail.)doc";

static const char* __doc_operations_research_Solver_Solve =
R"doc(@{ Solves the problem using the given DecisionBuilder and returns true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PyObject* PyObjFrom<int64_t>(const int64_t& c) {

// Conversion of IntExpr* and IntVar* are a bit special because of the two
// possible casts from IntExpr and Constraint. We define them here because
// they are used by both constraint_solver.i and routing.i, but need to
// they are used by both constraint_solver.swig and routing.swig, but need to
// be defined at a point where IntVar/IntExpr are known.
%define PY_CONVERT_HELPER_INTEXPR_AND_INTVAR()
%{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// This .i file cannot be used in isolation!
// It represents some of the inlined C++ content of ./constraint_solver.i,
// This .swig file cannot be used in isolation!
// It represents some of the inlined C++ content of ./constraint_solver.swig,
// and was split out because it's a large enough chunk of C++ code.
//
// It can only be interpreted in the context of ./constraint_solver.i, where
// It can only be interpreted in the context of ./constraint_solver.swig, where
// it is included.
%{
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion ortools/graph/csharp/graph.i
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// This .i file is only used in the open-source export to OR-Tools.
// This .swig file is only used in the open-source export to OR-Tools.
//
// It exposes some of the C++ classes in ../, namely :
// - SimpleMaxFlow, from ../max_flow.h
Expand Down
2 changes: 1 addition & 1 deletion ortools/graph/java/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ load("//bazel:swig_java.bzl", "ortools_java_wrap_cc")

ortools_java_wrap_cc(
name = "graph",
src = "graph.i",
src = "graph.swig",
module = "graph",
package = "com.google.ortools.graph",
swig_includes = [
Expand Down
10 changes: 5 additions & 5 deletions ortools/graph/java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set_property(SOURCE graph.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE graph.i PROPERTY SWIG_MODULE_NAME main)
set_property(SOURCE graph.i PROPERTY COMPILE_DEFINITIONS
set_property(SOURCE graph.swig PROPERTY CPLUSPLUS ON)
set_property(SOURCE graph.swig PROPERTY SWIG_MODULE_NAME main)
set_property(SOURCE graph.swig PROPERTY COMPILE_DEFINITIONS
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT=)
set_property(SOURCE graph.i PROPERTY COMPILE_OPTIONS
set_property(SOURCE graph.swig PROPERTY COMPILE_OPTIONS
-package ${JAVA_PACKAGE}.graph)
swig_add_library(jnigraph
TYPE OBJECT
LANGUAGE java
OUTPUT_DIR ${JAVA_PROJECT_DIR}/${JAVA_SRC_PATH}/graph
SOURCES graph.i)
SOURCES graph.swig)

target_include_directories(jnigraph PRIVATE ${JNI_INCLUDE_DIRS})
set_target_properties(jnigraph PROPERTIES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// This .i files exposes some of the C++ classes in ../, namely :
// This .swig files exposes some of the C++ classes in ../, namely :
// - MaxFlow, from SimpleMaxFlow in ../max_flow.h
// - MinCostFlow, from SimpleMinCostFlow in ../min_cost_flow.h
// - LinearSumAssignment, from SimpleLinearSumAssignment in ../assignment.h
Expand Down
2 changes: 1 addition & 1 deletion ortools/init/java/init.i
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

%include "std_string.i"

%include "ortools/util/java/absl_string_view.i"
%include "ortools/util/java/absl_string_view.swig"

%{
#include "ortools/init/init.h"
Expand Down
2 changes: 1 addition & 1 deletion ortools/init/python/init_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Simple unit tests for python/init.i. Not exhaustive."""
"""Simple unit tests for python/init.swig. Not exhaustive."""

from absl.testing import absltest
from ortools.init.python import init
Expand Down
2 changes: 1 addition & 1 deletion ortools/linear_solver/java/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ load("//bazel:swig_java.bzl", "ortools_java_wrap_cc")

ortools_java_wrap_cc(
name = "modelbuilder",
src = "modelbuilder.i",
src = "modelbuilder.swig",
module = "modelbuilder",
package = "com.google.ortools.modelbuilder",
swig_includes = [
Expand Down
20 changes: 10 additions & 10 deletions ortools/linear_solver/java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set_property(SOURCE linear_solver.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE linear_solver.i PROPERTY SWIG_MODULE_NAME main)
set_property(SOURCE linear_solver.i PROPERTY COMPILE_DEFINITIONS
set_property(SOURCE linear_solver.swig PROPERTY CPLUSPLUS ON)
set_property(SOURCE linear_solver.swig PROPERTY SWIG_MODULE_NAME main)
set_property(SOURCE linear_solver.swig PROPERTY COMPILE_DEFINITIONS
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT=)
set_property(SOURCE linear_solver.i PROPERTY COMPILE_OPTIONS
set_property(SOURCE linear_solver.swig PROPERTY COMPILE_OPTIONS
-package ${JAVA_PACKAGE}.linearsolver)
swig_add_library(jnilinear_solver
TYPE OBJECT
LANGUAGE java
OUTPUT_DIR ${JAVA_PROJECT_DIR}/${JAVA_SRC_PATH}/linearsolver
SOURCES linear_solver.i)
SOURCES linear_solver.swig)

target_include_directories(jnilinear_solver PRIVATE ${JNI_INCLUDE_DIRS})
set_target_properties(jnilinear_solver PROPERTIES
SWIG_USE_TARGET_INCLUDE_DIRECTORIES ON
POSITION_INDEPENDENT_CODE ON)
target_link_libraries(jnilinear_solver PRIVATE ortools::ortools)

set_property(SOURCE modelbuilder.i PROPERTY CPLUSPLUS ON)
set_property(SOURCE modelbuilder.i PROPERTY SWIG_MODULE_NAME main)
set_property(SOURCE modelbuilder.i PROPERTY COMPILE_DEFINITIONS
set_property(SOURCE modelbuilder.swig PROPERTY CPLUSPLUS ON)
set_property(SOURCE modelbuilder.swig PROPERTY SWIG_MODULE_NAME main)
set_property(SOURCE modelbuilder.swig PROPERTY COMPILE_DEFINITIONS
${OR_TOOLS_COMPILE_DEFINITIONS} ABSL_MUST_USE_RESULT=)
set_property(SOURCE modelbuilder.i PROPERTY COMPILE_OPTIONS
set_property(SOURCE modelbuilder.swig PROPERTY COMPILE_OPTIONS
-package ${JAVA_PACKAGE}.modelbuilder)
swig_add_library(jnimodelbuilder
TYPE OBJECT
LANGUAGE java
OUTPUT_DIR ${JAVA_PROJECT_DIR}/${JAVA_SRC_PATH}/modelbuilder
SOURCES modelbuilder.i)
SOURCES modelbuilder.swig)

target_include_directories(jnimodelbuilder PRIVATE ${JNI_INCLUDE_DIRS})
set_target_properties(jnimodelbuilder PROPERTIES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// This .i file exposes the linear programming and integer programming
// This .swig file exposes the linear programming and integer programming
// solver. See the C++/Python codelab: (there isn't
// a java codelab yet, as of July 2014)
//
Expand All @@ -33,7 +33,7 @@

// We prefer our in-house vector wrapper to std_vector.i, because it
// converts to and from native java arrays.
%import "ortools/util/java/vector.i"
%import "ortools/util/java/vector.swig"

%include "ortools/util/java/proto.i"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

%include "ortools/base/base.i"
%include "enums.swg"
%include "ortools/util/java/vector.i"
%include "ortools/util/java/vector.swig"

%{
#include "ortools/linear_solver/wrappers/model_builder_helper.h"
Expand All @@ -27,7 +27,7 @@
// The only difference is that the argument is not a basic type, and needs
// processing to be passed to the std::function.
//
// TODO(user): cleanup java/functions.i and move the code there.
// TODO(user): cleanup java/functions.swig and move the code there.
%{
#include <memory> // std::make_shared<GlobalRefGuard>

Expand Down
Loading
Loading