Explorar el Código

add simbody (#659)

* add simbody

* upload patch
Hoildkv hace 3 años
padre
commit
e487916004
Se han modificado 2 ficheros con 108 adiciones y 0 borrados
  1. 50 0
      packages/s/simbody/patches/3.7/msvc.patch
  2. 58 0
      packages/s/simbody/xmake.lua

+ 50 - 0
packages/s/simbody/patches/3.7/msvc.patch

@@ -0,0 +1,50 @@
+diff --git a/SimTKcommon/BigMatrix/include/SimTKcommon/internal/VectorIterator.h b/SimTKcommon/BigMatrix/include/SimTKcommon/internal/VectorIterator.h
+index 79c07e61e..b454fcefc 100644
+--- a/SimTKcommon/BigMatrix/include/SimTKcommon/internal/VectorIterator.h
++++ b/SimTKcommon/BigMatrix/include/SimTKcommon/internal/VectorIterator.h
+@@ -73,14 +73,14 @@ class VectorIterator {
+     same vector as the source iterator. **/
+     VectorIterator& operator=(const VectorIterator& source) = default;
+ 
+-    ELT& operator*() {
++    /** Dereference the iterator to access the element it points to. Note
++    that although the iterator may be const, it can still point to a 
++    mutable element. **/
++    ELT& operator*() const {
+         assert (index >= 0 && index < vectorp->size());
+         return (*vectorp)[(int)index];
+     }
+-    ELT& operator[](ptrdiff_t i) {
+-        assert (i >= 0 && i < vectorp->size());
+-        return (*vectorp)[(int)i];
+-    }
++
+     VectorIterator& operator++() {
+         assert (index < vectorp->size());
+         ++index;
+diff --git a/SimTKcommon/Polynomial/src/cpoly.cpp b/SimTKcommon/Polynomial/src/cpoly.cpp
+index 3b3b6f78d..d97b78c5a 100644
+--- a/SimTKcommon/Polynomial/src/cpoly.cpp
++++ b/SimTKcommon/Polynomial/src/cpoly.cpp
+@@ -602,7 +602,7 @@ T CPoly<T>::scale( const int nn, const T pt[], const T eta, const T infin, const
+       if( infin / sc > max ) sc = 1;
+       }
+    l = (int)( log( sc ) / log(base ) + 0.5 );
+-   fn_val = pow( base , l );
++   fn_val = T(std::pow( base , l )); // extraneous cast required by VS 16.8.2
+    return fn_val;
+    }
+ 
+diff --git a/SimTKcommon/Polynomial/src/rpoly.cpp b/SimTKcommon/Polynomial/src/rpoly.cpp
+index 10a399194..05afde29f 100644
+--- a/SimTKcommon/Polynomial/src/rpoly.cpp
++++ b/SimTKcommon/Polynomial/src/rpoly.cpp
+@@ -143,7 +143,7 @@ int RPoly<T>::findRoots(T *op, int degree, T *zeror, T *zeroi)
+             sc = smalno;
+     }
+     l = (int)(log(sc)/log(base) + 0.5);
+-    factor = pow(base*(T) 1.0,l);
++    factor = T(std::pow( base, l )); // extraneous cast required by VS 16.8.2
+     if (factor != 1.0) {
+         for (i=0;i<=n;i++) 
+             p[i] = factor*p[i];     /* Scale polynomial. */

+ 58 - 0
packages/s/simbody/xmake.lua

@@ -0,0 +1,58 @@
+package("simbody")
+
+    set_homepage("https://simtk.org/home/simbody")
+    set_description("High-performance C++ multibody dynamics/physics library for simulating articulated biomechanical and mechanical systems like vehicles, robots, and the human skeleton.")
+    set_license("Apache-2.0")
+
+    add_urls("https://github.com/simbody/simbody/archive/refs/tags/Simbody-$(version).tar.gz")
+    add_versions("3.7", "d371a92d440991400cb8e8e2473277a75307abb916e5aabc14194bea841b804a")
+
+    add_patches("3.7", path.join(os.scriptdir(), "patches", "3.7", "msvc.patch"), "ac80c1bf9266d7d5e256a632ea1e2a00260dcc4cb68d2a23272fb309af61d2b7")
+
+    add_configs("blas", {description = "Set BLAS vendor.", default = "openblas", type = "string", values = {"mkl", "openblas"}})
+
+    add_deps("cmake")
+    if not is_plat("windows") then
+        add_includedirs("include/simbody")
+    end
+    if is_plat("linux") then
+        add_syslinks("dl")
+    end
+    on_load("windows", "macosx", "linux", function (package)
+        package:add("deps", package:config("blas"))
+        if package:is_plat("windows") and not package:config("shared") then
+            package:add("defines", "SimTK_USE_STATIC_LIBRARIES")
+        end
+        local suffix = package:config("shared") and "" or "_static"
+        for _, lib in ipairs({"SimTKsimbody", "SimTKmath", "SimTKcommon"}) do
+            package:add("links", lib .. suffix)
+        end
+    end)
+
+    on_install("windows", "macosx", "linux", function (package)
+        io.replace("CMakeLists.txt", "if(WIN32)\n    set(LAPACK", "if(FALSE)\n    set(LAPACK", {plain = true})
+        if package:config("blas") == "openblas" then
+            io.replace("CMakeLists.txt", "REALTIME_LIB rt", "REALTIME_LIB rt gfortran", {plain = true})
+        end
+        io.replace("Simbody/Visualizer/simbody-visualizer/CMakeLists.txt", "TEST_STATIC_TARGET})", "TEST_STATIC_TARGET})\nadd_definitions(-DSimTK_USE_STATIC_LIBRARIES)", {plain = true})
+        if package:is_plat("windows") then
+            io.replace("CMakeLists.txt", "/MD", "/" .. package:config("vs_runtime"), {plain = true})
+        end
+        local configs = {"-DINSTALL_DOCS=OFF", "-DBUILD_TESTING=OFF", "-DBUILD_EXAMPLES=OFF"}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        table.insert(configs, "-DBUILD_STATIC_LIBRARIES=" .. (package:config("shared") and "OFF" or "ON"))
+        table.insert(configs, "-DBUILD_DYNAMIC_LIBRARIES=" .. (package:config("shared") and "ON" or "OFF"))
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            using namespace SimTK;
+            void test() {
+                MultibodySystem system;
+                SimbodyMatterSubsystem matter(system);
+                GeneralForceSubsystem forces(system);
+                Force::Gravity gravity(forces, matter, YAxis, 9.8);
+            }
+        ]]}, {configs = {languages = "c++11"}, includes = "Simbody.h"}))
+    end)