forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'conan-io:master' into CURA-8831_autoconf
- Loading branch information
Showing
305 changed files
with
5,924 additions
and
2,277 deletions.
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 |
---|---|---|
|
@@ -928,3 +928,6 @@ authorized_users: | |
- "BjoernAtBosch" | ||
- "dubvulture" | ||
- "ZbigniewRA" | ||
- "JorgenPo" | ||
- "AlexRamallo" | ||
- "kissandras" |
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
File renamed without changes.
132 changes: 132 additions & 0 deletions
132
docs/package_templates/autotools_package/all/conanfile.py
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,132 @@ | ||
from conan import ConanFile | ||
from conan.errors import ConanInvalidConfiguration | ||
from conan.tools.env import VirtualBuildEnv | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.files import copy, get, rm, rmdir, apply_conandata_patches | ||
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps | ||
from conan.tools.layout import basic_layout | ||
import os | ||
|
||
|
||
required_conan_version = ">=1.51.3" | ||
|
||
|
||
class PackageConan(ConanFile): | ||
name = "package" | ||
description = "short description" | ||
license = "" # Use short name only, conform to SPDX License List: https://spdx.org/licenses/ | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/project/package" | ||
topics = ("topic1", "topic2", "topic3") # no "conan" and project name in topics | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"with_foobar": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"with_foobar": True, | ||
} | ||
|
||
# no exports_sources attribute, but export_sources(self) method instead | ||
# this allows finer grain exportation of patches per version | ||
def export_sources(self): | ||
for p in self.conan_data.get("patches", {}).get(self.version, []): | ||
copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
try: | ||
del self.options.fPIC # once removed by config_options, need try..except for a second del | ||
except Exception: | ||
pass | ||
try: | ||
del self.settings.compiler.libcxx # for plain C projects only | ||
except Exception: | ||
pass | ||
try: | ||
del self.settings.compiler.cppstd # for plain C projects only | ||
except Exception: | ||
pass | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") # src_folder must use the same source folder name the project | ||
|
||
def requirements(self): | ||
self.requires("dependency/0.8.1") # prefer self.requires method instead of requires attribute | ||
if self.options.with_foobar: | ||
self.requires("foobar/0.1.0") | ||
|
||
def validate(self): | ||
# validate the minimum cpp standard supported. Only for C++ projects | ||
if self.info.settings.compiler.cppstd: | ||
check_min_cppstd(self, 11) | ||
if self.info.settings.os not in ["Linux", "FreeBSD", "MacOS"]: | ||
raise ConanInvalidConfiguration(f"{self.ref} is not supported on {self.info.settings.os}.") | ||
|
||
# if another tool than the compiler or autotools is required to build the project (pkgconf, bison, flex etc) | ||
def build_requirements(self): | ||
self.tool_requires("libtool/x.y.z") | ||
self.tool_requires("pkgconf/x.y.z") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], | ||
destination=self.source_folder, strip_root=True) | ||
|
||
def generate(self): | ||
# autotools usually uses 'yes' and 'no' to enable/disable options | ||
yes_no = lambda v: "yes" if v else "no" | ||
# --fpic is automatically managed when 'fPIC'option is declared | ||
# --enable/disable-shared is automatically managed when 'shared' option is declared | ||
tc = AutotoolsToolchain(self) | ||
tc.configure_args.append("--with-foobar=%s" % yes_no(self.options.with_foobar)) | ||
tc.configure_args.append("--enable-tools=no") | ||
tc.configure_args.append("--enable-manpages=no") | ||
tc.generate() | ||
# generate dependencies for pkg-config | ||
tc = PkgConfigDeps(self) | ||
tc.generate() | ||
# generate dependencies for autotools | ||
tc = AutotoolsDeps(self) | ||
tc.generate() | ||
# inject tools_require env vars in build context | ||
ms = VirtualBuildEnv(self) | ||
ms.generate(scope="build") | ||
|
||
def build(self): | ||
# apply patches listed in conandata.yml | ||
apply_conandata_patches(self) | ||
autotools = Autotools(self) | ||
# run autoreconf to generate configure file | ||
autotools.autoreconf() | ||
# ./configure + toolchain file | ||
autotools.configure() | ||
autotools.make() | ||
|
||
def package(self): | ||
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
autotools = Autotools(self) | ||
autotools.install() | ||
|
||
# some files extensions and folders are not allowed. Please, read the FAQs to get informed. | ||
rm(self, "*.la", os.path.join(self.package_folder, "lib")) | ||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
rmdir(self, os.path.join(self.package_folder, "share")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["package_lib"] | ||
|
||
# if package provides a pkgconfig file (package.pc, usually installed in <prefix>/lib/pkgconfig/) | ||
self.cpp_info.set_property("pkg_config_name", "package") | ||
|
||
# If they are needed on Linux, m, pthread and dl are usually needed on FreeBSD too | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.append("m") | ||
self.cpp_info.system_libs.append("pthread") | ||
self.cpp_info.system_libs.append("dl") |
12 changes: 12 additions & 0 deletions
12
docs/package_templates/autotools_package/all/test_package/CMakeLists.txt
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,12 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
|
||
project(test_package C) # if the project is pure C | ||
# project(test_package CXX) # if the project uses c++ | ||
|
||
find_package(package REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.c) | ||
# don't link to ${CONAN_LIBS} or CONAN_PKG::package | ||
target_link_libraries(${PROJECT_NAME} PRIVATE package::package) | ||
# In case the target project need a specific C++ standard | ||
# target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_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
16 changes: 16 additions & 0 deletions
16
docs/package_templates/autotools_package/all/test_package/test_package.c
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,16 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "package/foobar.h" // Make sure includes work as expected | ||
|
||
|
||
int main(void) { | ||
printf("Create a minimal usage for the target project here.\n"); | ||
printf("Avoid big examples, bigger than 100 lines\n"); | ||
printf("Avoid networking connections.\n"); | ||
printf("Avoid background apps or servers.\n"); | ||
printf("The propose is testing the generated artifacts only.\n"); | ||
|
||
foobar_print_version(); // Make sure to call something that will require linkage for compiled libraries | ||
|
||
return EXIT_SUCCESS; | ||
} |
16 changes: 16 additions & 0 deletions
16
docs/package_templates/autotools_package/all/test_v1_package/CMakeLists.txt
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,16 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
|
||
project(test_package C) # if the project is pure C | ||
# project(test_package CXX) # if the project uses c++ | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(package REQUIRED CONFIG) | ||
|
||
# Re-use the same source file from test_package folder | ||
add_executable(${PROJECT_NAME} ../test_package/test_package.c) | ||
# don't link to ${CONAN_LIBS} or CONAN_PKG::package | ||
target_link_libraries(${PROJECT_NAME} PRIVATE package::package) | ||
# in case the target project requires a C++ standard | ||
# set_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) |
File renamed without changes.
File renamed without changes.
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,29 @@ | ||
sources: | ||
# Newer versions at the top | ||
"1.2.0": | ||
url: [ | ||
"https://mirror1.net/package-1.2.0.tar.gz", | ||
"https://mirror2.net/package-1.2.0.tar.gz", | ||
] | ||
sha256: "________________________________________________________________" | ||
"1.1.0": | ||
url: [ | ||
"https://mirror1.net/package-1.1.0.tar.gz", | ||
"https://mirror2.net/package-1.1.0.tar.gz", | ||
] | ||
sha256: "________________________________________________________________" | ||
patches: | ||
# Newer versions at the top | ||
"1.1.0": | ||
- patch_file: "patches/0001-fix-cmake.patch" | ||
patch_description: "correct the order of cmake min and project" | ||
patch_type: "backport" | ||
patch_source: "https://github.com/owner/package/pulls/42" | ||
sha256: "________________________________________________________________" | ||
base_path: "source_subfolder" | ||
- patch_file: "patches/0002-fix-linux.patch" | ||
patch_description: "add missing header to support linux" | ||
patch_type: "portability" | ||
patch_source: "https://github.com/owner/package/issues/0" | ||
sha256: "________________________________________________________________" | ||
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
File renamed without changes.
27 changes: 27 additions & 0 deletions
27
docs/package_templates/cmake_package/all/test_package/conanfile.py
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,27 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
# It will become the standard on Conan 2.x | ||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
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") |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.