Skip to content

Commit

Permalink
Merge branch 'conan-io:master' into rocksdb/add_v6.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fennibay authored Jun 21, 2021
2 parents 2ac901a + 9292d54 commit ff45efe
Show file tree
Hide file tree
Showing 331 changed files with 7,174 additions and 336 deletions.
2 changes: 1 addition & 1 deletion docs/how_to_add_packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Then in your `conanfile.py` method, it has to be used to download the sources:

### How to provide a good recipe

The [recipes](https://github.com/conan-io/conan-center-index/tree/master/recipes) available in CCI can be used as good examples, you can use them as the base for your recipe.
The [recipes](https://github.com/conan-io/conan-center-index/tree/master/recipes) available in CCI can be used as good examples, you can use them as the base for your recipe. However it is important to note Conan features change over time and our best practices evolve so some minor details may be out of date due to the vast number of recipes.

If you are looking for header-only projects, you can take a look on [rapidjson](https://github.com/conan-io/conan-center-index/blob/master/recipes/rapidjson/all/conanfile.py), [rapidxml](https://github.com/conan-io/conan-center-index/blob/master/recipes/rapidxml/all/conanfile.py), and [nuklear](https://github.com/conan-io/conan-center-index/blob/master/recipes/nuklear/all/conanfile.py). Also, Conan Docs has a section about [how to package header-only libraries](https://docs.conan.io/en/latest/howtos/header_only.html).

Expand Down
2 changes: 1 addition & 1 deletion recipes/apr-util/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 2.8.12)
project(cmake_wrapper)
project(cmake_wrapper C)

include(conanbuildinfo.cmake)
conan_basic_setup()
Expand Down
24 changes: 12 additions & 12 deletions recipes/apr-util/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from conans import AutoToolsBuildEnvironment, ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import glob
import os


required_conan_version = ">=1.32.0"
required_conan_version = ">=1.33.0"


class AprUtilConan(ConanFile):
Expand Down Expand Up @@ -72,8 +71,11 @@ def _build_subfolder(self):

def requirements(self):
self.requires("apr/1.7.0")
if self.settings.os != "Windows":
#cmake build doesn't allow injection of iconv yet
self.requires("libiconv/1.16")
if self.options.with_openssl:
self.requires("openssl/1.1.1j")
self.requires("openssl/1.1.1k")
if self.options.with_nss:
# self.requires("nss/x.y.z")
raise ConanInvalidConfiguration("CCI has no nss recipe (yet)")
Expand All @@ -96,17 +98,17 @@ def requirements(self):
# self.requires("ldap/x.y.z")
raise ConanInvalidConfiguration("CCI has no ldap recipe (yet)")
if self.options.with_mysql:
self.requires("libmysqlclient/8.0.17")
self.requires("libmysqlclient/8.0.25")
if self.options.with_sqlite3:
self.requires("sqlite3/3.35.1")
self.requires("sqlite3/3.35.5")
if self.options.with_expat:
self.requires("expat/2.2.10")
self.requires("expat/2.4.1")
if self.options.with_postgresql:
self.requires("libpq/13.2")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("{}-{}".format(self.name, self.version), self._source_subfolder)
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def validate(self):
if self.options.shared != self.options["apr"].shared:
Expand Down Expand Up @@ -139,6 +141,7 @@ def _configure_autotools(self):
conf_args = [
"--with-apr={}".format(tools.unix_path(self.deps_cpp_info["apr"].rootpath)),
"--with-crypto" if self._with_crypto else "--without-crypto",
"--with-iconv={}".format(tools.unix_path(self.deps_cpp_info["libiconv"].rootpath)),
"--with-openssl={}".format(tools.unix_path(self.deps_cpp_info["openssl"].rootpath)) if self.options.with_openssl else "--without-openssl",
"--with-expat={}".format(tools.unix_path(self.deps_cpp_info["expat"].rootpath)) if self.options.with_expat else "--without-expat",
"--with-mysql={}".format(tools.unix_path(self.deps_cpp_info["libmysqlclient"].rootpath)) if self.options.with_mysql else "--without-mysql",
Expand Down Expand Up @@ -176,8 +179,7 @@ def package(self):
autotools = self._configure_autotools()
autotools.install()

for file in glob.glob(os.path.join(self.package_folder, "lib", "apr-util-1", "*.la")):
os.unlink(file)
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib", "apr-util-1"), "*.la")
os.unlink(os.path.join(self.package_folder, "lib", "libaprutil-1.la"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))

Expand All @@ -191,8 +193,6 @@ def package_info(self):
self.cpp_info.system_libs = ["dl", "pthread", "rt"]
elif self.settings.os == "Windows":
self.cpp_info.system_libs = ["mswsock", "rpcrt4", "ws2_32"]
elif self.settings.os == "Macos":
self.cpp_info.system_libs = ["iconv"]

binpath = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH env var : {}".format(binpath))
Expand Down
7 changes: 7 additions & 0 deletions recipes/arcus/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.11)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory(source_subfolder)
4 changes: 4 additions & 0 deletions recipes/arcus/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"4.9.1":
url: "https://github.com/Ultimaker/libArcus/archive/refs/tags/4.9.1.tar.gz"
sha256: "18d939fd2428c72fdce35a286c196438327cfc3c8476e463e5ca46570168c9ce"
127 changes: 127 additions & 0 deletions recipes/arcus/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
from conans import ConanFile, CMake, tools
import os
import textwrap

required_conan_version = ">=1.33.0"


class ArcusConan(ConanFile):
name = "arcus"
description = "This library contains C++ code and Python3 bindings for " \
"creating a socket in a thread and using this socket to send " \
"and receive messages based on the Protocol Buffers library."
license = "LGPL-3.0-or-later"
topics = ("arcus", "protobuf", "socket", "cura")
homepage = "https://github.com/Ultimaker/libArcus"
url = "https://github.com/conan-io/conan-center-index"

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],

}
default_options = {
"shared": False,
"fPIC": True,
}

