Add version info on python, java, .NET; add patch info on C++, #2861

This commit is contained in:
Laurent Perron
2021-10-22 10:08:28 +02:00
parent bb73699ff5
commit 758ead91e9
11 changed files with 63 additions and 5 deletions

View File

@@ -221,7 +221,7 @@ DEPENDENCIES_INC = -I$(INC_DIR) -I$(GEN_DIR) \
-Wno-deprecated -DUSE_GLOP -DUSE_BOP \
$(GLPK_INC) $(CPLEX_INC) $(XPRESS_INC)
CFLAGS = $(DEBUG) $(DEPENDENCIES_INC) -DOR_TOOLS_MAJOR=$(OR_TOOLS_MAJOR) -DOR_TOOLS_MINOR=$(OR_TOOLS_MINOR)
CFLAGS = $(DEBUG) $(DEPENDENCIES_INC) -DOR_TOOLS_MAJOR=$(OR_TOOLS_MAJOR) -DOR_TOOLS_MINOR=$(OR_TOOLS_MINOR) -DOR_TOOLS_PATCH=$(GIT_REVISION)
JNIFLAGS = $(JNIDEBUG) $(DEPENDENCIES_INC)
LDFLAGS += $(ZLIB_LNK) $(SYS_LNK) $(LINK_FLAGS)
DEPENDENCIES_LNK = $(GLPK_LNK) $(CPLEX_LNK) $(XPRESS_LNK)

View File

@@ -144,7 +144,7 @@ DEPENDENCIES_INC = /I$(INC_DIR) /I$(GEN_DIR) \
/DUSE_GLOP /DUSE_BOP \
$(GLPK_INC) $(GUROBI_INC) $(CPLEX_INC) $(XPRESS_INC)
CFLAGS = $(DEBUG) $(DEPENDENCIES_INC) /DOR_TOOLS_MAJOR=$(OR_TOOLS_MAJOR) /DOR_TOOLS_MINOR=$(OR_TOOLS_MINOR)
CFLAGS = $(DEBUG) $(DEPENDENCIES_INC) /DOR_TOOLS_MAJOR=$(OR_TOOLS_MAJOR) /DOR_TOOLS_MINOR=$(OR_TOOLS_MINOR) /DOR_TOOLS_PATCH=$(GIT_REVISION)
JNIFLAGS=$(CFLAGS) $(DEPENDENCIES_INC)
LDFLAGS =
DEPENDENCIES_LNK = $(SYS_LNK) $(STATIC_GLPK_LNK) $(STATIC_CPLEX_LNK) $(STATIC_XPRESS_LNK)

View File

@@ -39,8 +39,9 @@ cc_library(
"vlog_is_on.h",
],
copts = [
"-DOR_TOOLS_MAJOR=8",
"-DOR_TOOLS_MAJOR=9",
"-DOR_TOOLS_MINOR=1",
"-DOR_TOOLS_PATCH=9999",
],
defines = select({
"on_windows": ["OR_TOOLS_EXPORTS"],

View File

@@ -12,7 +12,8 @@ set_target_properties(${NAME} PROPERTIES
)
target_compile_definitions(${NAME} PRIVATE
-DOR_TOOLS_MAJOR=${PROJECT_VERSION_MAJOR}
-DOR_TOOLS_MINOR=${PROJECT_VERSION_MINOR})
-DOR_TOOLS_MINOR=${PROJECT_VERSION_MINOR}
-DOR_TOOLS_PATCH=${PROJECT_VERSION_PATCH})
if(MSVC)
target_compile_definitions(${NAME} PRIVATE -DOR_TOOLS_EXPORTS)
endif()

View File

@@ -17,5 +17,6 @@ namespace operations_research {
int OrToolsMajorVersion() { return OR_TOOLS_MAJOR; }
int OrToolsMinorVersion() { return OR_TOOLS_MINOR; }
int OrToolsPatchVersion() { return OR_TOOLS_PATCH; }
} // namespace operations_research

View File

@@ -18,6 +18,7 @@ namespace operations_research {
int OrToolsMajorVersion();
int OrToolsMinorVersion();
int OrToolsPatchVersion();
} // namespace operations_research

View File

@@ -16,6 +16,7 @@ target_include_directories(${NAME} PRIVATE
${PROJECT_BINARY_DIR})
target_link_libraries(${NAME} PRIVATE
absl::flags
absl::strings
protobuf::libprotobuf
${PROJECT_NAME}::proto)
#add_library(${PROJECT_NAME}::init ALIAS ${NAME})

View File

@@ -39,6 +39,12 @@
%unignore operations_research::CppBridge::SetFlags;
%unignore operations_research::CppBridge::LoadGurobiSharedLibrary;
%unignore operations_research::OrToolsVersion;
%unignore operations_research::OrToolsVersion::MajorNumber;
%unignore operations_research::OrToolsVersion::MinorNumber;
%unignore operations_research::OrToolsVersion::PatchNumber;
%unignore operations_research::OrToolsVersion::VersionString;
%include "ortools/init/init.h"
%unignoreall
%unignoreall

View File

@@ -18,7 +18,9 @@
#include <vector>
#include "absl/flags/flag.h"
#include "absl/strings/str_cat.h"
#include "ortools/base/logging.h"
#include "ortools/base/version.h"
#include "ortools/gurobi/environment.h"
#include "ortools/sat/cp_model_solver.h"
@@ -124,6 +126,39 @@ class CppBridge {
}
};
class OrToolsVersion {
public:
/**
* Returns the major version of OR-Tools.
*/
static int MajorNumber() {
return ::operations_research::OrToolsMajorVersion();
}
/**
* Returns the minor version of OR-Tools.
*/
static int MinorNumber() {
return ::operations_research::OrToolsMinorVersion();
}
/**
* Returns the patch version of OR-Tools.
*/
static int PatchNumber() {
return ::operations_research::OrToolsPatchVersion();
}
/**
* Returns the string version of OR-Tools.
*/
static std::string VersionString() {
return absl::StrCat(::operations_research::OrToolsMajorVersion(), ".",
::operations_research::OrToolsMinorVersion(), ".",
::operations_research::OrToolsPatchVersion(), ".");
}
};
} // namespace operations_research
#endif // OR_TOOLS_OPEN_SOURCE_INIT_INIT_H_

View File

@@ -39,6 +39,12 @@
%rename (setFlags) operations_research::CppBridge::SetFlags;
%rename (logGurobiSharedLibrary) operations_research::CppBridge::LoadGurobiSharedLibrary;
%unignore operations_research::OrToolsVersion;
%rename (getMajorNumber) operations_research::OrToolsVersion::MajorNumber;
%rename (getMinorNumber) operations_research::OrToolsVersion::MinorNumber;
%rename (getPatchNumber) operations_research::OrToolsVersion::PatchNumber;
%rename (getVersionString) operations_research::OrToolsVersion::VersionString;
%include "ortools/init/init.h"
%unignoreall

View File

@@ -39,6 +39,12 @@
%unignore operations_research::CppBridge::SetFlags;
%unignore operations_research::CppBridge::LoadGurobiSharedLibrary;
%unignore operations_research::OrToolsVersion;
%unignore operations_research::OrToolsVersion::MajorNumber;
%unignore operations_research::OrToolsVersion::MinorNumber;
%unignore operations_research::OrToolsVersion::PatchNumber;
%unignore operations_research::OrToolsVersion::VersionString;
%include "ortools/init/init.h"
%unignoreall