Skip to content

Commit

Permalink
Third-party libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny authored Jun 5, 2024
2 parents 9aff51e + ef4ccfe commit 74e5c15
Show file tree
Hide file tree
Showing 43 changed files with 298 additions and 234 deletions.
10 changes: 5 additions & 5 deletions cmake/clcachewrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
int main(int pArgC, char *pArgV[])
{
// Call clcache with the given arguments, except the first one, which is the
// full path to the MSVC compiler.
Expand All @@ -27,15 +27,15 @@ int main(int argc, char *argv[])
char clcacheCommand[STRING_SIZE] = "clcache";
int k = 6;

for (int i = 2; i < argc; ++i) {
for (int i = 2; i < pArgC; ++i) {
clcacheCommand[++k] = ' ';

for (int j = 0; argv[i][j]; ++j) {
if (argv[i][j] == '\\') {
for (int j = 0; pArgV[i][j]; ++j) {
if (pArgV[i][j] == '\\') {
clcacheCommand[++k] = '\\';
clcacheCommand[++k] = '\\';
} else {
clcacheCommand[++k] = argv[i][j];
clcacheCommand[++k] = pArgV[i][j];
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ function(add_target_property TARGET PROPERTY VALUE)
set(NEW_VALUE "${VALUE}")
endif()

set_target_properties(${TARGET} PROPERTIES ${PROPERTY} "${NEW_VALUE}")
set_target_properties(${TARGET} PROPERTIES
${PROPERTY} "${NEW_VALUE}")
endfunction()

function(prepare_test TARGET)
Expand Down
6 changes: 2 additions & 4 deletions cmake/packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ function(build_package PACKAGE_NAME)
execute_process(COMMAND ${CONFIGURE_COMMAND} -G "${CMAKE_GENERATOR}" -S . -B build
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
RESULT_VARIABLE RESULT
ERROR_VARIABLE ERROR
OUTPUT_QUIET)
ERROR_VARIABLE ERROR)

if(NOT RESULT EQUAL 0)
message(FATAL_ERROR "${ERROR}")
Expand All @@ -78,8 +77,7 @@ function(build_package PACKAGE_NAME)
execute_process(COMMAND ${CMAKE_COMMAND} --build build
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
RESULT_VARIABLE RESULT
ERROR_VARIABLE ERROR
OUTPUT_QUIET)
ERROR_VARIABLE ERROR)

if(NOT RESULT EQUAL 0)
message(FATAL_ERROR "${ERROR}")
Expand Down
4 changes: 4 additions & 0 deletions extern/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
`libOpenCOR <https://opencor.ws/libopencor/index.html>`__ relies on the following external projects:

- `GoogleTest <https://github.com/google/googletest>`__ at commit `305e5a2 <https://github.com/google/googletest/commit/305e5a238b3c8d11266fbafd85520fb6b3184851>`__; and
- `pybind11 <https://github.com/pybind/pybind11>`__ `2.12.0 <https://github.com/pybind/pybind11/releases/tag/v2.12.0>`__.
14 changes: 7 additions & 7 deletions src/3rdparty/OpenSSL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

set(PACKAGE_NAME OpenSSL)
set(PACKAGE_VERSION 3.0.13)
set(PACKAGE_VERSION 3.0.14)
set(PACKAGE_REPOSITORY openssl)
set(RELEASE_TAG openssl-3.0.13)
set(RELEASE_TAG openssl-3.0.14)
set(INSTALL_DIR ${PREBUILT_DIR}/${PACKAGE_NAME})

# Either retrieve or build our package.
Expand All @@ -25,26 +25,26 @@ if(LIBOPENCOR_PREBUILT_OPENSSL)
if(RELEASE_MODE)
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
02f852f95f8494d1defcf6cfa609b59bda77c8ba)
117fc350696f830cb82aafb95a47588f6434c177)
else()
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
ed11c82b4ea3d62633dc106391be4ef98d2303c7)
7293afb0786724e349cbc14d81b36b3bc15201e5)
endif()
elseif(APPLE)
if(INTEL_MODE)
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
6032fb3e7059dbb6554245ecb951e142b9d7e1a5)
5388837e3702b904b4d7b1a9891eda360537ec51)
else()
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
bc3b9c9a2453543cf3115221d912434ac79f19ce)
22f22109d28cea6ea55681e48bdfd040cc1352db)
endif()
else()
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
6a87632104f6c0e4d2d1c45cc41077a50e6b324d)
85dc755b012accd22114b42ddaabb22ea246dd2a)
endif()
else()
# Build our package.
Expand Down
15 changes: 7 additions & 8 deletions src/3rdparty/libCOMBINE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
set(PACKAGE_NAME libCOMBINE)
set(PACKAGE_VERSION 0.2.20)
set(PACKAGE_REPOSITORY libCombine)
set(RELEASE_TAG v0.2.20b)
set(RELEASE_TAG v0.2.20-buffer)
set(INSTALL_DIR ${PREBUILT_DIR}/${PACKAGE_NAME})