exports_sources = "CMakeLists.txt"
generators = "cmake", "cmake_find_package"
_cmake = None

@property
def _source_subfolder(self):
return "source_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 requirements(self):
self.requires("protobuf/3.17.1")

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],
destination=self._source_subfolder, strip_root=True)

def _patch_sources(self):
# Do not force PIC
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
"set(CMAKE_POSITION_INDEPENDENT_CODE ON)",
"")
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
"set_target_properties(Arcus PROPERTIES COMPILE_FLAGS -fPIC)",
"")
# TODO: this patch could be removed when CMake variables fixed in protobuf recipe
tools.replace_in_file(os.path.join(self._source_subfolder, "CMakeLists.txt"),
"target_link_libraries(Arcus PUBLIC ${PROTOBUF_LIBRARIES})",
"target_link_libraries(Arcus PUBLIC protobuf::libprotobuf)")

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["BUILD_PYTHON"] = False
self._cmake.definitions["BUILD_EXAMPLES"] = False
self._cmake.definitions["BUILD_STATIC"] = not self.options.shared
if self.settings.compiler == "Visual Studio":
self._cmake.definitions["MSVC_STATIC_RUNTIME"] = str(self.settings.compiler.runtime).startswith("MT")
self._cmake.configure()
return self._cmake

def build(self):
self._patch_sources()
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
self._create_cmake_module_alias_targets(
os.path.join(self.package_folder, self._module_file_rel_path),
{"Arcus": "Arcus::Arcus"}
)

@staticmethod
def _create_cmake_module_alias_targets(module_file, targets):
content = ""
for alias, aliased in targets.items():
content += textwrap.dedent("""\
if(TARGET {aliased} AND NOT TARGET {alias})
add_library({alias} INTERFACE IMPORTED)
set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})
endif()
""".format(alias=alias, aliased=aliased))
tools.save(module_file, content)

@property
def _module_subfolder(self):
return os.path.join("lib", "cmake")

