Browse Source

chipmunk2d: Fix Android static lib (#3658)

* chipmunk2d: Fix Android static lib

* Fix chipmunk2d on Android in shared mode

* Update xmake.lua
Jérôme Leclercq 1 year ago
parent
commit
1468df7234

+ 14 - 0
packages/c/chipmunk2d/patches/7.0.3/android.patch

@@ -15,6 +15,20 @@ index 9544da8..82d027e 100644
  #endif
  #endif
  
  
  /// @defgroup basicTypes Basic Types
  /// @defgroup basicTypes Basic Types
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 34882d1..56589fb 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -31,6 +31,9 @@ if(BUILD_SHARED)
+ 	  # need to explicitly link to the math library because the CMake/Android toolchains may not do it automatically
+ 	  target_link_libraries(chipmunk m)
+   endif(ANDROID OR UNIX)
++  if(ANDROID)
++	  target_link_libraries(chipmunk log)
++  endif(ANDROID)
+   install(TARGETS chipmunk RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+                            LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+                            ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
 diff --git a/src/cpHastySpace.c b/src/cpHastySpace.c
 diff --git a/src/cpHastySpace.c b/src/cpHastySpace.c
 index 8dca425..fa3074d 100644
 index 8dca425..fa3074d 100644
 --- a/src/cpHastySpace.c
 --- a/src/cpHastySpace.c

+ 3 - 1
packages/c/chipmunk2d/xmake.lua

@@ -1,5 +1,4 @@
 package("chipmunk2d")
 package("chipmunk2d")
-
     set_homepage("https://chipmunk-physics.net/")
     set_homepage("https://chipmunk-physics.net/")
     set_description("A fast and lightweight 2D game physics library.")
     set_description("A fast and lightweight 2D game physics library.")
     set_license("MIT")
     set_license("MIT")
@@ -23,6 +22,8 @@ package("chipmunk2d")
 
 
     if is_plat("linux") then
     if is_plat("linux") then
         add_syslinks("pthread", "m")
         add_syslinks("pthread", "m")
+    elseif is_plat("android") then
+        add_syslinks("log", "m")
     end
     end
 
 
     on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", "wasm", function (package)
     on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", "wasm", function (package)
@@ -35,6 +36,7 @@ package("chipmunk2d")
         else
         else
             table.insert(configs, "-DBUILD_SHARED=OFF")
             table.insert(configs, "-DBUILD_SHARED=OFF")
             table.insert(configs, "-DBUILD_STATIC=ON")
             table.insert(configs, "-DBUILD_STATIC=ON")
+            table.insert(configs, "-DINSTALL_STATIC=ON")
         end
         end
         import("package.tools.cmake").install(package, configs)
         import("package.tools.cmake").install(package, configs)
         os.vcp("include/chipmunk", package:installdir("include"))
         os.vcp("include/chipmunk", package:installdir("include"))