# Either retrieve or build our package.
Expand All @@ -28,32 +28,32 @@ if(LIBOPENCOR_PREBUILT_LIBCOMBINE)
if(EMSCRIPTEN)
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
fb6d723cb1f1ef533f8254d450abf227882f0e0b)
a6d9d575c87fb803fe63680d2b039e4e2aa4baed)
else()
if(WIN32)
if(RELEASE_MODE)
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
9781459729e039c3275eae5da37ac2c1aa143032)
c4d636fa1427eb6bb702e1e94a1b7149efd2ffb8)
else()
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
8da2f4f272e49c79b4d87d8175fd5ccd966d4dab)
6940a27fc80f5171072d7d3a0824e641811bc6b8)
endif()
elseif(APPLE)
if(INTEL_MODE)
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
ec6284679c7a85eafd3b92f4e97561383ffd2611)
0ad5a14ebbffd57c126d777116fa1f22aaa47ab0)
else()
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
5e2faaf876dc6b4acfaf05a1b1c147ad5633b1d3)
1eb9641b388e060e99cf52da93f83f5e17a4d78e)
endif()
else()
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
fb8a6411e2f33422e20aaa64093967fef5829a10)
2e0a1cd907d3fad09c20b8378e230ac10ba4a913)
endif()
endif()
else()
Expand All @@ -67,7 +67,6 @@ else()
-DBUILD_TEST=OFF
${CMAKE_ARGS}
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
-DCMAKE_POLICY_DEFAULT_CMP0074:STRING=NEW
-DLIBCOMBINE_SHARED_VERSION=OFF
-DLIBCOMBINE_SKIP_SHARED_LIBRARY=ON
-DLIBSBML_INCLUDE_DIR=${LIBSBML_INCLUDE_DIR}
Expand Down
10 changes: 5 additions & 5 deletions src/3rdparty/libcurl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ if(LIBOPENCOR_PREBUILT_LIBCURL)
if(RELEASE_MODE)
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
3714d2514e098a3ed0d0cb8c8a5bdd92a8f25d48)
d05d02ef482730c3a3d8886026aa2214d96f2e24)
else()
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
e77b33d053ceaf86701427fb1c935d2acbb4b920)
db94afcfbfa6c99ad50caea67383e1d4c531406b)
endif()
elseif(APPLE)
if(INTEL_MODE)
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
b3e3f894b02fccd3dfa7a40efc67bc2f7b86602b)
08e013a23400a052686419313baa93105d7c5813)
else()
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
d722a61e3793935149f99be6d22dd2caab12564b)
ec4cec188b6df415fa3e0367295b6792d4f42e90)
endif()
else()
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
a8079a1e656b374280ef896ed076b862d704921e)
f8d6d68a90c37f383a7f5e6730b1d7ea54452ccd)
endif()
else()
# Build our package.
Expand Down
10 changes: 5 additions & 5 deletions src/3rdparty/libssh2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ if(LIBOPENCOR_PREBUILT_LIBSSH2)
if(RELEASE_MODE)
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
9688b2a91f43b7789bc146f37aff90b3d6623db4)
b034aef740d10333d428ef3738cf9dcbf1319cdc)
else()
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
900d0364ec5eb5cda48b262baae270a173ccbaee)
fdb70ba76cc62673f8f80382b5c1504e5085fc7b)
endif()
elseif(APPLE)
if(INTEL_MODE)
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
276a86463fc431e89600f533bd3b13133c22b326)
3cbf4f7e8e9302bebb1fb7da6ea444f7c8c3496b)
else()
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
40c2e04655173653007519ffd34b87d19f101162)
91e84958df28389afeaf46f6432f44663bb147f1)
endif()
else()
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
e30e3fa0fce8542692cd6f97ecf6eb663b5a4887)
8c5b3930100cb97ec118dc645fb1273f51140145)
endif()
else()
# Build our package.
Expand Down
10 changes: 5 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ if(LIBOPENCOR_COMPILER_CACHING)
set(CMAKE_C_COMPILER_LAUNCHER ${BUILDCACHE_EXE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${BUILDCACHE_EXE})
elseif(CLCACHE_EXE)
set(CLCACHEWRAPPER ${CMAKE_CURRENT_BINARY_DIR}/clcachewrapper)
set(CLCACHEWRAPPER ${CMAKE_BINARY_DIR}/clcachewrapper)

execute_process(COMMAND ${CMAKE_C_COMPILER} /O2 /Fe${CLCACHEWRAPPER} ${CMAKE_SOURCE_DIR}/cmake/clcachewrapper.c
RESULT_VARIABLE RESULT
OUTPUT_QUIET ERROR_QUIET)
try_compile(CLCACHEWRAPPER_EXE ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/clcachewrapper.c
COPY_FILE ${CLCACHEWRAPPER})

if(RESULT EQUAL 0)
if(CLCACHEWRAPPER_EXE)
set(CMAKE_C_COMPILER_LAUNCHER ${CLCACHEWRAPPER})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CLCACHEWRAPPER})
endif()
Expand Down Expand Up @@ -201,6 +200,7 @@ set(SOURCE_FILES
)

