Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
jgillis committed Feb 25, 2023
1 parent 63425af commit 355eaf9
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 7 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ runs:
using: "composite"
steps:
- run: |
curl -OL https://github.com/casadi/mockups/releases/download/v41/mockups_${{ inputs.tag }}.zip
curl -OL https://github.com/casadi/mockups/releases/download/v43/mockups_${{ inputs.tag }}.zip
unzip mockups_${{ inputs.tag }}.zip -d mockups
ls mockups
ls mockups/cmake
Expand Down
25 changes: 22 additions & 3 deletions cplex/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ def function_ptr(decl):

fout.write("""
#if defined(_WIN32)
static HINSTANCE h;
#else
void * h;
#endif
void cplex_adaptor_unload() {
if (h) {
#if defined(_WIN32)
FreeLibray(h);
#elif defined(__APPLE__)
dlclose(h);
#endif
}
}
int cplex_adaptor_load(char* err_msg, unsigned int err_msg_len) {
const char* suffix = getenv("CPLEX_VERSION");
Expand Down Expand Up @@ -84,11 +99,11 @@ def function_ptr(decl):
snprintf(buffer, 100, "libcplex%s.%s", suffix, library_suffix);
#if defined(_WIN32)
HINSTANCE h = LoadLibrary(TEXT(buffer));
h = LoadLibrary(TEXT(buffer));
#elif defined(__APPLE__)
void * h = dlopen(buffer, RTLD_LAZY | RTLD_LOCAL);
h = dlopen(buffer, RTLD_LAZY | RTLD_LOCAL);
#else
void * h = dlopen(buffer, RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
h = dlopen(buffer, RTLD_LAZY | RTLD_LOCAL | RTLD_DEEPBIND);
#endif
if (h) {
Expand All @@ -98,10 +113,12 @@ def function_ptr(decl):
fout.write("""#if CPX_APIMODEL == CPX_APIMODEL_LARGE\n""")
for decl in method_declarations:
fout.write(""" %s = (%s) GetProcAddress(h, "%s");\n""" % (get_name(decl),function_ptr(decl),get_name(decl).replace("CPXX","CPXL")))
fout.write(""" if (%s==NULL) { snprintf(err_msg, err_msg_len, "Could not find symbol '%s' in libcplex%%s.%%s", suffix, library_suffix); return 2; };\n""" % (get_name(decl),get_name(decl).replace("CPXX","CPXL")))
fout.write("""#endif\n""")
fout.write("""#if CPX_APIMODEL == CPX_APIMODEL_SMALL\n""")
for decl in method_declarations:
fout.write(""" %s = (%s) GetProcAddress(h, "%s");\n""" % (get_name(decl),function_ptr(decl),get_name(decl).replace("CPXX","CPXS")))
fout.write(""" if (%s==NULL) { snprintf(err_msg, err_msg_len, "Could not find symbol '%s' in libcplex%%s.%%s", suffix, library_suffix); return 2; };\n""" % (get_name(decl),get_name(decl).replace("CPXX","CPXS")))
fout.write("""#endif\n""")

fout.write("""
Expand All @@ -111,10 +128,12 @@ def function_ptr(decl):
fout.write("""#if CPX_APIMODEL == CPX_APIMODEL_LARGE\n""")
for decl in method_declarations:
fout.write(""" %s = (%s) dlsym(h, "%s");\n""" % (get_name(decl),function_ptr(decl),get_name(decl).replace("CPXX","CPXL")))
fout.write(""" if (%s==NULL) { snprintf(err_msg, err_msg_len, "Could not find symbol '%s' in libcplex%%s.%%s", suffix, library_suffix); return 2; };\n""" % (get_name(decl),get_name(decl).replace("CPXX","CPXL")))
fout.write("""#endif\n""")
fout.write("""#if CPX_APIMODEL == CPX_APIMODEL_SMALL\n""")
for decl in method_declarations:
fout.write(""" %s = (%s) dlsym(h, "%s");\n""" % (get_name(decl),function_ptr(decl),get_name(decl).replace("CPXX","CPXS")))
fout.write(""" if (%s==NULL) { snprintf(err_msg, err_msg_len, "Could not find symbol '%s' in libcplex%%s.%%s", suffix, library_suffix); return 2; };\n""" % (get_name(decl),get_name(decl).replace("CPXX","CPXS")))
fout.write("""#endif\n""")
fout.write("""
#endif // _WIN32
Expand Down
1 change: 1 addition & 0 deletions cplex/include/cplex.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ typedef void *CPXVOIDptr;
#endif

int cplex_adaptor_load(char* err_msg, unsigned int err_msg_len);
void cplex_adaptor_unload();

#define CPXXaddmipstarts adaptor_CPXXaddmipstarts
DLLSYMBOL int (*CPXXaddmipstarts)(CPXCENVptr, CPXLPptr, int, CPXNNZ, CPXNNZ const *, CPXDIM const *, double const *, int const *, char const *const *);
Expand Down
1 change: 1 addition & 0 deletions cplex/include/cplex.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ typedef void *CPXVOIDptr;
#endif

int cplex_adaptor_load(char* err_msg, unsigned int err_msg_len);
void cplex_adaptor_unload();

[cplex_core.h]

Expand Down
Loading

0 comments on commit 355eaf9

Please sign in to comment.