@property
def _module_file_rel_path(self):
return os.path.join(self._module_subfolder,
"conan-official-{}-targets.cmake".format(self.name))

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "Arcus"
self.cpp_info.names["cmake_find_package_multi"] = "Arcus"
self.cpp_info.builddirs.append(self._module_subfolder)
self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path]
self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
self.cpp_info.libs = ["Arcus"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("pthread")
elif self.settings.os == "Windows":
self.cpp_info.system_libs.append("ws2_32")
11 changes: 11 additions & 0 deletions recipes/arcus/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

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

find_package(Arcus REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} Arcus)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
17 changes: 17 additions & 0 deletions recipes/arcus/all/test_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.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
6 changes: 6 additions & 0 deletions recipes/arcus/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <Arcus/Socket.h>

int main() {
Arcus::Socket socket;
return 0;
}
3 changes: 3 additions & 0 deletions recipes/arcus/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"4.9.1":
folder: all
2 changes: 2 additions & 0 deletions recipes/argtable2/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ patches:
base_path: "source_subfolder"
- patch_file: "patches/2.13-0002-msvc-nmake-accept-conan-flags.patch"
base_path: "source_subfolder"
- patch_file: "patches/2.13-0003-armv8-build.patch"
base_path: "source_subfolder"
20 changes: 20 additions & 0 deletions recipes/argtable2/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from conans import AutoToolsBuildEnvironment, ConanFile, tools
import os
import shutil


class Argtable2Conan(ConanFile):
Expand Down Expand Up @@ -45,10 +46,21 @@ def build_requirements(self):
if tools.os_info.is_windows and self.settings.compiler != "Visual Studio":
self.build_requires("msys2/20200517")

if self.settings.os != "Windows":
self.build_requires("gnu-config/cci.20201022")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("argtable{}".format(self.version.replace(".", "-")), self._source_subfolder)

@property
def _user_info_build(self):
# If using the experimental feature with different context for host and
# build, the 'user_info' attributes of the 'build_requires' packages
# will be located into the 'user_info_build' object. In other cases they
# will be located into the 'deps_user_info' object.
return getattr(self, "user_info_build", None) or self.deps_user_info

def _configure_autotools(self):
if self._autotools:
return self._autotools
Expand All @@ -58,6 +70,14 @@ def _configure_autotools(self):
"--enable-shared={}".format(yes_no(self.options.shared)),
"--enable-static={}".format(yes_no(not self.options.shared)),
]

# it contains outdated 'config.sub' and
# 'config.guess' files. It not allows to build libelf for armv8 arch.
shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB,
os.path.join(self._source_subfolder, "config.sub"))
shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS,
os.path.join(self._source_subfolder, "config.guess"))

self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder)
return self._autotools

Expand Down
12 changes: 12 additions & 0 deletions recipes/argtable2/all/patches/2.13-0003-armv8-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/arg_int.c b/src/arg_int.c
index 29c20e5..bc10012 100644
--- a/src/arg_int.c
+++ b/src/arg_int.c
@@ -30,6 +30,7 @@ USA.

#include "argtable2.h"
#include <limits.h>
+#include <ctype.h>

/* local error codes */
enum {EMINCOUNT=1,EMAXCOUNT,EBADINT,EOVERFLOW};
9 changes: 6 additions & 3 deletions recipes/b2/standard/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ def build(self):
os.chdir(build_dir)
command = os.path.join(
engine_dir, "b2.exe" if use_windows_commands else "b2")
full_command = \
"{0} --ignore-site-config --prefix=../output --abbreviate-paths install".format(
command)
if self.options.toolset != 'auto':
full_command = "{0} --ignore-site-config --prefix=../output --abbreviate-paths" \
" toolset={1} install".format(command, self.options.toolset)
else:
full_command = "{0} --ignore-site-config --prefix=../output --abbreviate-paths" \
" install".format(command)
self.run(full_command)

def package(self):
Expand Down
4 changes: 4 additions & 0 deletions recipes/confu_json/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
0.0.5:
url: https://github.com/werto87/confu_json/archive/refs/tags/v0.0.5.tar.gz
sha256: bc506d4b7836a7689b1c6a2d89bb0c3441f774c8f845fef79d85c71099df5bf9
Loading

0 comments on commit ff45efe

Please sign in to comment.