Skip to content

Commit

Permalink
Merge branch 'master' into ffmpeg/fix-android
Browse files Browse the repository at this point in the history
  • Loading branch information
uilianries authored Aug 14, 2024
2 parents 77b74fb + 59ecee3 commit d854331
Show file tree
Hide file tree
Showing 35 changed files with 213 additions and 519 deletions.
10 changes: 0 additions & 10 deletions recipes/box2d/2.4.x/conandata.yml

This file was deleted.

71 changes: 0 additions & 71 deletions recipes/box2d/2.4.x/conanfile.py

This file was deleted.

8 changes: 0 additions & 8 deletions recipes/box2d/2.4.x/test_package/CMakeLists.txt

This file was deleted.

26 changes: 0 additions & 26 deletions recipes/box2d/2.4.x/test_package/conanfile.py

This file was deleted.

16 changes: 0 additions & 16 deletions recipes/box2d/2.4.x/test_package/test_package.cpp

This file was deleted.

11 changes: 0 additions & 11 deletions recipes/box2d/2.4.x/test_v1_package/CMakeLists.txt

This file was deleted.

17 changes: 0 additions & 17 deletions recipes/box2d/2.4.x/test_v1_package/conanfile.py

This file was deleted.

16 changes: 0 additions & 16 deletions recipes/box2d/2.4.x/test_v1_package/test_package.cpp

This file was deleted.

17 changes: 14 additions & 3 deletions recipes/box2d/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
sources:
"2.3.1":
url: "https://github.com/erincatto/Box2D/archive/v2.3.1.zip"
sha256: "8ddd947400c59bcf09774bd75787e6253098a0bd337f5c61dae38b91aea678cf"
"2.4.2":
url: "https://github.com/erincatto/box2d/archive/refs/tags/v2.4.2.tar.gz"
sha256: "85b9b104d256c985e6e244b4227d447897fac429071cc114e5cc819dae848852"
"2.4.1":
url: "https://github.com/erincatto/box2d/archive/refs/tags/v2.4.1.tar.gz"
sha256: "d6b4650ff897ee1ead27cf77a5933ea197cbeef6705638dd181adc2e816b23c2"
"2.4.0":
url: "https://github.com/erincatto/Box2D/archive/v2.4.0.zip"
sha256: "6aebbc54c93e367c97e382a57ba12546731dcde51526964c2ab97dec2050f8b9"
patches:
"2.4.0":
- patch_file: "patches/0001-install-and-allow-shared.patch"
patch_description: "add install, allow shared build"
patch_type: "conan"
81 changes: 43 additions & 38 deletions recipes/box2d/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,73 @@
import os
from conan import ConanFile, tools
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
from conan import ConanFile
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, rm, rmdir, copy
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.scm import Version

required_conan_version = ">=1.46.0"
required_conan_version = ">=1.53.0"


class Box2dConan(ConanFile):
name = "box2d"
license = "Zlib"
description = "Box2D is a 2D physics engine for games"
topics = ("physics", "engine", "game development")
homepage = "http://box2d.org/"
license = "Zlib"
url = "https://github.com/conan-io/conan-center-index"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False],
"fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True,}
homepage = "http://box2d.org/"
topics = ("physics-engine", "graphic", "2d", "collision")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False]
}
default_options = {
"shared": False,
"fPIC": True
}

def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
try:
del self.options.fPIC
except Exception:
pass
self.options.rm_safe("fPIC")

def configure(self):
if self.options.shared:
try:
del self.options.fPIC
except Exception:
pass
self.options.rm_safe("fPIC")

def layout(self):
cmake_layout(self, src_folder="Box2D")
cmake_layout(self, src_folder="src")

def source(self):
tools.files.get(self,
**self.conan_data["sources"][self.version],
strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["BOX2D_BUILD_SHARED"] = self.options.shared
tc.variables["BOX2D_BUILD_STATIC"] = not self.options.shared
if self.settings.os == "Windows" and self.options.shared:
tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
tc.variables["BOX2D_BUILD_EXAMPLES"] = False
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
tc.variables["BOX2D_BUILD_TESTBED"] = False
tc.variables["BOX2D_BUILD_UNIT_TESTS"] = False
tc.generate()

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure(build_script_folder="Box2D")
cmake.configure()
cmake.build()

def package(self):
tools.files.copy(self, "License.txt", src=os.path.join(self.source_folder, "Box2D"), dst=os.path.join(self.package_folder,"licenses"))
tools.files.copy(self, os.path.join("Box2D", "*.h"), src=os.path.join(self.source_folder, "Box2D"), dst=os.path.join(self.package_folder, "include"))
tools.files.copy(self, "*.lib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
tools.files.copy(self, "*.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False)
tools.files.copy(self, "*.so*", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
tools.files.copy(self, "*.dylib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
tools.files.copy(self, "*.a", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.configure()
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rm(self, "*.pdb", self.package_folder, recursive=True)

def package_info(self):
self.cpp_info.libs = ["Box2D"]
if self.settings.os in ("FreeBSD", "Linux"):
self.cpp_info.system_libs = ["m"]
self.cpp_info.names["cmake_find_package"] = "box2d"
self.cpp_info.names["cmake_find_package_multi"] = "box2d"
self.cpp_info.libs = ["box2d"]
if Version(self.version) >= "2.4.1" and self.options.shared:
self.cpp_info.defines.append("B2_SHARED")
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")
11 changes: 6 additions & 5 deletions recipes/box2d/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
cmake_minimum_required(VERSION 3.4)
project(test_package)
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES CXX)

find_package(box2d)
find_package(box2d REQUIRED CONFIG)

add_executable(test_package test_package.cpp)
target_link_libraries(test_package box2d::box2d)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE box2d::box2d)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
6 changes: 4 additions & 2 deletions recipes/box2d/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import os
from conan import ConanFile, tools
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout


class Box2DTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)
Expand All @@ -19,6 +21,6 @@ def build(self):
cmake.build()

def test(self):
if not tools.build.cross_building(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
Loading

0 comments on commit d854331

Please sign in to comment.