set(INTERNAL_HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/file/filemanager_p.h
${CMAKE_CURRENT_SOURCE_DIR}/file/filemanager.h
${CMAKE_CURRENT_SOURCE_DIR}/misc/utils.h
${CMAKE_CURRENT_SOURCE_DIR}/solver/solver_p.h
Expand Down
3 changes: 1 addition & 2 deletions src/bindings/python/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ void fileApi(py::module_ &m)
.def_property_readonly("file_name", &libOpenCOR::File::fileName, "Get the file name for this File object.")
.def_property_readonly("url", &libOpenCOR::File::url, "Get the URL for this File object.")
.def_property_readonly("path", &libOpenCOR::File::path, "Get the path for this File object.")
.def_property_readonly("contents", &libOpenCOR::File::contents, "Get the contents of this File object.")
.def("set_contents", &libOpenCOR::File::setContents, "Set the contents of this File object.");
.def_property("contents", &libOpenCOR::File::contents, &libOpenCOR::File::setContents, "The contents of this File object.");
}
5 changes: 3 additions & 2 deletions src/file/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ FilePtr File::create(const std::string &pFileNameOrUrl)
// Check whether the given file name or URL is already managed and if so then return it otherwise create, manage,
// and return a new file object.

auto file = FileManager::instance().file(pFileNameOrUrl);
auto fileManager = FileManager::instance();
auto file = fileManager.file(pFileNameOrUrl);

if (file != nullptr) {
return file->shared_from_this();
Expand All @@ -182,7 +183,7 @@ FilePtr File::create(const std::string &pFileNameOrUrl)

res->pimpl()->checkType(res);

FileManager::instance().manage(res.get());
fileManager.manage(res.get());

return res;
}
Expand Down
39 changes: 33 additions & 6 deletions src/file/filemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#include "filemanager.h"
#include "filemanager_p.h"

#include <algorithm>

namespace libOpenCOR {

FileManager &FileManager::instance()
FileManager::Impl &FileManager::Impl::instance()
{
static FileManager instance;
static Impl instance;

return instance;
}

void FileManager::manage(File *pFile)
void FileManager::Impl::manage(File *pFile)
{
mFiles.push_back(pFile);
}

void FileManager::unmanage(File *pFile)
void FileManager::Impl::unmanage(File *pFile)
{
mFiles.erase(std::find(mFiles.cbegin(), mFiles.cend(), pFile));
}

FilePtr FileManager::file(const std::string &pFileNameOrUrl) const
FilePtr FileManager::Impl::file(const std::string &pFileNameOrUrl) const
{
#if __clang_major__ < 16
auto [tIsLocalFile, tFileNameOrUrl] = retrieveFileInfo(pFileNameOrUrl);
Expand All @@ -59,4 +59,31 @@ FilePtr FileManager::file(const std::string &pFileNameOrUrl) const
return {};
}

FileManager &FileManager::instance()
{
static FileManager instance;

return instance;
}

FileManager::FileManager()
: mPimpl(Impl::instance())
{
}

void FileManager::manage(File *pFile)
{
mPimpl.manage(pFile);
}

void FileManager::unmanage(File *pFile)
{
mPimpl.unmanage(pFile);
}

FilePtr FileManager::file(const std::string &pFileNameOrUrl) const
{
return mPimpl.file(pFileNameOrUrl);
}

} // namespace libOpenCOR
6 changes: 5 additions & 1 deletion src/file/filemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ class FileManager
FilePtr file(const std::string &pFileNameOrUrl) const;

private:
Files mFiles;
class Impl;

Impl &mPimpl;

explicit FileManager();
};

} // namespace libOpenCOR
Loading

0 comments on commit 74e5c15

Please sign in to comment.