-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rectanglebinpack: add rectanglebinpack/cci.20210901 recipe #7112
Merged
conan-center-bot
merged 4 commits into
conan-io:master
from
vbieleny:package/rectanglebinpack/cci.20210829
Sep 7, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
98b4dee
rectanglebinpack: add rectanglebinpack/cci.20210829 recipe
vbieleny 7665791
Enable C++11 standard
vbieleny 7d73337
Enable C++11 standard in test_package
vbieleny 3e73a4e
Update package version to cci.20210901 which includes C++11 support
vbieleny File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
|
||
add_subdirectory("source_subfolder") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
sources: | ||
"cci.20210901": | ||
- url: "https://github.com/juj/RectangleBinPack/archive/a40fcaf3871da57b0f6a080655b3387374840877.zip" | ||
sha256: "88cec105ca8d90d09e9e81f9862caa0cc1cdb851560fb701555eb58b29515748" | ||
- url: "https://unlicense.org/UNLICENSE" | ||
sha256: "7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c" | ||
patches: | ||
"cci.20210901": | ||
- patch_file: "patches/0001_fix_win32_build.patch" | ||
base_path: "source_subfolder" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
required_conan_version = ">=1.33.0" | ||
|
||
|
||
class RectangleBinPackConan(ConanFile): | ||
name = "rectanglebinpack" | ||
license = "Unlicense" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/juj/RectangleBinPack" | ||
description = "The code can be used to solve the problem of packing a set of 2D rectangles into a larger bin." | ||
topics = ("rectangle", "packing", "bin") | ||
exports_sources = ["CMakeLists.txt", "patches/**"] | ||
generators = "cmake" | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
|
||
_cmake = None | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
@property | ||
def _build_subfolder(self): | ||
return "build_subfolder" | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
del self.options.fPIC | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
tools.check_min_cppstd(self, 11) | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version][0], | ||
strip_root=True, destination=self._source_subfolder) | ||
tools.download(filename="LICENSE", **self.conan_data["sources"][self.version][1]) | ||
|
||
def build(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def _configure_cmake(self): | ||
if self._cmake: | ||
return self._cmake | ||
self._cmake = CMake(self) | ||
self._cmake.configure(build_folder=self._build_subfolder) | ||
return self._cmake | ||
|
||
def package(self): | ||
self.copy("LICENSE", dst="licenses") | ||
self.copy("*.h", dst=os.path.join("include", self.name), src=self._source_subfolder, excludes="old/**") | ||
self.copy("*.dll", dst="bin", keep_path=False) | ||
self.copy("*.lib", dst="lib", keep_path=False) | ||
self.copy("*.so", dst="lib", keep_path=False) | ||
self.copy("*.dylib", dst="lib", keep_path=False) | ||
self.copy("*.a", dst="lib", keep_path=False) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["RectangleBinPack"] | ||
self.cpp_info.names["cmake_find_package"] = "RectangleBinPack" | ||
self.cpp_info.names["cmake_find_package_multi"] = "RectangleBinPack" | ||
11 changes: 11 additions & 0 deletions
11
recipes/rectanglebinpack/all/patches/0001_fix_win32_build.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- a/test/MaxRectsBinPackTest.cpp | ||
+++ b/test/MaxRectsBinPackTest.cpp | ||
@@ -24,8 +24,6 @@ | ||
#if defined(WIN32) | ||
LARGE_INTEGER ddwTimer; | ||
BOOL success = QueryPerformanceCounter(&ddwTimer); | ||
- assume(success != 0); | ||
- MARK_UNUSED(success); | ||
return ddwTimer.QuadPart; | ||
#elif defined(__APPLE__) | ||
return mach_absolute_time(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.4) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) | ||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
47 changes: 47 additions & 0 deletions
47
recipes/rectanglebinpack/all/test_package/test_package.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Original source code: | ||
* https://github.com/juj/RectangleBinPack/blob/29eec60fe2c9aa0df855dddabd8d4d17023b95f3/test/MaxRectsBinPackTest.cpp | ||
*/ | ||
|
||
#include <cstdint> | ||
#include <cstdio> | ||
#include <vector> | ||
#include <rectanglebinpack/MaxRectsBinPack.h> | ||
|
||
using namespace rbp; | ||
|
||
bool AreDisjoint(const Rect &a, const Rect &b) | ||
{ | ||
return a.x >= b.x + b.width || a.x + a.width <= b.x || | ||
a.y >= b.y + b.height || a.y + a.height <= b.y; | ||
} | ||
|
||
bool AllRectsDisjoint(std::vector<Rect> &packed) | ||
{ | ||
for(size_t i = 0; i < packed.size(); ++i) | ||
for(size_t j = i+1; j < packed.size(); ++j) | ||
{ | ||
if (!AreDisjoint(packed[i], packed[j])) | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
int main() | ||
{ | ||
MaxRectsBinPack pack(256, 256, true); | ||
|
||
std::vector<Rect> packed; | ||
srand(12412); | ||
for(int i = 1; i < 128; ++i) | ||
{ | ||
int a = (rand() % 128) + 1; | ||
int b = (rand() % 128) + 1; | ||
Rect r = pack.Insert(a, b, MaxRectsBinPack::RectBestShortSideFit); | ||
if (!r.width) | ||
break; | ||
packed.push_back(r); | ||
} | ||
printf("Packed %d rectangles. All rects disjoint: %s. Occupancy: %f\n", | ||
(int)packed.size(), AllRectsDisjoint(packed) ? "yes" : "NO!", pack.Occupancy()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"cci.20210901": | ||
folder: "all" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
targets are not exported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blah #7153 they match upstream