Skip to content
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

antigrain: add library #16865

Merged
merged 14 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/agg/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"2.6.0":
url: "https://github.com/aggeom/agg-2.6/archive/3ee3b4bdb68fabfa0dbfb62a8adc3953c507e4e2.tar.gz"
sha256: a1b360925a9de2af3f31f6025bd6c1b3bcb7ab3bcf58f6082cb3897441b2f679
140 changes: 140 additions & 0 deletions recipes/agg/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rmdir
from conan.errors import ConanInvalidConfiguration

import os

required_conan_version = ">=1.52.0"
xakod marked this conversation as resolved.
Show resolved Hide resolved

class AggConan(ConanFile):
name = 'agg'
description = 'AGG Anti-Grain Geometry Library'
topics = ('graphics')
url = "https://github.com/conan-io/conan-center-index"
homepage = 'https://github.com/aggeom'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears this is a fork of the main repo which is still very active https://github.com/ghaerr/agg-2.6

We generally do not accept these, is there a reason you did not use the original or contribute to it? I saw they made improvements to their CMake just 2 days ago

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, my pr may look strange and I understand your position. Let me explain my position. Firstly, I don't see any commits since Jul 21, 2022. Secondly, it contains only 19 commits from May 6, 2019. Others commits do not relay to current repo and current owner. Thirdly, 2.6.0 was released in 2018 and no releases were published in current repo. You said it active, maybe. I'm not sure how to classify this is active and this is not. You can look at pull requests https://github.com/ghaerr/agg-2.6/pulls. There are 2 prs, and they related to cmake improvements, they were not reviewed for years. If you are strongly against using fork, I will create another third pull request. But I'd be willing to bet that no one will review it or accept for years.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In such a case I would recommend using our author- prefix so that it's more clearly evident that this is a specific variant of a project :)

this way people can benifit from the project while not getting mixed up :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prince-chrismc what is author- prefix? I could not find any docs about this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prince-chrismc thank you, I applied your suggestion but looks like cla bot is broken.

license = 'BSD-3-Clause'

settings = 'os', 'arch', 'compiler', 'build_type'
options = {
'shared': [True, False],
'fPIC': [True, False],
'with_gpc': [True, False],
'with_freetype': [True, False],
'with_agg2d': [True, False],
'with_agg2d_freetype': [True, False],
'with_platform': [True, False],
'with_controls': [True, False],
}

default_options = {
'shared': False,
'fPIC': True,
'with_gpc': True,
'with_freetype': True,
'with_agg2d': True,
'with_agg2d_freetype': True,
'with_platform': True,
'with_controls': True,
}

def validate(self):
if self.settings.os not in ("Windows", "Linux"):
raise ConanInvalidConfiguration("OS is not supported")
if self.options.shared:
raise ConanInvalidConfiguration("Invalid configuration")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to have this option? can we remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you are right. I still leave it there because maybe someone will test shared library, and we'll enable it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jihadist please, sign the CLA again. It has been updated. Sorry for the inconvenient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uilianries thank you, I signed


def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
try:
del self.options.fPIC
except Exception:
pass
xakod marked this conversation as resolved.
Show resolved Hide resolved

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

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

def requirements(self):
if self.options.with_freetype:
self.requires('freetype/2.13.0')
if self.options.with_platform and self.settings.os in ["Linux"]:
self.requires("xorg/system")

def generate(self):
tc = CMakeToolchain(self)
tc.variables['agg_USE_EXPAT'] = False
tc.variables['agg_USE_SDL_PLATFORM'] = False
tc.variables['agg_BUILD_DEMO'] = False
tc.variables['agg_BUILD_EXAMPLES'] = False

tc.variables['agg_USE_GPC'] = self.options.with_gpc
tc.variables['agg_USE_FREETYPE'] = self.options.with_freetype
tc.variables['agg_USE_AGG2D'] = self.options.with_agg2d
tc.variables['agg_USE_AGG2D_FREETYPE'] = self.options.with_agg2d_freetype
tc.variables['agg_BUILD_PLATFORM'] = self.options.with_platform
tc.variables['agg_BUILD_CONTROLS'] = self.options.with_controls

tc.generate()

deps = CMakeDeps(self)
deps.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self, "copying", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.configure()
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):

self.cpp_info.set_property("cmake_file_name", "agg")

self.cpp_info.components["agg"].set_property("cmake_target_name", "agg::agg")
self.cpp_info.components["agg"].libs = ["agg"]
self.cpp_info.components["agg"].includedirs = [os.path.join("include", "agg")]

if self.options.with_freetype:
self.cpp_info.components["fontfreetype"].set_property("cmake_target_name", "agg::fontfreetype")
self.cpp_info.components["fontfreetype"].libs = ["aggfontfreetype"]
self.cpp_info.components["fontfreetype"].includedirs = [os.path.join("include", "agg","fontfreetype")]
self.cpp_info.components["fontfreetype"].requires = ["agg", "freetype::freetype"]

if self.options.with_gpc:
self.cpp_info.components["gpc"].set_property("cmake_target_name", "agg::gpc")
self.cpp_info.components["gpc"].libs = [ "agggpc"]
self.cpp_info.components["gpc"].includedirs = [os.path.join("include", "agg","gpc")]


if self.options.with_agg2d:
self.cpp_info.components["2d"].set_property("cmake_target_name", "agg::2d")
self.cpp_info.components["2d"].libs = ["agg2d"]
self.cpp_info.components["2d"].includedirs = [os.path.join("include", "agg","2d")]
self.cpp_info.components["2d"].requires = ["agg"]
if self.options.with_agg2d_freetype:
self.cpp_info.components["2d"].requires = ["agg", "fontfreetype"]

if self.options.with_platform:

self.cpp_info.components["platform"].set_property("cmake_target_name", "agg::platform")
self.cpp_info.components["platform"].libs = ["aggplatform"]
self.cpp_info.components["platform"].includedirs = [os.path.join("include", "agg","platform")]
if self.settings.os in ["Linux"]:
self.cpp_info.components["platform"].requires = ["xorg::xorg", "agg"]

if self.options.with_controls:
self.cpp_info.components["controls"].set_property("cmake_target_name", "agg::controls")
self.cpp_info.components["controls"].libs = ["aggctrl"]
self.cpp_info.components["controls"].includedirs = [os.path.join("include", "agg","ctrl")]
self.cpp_info.components["controls"].requires = ["agg"]
10 changes: 10 additions & 0 deletions recipes/agg/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES CXX)

find_package(agg REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE agg::agg agg::platform )

set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE TRUE)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
29 changes: 29 additions & 0 deletions recipes/agg/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "VirtualRunEnv"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def generate(self):
tc = CMakeToolchain(self)
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
10 changes: 10 additions & 0 deletions recipes/agg/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <agg_basics.h>
#include <agg_platform_support.h>
enum flip_y_e { flip_y = true };

int agg_main(int argc, char* argv[]) {
agg::platform_support app(agg::pix_format_bgr24, flip_y);
app.caption("AGG Example. Anti-Aliasing Demo");

return 0;
}
8 changes: 8 additions & 0 deletions recipes/agg/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
${CMAKE_CURRENT_BINARY_DIR}/test_package)
17 changes: 17 additions & 0 deletions recipes/agg/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

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)
3 changes: 3 additions & 0 deletions recipes/agg/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.6.0":
folder: "all"